[MOD] Change Signal Strength bars to show REAL (dBm) signal level - XPERIA X10 Themes and Apps

MrRusch has devised a method to display actual signal strength (in dBm) on the statusbar.
FIND OUT HOW
(Alternative ADB commands)​
------------------------------ ORIGINAL POST ------------------------------
Let's see if we can figure out how to change the signal strength display on the statusbar to show proper signal strength in dBm, rather than the moderately useless bars that display now.
Why
Why not use one of the many widget or notification bar apps available on the market that provide this info? Well, on everyone's status bar we already have an icon dedicated to showing us our signal strength. It's just that it presents it as bars that really don't provide us with very useful info. Why have two icons on our already cramped status/notification bar essentially providing the same data, especially when the notification bar icons also take up a slot in the notification dropdown as well? And as for widgets, they aren't available all the time no matter what program you're using.
Preliminary Research
Being a complete noob when it comes to Android hacking and coding (I can follow other people's guides... that's about it), I don't have any coding experience I can really contribute. When it comes time, I can however create icons for each signal strength level (I believe -60 to -115 is the range). And I have also done some preliminary research:
We'll start with the Android SDK reference: SignalStrength (http://developer.android.com/reference/android/telephony/SignalStrength.html)
A thread regarding implementing this feature 9which they did) on CM6: [CM6 MOD] dBm Meter
A thread from Desire forum about this issue: dBm instead of signal bars? (similarly to supercircle battery
And some apps that display signal strength dbm either in the notification bar or as a widget.
Mobile Signal Widget
Real Signal
Signal Status Bar
I've also looked in framework-res.apk, and found (in \res\drawable-hdpi\) a series of icons starting with the names:
stat_sys_r_signal_
stat_sys_ra_signal_
stat_sys_signal_
stat_sys_signal_evdo_
A quick initial glance didn't lead me to find any XML files in framework-res.apk that jumped out at me as being associated with signal strength, but someone with more knowledge may still find something.

Perhaps we can talk to shaggy-h here at XDA. He created this mod for Nexus One, and it is now incorporated in CM builds. (Original thread)

MrRusch said:
Perhaps we can talk to shaggy-h here at XDA. He created this mod for Nexus One, and it is now incorporated in CM builds. (Original thread)
Click to expand...
Click to collapse
Good call. I just PMed him. We'll see what happens there.
If anyone has any ideas, please feel free to post.

Ok, so I've been looking into this.. Not sure if I'm getting smarter or just more confused.
Code:
if (asu <= 2 || asu == 99) iconLevel = 0;
else if (asu >= 12) iconLevel = 4;
else if (asu >= 8) iconLevel = 3;
else if (asu >= 5) iconLevel = 2;
else iconLevel = 1;
This is the calculation right now in statusBarPolicy.java. Problem is our firmware is SE-modified, so the rest of the source code is probably not the same. We can calculate the dBm from the asu value (I think, dBm=asu*2-113), and then create more specific IF statements and more iconsLevels to match dBm values. But I'm not quite familiar with smali bytecode yet..
However, we can convert java to class (javac *.java),
convert *.class to *.dex (java -jar dx.jar --dex --output=*.dex *.class), and then
dex to smali (java -jar baksmali.jar -o *.smali *.dex)
This would make it easier to understand (for me at least). But I'm not sure this will be accurate, because we don't have all the SE sources and would be forced to compile Android default sources. But perhaps compiling and simply replacing the relevant parts into our existing smali code could do it..
Please someone, hit me back.

Hey man,
where's statusBarPolicy.java? Is it compiled into services.jar? Sorry, but I'm a C++/C# guy, I don't even know my way around the file types with java... but I assume from the code you posted that a .java file is a source code file and you didn't decompile anything to get that code...

OK, been fishing about a bit. Found this on line 3391 of StatusBarPolicy.smali, looks like it's finally time to learn how to write this stuff (sorta looks similar to msil so shouldn't be too bad.... ).
Code:
.method private final updateSignalStrength()V
....
....
....
// LINE NUMBER 3483
.line 896
:goto_44
iget-object v3, p0, Lcom/android/server/status/StatusBarPolicy;->mPhone:Landroid/telephony/TelephonyManager;
invoke-virtual {v3}, Landroid/telephony/TelephonyManager;->isNetworkRoaming()Z
move-result v3
if-eqz v3, :cond_71
.line 897
sget-object v2, Lcom/android/server/status/StatusBarPolicy;->sSignalImages_r:[I
.line 916
.end local v0 #asu:I
.local v2, iconList:[I
:goto_4e
iget-object v3, p0, Lcom/android/server/status/StatusBarPolicy;->mPhoneData:Lcom/android/server/status/IconData;
aget v4, v2, v1
iput v4, v3, Lcom/android/server/status/IconData;->iconId:I
.line 917
iget-object v3, p0, Lcom/android/server/status/StatusBarPolicy;->mService:Lcom/android/server/status/StatusBarService;
iget-object v4, p0, Lcom/android/server/status/StatusBarPolicy;->mPhoneIcon:Landroid/os/IBinder;
iget-object v5, p0, Lcom/android/server/status/StatusBarPolicy;->mPhoneData:Lcom/android/server/status/IconData;
invoke-virtual {v3, v4, v5, v6}, Lcom/android/server/status/StatusBarService;->updateIcon(Landroid/os/IBinder;Lcom/android/server/status/IconData;Lcom/android/server/status/NotificationData;)V
goto :goto_28
.line 890
.end local v2 #iconList:[I
.restart local v0 #asu:I
:cond_5e
const/16 v3, 0x10
if-lt v0, v3, :cond_64
const/4 v1, 0x4
goto :goto_44
.line 891
:cond_64
const/16 v3, 0x8
if-lt v0, v3, :cond_6a
const/4 v1, 0x3
goto :goto_44
.line 892
:cond_6a
const/4 v3, 0x4
if-lt v0, v3, :cond_6f
const/4 v1, 0x2
goto :goto_44
.line 893
:cond_6f
const/4 v1, 0x1
goto :goto_44
....
....
....
.end method
And here's the updateIcon method from StatusBarServices.smali:
Code:
.method public updateIcon(Landroid/os/IBinder;Lcom/android/server/status/IconData;Lcom/android/server/status/NotificationData;)V
.registers 10
.parameter "key"
.parameter "data"
.parameter "n"
.prologue
.line 498
const/4 v1, 0x2
const/4 v5, -0x1
move-object v0, p0
move-object v2, p1
move-object v3, p2
move-object v4, p3
invoke-direct/range {v0 .. v5}, Lcom/android/server/status/StatusBarService;->addPendingOp(ILandroid/os/IBinder;Lcom/android/server/status/IconData;Lcom/android/server/status/NotificationData;I)V
.line 499
return-void
.end method
I'll have a look at addPendingOp() later...

OK, I need a bit of syntax help. If anyone can point me to a smali reference that would be great, I've looked at the examples here but I really need just a straight out syntax reference.
I've been looking at this code:
Code:
.line 890
.end local v2 #iconList:[I -> delete local variable v2
.restart local v0 #asu:I -> reset v0
:cond_5e -> goto marker ?
const/16 v3, 0x10 -> declare variable v3 and set to 16
if-lt v0, v3, :cond_64 -> if (v0 < v3)
-> {
const/4 v1, 0x4 -> v1 = 4;
goto :goto_44 -> goto goto_44;
-> } // does the 'if' end here??
.line 891 -> is this just a marker??
:cond_64 -> next block, repeats with v3 = 8
const/16 v3, 0x8
if-lt v0, v3, :cond_6a
Can anyone answer the questions in the code, or correct me please.

Sorry, I can't help you much with the syntax yet, trying to understand this myself.
However something struck me today.. Modifying this to work like the battery mod, i.e. switching image every state change, is not a good idea here. This will not be efficient as dBm value is constantly fluctuating, making this a crazy resource hog. For the battery this was ok, as it only loads a new image every so often, but this won't be good for the reception. So I was thinking, perhaps replacing the icon completely with a textfield would be better, as updating a text value would be way more efficient than loading images every state change. What do you think?
I'm going through the smali-examples myself, trying to learn how to write this. Because the cross-compilation method I described earlier is probably not gonna work as I hoped.
Anyway, I believe you got the markers switched up..?
:cond_5e - placement marker
if-lt v0, v3, :cond_64 - goto marker

OK, thanks. So
Code:
if-lt v0, v3, :cond_64
is like
Code:
if (v0 < v3) { goto cond_64; }
I was wondering why I couldn't find a clear end to the if block.
The text block idea is good, especially with a signal that goes in and out like mine. To be honest, I probably wouldn't have used this mod myself, it was just a good excuse to mess with things.
Also, we shouldn't have any compilation problems if we modify the smali files from the sony services.jar.

As for your question about IF-statements, perhaps this can be of some help.
I simplified the original Java comparison:
Code:
public class StatusBarPolicy {
StatusBarPolicy() {
int asu = 0, iconLevel = 0;
if (asu <= 2 || asu == 99) iconLevel = 0;
else if (asu >= 12) iconLevel = 4;
else if (asu >= 8) iconLevel = 3;
else if (asu >= 5) iconLevel = 2;
else iconLevel = 1;
}
}
And compiled it to smali:
Code:
.class public LStatusBarPolicy;
.super Ljava/lang/Object;
.source "StatusBarPolicy.java"
# direct methods
.method constructor <init>()V
.registers 3
.prologue
.line 3
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 5
const/4 v0, 0x0
.line 7
const/4 v1, 0x2
if-le v0, v1, :cond_b
const/16 v1, 0x63
if-ne v0, v1, :cond_c
.line 13
:cond_b
:goto_b
return-void
.line 8
:cond_c
const/16 v1, 0xc
if-ge v0, v1, :cond_b
.line 9
const/16 v1, 0x8
if-ge v0, v1, :cond_b
.line 10
const/4 v1, 0x5
if-lt v0, v1, :cond_b
goto :goto_b
.end method
Oddly, no matter what the asu value is set to at init, iconLevel value is never changed... But this is how I understand it:
Code:
.class public LStatusBarPolicy;
.super Ljava/lang/Object;
.source "StatusBarPolicy.java"
# direct methods
.method constructor <init>()V
.registers 3
.prologue
.line 3
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 5
const/4 v0, 0x0 /evaluates asu, put dec0 in v0
.line 7
const/4 v1, 0x2 /put dec2 in v1
if-le v0, v1, :cond_b /if v0(asu) <= v1(2) goto cond_b
const/16 v1, 0x63 /put dec99 in v1
if-ne v0, v1, :cond_c /if v0(asu) != v1(99) goto cond_c
.line 13
:cond_b /cond_b start
:goto_b /goto_b start
return-void /donb_b & goto_b end by return void
.line 8
:cond_c /cond_c start
const/16 v1, 0xc /put dec12 in v1
if-ge v0, v1, :cond_b /if v0(asu) >= v1(12) goto cond_b
.line 9
const/16 v1, 0x8 /put dec8 in v1
if-ge v0, v1, :cond_b /if v0(asu) >= v1(8) goto cond_b
.line 10
const/4 v1, 0x5 /put dec4 in v1
if-lt v0, v1, :cond_b /if v0(asu) < v1(4) goto cond_b
goto :goto_b
.end method
From this we can see that it seems to be the .line statements that separate blocks. I.e. .line 7 holds two conditions, asu <= 2 and asu != 99. I'm not sure how the OR is determined here. Will recompile and see.
EDIT: Duh, the jump instruction provides this logic here.

Thanks
I think I'm getting the hang of it now. I just made some notes on another bit of code here (see section 5): http://forum.xda-developers.com/showthread.php?p=9126650#post9126650
Edit: just saw your edit now. I noted in the post above that I'm pretty sure the .line entries refer to source code lines. All of the blocks I've looked at would be easily written in a single line of code. Another thing is that you don't really need the OR if you split it up: if the first one is true then you will jump to somewhere else and the second condition won't be evaluated.
I'm off for a bit, I'll have a better look at your last edit later.

_calum_ said:
Thanks
I think I'm getting the hang of it now. I just made some notes on another bit of code here (see section 5): http://forum.xda-developers.com/showthread.php?p=9126650#post9126650
Edit: just saw your edit now. I noted in the post above that I'm pretty sure the .line entries refer to source code lines. All of the blocks I've looked at would be easily written in a single line of code. Another thing is that you don't really need the OR if you split it up: if the first one is true then you will jump to somewhere else and the second condition won't be evaluated.
I'm off for a bit, I'll have a better look at your last edit later.
Click to expand...
Click to collapse
@ .line entries, yeah seems to be the case.
@ OR, when you put it that way yeah.. I suppose it becomes more interesting with the AND operator, i.e. asu > 1 && asu < 10.
The time is quickly approaching beer o'clock again, so I'm gonna put this away for tonight as well. But I thought I'd upload a little tool I put together, that may be useful. It's a java2smali converter, sadly the other way around doesn't work too well. Anyway, only prerequisite is that you have JDK installed and properly linked to environmental path variable.
Extract the archive to some folder, shove your *.java files in there, and run the batch file.. When entering the class name e.g. StatusBarPolicy, leave out the file extension.

Hey guys. Wish I could be of more help, but I'm having alot of trouble wrapping my head around the code. My coding experience is pretty limited (JavaScript for Adobe Acrobat is the only thing I've worked in in the past 10 years).
As for the icon update being battery hog: I can say I've been using Signal Status for the past few days (it shows the signal dBm in the notification bar) and according to SystemPanel it's used all of 2 sec of CPU time in the past 12 hours. I think it may display as text (vs. icon), but I'll need to look into it's code for that (which I'll do tonight).

Ok, can't let it go yet.
According to the source code, ASU values range from 0 to 31 (except 99 meaning unknown), which translated to dBm would mean -133 to -71. So, we could change the current if-statement to something like this, leaving iconLevel = 0 as unkown, and then increasing iconLevels with signal strength in dBm..
Code:
dBm = asu * 2 -133;
if (dBm == -133) iconLevel = 1;
else if (dBm == -132) iconLevel = 2;
else if (dBm == -131) iconLevel = 3;
else if (dBm == -130) iconLevel = 4;
else if (dBm == -129) iconLevel = 5;
else if (dBm == -128) iconLevel = 6;
else if (dBm == -127) iconLevel = 7;
else if (dBm == -126) iconLevel = 8;
else if (dBm == -125) iconLevel = 9;
else if (dBm == -124) iconLevel = 10;
else if (dBm == -123) iconLevel = 11;
else if (dBm == -122) iconLevel = 12;
else if (dBm == -121) iconLevel = 13;
else if (dBm == -120) iconLevel = 14;
else if (dBm == -119) iconLevel = 15;
else if (dBm == -118) iconLevel = 16;
else if (dBm == -117) iconLevel = 17;
else if (dBm == -116) iconLevel = 18;
else if (dBm == -115) iconLevel = 19;
else if (dBm == -114) iconLevel = 20;
else if (dBm == -113) iconLevel = 21;
else if (dBm == -112) iconLevel = 22;
else if (dBm == -111) iconLevel = 23;
else if (dBm == -110) iconLevel = 24;
else if (dBm == -109) iconLevel = 25;
else if (dBm == -108) iconLevel = 26;
else if (dBm == -107) iconLevel = 27;
else if (dBm == -106) iconLevel = 28;
else if (dBm == -105) iconLevel = 29;
else if (dBm == -104) iconLevel = 30;
else if (dBm == -103) iconLevel = 31;
else if (dBm == -102) iconLevel = 32;
else if (dBm == -101) iconLevel = 33;
else if (dBm == -100) iconLevel = 34;
else if (dBm == -99) iconLevel = 35;
else if (dBm == -98) iconLevel = 36;
else if (dBm == -97) iconLevel = 37;
else if (dBm == -96) iconLevel = 38;
else if (dBm == -95) iconLevel = 39;
else if (dBm == -94) iconLevel = 40;
else if (dBm == -93) iconLevel = 41;
else if (dBm == -92) iconLevel = 42;
else if (dBm == -91) iconLevel = 43;
else if (dBm == -90) iconLevel = 44;
else if (dBm == -89) iconLevel = 45;
else if (dBm == -88) iconLevel = 46;
else if (dBm == -87) iconLevel = 47;
else if (dBm == -86) iconLevel = 48;
else if (dBm == -85) iconLevel = 49;
else if (dBm == -84) iconLevel = 50;
else if (dBm == -83) iconLevel = 51;
else if (dBm == -82) iconLevel = 52;
else if (dBm == -81) iconLevel = 53;
else if (dBm == -80) iconLevel = 54;
else if (dBm == -79) iconLevel = 55;
else if (dBm == -78) iconLevel = 56;
else if (dBm == -77) iconLevel = 57;
else if (dBm == -76) iconLevel = 58;
else if (dBm == -75) iconLevel = 59;
else if (dBm == -74) iconLevel = 60;
else if (dBm == -73) iconLevel = 61;
else if (dBm == -72) iconLevel = 62;
else if (dBm == -71) iconLevel = 63;
if (asu == 99) iconLevel = 0;
This would mean 64 images (including unkown), which in itself isn't too bad considering the percentage battery mod has a bunch more. But obviously we would need to express this better, for example:
Code:
dBm = asu * 2 - 133;
if (asu == 99) iconLevel = 0;
else iconLevel = dBm + 134;
This would make the lookup quick. Question then is how often the signal strength is calculated. Might not be that bad, but it's hard to know before trying it. And as I have no idea how to swap this image space for a textfield, I'll leave that to someone who knows that he/she is doing.
But following my approach, replacing this if-statement, only two more things need to be done as far as I can see:
1. add the extra resources to the framework-res.apk (which isn't a problem), but also to
2. extend the array which the iconLevel variable refers to - sSignalImages.
The Java source code here says,
Code:
private static final int[] sSignalImages = new int[] {
com.android.internal.R.drawable.stat_sys_signal_0,
com.android.internal.R.drawable.stat_sys_signal_1,
com.android.internal.R.drawable.stat_sys_signal_2,
com.android.internal.R.drawable.stat_sys_signal_3,
com.android.internal.R.drawable.stat_sys_signal_4
};
which in smali code is,
Code:
:array_44
.array-data 0x4
0x2at 0x4t 0x8t 0x1t
0x2ct 0x4t 0x8t 0x1t
0x2et 0x4t 0x8t 0x1t
0x30t 0x4t 0x8t 0x1t
0x32t 0x4t 0x8t 0x1t
0x34t 0x4t 0x8t 0x1t
.end array-data
I'm wondering if simply extending this array in increments of 2s would suffice if we use the same filenames? I.e. adding 0x36t 0x4t 0x8t 0x1t, 0x38t 0x4t 0x8t 0x1t, 0x3at 0x4t 0x8t 0x1t, etc. against stat_sys_signal_5, stat_sys_signal_6, stat_sys_signal_7, etc..

If I get some time later on, I'll try and add some text next to the signal. I'll just duplicate the bars for the moment i.e. the text will be 1,2,3,4 or 5.
Shouldn't be too hard (I think) it should just be a matter of adding some xml and then duplicating the smali code to change the text as well... OK, so maybe it won't be that easy we'll see...
Ans thanks for the converter, now I just need to learn java although it's not that far from c++
Can I upload the tool to the themes reference thread?

_calum_ said:
If I get some time later on, I'll try and add some text next to the signal. I'll just duplicate the bars for the moment i.e. the text will be 1,2,3,4 or 5.
Shouldn't be too hard (I think) it should just be a matter of adding some xml and then duplicating the smali code to change the text as well... OK, so maybe it won't be that easy we'll see...
Ans thanks for the converter, now I just need to learn java although it's not that far from c++
Can I upload the tool to the themes reference thread?
Click to expand...
Click to collapse
Sure, no problem.
On another issue, I think we might be screwed.. Try extracting and decompiling services.jar's classes.dex, and then recompiling it (baksmali/smali). I get file size difference and total corruption when viewing through HexCompare. I.e. without having made any changes, things get messed up.

I get the same file size (EDIT: 8 bytes smaller) - but the contents are different...
I'm just gonna bite the bullet now and push that puppy to my phone
I'll get back to you....
EDIT: Phone's still alive and it took a lot longer to reboot so I'm pretty sure the push was successfull (the cache was probably being rebuilt).
I'm going to hard code the notification bar text colour now just to make sure the update was OK. I'll post again in a few minutes

_calum_ said:
I get the same file size - but the contents are different...
I'm just gonna bite the bullet now and push that puppy to my phone
I'll get back to you....
Click to expand...
Click to collapse
Hmm.. I'm loosing 8 bytes What version of smali are you using?
I'm on 1.2.5, and commands used are..
Decompile: java -jar baksmali.jar -o out/ classes.dex
Recompile: java -Xmx512 -jar smali.jar out/ -o new-classes.dex

MrRusch said:
Ok, can't let it go yet.
According to the source code, ASU values range from 0 to 31 (except 99 meaning unknown), which translated to dBm would mean -133 to -71. So, we could change the current if-statement to something like this, leaving iconLevel = 0 as unkown, and then increasing iconLevels with signal strength in dBm..
This would make the lookup quick. Question then is how often the signal strength is calculated. Might not be that bad, but it's hard to know before trying it. And as I have no idea how to swap this image space for a textfield, I'll leave that to someone who knows that he/she is doing.
But following my approach, replacing this if-statement, only two more things need to be done as far as I can see:
1. add the extra resources to the framework-res.apk (which isn't a problem), but also to
2. extend the array which the iconLevel variable refers to - sSignalImages.
The Java source code here says,
which in smali code is,
Code:
:array_44
.array-data 0x4
0x2at 0x4t 0x8t 0x1t
0x2ct 0x4t 0x8t 0x1t
0x2et 0x4t 0x8t 0x1t
0x30t 0x4t 0x8t 0x1t
0x32t 0x4t 0x8t 0x1t
0x34t 0x4t 0x8t 0x1t
.end array-data
I'm wondering if simply extending this array in increments of 2s would suffice if we use the same filenames? I.e. adding 0x36t 0x4t 0x8t 0x1t, 0x38t 0x4t 0x8t 0x1t, 0x3at 0x4t 0x8t 0x1t, etc. against stat_sys_signal_5, stat_sys_signal_6, stat_sys_signal_7, etc..
Click to expand...
Click to collapse
I got your pm and think I can shed a little light here, first this is the only smali
reference I could find but it helps:
http://pallergabor.uw.hu/androidblog/dalvik_opcodes.html
second it is better to think of smali as assembly code than C/Java
things like "||", "&&", "else" are really just macros that get expanded
buy the compiler to what amounts to a bunch of "if" "goto/jump"
statements that are PITA to code by hand.
the data in the array are resource id's which can be found in public.xml in
framework-res.apk
this is the array from my phone:
Code:
.array-data 0x4
0xdet 0x2t 0x8t 0x1t
0xe0t 0x2t 0x8t 0x1t
0xe2t 0x2t 0x8t 0x1t
0xe4t 0x2t 0x8t 0x1t
0xe6t 0x2t 0x8t 0x1t
.end array-data
which resolves to these resources in framework-res.apk
Code:
<public type="drawable" name="stat_sys_signal_0" id="0x010802de" />
<public type="drawable" name="stat_sys_signal_1" id="0x010802e0" />
<public type="drawable" name="stat_sys_signal_2" id="0x010802e2" />
<public type="drawable" name="stat_sys_signal_3" id="0x010802e4" />
<public type="drawable" name="stat_sys_signal_4" id="0x010802e6" />
the resource id's are little-endian which means read backwards so if you want
to add to the array first add your images to framework-res so you have the
resource id's handy then add the resources to the array
like this:
Code:
<public type="drawable" name="example" id="0x11223344" />
Code:
0x44t 0x33t 0x22t 0x11t
I hope this helps.

sweet, thanks for that untermensch, I hadn't quite made the connection from the array data to the IDs, but it makes perfect sense when you look at it side by side like that.
That link is perfect. I was sort of looking at it like MSIL, it is in fact very similar the deeper I dig. All I really needed was to see what the commands where doing (it took me a while to realise that move x y moves y to x and not the other way around )
Anyway, thanks again.

Related

[Think Tank] Getting Google Market (vending.apk) to work without google apps.

In adding google apps support to my last 2.0 rom, I experimented a lot of things and, of all the google apps programs, Vending was the one that was the most interesting to me because I noticed that the program would not force-close like the others with other missing google apps, the program just exits, so it's safe to assume that it's looking for a login somewhere. Even after GoogleApps.apk is removed, the market will still work, something it won't do if you don't sign in before removing GoogleApps. All it seems to require are the two permissions in etc (com.google.android.gtalkservice.xml and com.google.android.datamessaging.xml).
Now, here's what I think, if we're able to look what Vending is looking for and create a small app to generate the necessary login information and put it where needed as best-case goal. A more realistic goal, though, would be to look at the smali code and see where the login information is being requested and causes the program to shut off if it's not available. If we find it, we can just bypass it and have the program start without a login, and I believe the only thing that would be affected would be the cloud storage of the apps we've downloaded, but we'd still have full access to market.
Trying to start the app alone gives me this error:
Code:
12-02 10:42:11.522: INFO/ActivityManager(72): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.vending/.AssetBrowserActivity }
12-02 10:42:11.633: WARN/AudioFlinger(375): write blocked for 95 msecs, 68 delayed writes, thread 0xcd90
12-02 10:42:11.982: DEBUG/AccountManagerService(72): bind attempt failed for Session: expectLaunch false, connected false, stats (0/0/0), lifetime 0.003, getAccountsByTypeAndFeatures, legacy_hosted_or_google
12-02 10:42:12.022: DEBUG/vending(2893): com.android.vending.BaseActivity.completeGetAuthToken(): auth result is RESULT_CANCELED
12-02 10:42:12.033: DEBUG/vending(2893): com.android.vending.BaseActivity.onAuthTokenComplete(): null auth token.
12-02 10:42:12.042: WARN/InputManagerService(72): Starting input on non-focused client [email protected] (uid=10006 pid=2893)
12-02 10:42:12.052: WARN/InputManagerService(72): Client not active, ignoring focus gain of: [email protected]
12-02 10:42:12.222: WARN/InputManagerService(72): Window already focused, ignoring focus gain of: [email protected]
12-02 10:42:41.273: WARN/AudioFlinger(375): write blocked for 95 msecs, 69 delayed writes, thread 0xcd90
so, theoretically, if we have onAuthTokenComplete() ignore the result from completeGetAuthToken() of if we modify completeGetAuthToken() to pass something to onAuthTokenComplete() something to allow the program to start, we should be good to go.
Testers, ideas, experiences?.
I guess this is where we start com.android.vending.BaseActivity.smali:
Code:
.method private completeGetAuthToken(ILandroid/content/Intent;)Ljava/lang/String;
.registers 6
.parameter "resultCode"
.parameter "data"
.prologue
const/4 v2, 0x0
.line 1328
const/4 v1, -0x1
if-ne p1, v1, :cond_11
.line 1329
invoke-virtual {p2}, Landroid/content/Intent;->getExtras()Landroid/os/Bundle;
move-result-object v0
.line 1330
.local v0, extras:Landroid/os/Bundle;
if-eqz v0, :cond_20
.line 1331
const-string v1, "authtoken"
invoke-virtual {v0, v1}, Landroid/os/Bundle;->getString(Ljava/lang/String;)Ljava/lang/String;
move-result-object v1
.line 1338
.end local v0 #extras:Landroid/os/Bundle;,
:goto_10
return-object v1
.line 1333
:cond_11
if-nez p1, :cond_20
.line 1334
invoke-virtual {p0, v2}, Lcom/android/vending/BaseActivity;->setResult(I)V
.line 1335
const-string v1, "auth result is RESULT_CANCELED"
new-array v2, v2, [Ljava/lang/Object;
invoke-static {v1, v2}, Lcom/android/vending/util/Log;->d(Ljava/lang/String;[Ljava/lang/Object;)V
.line 1336
invoke-virtual {p0}, Lcom/android/vending/BaseActivity;->finish()V
.line 1338
:cond_20
const/4 v1, 0x0
goto :goto_10
.end method
Try the youtube app, it will insert login data when you log in with your gmail account.
I think this is it, again, at com.android.vending.BaseActivity.smali:
Code:
.method protected final onAuthTokenComplete(Lcom/android/vending/BaseActivity$AuthService;Ljava/lang/String;Z)V
.registers 6
.parameter "service"
.parameter "authToken"
.parameter "performRetry"
.prologue
.line 1083
if-eqz p2, :cond_d
.line 1084
iget-object v0, p0, Lcom/android/vending/BaseActivity;->mApplication:Lcom/android/vending/VendingApplication;
invoke-virtual {v0, p1, p2}, Lcom/android/vending/VendingApplication;->setCachedAuthToken(Lcom/android/vending/BaseActivity$AuthService;Ljava/lang/String;)V
.line 1085
if-eqz p3, :cond_c
invoke-virtual {p0}, Lcom/android/vending/BaseActivity;->doRetry()V
.line 1089
:cond_c
:goto_c
return-void
.line 1087
:cond_d
const-string v0, "null auth token."
const/4 v1, 0x0
new-array v1, v1, [Ljava/lang/Object;
invoke-static {v0, v1}, Lcom/android/vending/util/Log;->d(Ljava/lang/String;[Ljava/lang/Object;)V
goto :goto_c
.end method
p3 takes you to cond_c which is an auth login retry
p2 looks like it loads the vending app and then tries to get pass AuthService() to setCachedAuthToken(), and if that fails takes you to "null auth token" tossed into log.
Progress!!!!
I got the app to load without closing by removing all calls to onAuthTokenComplete, completeGetAuthToken, and onActivityResult.
Now I'm stuck at the ToS page, it won't load anything, so I'll try to bypass that.
past the ToS and stuck at market "Loading" screen.
removed the call to forwardIfNeededToTosActivity in BaseActivity.
Here's where I'm at right now, all necessary files inside, should work on a vanilla build of master. Either update.zip flash it or adb push it, whatever.
I'm tired, need sleep
Hope somebody else works on this too.
Cant sleep without this suggestion. Hopefully somebody is reading and can make it work.
At this point, I think we're just requiring a login so we can browse market. Search never completes, browse never completes, and I think it's because we're not logged in. If we pull whatever necessary bit from /data/data/com.android.vending from a working market build and toss it in, it should, theoretically again, work. If we remove the personal logins and pass it something generic, it should work too.
I'm still bothered by something, though, what happens with paid apps? Probably a force-close.
Anyway, I hope google at least releases a "free market" app that's standalone and we can toss into generic builds without anything else needed so we can at least download free apps.
it's a database problem.
I know nothing of sqlite so this is as far as I get
use youtube app to login.
either you already have it working or you're just suggesting that I use youtube app to login. I tried it but doesn't work with my hacked market. Is there another way that you know of?
jubeh said:
either you already have it working or you're just suggesting that I use youtube app to login. I tried it but doesn't work with my hacked market. Is there another way that you know of?
Click to expand...
Click to collapse
Have you logged in with your Google or with your YouTube account?
Yeah, I tried it with my google account (and it's already synced to my youtube account). I then opened up the market app I attached to an earlier post and still hanged at the "Loading" screen.
I then pushed a full Market app, which dutyfully force-closed due to the missing GoogleApps.apk, I then pushed it, SetupWizard, Checkin, and the rom started boot-looping so I gave up
how to use Market.zip?thank you!
Launched on CyanogenMod v5.0.7 (Android 2.1) Dream
In order to launch Market app you need Vending.apk, GoogleApps.apk, GoogleCheckin.apk, SetupWizard.apk, TalkProvider.apk, gtalkservice.apk and these framework files:
Code:
/system/etc/permissions/com.google.android.datamessaging.xml
/system/etc/permissions/com.google.android.gtalkservice.xml
/system/framework/com.google.android.datamessaging.jar (often absent, seems works without it)
/system/framework/com.google.android.gtalkservice.jar
/system/lib/libgtalk_jni.so
Vending.apk, GoogleApps.apk, SetupWizard.apk, gtalkservice.apk should be placed only on /system (because they require privileges that can be acquired only there, like WRITE_SECURE_SETTINGS, see https://www.isecpartners.com/files/iSEC_Securing_Android_Apps.pdf), GoogleCheckin.apk & TalkProvider.apk probably can be placed anywhere (but I didn't try).
no success
I have try it follow your instructions,
but with no success;
it stays in the UI "Searching..."
any suggestion?
I put your vending.apk to /system/app/,
and the com.google.android.gtalkservice.jar to /system/framework/;
and
com.google.android.gtalkservice.xml
com.google.android.datamessaging.xml
to /etc/permissions/
am I right?
this would be crucial if I could get this too work. I have a Camangi WebStation, which runs a custom Cupcake 1.5 with NO GAPPS or Market even worse NO Google Maps. I would love to get Google Maps to work on it, cause it has a GPS, but no GPS app or Maps function. But yeah it dont have the Google branding, so it doesnt have any important Google Apps.
If this could be implemented to work on other devices, it would be freaking nice
This doesn't work, at least in it's current form, and I have no interest on working on it. This was from when we had the infinite sync problem with eclair and I wanted to make a rom without gapps and just market.
Also, this is not for users, this was for dev help to try to make a googlelogin that vending could use after bypassing the check for googleapps.
Mod, please close this thread.
Where to get
com.google.android.datamessaging.xml etc.,
Please let me know
thanks
-Venu
I USE THIS SETUPS
adb remount
adb push whatever.apk /system/app (put an apk in your sdk tools and replace "whatever" with the name of the apk and this
will push it to your system app folder. You can change the destination as well for example: You want to push Launcher2.apk
to your data/app folder: adb remount
adb push Launcher2.apk /data/app )
but when i type adb remount in cmd show this error
C:\android-sdk\tools>adb remount
remount failed: Operation not permitted

[MOD] YouTube that always defaults to high quality

I got fed up with the YouTube app starting videos in normal quality. To watch high quality I had to click menu and select it. The app is supposed to default to a quality suitable for your current connection but IMHO it sucks at that.
My solution was to mod the app so it always defaults to high quality. It was a 2 minute hack using apktool from brut.all (great tool, thanks!). Changes was made to PlayerActivity.smali. All I did was to remove a if condition statement by adding a # first on the line (comment) so preferHiRes always is true.
Code:
.line 166
invoke-virtual {p0}, Lcom/google/android/youtube/PlayerActivity;->getNetworkSpeed()I
move-result v0
const/4 v1, 0x3
#if-ne v0, v1, :cond_0
const/4 v0, 0x1
:goto_0
iput-boolean v0, p0, Lcom/google/android/youtube/PlayerActivity;->preferHiRes:Z
.line 168
invoke-direct {p0}, Lcom/google/android/youtube/PlayerActivity;->loadYouTubePlayer()V
Source apk is YouTube.apk from gapps-passion-EPE54B-signed.zip.
Download HQ mod
Install (root required, tested on CM 5.0.6):
Extract the apk from the zip (it's NOT a flashable update.zip)
Push it to /system/app
Code:
adb remount
adb push YouTube.apk /system/app/YouTube.apk
This mod is provided as is without guarantees. It works for me and I though I'd share it in case anyone else wanted it. Nandroid first is always good.
AWESOME!!!
There's a thread in the general forum with a modified apk file. Works great
http://forum.xda-developers.com/showthread.php?t=632969&page=6
jonasl, just a nood question...
Where would it have to put "#" to set low qualitiy as default?
Missed the other one completely... I didn't look for app mods in the Q&A section
To get normal quality as default you should ensure that the boolean variable preferHiRes always is false. There are several ways to do this. A rough translation of the original assembly code to java would look something like this
Code:
if(getNetworkSpeed() == 3)
preferHiRes = true;
else
preferHiRes = false;
loadYouTubePlayer()
My mod takes away the if so the code logically runs like this
Code:
if(true)
preferHiRes = true;
else
preferHiRes = false;
loadYouTubePlayer()
You want something like
Code:
if(true)
preferHiRes = false;
else
preferHiRes = false;
loadYouTubePlayer()
This could be done like this
Code:
.line 166
invoke-virtual {p0}, Lcom/google/android/youtube/PlayerActivity;->getNetworkSpeed()I
move-result v0
const/4 v1, 0x3
#if-ne v0, v1, :cond_0
const/4 v0, 0x0
:goto_0
iput-boolean v0, p0, Lcom/google/android/youtube/PlayerActivity;->preferHiRes:Z
.line 168
invoke-direct {p0}, Lcom/google/android/youtube/PlayerActivity;->loadYouTubePlayer()V
Notice that I have only changed const/4 v0, 0x1 to const/4 v0, 0x0. This corresponds to the pseudo java code outlined above.
Of course one could rewrite it all a little bit more for easier reading:
Code:
preferHiRes = false;
loadYouTubePlayer()
This would correspond to
Code:
.line 166
const/4 v0, 0x0
iput-boolean v0, p0, Lcom/google/android/youtube/PlayerActivity;->preferHiRes:Z
.line 168
invoke-direct {p0}, Lcom/google/android/youtube/PlayerActivity;->loadYouTubePlayer()V
.line 169
return-void
.end method
Find .line 166 in PlayerActivity.smali and substitute everything between it and .end method with the snippet above. Change const/4 v0, 0x0 to const/4 v0, 0x1 to default to high quality.
Hope you learned something from this... I know I suck at explaining things that I think are simple but I'm trying Sharing knowledge is what pushes this and other communities forward.
Thanx for taking your time and sharing knowledge, I appreciate it!
jonasl said:
I know I suck at explaining things that I think are simple but I'm trying
Click to expand...
Click to collapse
You don't suck. That was excellent.
Thanks.
wow~thanks!!!!
it works for my hero!
btw, do you know how can i set my location in this app?
my previous youtube app's front page showed the video according to my location(Hong Kong ) such as Most viewed, most discussed...etc...
but now seems to be connected to worldwide...
No idea about the localization. Everything changed is outlined above (ie I haven't touched it). I would guess that the application checks your locale to determine what to show since that's how other Google stuff works (GeneWidget for example). Maybe other versions of the apps works different from this one.
thanks for your reply!
actually i've tried several versions of Youtube.apk...
only some older versions could check my locale correctly, but, those are not high quality supported in 3G connection...
it's there any methods that can change the older versions youtube.apk to default always high quality??
not to be condescending, but a youtube that defaults to HQ was done like back in january...
http://alldroid.org/threads/14738-app-script-xUltimate-v1.2.4-**UPDATED-02-17-10**
and thats just to show that a patcher xeudoxus created already had it implemented by the end of january...i dont remember exactly how much further back it was actually released.
Wow~finally I did it too!
I followed your instruction and usee apktool to modify the older version YouTube.apk and it really work on my Hero
There was some differents as it didn't have PlayerActivity.smali, instead, i found YouTubeplayer.smali which is similar to it.
I just removed the whole line of ' if-ne v0, v1, :cond_0 ' and didn't change anything.
Really thanks for your instruction. I can now see the local high quality videos!
File is uploaded in case someone needs.
I tried to push the YouTube.apk to /system/app/YouTube.apk but it gives me an error about read only file system.
Does anyone know how to solve this?
Thanks.
crimsondr said:
I tried to push the YouTube.apk to /system/app/YouTube.apk but it gives me an error about read only file system.
Does anyone know how to solve this?
Thanks.
Click to expand...
Click to collapse
do:
adb remount
first.
gIMpSTa said:
do:
adb remount
first.
Click to expand...
Click to collapse
That worked. Thanks!
MYxdaUSERNAME said:
not to be condescending, but a youtube that defaults to HQ was done like back in january...
http://alldroid.org/threads/14738-app-script-xUltimate-v1.2.4-**UPDATED-02-17-10**
and thats just to show that a patcher xeudoxus created already had it implemented by the end of january...i dont remember exactly how much further back it was actually released.
Click to expand...
Click to collapse
Off topic: Not getting what you are trying to say and the link doesn't contain any details. Personally I don't really care if someone made a similar or identical mod before me. I'm not in for the attention. I'm in for the fun of it and then share stuff I think others will enjoy as well (including the know how). Also, this mod isn't exactly that advanced so anyone with some basic Dalvik experience could have done it independently just as I did.
On topic:
If you are getting messages about xml parser errors (that can just be dismissed my hitting back):
I've been getting this more and more myself both prior to applying my HQ mod and afterward. It's not related, not if you are using my mod anyway. What's changed in my mod is described in detail in this thread and it's not related to xml parsing. Several users of stock firmware have this issue as well, here are some examples:
http://www.google.com/support/forum/p/android/thread?tid=7520c38a6e2e4ce3&hl=en
http://www.google.com/support/forum/p/android/thread?tid=44b225740841f9d4&hl=en
http://www.droidforums.net/forum/te...ggestions/20880-connection-error-youtube.html
The solution seems to be to clear the YouTube data and cache in Manage Applications. Try this if you run into this issue.
Always HQ built into version 1.6.20
I just discovered that Youtube version 1.6.20 has this option built in already. It's in the settings menu. I pulled it from Paul's Desire rom and it works perfectly. It also has a HQ toggle button on the right side of the time slider.
gj13 said:
I just discovered that Youtube version 1.6.20 has this option built in already. It's in the settings menu. I pulled it from Paul's Desire rom and it works perfectly. It also has a HQ toggle button on the right side of the time slider.
Click to expand...
Click to collapse
Could you post the apk?
hey i do i go back to the regular setting theres alot of videos that dont have the high quality option im assuming so they wont even play for me
Aitese said:
Could you post the apk?
Click to expand...
Click to collapse
here: YouTube 1.6.20 (E)

Problems on SMS text limitation to 1000 per conversation

Hey guys, I am very upset towards the limitation over the stock sms apps in my razr maxx as I would certainly like to store something SMS sent from my dearest.
So I desired to make some tweaks over the messaging apps. I search over and over and finally got the setting code in MessageSettings.smali.
Let me give you some code about it
.field private static final MMS_MAX_SMIL_SIZE:I = 0xc8
.field public static final SMS_MMS_DEFAULT_MESSAGE_COUNT_PER_THREAD:I = 0xc8
.field public static final SMS_MMS_MAX_MESSAGE_COUNT_PER_THREAD:I = 0x3e8
.method public static getConversationMessageLimit()I
.locals 3
.prologue
.line 1280
sget-object v0, Lcom/motorola/messaging/settings/MessageSettings;->mDefaultPrefs:Landroid/content/SharedPreferences;
const-string v1, "MaxMessagesPerThread"
const/16 v2, 0x3e8
invoke-interface {v0, v1, v2}, Landroid/content/SharedPreferences;->getInt(Ljava/lang/String;I)I
move-result v0
return v0
.end method
Click to expand...
Click to collapse
I modify them, both the default and max limitation to "0xffff", and replace the original apk in system, seems the 1000 limitation is still there:crying:
Anyone knows exactly what's wrong with my modification? Or I need to make more changes in other files?
Thx guys!
Please, don't ask me to use 3rd party SMS apps, as I love my stock SMS apps a lot except for such a limitation!

Samsung RIL (Low level network info)

All,
I am attempting to obtain low level network info from RIL.java, from my Samsung SGH-I747. Per thread https ://groups.google.com/forum/?fromgroups=#!topic/android-platform/tVyNMnXtcEI,
Using OEM_REQUEST_RAW requests, I can bypass everything and make raw byte string requests to and from the radio.
- requests to ril: "> OEM_HOOK_RAW"
- responses from ril: "< OEM_HOOK_RAW"
By default however, you cannot see these responses to the log as byte[] types are ignored in method retToString (RIL.java)
Change to RIL.java:
} else if (ret instanceof byte[]) {
byte[] bytes = (byte[]) ret;
s = IccUtils.bytesToHexString(bytes);
Unfortunately, Samsung seems to have added a lot of code to RIL.java and there is no place to get the source. So I added this code in smali. (wasn't fun haha)
Code:
:cond_81
move-object/from16 v0, p2
instance-of v13, v0, [B
if-eqz v13, :cond_93
check-cast p2, [B
.end local p2
move-object/from16 v1, p2
check-cast v1, [B
.local v1, bytes:[B
invoke-static {v1}, Lcom/android/internal/telephony/IccUtils;->bytesToHexString([B)Ljava/lang/String;
move-result-object v10
.restart local v10 #s:Ljava/lang/String;
goto/16 :goto_4
.end local v1 #bytes:[B
.end local v10 #s:Ljava/lang/String;
.restart local p2
Before & After - No change
[email protected]:/ $ logcat -b radio|grep OEM
D/RILS ( 1937): [0007]< OEM_HOOK_RAW { what=1008 when=-2m37s688ms }
D/RILS ( 1937): [0008]> OEM_HOOK_RAW[010300060001]
D/RILS ( 1937): [0008]< OEM_HOOK_RAW { what=1008 when=-2m37s914ms }
D/RILS ( 1937): [0009]> OEM_HOOK_RAW[010300060001]
But there is no bytes written from the log, just OEM_HOOK_RAW { what=1008 when=-2m37s914ms }. Any ideas?
I'm also trying similar. I'm currently trying to enable QXDM logging on my Galaxy S3, but since Samsung took away the radiooptions command that's in AOSP, I'm having absolutely zero luck. Samsung's RIL looks to be considerably different, I found a repo of the code here: http://gitorious.org/replicant/hardware_ril_samsung-ril/trees/master.
I also tried my hand at doing it through the SDK and ran into issues since you must be able to get a Phone object in order to actually communicate with the RIL that is defined in RIL.java (at least from what I've seen). The problem is that the in order to get the defaultPhone, you have to run your application in the Phone process, which requires you to sign it with the same key as the Phone class, which seemed too bothersome to be practical.

[Q] Help defining values in PhoneNumberUtils.smali [SOLVED]

It seems to be a reoccurring problem across many roms, even some stock, that incoming calls without prefix (+47 etc) does not do lookup (and match) to contact stored with prefixes. Now there is an app called Prefixer wich can do alot with the subject, but it seems no app can actually manipulate the incoming call ID. Thus, after alot of ravaging through here and other forums, I've been led to the conclusion that this is bad/wrong values in the following file:
Framework.jar->classes/android/telephony/PhoneNumberUtils.smali
Now the values I was told to look for was :
Code:
.local v7, minMatchLen:I
const/4 v7, 0xb
.local v0, minMatchLen:I
const/4 v0, 0xb
And change the minMatchLen:I vaules to:
Code:
.local v7, minMatchLen:I
const/4 v7, 0x7
.local v0, minMatchLen:I
const/4 v0, 0x7
Now - When I extracted the PhoneNumberUtils.mali from my current rom (Gthrill V3 (CM10 mod), The corresponding values were:
Code:
.local v7, minMatchLen:I
const/16 v7, 0xb
.local v0, minMatchLen:I
const/16 v0, 0xb
What I'm really wondering here is - can someone elaborate what these lines define - and what the practical difference between "const/4" and "const/16" acually is?
const/16 allows for a bigger value than const/4
It's safe to lower it from 0xb (11) to 0x7 (7) and leave the const/16 alone.
If you have a const/4 and wanted to apply a larger value, chances are a smali compile will fail without changing the const/4 to const/16.
Thanks - cleared up alot Luckily I was "already at 16". And, it might explain why I got stuck in boot loop when I tried to change the values to const/4 v0, 0x7 ...(?)
Deleted.

Categories

Resources