Search This thread

Sami Kabir

Senior Member
Oct 3, 2012
2,233
1,410
Part 2: Allows installing older versions on top of newer versions

Note that this mod also lets you install unsigned versions over other current versions, as well as installing older versions on top of newer versions of an app

This is what .method private installLocationPolicy(Landroid/content/pm/PackageInfoLite;I)I looks like in my PackageManagerService$InstallParams.smali:

Code:
.method private installLocationPolicy(Landroid/content/pm/PackageInfoLite;I)I
    .locals 8

    const/4 v5, 0x2

    const/4 v4, 0x1

    iget-object v2, p1, Landroid/content/pm/PackageInfoLite;->packageName:Ljava/lang/String;

    iget v0, p1, Landroid/content/pm/PackageInfoLite;->installLocation:I

    and-int/lit8 v6, p2, 0x8

    if-eqz v6, :cond_0

    move v1, v4

    :goto_0
    iget-object v6, p0, Lcom/android/server/pm/PackageManagerService$InstallParams;->this$0:Lcom/android/server/pm/PackageManagerService;

    iget-object v6, v6, Lcom/android/server/pm/PackageManagerService;->mPackages:Ljava/util/HashMap;

    monitor-enter v6

    :try_start_0
    iget-object v7, p0, Lcom/android/server/pm/PackageManagerService$InstallParams;->this$0:Lcom/android/server/pm/PackageManagerService;

    iget-object v7, v7, Lcom/android/server/pm/PackageManagerService;->mPackages:Ljava/util/HashMap;

    invoke-virtual {v7, v2}, Ljava/util/HashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v3

    check-cast v3, Landroid/content/pm/PackageParser$Package;

    if-eqz v3, :cond_5

    and-int/lit8 v7, p2, 0x2

    if-eqz v7, :cond_8

    iget-object v7, v3, Landroid/content/pm/PackageParser$Package;->applicationInfo:Landroid/content/pm/ApplicationInfo;

    iget v7, v7, Landroid/content/pm/ApplicationInfo;->flags:I

    and-int/lit8 v7, v7, 0x1

    if-eqz v7, :cond_2

    if-eqz v1, :cond_1

    const-string v4, "PackageManager"

    const-string v5, "Cannot install update to system app on sdcard"

    invoke-static {v4, v5}, Landroid/util/Slog;->w(Ljava/lang/String;Ljava/lang/String;)I

    const/4 v4, -0x3

    monitor-exit v6

    :goto_1
    return v4

    :cond_0
    const/4 v1, 0x0

    goto :goto_0

    :cond_1
    monitor-exit v6

    goto :goto_1

    :catchall_0
    move-exception v4

    monitor-exit v6
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw v4

    :cond_2
    if-eqz v1, :cond_3

    :try_start_1
    monitor-exit v6

    move v4, v5

    goto :goto_1

    :cond_3
    if-ne v0, v4, :cond_4

    monitor-exit v6

    goto :goto_1

    :cond_4
    if-ne v0, v5, :cond_6

    :cond_5
    monitor-exit v6

    if-eqz v1, :cond_9

    move v4, v5

    goto :goto_1

    :cond_6
    #calls: Lcom/android/server/pm/PackageManagerService;->isExternal(Landroid/content/pm/PackageParser$Package;)Z
    invoke-static {v3}, Lcom/android/server/pm/PackageManagerService;->access$1900(Landroid/content/pm/PackageParser$Package;)Z

    move-result v7

    if-eqz v7, :cond_7

    monitor-exit v6

    move v4, v5

    goto :goto_1

    :cond_7
    monitor-exit v6

    goto :goto_1

    :cond_8
    const/4 v4, -0x4

    monitor-exit v6
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    goto :goto_1

    :cond_9
    iget v4, p1, Landroid/content/pm/PackageInfoLite;->recommendedInstallLocation:I

    goto :goto_1
.end method

I can't find the codes you mentioned...
Code:
if-nez v7, :cond_1

iget v7, p1, Landroid/content/pm/PackageInfoLite;->versionCode:I

iget v8, v3, Landroid/content/pm/PackageParser$Package;->mVersionCode:I

if-ge v7, v8, :cond_1

const-string v4, "PackageManager"

new-instance v5, Ljava/lang/StringBuilder;

invoke-direct {v5}, Ljava/lang/StringBuilder;->()V

