Skip to content

Commit

Permalink
gmscompat: improve support for test packages on debuggable builds
Browse files Browse the repository at this point in the history
  • Loading branch information
muhomorr authored and thestinger committed Mar 28, 2023
1 parent ada89ee commit fe03a27
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions core/java/android/app/compat/gms/GmsCompat.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ public static boolean isGmsApp(ApplicationInfo app) {
}

private static boolean isGmsPackageName(String pkg) {
if (Build.IS_DEBUGGABLE) {
if (isTestPackage(pkg)) {
return true;
}
}

return GmsInfo.PACKAGE_GMS_CORE.equals(pkg)
|| GmsInfo.PACKAGE_PLAY_STORE.equals(pkg)
|| GmsInfo.PACKAGE_GSF.equals(pkg)
Expand Down Expand Up @@ -258,15 +264,18 @@ public static boolean hasPermission(@NonNull String perm) {
return ctx.checkSelfPermission(perm) == PackageManager.PERMISSION_GRANTED;
}

private static boolean isTestPackage(String packageName) {
String testPkgs = SystemProperties.get("persist.gmscompat_test_pkgs");
return ArrayUtils.contains(testPkgs.split(","), packageName);
}

// call only when Build.isDebuggable() is true
/** @hide */
public static boolean isTestPackage(String packageName, int userId, boolean matchDisabledApp) {
if (!Build.isDebuggable()) {
return false;
}
String testPkgs = SystemProperties.get("persist.gmscompat_test_pkgs");

if (!ArrayUtils.contains(testPkgs.split(","), packageName)) {
if (!isTestPackage(packageName)) {
return false;
}

Expand Down

0 comments on commit fe03a27

Please sign in to comment.