[Android Software/Hacking General [Developers Only]] niaboc79:
9) Look for this method in com/android/server/pm/permission/PermissionManagerService.smali

.method private grantSignaturePermission(Ljava/lang/String;Landroid/content/pm/PackageParser$Package;Lcom/android/server/pm/permission/BasePermission;Lcom/android/server/pm/permission/PermissionsState;)Z

Replace whole method by:

.method private grantSignaturePermission(Ljava/lang/String;Landroid/content/pm/PackageParser$Package;Lcom/android/server/pm/permission/BasePermission;Lcom/android/server/pm/permission/PermissionsState;)Z
.registers 26
.param p1, "perm" # Ljava/lang/String;
.param p2, "pkg" # Landroid/content/pm/PackageParser$Package;
.param p3, "bp" # Lcom/android/server/pm/permission/BasePermission;
.param p4, "origPermissions" # Lcom/android/server/pm/permission/PermissionsState;

move-object/from16 v0, p0

move-object/from16 v1, p1

move-object/from16 v2, p2

.line 1046
invoke-virtual/range {p3 .. p3}, Lcom/android/server/pm/permission/BasePermission;->isOEM()Z

move-result v3

.line 1047
.local v3, "oemPermission":Z
invoke-virtual/range {p3 .. p3}, Lcom/android/server/pm/permission/BasePermission;->isVendorPrivileged()Z

move-result v4

.line 1048
.local v4, "vendorPrivilegedPermission":Z
invoke-virtual/range {p3 .. p3}, Lcom/android/server/pm/permission/BasePermission;->isPrivileged()Z

move-result v5

const/4 v7, 0x0

if-nez v5, :cond_1e

invoke-virtual/range {p3 .. p3}, Lcom/android/server/pm/permission/BasePermission;->isVendorPrivileged()Z

move-result v5

if-eqz v5, :cond_1c

goto :goto_1e

:cond_1c
move v5, v7

goto :goto_1f

:cond_1e
:goto_1e
const/4 v5, 0x1

.line 1049
.local v5, "privilegedPermission":Z
:goto_1f
sget-boolean v8, Lcom/android/internal/os/RoSystemProperties;->CONTROL_PRIVAPP_PERMISSIONS_DISABLE:Z

.line 1051
.local v8, "privappPermissionsDisable":Z
const-string v9, "android"

invoke-virtual/range {p3 .. p3}, Lcom/android/server/pm/permission/BasePermission;->getSourcePackageName()Ljava/lang/String;

move-result-object v10

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

move-result v9

.line 1052
.local v9, "platformPermission":Z
const-string v10, "android"

iget-object v11, v2, Landroid/content/pm/PackageParser$Package;->packageName:Ljava/lang/String;

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

move-result v10

.line 1053
.local v10, "platformPackage":Z
if-nez v8, :cond_e2

if-eqz v5, :cond_e2

invoke-virtual/range {p2 .. p2}, Landroid/content/pm/PackageParser$Package;->isPrivileged()Z

move-result v11

if-eqz v11, :cond_e2

if-nez v10, :cond_e2

if-eqz v9, :cond_e2

.line 1055
invoke-direct/range {p0 .. p2}, Lcom/android/server/pm/permission/PermissionManagerService;->hasPrivappWhitelistEntry(Ljava/lang/String;Landroid/content/pm/PackageParser$Package;)Z

move-result v11

if-nez v11, :cond_e2

.line 1057
iget-boolean v11, v0, Lcom/android/server/pm/permission/PermissionManagerService;->mSystemReady:Z

if-nez v11, :cond_dd

invoke-virtual/range {p2 .. p2}, Landroid/content/pm/PackageParser$Package;->isUpdatedSystemApp()Z

move-result v11

if-nez v11, :cond_dd

.line 1059
const/4 v11, 0x0

