Micromax Yureka: Indian Handset with CyanogenMod

Thesoap opera involving Cyanogen Inc., OnePlus, and Micromax is one of the most talked about … more

Chainfire Turns Your Bootanimation into a Logging Center

Having a nice boot animation certainly adds a little bit of aesthetic polish to your … more

Android TV Launcher Pushed to Google Play

Over the past decade, the tech universe has seen two drastic and widely contrasting changes with … more

Cyngn, OnePlus, Micromax – The Legal Battle

Recently, a battle has been waging in India over the rights to distribute the commercial … more

Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

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

OP Decad3nce

15th February 2011, 11:32 PM   |  #1  
Decad3nce's Avatar
OP Retired Forum Moderator / Recognized Developer
Thanks Meter: 2,772
 
2,083 posts
Join Date:Joined: Feb 2010
Donate to Me
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 by Decad3nce; 15th February 2011 at 11:44 PM.
The Following 3 Users Say Thank You to Decad3nce For This Useful Post: [ View ]
15th February 2011, 11:32 PM   |  #2  
Decad3nce's Avatar
OP Retired Forum Moderator / Recognized Developer
Thanks Meter: 2,772
 
2,083 posts
Join Date:Joined: 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;
16th February 2011, 01:01 AM   |  #3  
Senior Member
Thanks Meter: 70
 
476 posts
Join Date:Joined: Oct 2010
Deca, anyway to move files with root explorer? I am lazy.
16th February 2011, 01:06 AM   |  #4  
Decad3nce's Avatar
OP Retired Forum Moderator / Recognized Developer
Thanks Meter: 2,772
 
2,083 posts
Join Date:Joined: Feb 2010
Donate to Me
Quote:
Originally Posted by bdcrim

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
16th February 2011, 05:55 AM   |  #5  
Senior Member
Flag Davie, FL
Thanks Meter: 480
 
624 posts
Join Date:Joined: Oct 2010
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?
16th February 2011, 06:05 AM   |  #6  
Decad3nce's Avatar
OP Retired Forum Moderator / Recognized Developer
Thanks Meter: 2,772
 
2,083 posts
Join Date:Joined: Feb 2010
Donate to Me
Quote:
Originally Posted by brianf21

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.
16th February 2011, 07:16 AM   |  #7  
Senior Member
Flag Davie, FL
Thanks Meter: 480
 
624 posts
Join Date:Joined: Oct 2010
Quote:
Originally Posted by Decad3nce

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.
16th February 2011, 01:34 PM   |  #8  
Senior Member
Thanks Meter: 22
 
183 posts
Join Date:Joined: 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.
Last edited by clockworx; 16th February 2011 at 01:36 PM.
16th February 2011, 11:52 PM   |  #9  
racks11479's Avatar
Senior Member
Flag Fresh Meadows
Thanks Meter: 751
 
990 posts
Join Date:Joined: Jan 2011
Donate to Me
More
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 by racks11479; 17th February 2011 at 01:45 PM.
17th February 2011, 02:13 AM   |  #10  
Senior Member
Thanks Meter: 633
 
1,747 posts
Join Date:Joined: 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!
Last edited by paleh0rse; 17th February 2011 at 02:19 AM.

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes