[Sony Cross-Device General] serajr:
How to patch your own services.jar

First of all, DO NOT COPY CODE FROM ANY GUIDE/TUTORIAL, NOT EVEN FROM THIS ONE! Firmwares do change all the time, DO THE PROCEDURE BELOW ALWAYS BY YOURSELF!

Keep in mind that all code below is just for your undertanding, so again, DO NOT COPY CODE FROM ANY GUIDE/TUTORIAL, NOT EVEN FROM THIS ONE!

1. Decompile your ALREADY DEODEXED and stock/untouched services.jar

2. Edit ...\smali\com\android\server\pm\PackageManagerService.smali file with notepad++

3. Look for compareSignatures method:

Note: NEVER TOUCH RED LINES

.method static compareSignatures([Landroid/content/pm/Signature;[Landroid/content/pm/Signature;)I
[B][COLOR="Red"].locals 8
.param p0, "s1" # [Landroid/content/pm/Signature;
.param p1, "s2" # [Landroid/content/pm/Signature;[/COLOR][/B]

.prologue
const/4 v3, 0x1

const/4 v5, -0x3

[B][COLOR="Blue"]const/4 [COLOR="DarkOrange"]v4[/COLOR], 0x0[/COLOR][/B]

.line 4832
if-nez p0, :cond_1

.line 4833
if-nez p1, :cond_0

:goto_0
return v3

.line 4835
:cond_0
const/4 v3, -0x1

goto :goto_0

.line 4838
:cond_1
if-nez p1, :cond_2

.line 4839
const/4 v3, -0x2

return v3

.line 4842
:cond_2
array-length v6, p0

array-length v7, p1

if-eq v6, v7, :cond_3

.line 4843
return v5

.line 4847
:cond_3
array-length v6, p0

if-ne v6, v3, :cond_5

.line 4848
aget-object v3, p0, v4

aget-object v6, p1, v4

invoke-virtual {v3, v6}, Landroid/content/pm/Signature;->equals(Ljava/lang/Object;)Z

move-result v3

if-eqz v3, :cond_4

move v3, v4

:goto_1
return v3

:cond_4
move v3, v5

.line 4850
goto :goto_1

.line 4853
:cond_5
new-instance v0, Landroid/util/ArraySet;

invoke-direct {v0}, Landroid/util/ArraySet;-><init>()V

.line 4854
.local v0, "set1":Landroid/util/ArraySet;, "Landroid/util/ArraySet<Landroid/content/pm/Signature;>;"
array-length v6, p0

move v3, v4

:goto_2
if-ge v3, v6, :cond_6

aget-object v2, p0, v3

.line 4855
.local v2, "sig":Landroid/content/pm/Signature;
invoke-virtual {v0, v2}, Landroid/util/ArraySet;->add(Ljava/lang/Object;)Z

.line 4854
add-int/lit8 v3, v3, 0x1

goto :goto_2

.line 4857
.end local v2 # "sig":Landroid/content/pm/Signature;
:cond_6
new-instance v1, Landroid/util/ArraySet;

invoke-direct {v1}, Landroid/util/ArraySet;-><init>()V

.line 4858
.local v1, "set2":Landroid/util/ArraySet;, "Landroid/util/ArraySet<Landroid/content/pm/Signature;>;"
array-length v6, p1

move v3, v4

:goto_3
if-ge v3, v6, :cond_7

aget-object v2, p1, v3

.line 4859
.restart local v2 # "sig":Landroid/content/pm/Signature;
invoke-virtual {v1, v2}, Landroid/util/ArraySet;->add(Ljava/lang/Object;)Z

.line 4858
add-int/lit8 v3, v3, 0x1

goto :goto_3

.line 4862
.end local v2 # "sig":Landroid/content/pm/Signature;
:cond_7
invoke-virtual {v0, v1}, Landroid/util/ArraySet;->equals(Ljava/lang/Object;)Z

move-result v3

if-eqz v3, :cond_8

.line 4863
return v4

.line 4865
:cond_8
return v5
.end method

4. Shrink it:

Note: There will always be a line with value 0x0, and this is the line you will use for the return of the method (orange v? below), in my case it is: const/4 v4, 0x0 (yours may differs)

.method static compareSignatures([Landroid/content/pm/Signature;[Landroid/content/pm/Signature;)I
[B][COLOR="Red"].locals 8
.param p0, "s1" # [Landroid/content/pm/Signature;
.param p1, "s2" # [Landroid/content/pm/Signature;[/COLOR][/B]

.prologue
[B][COLOR="Blue"]const/4 [COLOR="DarkOrange"]v4[/COLOR], 0x0[/COLOR][/B]

return [B][COLOR="DarkOrange"]v4[/COLOR][/B]
.end method

REMEMBER, THE METHOD ABOVE IS JUST FOR YOUR UNDERSTANDING, DO NOT USE IT, UNLESS IT'S IDENTICAL TO YOURS!

That's it!