Skip to content

Commit 70831d9

Browse files
quh4gko8thestinger
authored andcommitted
Hide provider(s) for startup on apps with a valid Play Store source
stamp
1 parent 4f353a0 commit 70831d9

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

services/core/java/com/android/server/pm/ComputerEngine.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4836,6 +4836,9 @@ public ProviderInfo resolveContentProvider(@NonNull String name,
48364836
}
48374837
final PackageStateInternal packageState = getPackageStateInternal(
48384838
providerInfo.packageName);
4839+
if (com.android.server.pm.ext.PackageHooks.shouldHideContentProvider(packageState, providerInfo)) {
4840+
return null;
4841+
}
48394842
if (!PackageStateUtils.isEnabledAndMatches(packageState, providerInfo, flags, userId)) {
48404843
return null;
48414844
}
@@ -4924,6 +4927,9 @@ public ParceledListSlice<ProviderInfo> queryContentProviders(@Nullable String pr
49244927
continue;
49254928
}
49264929
final PackageStateInternal ps = mSettings.getPackage(providerInfo.packageName);
4930+
if (com.android.server.pm.ext.PackageHooks.shouldHideContentProvider(ps, providerInfo)) {
4931+
continue;
4932+
}
49274933
final ComponentName component =
49284934
new ComponentName(providerInfo.packageName, providerInfo.name);
49294935
if (shouldFilterApplication(

services/core/java/com/android/server/pm/ext/PackageHooks.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,30 @@ protected static boolean isUserInstalledPkg(PackageState ps) {
8989
public boolean shouldAllowFgsWhileInUsePermission(PackageManagerInternal pm, int userId) {
9090
return false;
9191
}
92+
93+
public static boolean shouldHideContentProvider(
94+
@Nullable PackageStateInternal psi,
95+
@Nullable android.content.pm.ProviderInfo providerInfo) {
96+
if (providerInfo == null) {
97+
return false;
98+
}
99+
100+
if (psi == null) {
101+
return false;
102+
}
103+
104+
AndroidPackage pkg = psi.getPkg();
105+
if (pkg == null) {
106+
return false;
107+
}
108+
109+
PackageExt pkgExt = PackageExt.get(pkg);
110+
final int flagBitToCheck = android.ext.AppInfoExtFlag.HAS_PLAY_STORE_SOURCE_STAMP_ON_APK_CERTS;
111+
final String providerToHide = "com.pairip.licensecheck.LicenseContentProvider";
112+
if (pkgExt.hasFlag(flagBitToCheck) && providerToHide.equals(providerInfo.name)) {
113+
return true;
114+
}
115+
116+
return false;
117+
}
92118
}

0 commit comments

Comments
 (0)