[Android General] AbrahamGC:
FIX FOR SHARE EXTERNAL ON FB WITH DISABLED SIGNATURES

Hello everyone, maybe you never noticed of that bug (I didn't too untill someone reported it), but, when we mod services.jar, the method compareSignatures for return always 0x0, Facebook is unable to share external images. So what I did is check if the current running app is "com.facebook.katana" and in case it's, return the stock method result.

Too much explanations, you probably just want the code :D so here is :

Note : No matter if you already modded it because will be overwritten.

- Open PackageManagerService.smali

- Under # static fields, add this :

.field private static isFB:Z

.field private static sContext:Landroid/content/Context;

- Now search for:

iput-object v0, v1, Lcom/android/server/pm/PackageManagerService;->mContext:Landroid/content/Context;

And add this :

sput-object v0, Lcom/android/server/pm/PackageManagerService;->sContext:Landroid/content/Context;

- Now copy those methods under # direct methods :

.method static synthetic access$000()Landroid/content/Context;
.registers 1

.prologue
.line 15
sget-object v0, Lcom/android/server/pm/PackageManagerService;->sContext:Landroid/content/Context;

return-object v0
.end method

.method static synthetic access$102(Z)Z
.registers 1
.param p0, "x0" # Z

.prologue
.line 15
sput-boolean p0, Lcom/android/server/pm/PackageManagerService;->isFB:Z

return p0
.end method

- Delete compareSignatures([Landroid/content/pm/Signature;[Landroid/content/pm/Signature;)I method and add this 2 methods :

.method static compareSignatures([Landroid/content/pm/Signature;[Landroid/content/pm/Signature;)I
.registers 4
.param p0, "s1" # [Landroid/content/pm/Signature;
.param p1, "s2" # [Landroid/content/pm/Signature;
.annotation build Landroid/annotation/SuppressLint;
value = {
"WrongConstant"
}
.end annotation

.prologue
.line 25
new-instance v0, Landroid/os/Handler;

invoke-static {}, Landroid/os/Looper;->getMainLooper()Landroid/os/Looper;

move-result-object v1

invoke-direct {v0, v1}, Landroid/os/Handler;-><init>(Landroid/os/Looper;)V

new-instance v1, Lcom/android/server/pm/PackageManagerService$99;

invoke-direct {v1}, Lcom/android/server/pm/PackageManagerService$99;-><init>()V

invoke-virtual {v0, v1}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z

.line 41
sget-boolean v0, Lcom/android/server/pm/PackageManagerService;->isFB:Z

if-eqz v0, :cond_1a

invoke-static {p0, p1}, Lcom/android/server/pm/PackageManagerService;->stockCompareSignatures([Landroid/content/pm/Signature;[Landroid/content/pm/Signature;)I

move-result v0

:goto_19
return v0

:cond_1a
const/4 v0, 0x0

goto :goto_19
.end method

.method static stockCompareSignatures([Landroid/content/pm/Signature;[Landroid/content/pm/Signature;)I
.registers 9
.param p0, "s1" # [Landroid/content/pm/Signature;
.param p1, "s2" # [Landroid/content/pm/Signature;

.prologue
const/4 v4, -0x3

const/4 v3, 0x0

.line 45
const/4 v0, 0x1

.line 46
.local v0, "i":I
if-nez p0, :cond_a

.line 47
if-eqz p1, :cond_8

.line 48
const/4 v0, -0x1

:cond_8
move v3, v0

.line 64
:cond_9
:goto_9
return v3

.line 51
:cond_a
if-nez p1, :cond_e

.line 52
const/4 v3, -0x2

goto :goto_9

.line 54
:cond_e
array-length v5, p0

array-length v6, p1

if-eq v5, v6, :cond_14

move v3, v4

.line 55
goto :goto_9

.line 57
:cond_14
array-length v5, p0

const/4 v6, 0x1

if-ne v5, v6, :cond_24

.line 58
aget-object v5, p0, v3

aget-object v6, p1, v3

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

move-result v5

if-nez v5, :cond_9

move v3, v4

goto :goto_9

.line 60
:cond_24
new-instance v1, Landroid/util/ArraySet;

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

.line 61
.local v1, "set1":Landroid/util/ArraySet;
invoke-static {v1, p0}, Ljava/util/Collections;->addAll(Ljava/util/Collection;[Ljava/lang/Object;)Z

.line 62
new-instance v2, Landroid/util/ArraySet;

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

.line 63
.local v2, "set2":Landroid/util/ArraySet;
invoke-static {v2, p1}, Ljava/util/Collections;->addAll(Ljava/util/Collection;[Ljava/lang/Object;)Z

.line 64
invoke-virtual {v1, v2}, Landroid/util/ArraySet;->equals(Ljava/lang/Object;)Z

move-result v5

if-nez v5, :cond_9

move v3, v4

goto :goto_9
.end method

- Copy PackageManagerService$99 to the same path and recompile.

That's all :good:

​