const-string v7, "Can\'t install update of "
 
Last edited:

talkingmonkeys

Inactive Recognized RC / RT
May 15, 2013
2,644
4,415
Just want to note that for lollipop instead of core.jar its core-libart.jar. Same edits in the same spots. :good:
 
  • Like
Reactions: CNexus

Thebear j koss

Senior Member
Lol, I was just fixing to ask this question, looks like the answer is right here, Thanks @CNexus, good work, easy and quick!

btw, I didnt find the lollipop file info in the OP. just a reminder.[emoji14] or, I am blind, and did not see it.

Thank you sir for this!!!:good::good:
Follow the same edits but in lib core jar instead. The jar file just has core added into the name.
 
  • Like
Reactions: talkingmonkeys

starbucks2010

Senior Member
Jun 30, 2010
3,481
2,550
Hello,

I'm on 5.1.1 and the I cannot find the method explained in step 2 . This is what I have in my method:
.method private installLocationPolicy(Landroid/content/pm/PackageInfoLite;)I
.locals 9
.param p1, "pkgLite" # Landroid/content/pm/PackageInfoLite;

.prologue
const/4 v6, 0x2

const/4 v5, 0x1

.line 13620
iget-object v3, p1, Landroid/content/pm/PackageInfoLite;->packageName:Ljava/lang/String;

.line 13621
.local v3, "packageName":Ljava/lang/String;
iget v1, p1, Landroid/content/pm/PackageInfoLite;->installLocation:I

.line 13622
.local v1, "installLocation":I
iget v7, p0, Lcom/android/server/pm/PackageManagerService$InstallParams;->installFlags:I

and-int/lit8 v7, v7, 0x8

if-eqz v7, :cond_1

move v2, v5

.line 13624
.local v2, "onSd":Z
:goto_0
sget-object v7, Lcom/android/server/pm/PackageManagerService;->mPackages:Landroid/util/ArrayMap;

monitor-enter v7

.line 13625
:try_start_0
sget-object v8, Lcom/android/server/pm/PackageManagerService;->mPackages:Landroid/util/ArrayMap;

invoke-virtual {v8, v3}, Landroid/util/ArrayMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

move-result-object v4

check-cast v4, Landroid/content/pm/PackageParser$Package;

.line 13626
.local v4, "pkg":Landroid/content/pm/PackageParser$Package;
if-eqz v4, :cond_6

.line 13627
iget v8, p0, Lcom/android/server/pm/PackageManagerService$InstallParams;->installFlags:I

and-int/lit8 v8, v8, 0x2

if-eqz v8, :cond_9

.line 13629
iget v8, p0, Lcom/android/server/pm/PackageManagerService$InstallParams;->installFlags:I
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0

and-int/lit16 v8, v8, 0x80

if-nez v8, :cond_0

.line 13631
:try_start_1
# invokes: Lcom/android/server/pm/PackageManagerService;->checkDowngrade(Landroid/content/pm/PackageParser$Package;Landroid/content/pm/PackageInfoLite;)V
invoke-static {v4, p1}, Lcom/android/server/pm/PackageManagerService;->access$3100(Landroid/content/pm/PackageParser$Package;Landroid/content/pm/PackageInfoLite;)V
:try_end_1
.catch Lcom/android/server/pm/PackageManagerException; {:try_start_1 .. :try_end_1} :catch_0
.catchall {:try_start_1 .. :try_end_1} :catchall_0

.line 13638
:cond_0
:try_start_2
iget-object v8, v4, Landroid/content/pm/PackageParser$Package;->applicationInfo:Landroid/content/pm/ApplicationInfo;

iget v8, v8, Landroid/content/pm/ApplicationInfo;->flags:I

and-int/lit8 v8, v8, 0x1

if-eqz v8, :cond_3

.line 13639
if-eqz v2, :cond_2

.line 13640
const-string v5, "PackageManager"

const-string v6, "Cannot install update to system app on sdcard"

invoke-static {v5, v6}, Landroid/util/Slog;->w(Ljava/lang/String;Ljava/lang/String;)I

.line 13641
const/4 v5, -0x3

monitor-exit v7

.line 13674
:goto_1
return v5

.line 13622
.end local v2 # "onSd":Z
.end local v4 # "pkg":Landroid/content/pm/PackageParser$Package;
:cond_1
const/4 v2, 0x0