.line 1060
.local v11, "deniedPermissions":Landroid/util/ArraySet;, "Landroid/util/ArraySet<Ljava/lang/String;>;"
invoke-virtual/range {p2 .. p2}, Landroid/content/pm/PackageParser$Package;->isVendor()Z

move-result v12

if-eqz v12, :cond_63

.line 1061
invoke-static {}, Lcom/android/server/SystemConfig;->getInstance()Lcom/android/server/SystemConfig;

move-result-object v12

iget-object v13, v2, Landroid/content/pm/PackageParser$Package;->packageName:Ljava/lang/String;

.line 1062
invoke-virtual {v12, v13}, Lcom/android/server/SystemConfig;->getVendorPrivAppDenyPermissions(Ljava/lang/String;)Landroid/util/ArraySet;

move-result-object v11

goto :goto_7e

.line 1063
:cond_63
invoke-virtual/range {p2 .. p2}, Landroid/content/pm/PackageParser$Package;->isProduct()Z

move-result v12

if-eqz v12, :cond_74

.line 1064
invoke-static {}, Lcom/android/server/SystemConfig;->getInstance()Lcom/android/server/SystemConfig;

move-result-object v12

iget-object v13, v2, Landroid/content/pm/PackageParser$Package;->packageName:Ljava/lang/String;

.line 1065
invoke-virtual {v12, v13}, Lcom/android/server/SystemConfig;->getProductPrivAppDenyPermissions(Ljava/lang/String;)Landroid/util/ArraySet;

move-result-object v11

goto :goto_7e

.line 1067
:cond_74
invoke-static {}, Lcom/android/server/SystemConfig;->getInstance()Lcom/android/server/SystemConfig;

move-result-object v12

iget-object v13, v2, Landroid/content/pm/PackageParser$Package;->packageName:Ljava/lang/String;

.line 1068
invoke-virtual {v12, v13}, Lcom/android/server/SystemConfig;->getPrivAppDenyPermissions(Ljava/lang/String;)Landroid/util/ArraySet;

move-result-object v11

.line 1070
:goto_7e
if-eqz v11, :cond_89

.line 1071
invoke-virtual {v11, v1}, Landroid/util/ArraySet;->contains(Ljava/lang/Object;)Z

move-result v12

if-nez v12, :cond_87

goto :goto_89

:cond_87
move v12, v7

goto :goto_8a

:cond_89
:goto_89
const/4 v12, 0x1

.line 1072
.local v12, "permissionViolation":Z
:goto_8a
if-eqz v12, :cond_dc

.line 1073
const-string v13, "PackageManager"

new-instance v14, Ljava/lang/StringBuilder;

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

const-string v15, "Privileged permission "

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

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

const-string v15, " for package "

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

iget-object v15, v2, Landroid/content/pm/PackageParser$Package;->packageName:Ljava/lang/String;

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

const-string v15, " - not in privapp-permissions whitelist"

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

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

move-result-object v14

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

.line 1076
sget-boolean v13, Lcom/android/internal/os/RoSystemProperties;->CONTROL_PRIVAPP_PERMISSIONS_ENFORCE:Z

if-eqz v13, :cond_dd

.line 1077
iget-object v13, v0, Lcom/android/server/pm/permission/PermissionManagerService;->mPrivappPermissionsViolations:Landroid/util/ArraySet;

if-nez v13, :cond_c0

.line 1078
new-instance v13, Landroid/util/ArraySet;

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

iput-object v13, v0, Lcom/android/server/pm/permission/PermissionManagerService;->mPrivappPermissionsViolations:Landroid/util/ArraySet;

.line 1080
:cond_c0
iget-object v13, v0, Lcom/android/server/pm/permission/PermissionManagerService;->mPrivappPermissionsViolations:Landroid/util/ArraySet;

new-instance v14, Ljava/lang/StringBuilder;

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

iget-object v15, v2, Landroid/content/pm/PackageParser$Package;->packageName:Ljava/lang/String;

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

