Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
fixup! dpc check if play exists
Browse files Browse the repository at this point in the history
  • Loading branch information
mkg20001 committed Aug 13, 2024
1 parent d2a4864 commit ce59d0b
Showing 1 changed file with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21248,20 +21248,18 @@ private void maybeInstallDevicePolicyManagementRoleHolderInUser(int targetUserId
* Check if app requires play services
*/
private boolean requiresPlay(String pkg, int callerUserId) throws RemoteException {
// ApplicationInfo ai = mIPackageManager.getApplicationInfo(pkg, PackageManager.GET_META_DATA, PackageManager.MATCH_ANY_USER);
ApplicationInfo ai = mIPackageManager.getApplicationInfo(pkg, PackageManager.GET_META_DATA, callerUserId);
if (ai.metaData != null) {
int playVersion = ai.metaData.getInt("com.google.android.gms.version", -1);
return playVersion != -1; // || pkg.equals(PackageId.DPC_NAME);
return playVersion != -1;
}

return false;
}

/**
* GrapheneOS Handler to check if any app such as
* role owner in a profile requires play services
* and install them
* GrapheneOS Handler to check if any app such as role owner in a profile
* requires play services and install them
*/
private void maybeInstallPlay(int targetUserId, int callerUserId, String[] pkgNames) {
boolean shouldInstall = false;
Expand All @@ -21278,27 +21276,27 @@ private void maybeInstallPlay(int targetUserId, int callerUserId, String[] pkgNa
}

if (shouldInstall) {
installPlay(targetUserId);
installPlay(targetUserId, callerUserId);
}
}
/**
* GrapheneOS Handler to install sandboxed play into managed user profile
* in order to allow DPC apps that require
* play services to work normally
* in order to allow DPC apps that require play services to work normally
*/
private void installPlay(int targetUserId) {
// TODO: Add option to toggle whether or not play should be installed
private void installPlay(int targetUserId, int callerUserId) {
// TODO: possibly copy permissions from existing install in managing user?
// TODO: handle play services not being installed correctly (shouldn't do anything in that case)
Slogf.d(LOG_TAG, "Installing play for user " + targetUserId);
Slogf.i(LOG_TAG, "Installing play for user " + targetUserId);

List<String> playPkgList = Arrays.asList(PackageId.GSF_NAME, PackageId.GMS_CORE_NAME, PackageId.PLAY_STORE_NAME);

boolean playAllAvailableOnSystem = true;

try {
for (final String playPkg : playPkgList) {
// TODO: check for pkg available
if (mIPackageManager.getApplicationInfo(playPkg, 0, callerUserId) == null) {
playAllAvailableOnSystem = false;
Slogf.w(LOG_TAG, "Play package missing: " + playPkg);
}
}
if (playAllAvailableOnSystem) {
for (final String playPkg : playPkgList) {
Expand All @@ -21319,6 +21317,7 @@ private void installPlay(int targetUserId) {
}
} else {
// TODO: intent to app store to install play packages?
Slogf.w(LOG_TAG, "Play Services not installed, yet requested for profile!");
}

Slogf.d(LOG_TAG, "Granting REQUEST_INSTALL_PACKAGES to Play Store");
Expand Down

0 comments on commit ce59d0b

Please sign in to comment.