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

Search This thread

Decad3nce

Retired Forum Mod / Inactive Recognized Developer
Feb 19, 2010
2,086
2,761
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
 
Last edited:

Decad3nce

Retired Forum Mod / Inactive Recognized Developer
Feb 19, 2010
2,086
2,761
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;
 

brianf21

Senior Member
Oct 27, 2010
626
480
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

Retired Forum Mod / Inactive Recognized Developer
Feb 19, 2010
2,086
2,761
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

Senior Member
Oct 27, 2010
626
480
Davie, FL
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

Senior Member
Jun 7, 2009
191
22
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.
 
Last edited:

racks11479

Senior Member
Jan 2, 2011
990
748
Fresh Meadows
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.
 
Last edited:

paleh0rse

Senior Member
Jan 4, 2011
1,942
627
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!
 
Last edited:

jboxer

Senior Member
Apr 16, 2009
1,791
509
Bangkok
Not working in Windows

Okay, I have the file decompiled but there is nothing to execute "patch" on my Windows system. Where do I get the tool to do the actual patching. Or how do you do the patch in Windows?
 
Last edited:

jboxer

Senior Member
Apr 16, 2009
1,791
509
Bangkok
Just google for UnxUtil or GNUWin32.

Sent from my "NookDroid" using XDA App

Okay. I did that and tried to patch the file but I got the following error:

patching file `TelephonyManager.smali'
Assertion failed: hunk, file patch.c, line 321

What do I need to do to fix this problem?

Thanks again for your help.
 

don_ernesto

Senior Member
Nov 19, 2010
134
25
i replaced my framework.jar with the one provided by decadence, and, as racks11479 suggested i also added the META-INF and the preloaded-class from my original file.

it works, it also fixed my gameloft games problems, but now it takes a lot more time when booting and once booted, the startup time (show my homescreen) also takes longer. i have rebooted 3 times to check if the delay dissapear, but no....

is there any logical explanation for this behaviour?
 

racks11479

Senior Member
Jan 2, 2011
990
748
Fresh Meadows
Strange. Because mine only delayed the first time after replacing my framework.jar file. Seems fine since. I've just rebooted again to make sure. And no delay whatsoever. Not sure what could be causing your problem.
 

rohit275

Senior Member
Dec 26, 2008
127
5
Please excuse my ignorance, but what exactly does this patch provide? Is it for stability issues with the stock eclair rom?
 

racks11479

Senior Member
Jan 2, 2011
990
748
Fresh Meadows
Also want to confirm that since the framework patch. My XDA app is surviving login like it used to on 1.0.1.

I understand that this was an issue with the 1.1.0 release.

Stock 1.1.0 rooted.

Sent from my "NookDroid" using XDA App
 

clockworx

Senior Member
Jun 7, 2009
191
22
i replaced my framework.jar with the one provided by decadence, and, as racks11479 suggested i also added the META-INF and the preloaded-class from my original file.

it works, it also fixed my gameloft games problems, but now it takes a lot more time when booting and once booted, the startup time (show my homescreen) also takes longer. i have rebooted 3 times to check if the delay dissapear, but no....

is there any logical explanation for this behaviour?

The first boot, yes, as it would force a dalvik cache rebuild, but on subsequent boots no
 

paleh0rse

Senior Member
Jan 4, 2011
1,942
627
Little bit confused...

1) What problem(s) does this address? ie. What is this for??

2) 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!
Anyone? Please?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 3
    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
    1
    Where are the META and preloaded-class files that need to be included? I decompiled my original framework.jar and couldn't find anything regarding that in there. Do you have a file already patched with those in that you could share, or let me know where to get those files? Thanks in advance.

    edit: opened in winrar and found the meta and preloaded-class files... copied them over to the patched file and it looks like it's working... i've attached my file to help future noobs like me :)

    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.
    1
    Here's one for Nookie Froyo 0.6.8:

    http://www.mediafire.com/?fv6rq4nvq6g462d

    I suggest backing up your old framework.jar before using this one, in case you need to reverse out.

    I haven't even had a chance to test yet myself, so everything about functionality is what I am hoping it does :) If you're logcat-ing, you can look for messages tagged "mockTelephony" to see if it is doing anything.

    The planned operation is that it will still generate an IMEI, and "1" for network type (GSM), and then store it for next round. There should be messages when an IMEI is requested, and whether it finds a stored one or tries to generate one and then store. The only thing I'm still not sure on is whether the storing will work across sessions/reboots/etc, I think at the very worst it should behave like the old version if IMEI storing doesn't work.

    There's more stuff you can do, but I'll leave it at this for now just to see if we can get confirmation of it working.

    Thanks!