const-string v15, ": "

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

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

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

move-result-object v14

invoke-virtual {v13, v14}, Landroid/util/ArraySet;->add(Ljava/lang/Object;)Z

goto :goto_dd

.line 1083
:cond_dc
return v7

.line 1086
.end local v11 # "deniedPermissions":Landroid/util/ArraySet;, "Landroid/util/ArraySet<Ljava/lang/String;>;"
.end local v12 # "permissionViolation":Z
:cond_dd
:goto_dd
sget-boolean v11, Lcom/android/internal/os/RoSystemProperties;->CONTROL_PRIVAPP_PERMISSIONS_ENFORCE:Z

if-eqz v11, :cond_e2

.line 1087
return v7

.line 1091
:cond_e2
iget-object v11, v0, Lcom/android/server/pm/permission/PermissionManagerService;->mPackageManagerInt:Landroid/content/pm/PackageManagerInternal;

invoke-virtual {v11, v7, v7}, Landroid/content/pm/PackageManagerInternal;->getKnownPackageName(II)Ljava/lang/String;

move-result-object v11

.line 1093
.local v11, "systemPackageName":Ljava/lang/String;
iget-object v12, v0, Lcom/android/server/pm/permission/PermissionManagerService;->mPackageManagerInt:Landroid/content/pm/PackageManagerInternal;

.line 1094
invoke-virtual {v12, v11}, Landroid/content/pm/PackageManagerInternal;->getPackage(Ljava/lang/String;)Landroid/content/pm/PackageParser$Package;

move-result-object v12

.line 1104
.local v12, "systemPackage":Landroid/content/pm/PackageParser$Package;
iget-object v13, v2, Landroid/content/pm/PackageParser$Package;->mSigningDetails:Landroid/content/pm/PackageParser$SigningDetails;

.line 1106
invoke-virtual/range {p3 .. p3}, Lcom/android/server/pm/permission/BasePermission;->getSourcePackageSetting()Lcom/android/server/pm/PackageSettingBase;

move-result-object v14

invoke-virtual {v14}, Lcom/android/server/pm/PackageSettingBase;->getSigningDetails()Landroid/content/pm/PackageParser$SigningDetails;

move-result-object v14

.line 1105
invoke-virtual {v13, v14}, Landroid/content/pm/PackageParser$SigningDetails;->hasAncestorOrSelf(Landroid/content/pm/PackageParser$SigningDetails;)Z

move-result v13

if-nez v13, :cond_132

.line 1107
invoke-virtual/range {p3 .. p3}, Lcom/android/server/pm/permission/BasePermission;->getSourcePackageSetting()Lcom/android/server/pm/PackageSettingBase;

move-result-object v13

invoke-virtual {v13}, Lcom/android/server/pm/PackageSettingBase;->getSigningDetails()Landroid/content/pm/PackageParser$SigningDetails;

move-result-object v13

iget-object v14, v2, Landroid/content/pm/PackageParser$Package;->mSigningDetails:Landroid/content/pm/PackageParser$SigningDetails;

const/4 v15, 0x4

invoke-virtual {v13, v14, v15}, Landroid/content/pm/PackageParser$SigningDetails;->checkCapability(Landroid/content/pm/PackageParser$SigningDetails;I)Z

move-result v13

if-nez v13, :cond_132

iget-object v13, v2, Landroid/content/pm/PackageParser$Package;->mSigningDetails:Landroid/content/pm/PackageParser$SigningDetails;

iget-object v14, v12, Landroid/content/pm/PackageParser$Package;->mSigningDetails:Landroid/content/pm/PackageParser$SigningDetails;

.line 1110
invoke-virtual {v13, v14}, Landroid/content/pm/PackageParser$SigningDetails;->hasAncestorOrSelf(Landroid/content/pm/PackageParser$SigningDetails;)Z

move-result v13

if-nez v13, :cond_132

