Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,732,020 Members 41,086 Now Online
XDA Developers Android and Mobile Development Forum

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

Tip us?
 
espaciosalter20
Old
(Last edited by espaciosalter20; 19th September 2012 at 09:55 PM.)
#1  
espaciosalter20's Avatar
Senior Member - OP
Thanks Meter 712
Posts: 1,264
Join Date: Jun 2011
Location: Bogotá, Colombia, Colombia

 
DONATE TO ME
Info 2 [GUIDE] Locking contacts/sms apps in memory on JB/cm10 (technical / baksmali way)

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, 209 views)
The Following 14 Users Say Thank You to espaciosalter20 For This Useful Post: [ Click to Expand ]
 
meilbox
Old
(Last edited by meilbox; 17th September 2012 at 01:54 AM.)
#2  
Senior Member
Thanks Meter 117
Posts: 621
Join Date: Feb 2009
Location: Ruda Śląska
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
 
espaciosalter20
Old
#3  
espaciosalter20's Avatar
Senior Member - OP
Thanks Meter 712
Posts: 1,264
Join Date: Jun 2011
Location: Bogotá, Colombia, Colombia

 
DONATE TO ME
Quote:
Originally Posted by meilbox View Post
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: [ Click to Expand ]
 
vaibhav palande
Old
#4  
vaibhav palande's Avatar
Senior Member
Thanks Meter 108
Posts: 281
Join Date: Jan 2012
Location: Pune
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
Using Lifeproof Motorola Defy+ (MB526) on Android 4.4.2 (KITKAT) by Quarx,
USE THANKS BUTTON IF I HELPED
 
espaciosalter20
Old
#5  
espaciosalter20's Avatar
Senior Member - OP
Thanks Meter 712
Posts: 1,264
Join Date: Jun 2011
Location: Bogotá, Colombia, Colombia

 
DONATE TO ME
Quote:
Originally Posted by vaibhav palande View Post
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
 
vaibhav palande
Old
#6  
vaibhav palande's Avatar
Senior Member
Thanks Meter 108
Posts: 281
Join Date: Jan 2012
Location: Pune
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:


Using Lifeproof Motorola Defy+ (MB526) on Android 4.4.2 (KITKAT) by Quarx,
USE THANKS BUTTON IF I HELPED
 
espaciosalter20
Old
#7  
espaciosalter20's Avatar
Senior Member - OP
Thanks Meter 712
Posts: 1,264
Join Date: Jun 2011
Location: Bogotá, Colombia, Colombia

 
DONATE TO ME
Quote:
Originally Posted by vaibhav palande View Post
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
 
vaibhav palande
Old
#8  
vaibhav palande's Avatar
Senior Member
Thanks Meter 108
Posts: 281
Join Date: Jan 2012
Location: Pune
Quote:
Originally Posted by espaciosalter20 View Post
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?
Using Lifeproof Motorola Defy+ (MB526) on Android 4.4.2 (KITKAT) by Quarx,
USE THANKS BUTTON IF I HELPED
 
espaciosalter20
Old
#9  
espaciosalter20's Avatar
Senior Member - OP
Thanks Meter 712
Posts: 1,264
Join Date: Jun 2011
Location: Bogotá, Colombia, Colombia

 
DONATE TO ME
Quote:
Originally Posted by vaibhav palande View Post
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....
 
vaibhav palande
Old
#10  
vaibhav palande's Avatar
Senior Member
Thanks Meter 108
Posts: 281
Join Date: Jan 2012
Location: Pune
Quote:
Originally Posted by espaciosalter20 View Post
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?
Using Lifeproof Motorola Defy+ (MB526) on Android 4.4.2 (KITKAT) by Quarx,
USE THANKS BUTTON IF I HELPED

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

Advanced Search
Display Modes


XDA PORTAL POSTS

Samsung Gear Live Stock Firmware Image Pulled, Temp Root

Just yesterday,XDA Recognized Developer and TV ProducerAdamOutlertore apart … more

Draw a Line and Let Your Device Do the Rest with LineitApp

Over the years, since evenbefore Android entered the scene, we have striven to … more

[APK] Chrome Beta 37 Brings First Traces of Material Design

With Android L on the horizon, it’s no surprise that Google’s … more

Immersive Mode on Unrooted Devices with GMD Full Screen Immersive Mode

Everyone likes screen real estate–no question about that. The … more