Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,777,659 Members 44,368 Now Online
XDA Developers Android and Mobile Development Forum

[DEV][PATCH] AndroidID for gapps (patched framework.jar) || Firmware 1.1.0

Tip us?
 
Decad3nce
Old
(Last edited by Decad3nce; 15th February 2011 at 10:44 PM.)
#1  
Decad3nce's Avatar
Retired Forum Moderator / Recognized Developer - OP
Thanks Meter 2768
Posts: 2,083
Join Date: Feb 2010

 
DONATE TO ME
Default [DEV][PATCH] AndroidID for gapps (patched framework.jar) || Firmware 1.1.0

This is work done by clockworx which can originally be found: http://forum.xda-developers.com/showthread.php?t=877752

I just grabbed the original patch and merged it into 1.1.0 framework.jar; and I'm posting this here for reference on how to patch framework.jar in future B&N releases.

Things you'll need:
APKtool(by brutall): http://code.google.com/p/android-apktool/
framework.jar: Just grab it from the official sideload update.zip
Patch: http://dl.dropbox.com/u/9992367/TelephonyManager.patch
Pastebin: http://pastebin.com/4gxqHw6B

How-to:

You'll need to decompile the framework.jar from the sideload update.zip.

Create a separate folder to do all of this.

Code:
apktool d framework.jar
Should output:
Code:
I: Baksmaling...
I: Copying assets and libs...
Then you'll grab the above patch, and copy it to /framework.jar.out/smali/android/telephony/

Code:
cp TelephonyManager.patch /framework.jar.out/smali/android/telephony/TelephonyManager.patch
Then cd to the directory, and patch the file!

Code:
cd framework.jar.out/smali/android/telephony
patch -p0 -E < TelephonyManager.patch
output:
Code:
patching file TelephonyManager.smali
and you're done patching the file!

Remove the patch file before continuing!

You'll now need to build framework.jar again. Go back to the initial directory and run:

Code:
apktool b framework.jar.out
output:
Code:
I: Checking whether sources has changed...
I: Smaling...
W: Could not find resources
I: Building apk file...
Don't worry about the warning about not finding resources, it's expected.

And thats about it.

Here's the patched framework.jar for 1.1.0 that's already included in IOMonsters rootpack: http://dl.dropbox.com/u/9992367/framework.jar

Hopefully this will be a valuable reference in the future!

Credits:
Clockworx
brut.all
The Following 3 Users Say Thank You to Decad3nce For This Useful Post: [ Click to Expand ]
 
Decad3nce
Old
#2  
Decad3nce's Avatar
Retired Forum Moderator / Recognized Developer - OP
Thanks Meter 2768
Posts: 2,083
Join Date: Feb 2010

 
DONATE TO ME
Full patch, visualized:

(for analysis)

Code:
--- TelephonyManager.smali	2011-02-15 16:14:11.000000000 -0600
+++ TelephonyManager.smali	2011-02-02 19:17:21.000000000 -0600
@@ -82,6 +82,8 @@
 
 .field private static final TAG:Ljava/lang/String; = "TelephonyManager"
 
+.field private static final TAG_CWX:Ljava/lang/String; = "CLOCKWORX"
+
 .field private static sInstance:Landroid/telephony/TelephonyManager;
 
 
@@ -687,52 +689,73 @@
 .end method
 
 .method public getDeviceId()Ljava/lang/String;
-    .locals 3
+    .locals 5
 
     .prologue
-    const/4 v2, 0x0
+    .line 191
+    const-string v0, "35828001"
 
-    .line 187
-    :try_start_0
-    invoke-direct {p0}, Landroid/telephony/TelephonyManager;->getSubscriberInfo()Lcom/android/internal/telephony/IPhoneSubInfo;
+    .line 192
+    .local v0, fakeDevId:Ljava/lang/String;
+    new-instance v1, Ljava/util/Random;
 
-    move-result-object v1
+    invoke-direct {v1}, Ljava/util/Random;-><init>()V
 
-    invoke-interface {v1}, Lcom/android/internal/telephony/IPhoneSubInfo;->getDeviceId()Ljava/lang/String;
-    :try_end_0
-    .catch Landroid/os/RemoteException; {:try_start_0 .. :try_end_0} :catch_0
-    .catch Ljava/lang/NullPointerException; {:try_start_0 .. :try_end_0} :catch_1
+    .line 193
+    .local v1, randomGenerator:Ljava/util/Random;
+    new-instance v2, Ljava/lang/StringBuilder;
 