iget-object v13, v12, Landroid/content/pm/PackageParser$Package;->mSigningDetails:Landroid/content/pm/PackageParser$SigningDetails;

iget-object v14, v2, Landroid/content/pm/PackageParser$Package;->mSigningDetails:Landroid/content/pm/PackageParser$SigningDetails;

.line 1111
invoke-virtual {v13, v14, v15}, Landroid/content/pm/PackageParser$SigningDetails;->checkCapability(Landroid/content/pm/PackageParser$SigningDetails;I)Z

move-result v13

if-nez v13, :cond_132

iget-object v13, v0, Lcom/android/server/pm/permission/PermissionManagerService;->mVendorPlatformSignatures:[Landroid/content/pm/Signature;

iget-object v14, v2, Landroid/content/pm/PackageParser$Package;->mSigningDetails:Landroid/content/pm/PackageParser$SigningDetails;

iget-object v14, v14, Landroid/content/pm/PackageParser$SigningDetails;->signatures:[Landroid/content/pm/Signature;

.line 1114
invoke-static {v13, v14}, Lcom/android/server/pm/PackageManagerServiceUtils;->compareSignatures2([Landroid/content/pm/Signature;[Landroid/content/pm/Signature;)I

move-result v13

if-nez v13, :cond_130

goto :goto_132

:cond_130
move v13, v7

goto :goto_133

:cond_132
:goto_132
const/4 v13, 0x1

.line 1116
.local v13, "allowed":Z
:goto_133
if-nez v13, :cond_25f

if-nez v5, :cond_139

if-eqz v3, :cond_25f

.line 1117
:cond_139
invoke-virtual/range {p2 .. p2}, Landroid/content/pm/PackageParser$Package;->isSystem()Z

move-result v14

if-eqz v14, :cond_25f

.line 1120
invoke-virtual/range {p2 .. p2}, Landroid/content/pm/PackageParser$Package;->isUpdatedSystemApp()Z

move-result v14

if-eqz v14, :cond_20e

.line 1121
iget-object v14, v0, Lcom/android/server/pm/permission/PermissionManagerService;->mPackageManagerInt:Landroid/content/pm/PackageManagerInternal;

iget-object v15, v2, Landroid/content/pm/PackageParser$Package;->packageName:Ljava/lang/String;

.line 1122
invoke-virtual {v14, v15}, Landroid/content/pm/PackageManagerInternal;->getDisabledPackage(Ljava/lang/String;)Landroid/content/pm/PackageParser$Package;

move-result-object v14

.line 1124
.local v14, "disabledPkg":Landroid/content/pm/PackageParser$Package;
if-eqz v14, :cond_154

iget-object v15, v14, Landroid/content/pm/PackageParser$Package;->mExtras:Ljava/lang/Object;

check-cast v15, Lcom/android/server/pm/PackageSetting;

goto :goto_155

:cond_154
const/4 v15, 0x0

.line 1125
.local v15, "disabledPs":Lcom/android/server/pm/PackageSetting;
:goto_155
if-eqz v15, :cond_17a

.line 1126
invoke-virtual {v15}, Lcom/android/server/pm/PackageSetting;->getPermissionsState()Lcom/android/server/pm/permission/PermissionsState;

move-result-object v6

invoke-virtual {v6, v1}, Lcom/android/server/pm/permission/PermissionsState;->hasInstallPermission(Ljava/lang/String;)Z

move-result v6

if-eqz v6, :cond_17a

.line 1130
if-eqz v5, :cond_169

invoke-virtual {v15}, Lcom/android/server/pm/PackageSetting;->isPrivileged()Z

move-result v6

if-nez v6, :cond_177

:cond_169
if-eqz v3, :cond_20d

.line 1131
invoke-virtual {v15}, Lcom/android/server/pm/PackageSetting;->isOem()Z

move-result v6

if-eqz v6, :cond_20d

.line 1132
invoke-static {v15, v1}, Lcom/android/server/pm/permission/PermissionManagerService;->canGrantOemPermission(Lcom/android/server/pm/PackageSetting;Ljava/lang/String;)Z

move-result v6

if-eqz v6, :cond_20d

.line 1133
:cond_177
const/4 v13, 0x1

goto/16 :goto_20d

.line 1142
:cond_17a
if-eqz v15, :cond_19b

if-eqz v14, :cond_19b

.line 1143
invoke-direct {v0, v14, v1}, Lcom/android/server/pm/permission/PermissionManagerService;->isPackageRequestingPermission(Landroid/content/pm/PackageParser$Package;Ljava/lang/String;)Z

move-result v6

if-eqz v6, :cond_19b

if-eqz v5, :cond_18c

.line 1144
invoke-virtual {v15}, Lcom/android/server/pm/PackageSetting;->isPrivileged()Z

move-result v6

if-nez v6, :cond_19a

:cond_18c
if-eqz v3, :cond_19b

.line 1145
invoke-virtual {v15}, Lcom/android/server/pm/PackageSetting;->isOem()Z

move-result v6

if-eqz v6, :cond_19b

.line 1146
invoke-static {v15, v1}, Lcom/android/server/pm/permission/PermissionManagerService;->canGrantOemPermission(Lcom/android/server/pm/PackageSetting;Ljava/lang/String;)Z

move-result v6

if-eqz v6, :cond_19b

.line 1147
:cond_19a
const/4 v13, 0x1

.line 1152
:cond_19b
iget-object v6, v2, Landroid/content/pm/PackageParser$Package;->parentPackage:Landroid/content/pm/PackageParser$Package;

if-eqz v6, :cond_20d

.line 1153
iget-object v6, v0, Lcom/android/server/pm/permission/PermissionManagerService;->mPackageManagerInt:Landroid/content/pm/PackageManagerInternal;

iget-object v7, v2, Landroid/content/pm/PackageParser$Package;->parentPackage:Landroid/content/pm/PackageParser$Package;

iget-object v7, v7, Landroid/content/pm/PackageParser$Package;->packageName:Ljava/lang/String;

.line 1154
invoke-virtual {v6, v7}, Landroid/content/pm/PackageManagerInternal;->getDisabledPackage(Ljava/lang/String;)Landroid/content/pm/PackageParser$Package;

move-result-object v6

.line 1155
.local v6, "disabledParentPkg":Landroid/content/pm/PackageParser$Package;
if-eqz v6, :cond_1b0

.line 1156
iget-object v7, v6, Landroid/content/pm/PackageParser$Package;->mExtras:Ljava/lang/Object;

check-cast v7, Lcom/android/server/pm/PackageSetting;

goto :goto_1b1

:cond_1b0
const/4 v7, 0x0

.line 1157
.local v7, "disabledParentPs":Lcom/android/server/pm/PackageSetting;
:goto_1b1
if-eqz v6, :cond_20d

if-eqz v5, :cond_1bb

.line 1158
invoke-virtual {v7}, Lcom/android/server/pm/PackageSetting;->isPrivileged()Z

move-result v16

if-nez v16, :cond_1c3

:cond_1bb
if-eqz v3, :cond_20d

.line 1159
invoke-virtual {v7}, Lcom/android/server/pm/PackageSetting;->isOem()Z

move-result v16

if-eqz v16, :cond_20d

.line 1160
:cond_1c3
invoke-direct {v0, v6, v1}, Lcom/android/server/pm/permission/PermissionManagerService;->isPackageRequestingPermission(Landroid/content/pm/PackageParser$Package;Ljava/lang/String;)Z

move-result v16

if-eqz v16, :cond_1d1

.line 1161
invoke-static {v7, v1}, Lcom/android/server/pm/permission/PermissionManagerService;->canGrantOemPermission(Lcom/android/server/pm/PackageSetting;Ljava/lang/String;)Z

move-result v16

if-eqz v16, :cond_1d1

.line 1162
const/4 v13, 0x1

goto :goto_20d

.line 1163
:cond_1d1
move-object/from16 v17, v7

iget-object v7, v6, Landroid/content/pm/PackageParser$Package;->childPackages:Ljava/util/ArrayList;

.end local v7 # "disabledParentPs":Lcom/android/server/pm/PackageSetting;
.local v17, "disabledParentPs":Lcom/android/server/pm/PackageSetting;
if-eqz v7, :cond_20d

.line 1165
iget-object v7, v6, Landroid/content/pm/PackageParser$Package;->childPackages:Ljava/util/ArrayList;

invoke-virtual {v7}, Ljava/util/ArrayList;->iterator()Ljava/util/Iterator;

move-result-object v7

:goto_1dd
invoke-interface {v7}, Ljava/util/Iterator;->hasNext()Z

move-result v16

if-eqz v16, :cond_20d

invoke-interface {v7}, Ljava/util/Iterator;->next()Ljava/lang/Object;

move-result-object v16

move-object/from16 v18, v6

move-object/from16 v6, v16

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

.line 1167
.local v6, "disabledChildPkg":Landroid/content/pm/PackageParser$Package;
.local v18, "disabledParentPkg":Landroid/content/pm/PackageParser$Package;
if-eqz v6, :cond_1f6

.line 1168
move-object/from16 v19, v7

iget-object v7, v6, Landroid/content/pm/PackageParser$Package;->mExtras:Ljava/lang/Object;

check-cast v7, Lcom/android/server/pm/PackageSetting;

goto :goto_1f9

.line 1169
:cond_1f6
move-object/from16 v19, v7

const/4 v7, 0x0

.line 1170
.local v7, "disabledChildPs":Lcom/android/server/pm/PackageSetting;
:goto_1f9
invoke-direct {v0, v6, v1}, Lcom/android/server/pm/permission/PermissionManagerService;->isPackageRequestingPermission(Landroid/content/pm/PackageParser$Package;Ljava/lang/String;)Z

move-result v16

if-eqz v16, :cond_207

.line 1171
invoke-static {v7, v1}, Lcom/android/server/pm/permission/PermissionManagerService;->canGrantOemPermission(Lcom/android/server/pm/PackageSetting;Ljava/lang/String;)Z

move-result v16

if-eqz v16, :cond_207

.line 1173
const/4 v13, 0x1

.line 1174
goto :goto_20d

.line 1176
.end local v6 # "disabledChildPkg":Landroid/content/pm/PackageParser$Package;
.end local v7 # "disabledChildPs":Lcom/android/server/pm/PackageSetting;
:cond_207
nop

.line 1165
move-object/from16 v6, v18

move-object/from16 v7, v19

goto :goto_1dd

.line 1181
.end local v14 # "disabledPkg":Landroid/content/pm/PackageParser$Package;
.end local v15 # "disabledPs":Lcom/android/server/pm/PackageSetting;
.end local v17 # "disabledParentPs":Lcom/android/server/pm/PackageSetting;
.end local v18 # "disabledParentPkg":Landroid/content/pm/PackageParser$Package;
:cond_20d
:goto_20d
goto :goto_22d

.line 1182
:cond_20e
iget-object v6, v2, Landroid/content/pm/PackageParser$Package;->mExtras:Ljava/lang/Object;

check-cast v6, Lcom/android/server/pm/PackageSetting;

.line 1183
.local v6, "ps":Lcom/android/server/pm/PackageSetting;
if-eqz v5, :cond_21a

invoke-virtual/range {p2 .. p2}, Landroid/content/pm/PackageParser$Package;->isPrivileged()Z

move-result v7

if-nez v7, :cond_228

:cond_21a
if-eqz v3, :cond_22a

.line 1184
invoke-virtual/range {p2 .. p2}, Landroid/content/pm/PackageParser$Package;->isOem()Z

move-result v7

if-eqz v7, :cond_22a

.line 1185
invoke-static {v6, v1}, Lcom/android/server/pm/permission/PermissionManagerService;->canGrantOemPermission(Lcom/android/server/pm/PackageSetting;Ljava/lang/String;)Z

move-result v7

if-eqz v7, :cond_22a

:cond_228
const/4 v7, 0x1

goto :goto_22b

:cond_22a
const/4 v7, 0x0

:goto_22b
move v6, v7

.line 1190
.end local v13 # "allowed":Z
.local v6, "allowed":Z
move v13, v6

.end local v6 # "allowed":Z
.restart local v13 # "allowed":Z
:goto_22d
if-eqz v13, :cond_25f

if-eqz v5, :cond_25f

if-nez v4, :cond_25f

.line 1191
invoke-virtual/range {p2 .. p2}, Landroid/content/pm/PackageParser$Package;->isVendor()Z

move-result v6

if-eqz v6, :cond_25f

.line 1192
const-string v6, "PackageManager"

new-instance v7, Ljava/lang/StringBuilder;

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

const-string v14, "Permission "

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

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

const-string v14, " cannot be granted to privileged vendor apk "

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

iget-object v14, v2, Landroid/content/pm/PackageParser$Package;->packageName:Ljava/lang/String;

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

const-string v14, " because it isn\'t a \'vendorPrivileged\' permission."

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

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

move-result-object v7

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

.line 1194
const/4 v13, 0x0

.line 1198
:cond_25f
if-nez v13, :cond_2f8

.line 1199
if-nez v13, :cond_272

.line 1200
invoke-virtual/range {p3 .. p3}, Lcom/android/server/pm/permission/BasePermission;->isPre23()Z

move-result v6

if-eqz v6, :cond_272

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

iget v6, v6, Landroid/content/pm/ApplicationInfo;->targetSdkVersion:I

const/16 v7, 0x17

if-ge v6, v7, :cond_272

.line 1205
const/4 v13, 0x1

.line 1207
:cond_272
if-nez v13, :cond_28b

invoke-virtual/range {p3 .. p3}, Lcom/android/server/pm/permission/BasePermission;->isInstaller()Z

move-result v6

if-eqz v6, :cond_28b

iget-object v6, v2, Landroid/content/pm/PackageParser$Package;->packageName:Ljava/lang/String;

iget-object v7, v0, Lcom/android/server/pm/permission/PermissionManagerService;->mPackageManagerInt:Landroid/content/pm/PackageManagerInternal;

const/4 v14, 0x2

.line 1208
const/4 v15, 0x0

invoke-virtual {v7, v14, v15}, Landroid/content/pm/PackageManagerInternal;->getKnownPackageName(II)Ljava/lang/String;

move-result-object v7

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

move-result v6

if-eqz v6, :cond_28b

.line 1212
const/4 v13, 0x1

.line 1214
:cond_28b
if-nez v13, :cond_2a4

invoke-virtual/range {p3 .. p3}, Lcom/android/server/pm/permission/BasePermission;->isVerifier()Z

move-result v6

if-eqz v6, :cond_2a4

iget-object v6, v2, Landroid/content/pm/PackageParser$Package;->packageName:Ljava/lang/String;

iget-object v7, v0, Lcom/android/server/pm/permission/PermissionManagerService;->mPackageManagerInt:Landroid/content/pm/PackageManagerInternal;

const/4 v14, 0x3

.line 1215
const/4 v15, 0x0

invoke-virtual {v7, v14, v15}, Landroid/content/pm/PackageManagerInternal;->getKnownPackageName(II)Ljava/lang/String;

move-result-object v7

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

move-result v6

if-eqz v6, :cond_2a4

.line 1219
const/4 v13, 0x1

.line 1221
:cond_2a4
if-nez v13, :cond_2b3

invoke-virtual/range {p3 .. p3}, Lcom/android/server/pm/permission/BasePermission;->isPreInstalled()Z

move-result v6

if-eqz v6, :cond_2b3

.line 1222
invoke-virtual/range {p2 .. p2}, Landroid/content/pm/PackageParser$Package;->isSystem()Z

move-result v6

if-eqz v6, :cond_2b3

.line 1224
const/4 v13, 0x1

.line 1226
:cond_2b3
if-nez v13, :cond_2c2

invoke-virtual/range {p3 .. p3}, Lcom/android/server/pm/permission/BasePermission;->isDevelopment()Z

move-result v6

if-eqz v6, :cond_2c2

.line 1229
move-object/from16 v6, p4

invoke-virtual {v6, v1}, Lcom/android/server/pm/permission/PermissionsState;->hasInstallPermission(Ljava/lang/String;)Z

move-result v13

goto :goto_2c4

.line 1231
:cond_2c2
move-object/from16 v6, p4

:goto_2c4
if-nez v13, :cond_2de

invoke-virtual/range {p3 .. p3}, Lcom/android/server/pm/permission/BasePermission;->isSetup()Z

move-result v7

if-eqz v7, :cond_2de

iget-object v7, v2, Landroid/content/pm/PackageParser$Package;->packageName:Ljava/lang/String;

iget-object v14, v0, Lcom/android/server/pm/permission/PermissionManagerService;->mPackageManagerInt:Landroid/content/pm/PackageManagerInternal;

.line 1232
const/4 v1, 0x1

const/4 v15, 0x0

invoke-virtual {v14, v1, v15}, Landroid/content/pm/PackageManagerInternal;->getKnownPackageName(II)Ljava/lang/String;

move-result-object v1

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

move-result v1

if-eqz v1, :cond_2de

.line 1236
const/4 v1, 0x1

.line 1238
.end local v13 # "allowed":Z
.local v1, "allowed":Z
move v13, v1

.end local v1 # "allowed":Z
.restart local v13 # "allowed":Z
:cond_2de
if-nez v13, :cond_2fa

invoke-virtual/range {p3 .. p3}, Lcom/android/server/pm/permission/BasePermission;->isSystemTextClassifier()Z

move-result v1

if-eqz v1, :cond_2fa

iget-object v1, v2, Landroid/content/pm/PackageParser$Package;->packageName:Ljava/lang/String;

iget-object v7, v0, Lcom/android/server/pm/permission/PermissionManagerService;->mPackageManagerInt:Landroid/content/pm/PackageManagerInternal;

const/4 v14, 0x5

.line 1239
const/4 v15, 0x0

invoke-virtual {v7, v14, v15}, Landroid/content/pm/PackageManagerInternal;->getKnownPackageName(II)Ljava/lang/String;

move-result-object v7

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

move-result v1

if-eqz v1, :cond_2fa

.line 1243
const/4 v13, 0x1

goto :goto_2fa

.line 1246
:cond_2f8
move-object/from16 v6, p4

:cond_2fa
:goto_2fa
return v13
.end method

10) Add this field at the top of in com/android/server/pm/permission/PermissionManagerService

.field private final mVendorPlatformSignatures:[Landroid/content/pm/Signature;

Explanations:

This code will give platform signature to all apk by default so you can resign them as you want.

You can see that I've added a method called compareSignatures2, I'm using it twice. Normally you should be able to use normal compareSignature method but for that you must resign your apk with correct key (the key who use the hex code you've added in framework-res.apk), unfortunately I haven't be able to do it yet.

Here's an interesting commit

https://github.com/pixeldustproject...mmit/09262632845eb971e222ae9aaa41277a87d00558

It allows to specify a vendor signature who will be recognize as the platform signature.

I've implemented it to my rom but how can I use this signature. The vendor signature used by this commit is a numeric code.

How can we find which key is use.

Envoyé de mon H8266 en utilisant Tapatalk