goto :goto_0

.line 13632
.restart local v2 # "onSd":Z
.restart local v4 # "pkg":Landroid/content/pm/PackageParser$Package;
:catch_0
move-exception v0

.line 13633
.local v0, "e":Lcom/android/server/pm/PackageManagerException;
const-string v5, "PackageManager"

new-instance v6, Ljava/lang/StringBuilder;

invoke-direct {v6}, Ljava/lang/StringBuilder;-><init>()V

const-string v8, "Downgrade detected: "

invoke-virtual {v6, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

move-result-object v6

invoke-virtual {v0}, Lcom/android/server/pm/PackageManagerException;->getMessage()Ljava/lang/String;

move-result-object v8

invoke-virtual {v6, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

move-result-object v6

invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

move-result-object v6

invoke-static {v5, v6}, Landroid/util/Slog;->w(Ljava/lang/String;Ljava/lang/String;)I

.line 13634
const/4 v5, -0x7

monitor-exit v7

goto :goto_1

.line 13668
.end local v0 # "e":Lcom/android/server/pm/PackageManagerException;
.end local v4 # "pkg":Landroid/content/pm/PackageParser$Package;
:catchall_0
move-exception v5

monitor-exit v7
:try_end_2
.catchall {:try_start_2 .. :try_end_2} :catchall_0

throw v5

.line 13643
.restart local v4 # "pkg":Landroid/content/pm/PackageParser$Package;
:cond_2
:try_start_3
monitor-exit v7

goto :goto_1

.line 13645
:cond_3
if-eqz v2, :cond_4

.line 13647
monitor-exit v7

move v5, v6

goto :goto_1

.line 13650
:cond_4
if-ne v1, v5, :cond_5

.line 13652
monitor-exit v7

goto :goto_1

.line 13653
:cond_5
if-ne v1, v6, :cond_7

.line 13668
:cond_6
monitor-exit v7

.line 13671
if-eqz v2, :cond_a

move v5, v6

.line 13672
goto :goto_1

.line 13657
:cond_7
# invokes: Lcom/android/server/pm/PackageManagerService;->isExternal(Landroid/content/pm/PackageParser$Package;)Z
invoke-static {v4}, Lcom/android/server/pm/PackageManagerService;->access$1100(Landroid/content/pm/PackageParser$Package;)Z

move-result v8

if-eqz v8, :cond_8

.line 13658
monitor-exit v7

move v5, v6

goto :goto_1

.line 13660
:cond_8
monitor-exit v7

goto :goto_1

.line 13665
:cond_9
const/4 v5, -0x4

monitor-exit v7
:try_end_3
.catchall {:try_start_3 .. :try_end_3} :catchall_0

goto :goto_1

.line 13674
:cond_a
iget v5, p1, Landroid/content/pm/PackageInfoLite;->recommendedInstallLocation:I

goto :goto_1
.end method

Can you help me please to adapt it?

Thank you in advance.
 

nemran

Member
Jul 15, 2013
14
1
[SIZE=+1]Part 2: Allows installing older versions on top of newer versions[/SIZE]



[SIZE=+1]Note that this mod also lets you install unsigned versions over other current versions, as well as installing older versions on top of newer versions of an app[/SIZE]

Please help when you change the language to be Arab suspended SecContacts_L_USA_qHD.apk
i get unfortunately,contacts has stopped
in the sm-g530p 5.1.1
 

awadh730

Senior Member
Feb 23, 2015
77
6
everything work normal greatguid...but after formating mobile SystemUI dosnt appear?
plz help
 

Top Liked Posts

  • There are no posts matching your filters.
  • 36
    Now there are guides out there that will disable signature checking (such as THIS one)

    But no guides (as far as I know) show you how to FULLY disable signature checking...including for user apps that have been modified and so had their original signatures broken

    Here I will show you how to do just that :good:

    Let's get started.


    You will need the following:
    • core.jar from your rom (use core-libart.jar if you are on Lollipop)
    • services.jar
    • apktool/baksmali+smali

    [SIZE=+1]Part 1: Allows installing apps with broken/mismatched signatures [/SIZE]
    [SIZE=+1]Modding core.jar (or core-libart.jar if on Lollipop)[/SIZE]
    • Decompile core.jar and navigate to java/security
    • Open MessageDigest.smali and find the following method
      Code:
      .method public static isEqual([B[B)Z
    • At the beginning you will find code like this:
      Code:
          const/4 v1, [color=red]0x0[/color]
      
          array-length v2, p0

      Change the 0x0 to 0x1 so that it becomes

      Code:
          const/4 v1, [color=blue]0x1[/color]
      
          array-length v2, p0
    • Now save and close MessageDigest.smali
    • In the same directory, open Signature.smali
    • Find the method
      Code:
      .method public final verify([B)Z
    • Find this code at the very end of the method:
      Code:
          invoke-virtual {p0, p1}, Ljava/security/SignatureSpi;->engineVerify([B)Z
      
          [color=red]move-result v0[/color]
      
          return v0

      Change the move-result v0 to the following:

      Code:
          invoke-virtual {p0, p1}, Ljava/security/SignatureSpi;->engineVerify([B)Z
      
          [color=blue]const/4 v0, 0x1[/color]
      
          return v0
    • Now find the method
      Code:
      .method public final verify([BII)Z
    • Scroll to the end of the method and find this code:
      Code:
          invoke-virtual {p0, p1, p2, p3}, Ljava/security/SignatureSpi;->engineVerify([BII)Z
      
          [color=red]move-result v0[/color]
      
          return v0

      And replace it with this:

      Code:
          invoke-virtual {p0, p1, p2, p3}, Ljava/security/SignatureSpi;->engineVerify([BII)Z
      
          [color=blue]const/4 v0, 0x1[/color]
      
          return v0
    • Now save and close Signature.smali
    • Recompile core.jar (core-libart.jar for Lollipop)

    [SIZE=+1]Now move on to step 2[/SIZE]
    29
    [SIZE=+1]Part 2: Allows installing older versions on top of newer versions[/SIZE]

    [SIZE=+1]Modding services.jar[/SIZE]
    • Decompile services.jar and navigate to com\android\server\pm
    • Open PackageManagerService$InstallParams.smali and find the following method
      Code:
      .method private installLocationPolicy(Landroid/content/pm/PackageInfoLite;I)I
    • Scroll down until you find code that looks like the following
      Code:
          if-nez v7, :cond_1
      
          iget v7, p1, Landroid/content/pm/PackageInfoLite;->versionCode:I
      
          iget v8, v3, Landroid/content/pm/PackageParser$Package;->mVersionCode:I
      
          [color=red]if-ge v7, v8, :cond_1[/color]
      
          const-string v4, "PackageManager"
      
          new-instance v5, Ljava/lang/StringBuilder;
      
          invoke-direct {v5}, Ljava/lang/StringBuilder;->()V
      
          const-string v7, "Can\'t install update of "

      And change the highlighted part above to this (register numbers may vary, but just make sure that you change it to if-ge vXX, vXX)

      Code:
         if-nez v7, :cond_1
      
          iget v7, p1, Landroid/content/pm/PackageInfoLite;->versionCode:I
      
          iget v8, v3, Landroid/content/pm/PackageParser$Package;->mVersionCode:I
      
          [color=blue]if-ge v8, v8, :cond_1[/color]
      
          const-string v4, "PackageManager"
      
          new-instance v5, Ljava/lang/StringBuilder;
      
          invoke-direct {v5}, Ljava/lang/StringBuilder;->()V
      
          const-string v7, "Can\'t install update of "
    • Recompile services.jar. This is conjunction with disabling signature checking in services.jar (shown here for example) allows you to FULLY disable ALL app verification. Mod away :victory:

    [SIZE=+1]Note that this mod also lets you install unsigned versions over other current versions, as well as installing older versions on top of newer versions of an app[/SIZE]
    6
    Mod updated...accidentally left out the second part :silly:
    @tdunham @Chad The Pathfinder...if you guys have already implemented, sorry but add the second part :eek:
    5
    Nice. Did your brain explode today from all the genius it possessed? Lol. May give this a try tomorrow. Hangouts update killed me...

    Thebe@r'$ G@L@XY- eliminate white backgrounds and any form of ics/holo blue.
    3
    Mod updated...accidentally left out the second part :silly:
    @tdunham @Chad The Pathfinder...if you guys have already implemented, sorry but add the second part :eek:

    2 parts? This is getting out of hand. Lol

    Thebe@r'$ G@L@XY- eliminate white backgrounds and any form of ics/holo blue.