-    move-result-object v1
+    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
 
-    .line 191
-    :goto_0
-    return-object v1
+    invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
 
-    .line 188
-    :catch_0
-    move-exception v1
+    move-result-object v2
 
-    move-object v0, v1
+    const v3, 0xf4240
 
-    .local v0, ex:Landroid/os/RemoteException;
-    move-object v1, v2
+    invoke-virtual {v1, v3}, Ljava/util/Random;->nextInt(I)I
 
-    .line 189
-    goto :goto_0
+    move-result v3
 
-    .line 190
-    .end local v0           #ex:Landroid/os/RemoteException;
-    :catch_1
-    move-exception v1
+    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
 
-    move-object v0, v1
+    move-result-object v2
 
-    .local v0, ex:Ljava/lang/NullPointerException;
-    move-object v1, v2
+    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
 
-    .line 191
-    goto :goto_0
+    move-result-object v0
+
+    .line 203
+    const-string v2, "TAG_CWX"
+
+    new-instance v3, Ljava/lang/StringBuilder;
+
+    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V
+
+    const-string v4, "Generated:"
+
+    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
+
+    move-result-object v3
+
+    invoke-virtual {v3, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
+
+    move-result-object v3
+
+    const-string v4, "."
+
+    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
+
+    move-result-object v3
+
+    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
+
+    move-result-object v3
+
+    invoke-static {v2, v3}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I
+
+    .line 204
+    return-object v0
 .end method
 
 .method public getDeviceSoftwareVersion()Ljava/lang/String;
@@ -1139,70 +1162,20 @@
 .end method
 
 .method public getPhoneType()I
-    .locals 3
+    .locals 2
 
     .prologue
-    .line 282
-    :try_start_0
-    invoke-direct {p0}, Landroid/telephony/TelephonyManager;->getITelephony()Lcom/android/internal/telephony/ITelephony;
-
-    move-result-object v1
-
-    .line 283
-    .local v1, telephony:Lcom/android/internal/telephony/ITelephony;
-    if-eqz v1, :cond_0
-
-    .line 284
-    invoke-interface {v1}, Lcom/android/internal/telephony/ITelephony;->getActivePhoneType()I
-
-    move-result v2
-
-    .line 296
-    .end local v1           #telephony:Lcom/android/internal/telephony/ITelephony;
-    :goto_0
-    return v2
-
-    .line 287
-    .restart local v1       #telephony:Lcom/android/internal/telephony/ITelephony;
-    :cond_0
-    invoke-direct {p0}, Landroid/telephony/TelephonyManager;->getPhoneTypeFromProperty()I
-    :try_end_0
-    .catch Landroid/os/RemoteException; {:try_start_0 .. :try_end_0} :catch_0
-    .catch Ljava/lang/NullPointerException; {:try_start_0 .. :try_end_0} :catch_1
+    .line 318
+    const-string v0, "CLOCKWORX"
 
-    move-result v2
+    const-string v1, "Returning 1."
 
-    goto :goto_0
+    invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I
 
-    .line 289
-    .end local v1           #telephony:Lcom/android/internal/telephony/ITelephony;
-    :catch_0
-    move-exception v2
-
-    move-object v0, v2
-
-    .line 292
-    .local v0, ex:Landroid/os/RemoteException;
-    invoke-direct {p0}, Landroid/telephony/TelephonyManager;->getPhoneTypeFromProperty()I
-
-    move-result v2
-
-    goto :goto_0
-
-    .line 293
-    .end local v0           #ex:Landroid/os/RemoteException;
-    :catch_1
-    move-exception v2
-
-    move-object v0, v2
-
-    .line 296
-    .local v0, ex:Ljava/lang/NullPointerException;
-    invoke-direct {p0}, Landroid/telephony/TelephonyManager;->getPhoneTypeFromProperty()I
-
-    move-result v2
-
-    goto :goto_0
+    .line 319
+    const/4 v0, 0x1
+    
+    return v0
 .end method
 
 .method public getSimCountryIso()Ljava/lang/String;
 
bdcrim
Old
#3  
Senior Member
Thanks Meter 68
Posts: 461
Join Date: Oct 2010
Deca, anyway to move files with root explorer? I am lazy.
 
Decad3nce
Old
#4  
Decad3nce's Avatar
Retired Forum Moderator / Recognized Developer - OP
Thanks Meter 2768
Posts: 2,083
Join Date: Feb 2010

 
DONATE TO ME
Quote:
Originally Posted by bdcrim View Post
Deca, anyway to move files with root explorer? I am lazy.
lol, no. You need to decompile framework.jar to be able to patch telephony manager to generate an AndroidID
 
brianf21
Old
#5  
Senior Member
Thanks Meter 480
Posts: 623
Join Date: Oct 2010
Location: Davie, FL
This patch file does not work with the framework.jar for NF. Could we get an updated patch file? Or the method on how the patch file was created?
 
Decad3nce
Old
#6  
Decad3nce's Avatar
Retired Forum Moderator / Recognized Developer - OP
Thanks Meter 2768
Posts: 2,083
Join Date: Feb 2010

 
DONATE TO ME
Quote:
Originally Posted by brianf21 View Post
This patch file does not work with the framework.jar for NF. Could we get an updated patch file? Or the method on how the patch file was created?
The patch file itself will give you an idea of what needs to be done. There are a lot of differences between the 2.1 Telephony Manager and the 2.2(NF) Telephony Manager so you'll have to take those things into account when merging them in.
 
brianf21
Old
#7  
Senior Member
Thanks Meter 480
Posts: 623
Join Date: Oct 2010
Location: Davie, FL
Quote:
Originally Posted by Decad3nce View Post
The patch file itself will give you an idea of what needs to be done. There are a lot of differences between the 2.1 Telephony Manager and the 2.2(NF) Telephony Manager so you'll have to take those things into account when merging them in.
When i did, i was getting a 15 digit IMEI number error in logcat when i opened thr market.
 
clockworx
Old
(Last edited by clockworx; 16th February 2011 at 12:36 PM.)
#8  
Senior Member
Thanks Meter 22
Posts: 183
Join Date: Jun 2009
Huh, I had no idea this was still in use

I might be able to do a 2.2 version over weekend if no one else gets around to it (on the road currently and my Dev tools are back at home)

Also, at some point I need to have it save to a SqlDB. Right now it generates a new one each request, which doesn't matter for most people since you only get the Android ID once, but I did see a thread complaining that their app validated by IMEI and it generated a new one each time. Oops!


For what it's worth, I've never had to use a hacked framework.jar for NF, otherwise I would have done one already. Does anyone have a further description of why they want it? The main purpose this was used for was to make Market/Talk work, and they both work for me in NF out of the box.
 
racks11479
Old
(Last edited by racks11479; 17th February 2011 at 12:45 PM.)
#9  
racks11479's Avatar
Senior Member
Thanks Meter 751
Posts: 990
Join Date: Jan 2011
Location: Fresh Meadows

 
DONATE TO ME
Just wanted to say thanks for the patch. After I replaced my framework.jar with the patched one. Some apps that were FC'ing now runs. Especially my NBA Gametime is back up and running. Some of my GAMELOFT HD games that were FC'ing is also running as well now. Guess it has to do with the app looking for an AndroidID.

Stock 1.1.0 Rooted

Update: My apps work now but it broke my stock B&N shop. Goes to a black screen after loading. Im able to exit out of it. What could be causing this?

Edit: Neva mind. Seems that the modified framework didn't include the META and preloaded-class files from my original framework.jar. Guess shop is dependent on it somehow. Everything works now. Thanx again.
 
paleh0rse
Old
(Last edited by paleh0rse; 17th February 2011 at 01:19 AM.)
#10  
Senior Member
Thanks Meter 633
Posts: 1,747
Join Date: Jan 2011

 
DONATE TO ME
Little bit confused...

1) What problem(s) does this address?

2) Will this fix my current inability to use the web-based market?

3) Can we simply replace our framwork.jar file with the one in the OP, or do we have to compile our own? What directory is it in?

Note: I used the unofficial AN3.0 on top of stock 1.1 to root and install gapps...

Thanks ahead of time!
"To be rooted is perhaps the most important and least recognized need of the human soul." - Simone Weil

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Add Bits and Pieces of Honami to Your Current ROM

In the last few months, we’ve talked about quite a few Sony Honami-related projects. … more

Always Enter the Correct Password with HideNoPasswords

If you’ve ever entered apassword on your mobile device, you’ve surely … more

Revert to Stock Recovery Effortless with Simple Recovery Switcher

Android updates released as OTA packages are very easy to apply,but they … more

Convert PNGs into RLEs Easily on Any OS with PNG2RLE

Unlike other operating systems, Android uses its own graphical image formats. Most of … more