Post Reply

[GUIDE] Locking contacts/sms apps in memory on JB/cm10 (technical / baksmali way)

OP espaciosalter20

16th September 2012, 11:47 PM   |  #1  
espaciosalter20's Avatar
OP Senior Member
Flag Bogotá, Colombia, Colombia
Thanks Meter: 715
 
1,269 posts
Join Date:Joined: Jun 2011
Donate to Me
More
Hi everyone!

kanpurite made a great job giving us the easy way to locking apps in memory in this thread.

But, as i told in http://forum.xda-developers.com/show...6&postcount=23 there is other, a little bit harder, but still it can be done.

Requirements:

A Pc (this guide is made over Windows, but may work on linux as well)
notepad++
baksmali/smali tools (attached at this thread)
root explorer (or any file explorer with root capabilities)

Here is a step by step guide to do it:

1. Extract baksmali tools to a new folder

2. Extract services.jar from your phone (at /system/framework) and copy to your baksmali folder

3. Run baksmali manager.bat

4. select option 4 (select file to work), then select services.jar

5. select option 1 (baksmali) and wait (CAUTION: DON'T CLOSE THE BAKSMALI MANAGER WINDOW)

6. Go to your baksmali folder, there must be a new folder named "services"

7. enter to services folder and go to this sub-folder
Code:
\com\android\server\am
8. open ActivityManagerService.smali with notepad++

9. search for ".line 13892" and add the following after "if-lez v10, :cond_2af":

Code:
iget-object v2, v0, Lcom/android/server/am/ProcessRecord;->processName:Ljava/lang/String;

    const-string v5, "com.android.contacts"

    invoke-virtual {v2, v5}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-nez v2, :cond_2b4

    move-object/from16 v0, p1

    iget-object v2, v0, Lcom/android/server/am/ProcessRecord;->processName:Ljava/lang/String;

    const-string v5, "com.android.mms"

    invoke-virtual {v2, v5}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-eqz v2, :cond_2bf

    .line 13894
    :cond_2b4
    const/4 v11, 0x0
(NOTE: You can change to any app you want, just give the proper name of the app process....)

10. add the following:

Code:
.line 13895
    .end local v11           #adj:I
    .end local v34           #schedGroup:I
    :cond_2bf
11. change the subsequent numbers of ".line" (including the old .line 13895) like this:

Code:
.line 13896
    move/from16 v11, p2

.line 13897
    .restart local v11       #adj:I
    const/16 v34, 0x0

    .line 13898
    .restart local v34       #schedGroup:I
    const/4 v2, 0x1

    move-object/from16 v0, p1

    iput-boolean v2, v0, Lcom/android/server/am/ProcessRecord;->hidden:Z

    .line 13899
    const-string v2, "bg-activities"

    move-object/from16 v0, p1

    iput-object v2, v0, Lcom/android/server/am/ProcessRecord;->adjType:Ljava/lang/String;

    goto/16 :goto_f1
12. Save the file.

13. Go to the baksmali manager window and select option 2 (smali) and wait, it will create a classes.dex file on your baksmali folder

14. Open up services.jar with 7zip or WinRAR and drag the newly created classes.dex into the window to refresh services.jar with the new
classes.dex

15. Copy the new services.jar file to your sdcard and from there, copy to /system/framework (use root explorer, mount read/write and copy the
file).

16. set proper permissions: set 644 permissions ((rw-r--r--) or (tick Read: owner, group, others / Write: owner)

17. Restart, make a wipe dalvik and cache and

18. Enjoy!
Attached Files
File Type: rar baskmali.rar - [Click for QR Code] (1.17 MB, 217 views)
Last edited by espaciosalter20; 19th September 2012 at 09:55 PM.
The Following 14 Users Say Thank You to espaciosalter20 For This Useful Post: [ View ]
17th September 2012, 01:51 AM   |  #2  
Senior Member
Flag Ruda Śląska
Thanks Meter: 117
 
620 posts
Join Date:Joined: Feb 2009
thx... but why not just upload a baked/moded ver of services.jar... it would be much easier just to replace this specific file ;p as i assume u did for youreself ;p
Last edited by meilbox; 17th September 2012 at 01:54 AM.
17th September 2012, 02:33 AM   |  #3  
espaciosalter20's Avatar
OP Senior Member
Flag Bogotá, Colombia, Colombia
Thanks Meter: 715
 
1,269 posts
Join Date:Joined: Jun 2011
Donate to Me
More
Quote:
Originally Posted by meilbox

thx... but why not just upload a baked/moded ver of services.jar... it would be much easier just to replace this specific file ;p as i assume u did for youreself ;p

I could do it, but I do prefer to share knowledge with everyone... I could upload a services.jar but it's more fun to learn new things.

Enviado desde mi MB525 usando Tapatalk 2
The Following 5 Users Say Thank You to espaciosalter20 For This Useful Post: [ View ]
17th September 2012, 03:38 AM   |  #4  
vaibhav palande's Avatar
Senior Member
Flag Pune
Thanks Meter: 109
 
281 posts
Join Date:Joined: Jan 2012
More
Question
i dont have line 10429..

This is what is in my services.jar (Latest Build):

Quote:

.line 10420
:cond_167
const/16 v48, 0x0

.line 10421
.local v48, mi:Landroid/os/Debug$MemoryInfo;
if-eqz v38, :cond_22a

.line 10423
:try_start_16b
move-object/from16 v0, v61

iget-object v5, v0, Lcom/android/server/am/ProcessRecord;->thread:Landroid/app/IApplicationThread;

move-object/from16 v0, p1

move/from16 v1, v43

move/from16 v2, v38

move-object/from16 v3, v42

invoke-interface {v5, v0, v1, v2, v3}, Landroid/app/IApplicationThread;->dumpMemInfo(Ljava/io/FileDescriptor;ZZ[Ljava/lang/StringLandroid/os/Debug$MemoryInfo;
:try_end_17a
.catch Landroid/os/RemoteException; {:try_start_16b .. :try_end_17a} :catch_21b

move-result-object v48

.line 10435
:cond_17b
:goto_17b
if-nez v43, :cond_26b

if-eqz v48, :cond_26b

.line 10436
invoke-virtual/range {v48 .. v48}, Landroid/os/Debug$MemoryInfo;->getTotalPss()I

move-result v5

int-to-long v7, v5

.line 10437
.local v7, myTotalPss:J
add-long v68, v68, v7

17th September 2012, 01:06 PM   |  #5  
espaciosalter20's Avatar
OP Senior Member
Flag Bogotá, Colombia, Colombia
Thanks Meter: 715
 
1,269 posts
Join Date:Joined: Jun 2011
Donate to Me
More
Quote:
Originally Posted by vaibhav palande

i dont have line 10429..

This is what is in my services.jar (Latest Build):

I'm not talking about ".line" on the code, I'm talking about the number of the line in the document. On notepad++ look at the numbers at the most left and you will find line 10429 with no problem

Enviado desde mi MB525 usando Tapatalk 2
17th September 2012, 01:24 PM   |  #6  
vaibhav palande's Avatar
Senior Member
Flag Pune
Thanks Meter: 109
 
281 posts
Join Date:Joined: Jan 2012
More
Arrow Should i add here?
SO Should i add the code u gave above in line 10429 in the pic??

This is my services.jar:


17th September 2012, 01:53 PM   |  #7  
espaciosalter20's Avatar
OP Senior Member
Flag Bogotá, Colombia, Colombia
Thanks Meter: 715
 
1,269 posts
Join Date:Joined: Jun 2011
Donate to Me
More
Quote:
Originally Posted by vaibhav palande

SO Should i add the code u gave above in line 10429 in the pic??

This is my services.jar:


Ummm... Weird it's send that I have to polish my guide... I'm using last version of quarx too but my code it's aligned different. Don't add the code in that line cause could break all the code. Please, wait a little bit for me to be on my pc to check what is wrong...

Enviado desde mi MB525 usando Tapatalk 2
17th September 2012, 02:00 PM   |  #8  
vaibhav palande's Avatar
Senior Member
Flag Pune
Thanks Meter: 109
 
281 posts
Join Date:Joined: Jan 2012
More
Quote:
Originally Posted by espaciosalter20

Ummm... Weird it's send that I have to polish my guide... I'm using last version of quarx too but my code it's aligned different. Don't add the code in that line cause could break all the code. Please, wait a little bit for me to be on my pc to check what is wrong...

Enviado desde mi MB525 usando Tapatalk 2

I am using latest build 09-12.. U have latest build? or u want me to send u services.jar?
17th September 2012, 03:25 PM   |  #9  
espaciosalter20's Avatar
OP Senior Member
Flag Bogotá, Colombia, Colombia
Thanks Meter: 715
 
1,269 posts
Join Date:Joined: Jun 2011
Donate to Me
More
Quote:
Originally Posted by vaibhav palande

I am using latest build 09-12.. U have latest build? or u want me to send u services.jar?

ok, it was my bad... i was using an old services.jar as reference. I double check again that and the right code is:

Code:
iget-object v2, v0, Lcom/android/server/am/ProcessRecord;->processName:Ljava/lang/String;

    const-string v5, "com.android.contacts"

    invoke-virtual {v2, v5}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-nez v2, :cond_2b4

    move-object/from16 v0, p1

    iget-object v2, v0, Lcom/android/server/am/ProcessRecord;->processName:Ljava/lang/String;

    const-string v5, "com.android.mms"

    invoke-virtual {v2, v5}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-eqz v2, :cond_2bf

    .line 13894
    :cond_2b4
    const/4 v11, 0x0
after this part:

Code:
.line 13892
    .end local v11           #adj:I
    .end local v34           #schedGroup:I
    :cond_29c
    if-lez v10, :cond_2af
.line 13892, it's the key....
17th September 2012, 03:34 PM   |  #10  
vaibhav palande's Avatar
Senior Member
Flag Pune
Thanks Meter: 109
 
281 posts
Join Date:Joined: Jan 2012
More
Quote:
Originally Posted by espaciosalter20

ok, it was my bad... i was using an old services.jar as reference. I double check again that and the right code is:

Code:
iget-object v2, v0, Lcom/android/server/am/ProcessRecord;->processName:Ljava/lang/String;

    const-string v5, "com.android.contacts"

    invoke-virtual {v2, v5}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-nez v2, :cond_2b4

    move-object/from16 v0, p1

    iget-object v2, v0, Lcom/android/server/am/ProcessRecord;->processName:Ljava/lang/String;

    const-string v5, "com.android.mms"

    invoke-virtual {v2, v5}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-eqz v2, :cond_2bf

    .line 13894
    :cond_2b4
    const/4 v11, 0x0
after this part:

Code:
.line 13892
    .end local v11           #adj:I
    .end local v34           #schedGroup:I
    :cond_29c
    if-lez v10, :cond_2af
.line 13892, it's the key....

So, where should i add this code? Which line?

Post Reply Subscribe to Thread

Tags
contacts, guide, locking in memory, smali, sms
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Defy General by ThreadRank