Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 676e7251 authored by Jessica Hummel's avatar Jessica Hummel Committed by Android Git Automerger
Browse files

am a38239d3: Merge "bug fix: Allow enableSystemApps to be called by profile...

am a38239d3: Merge "bug fix: Allow enableSystemApps to be called by profile and device owner." into lmp-dev

* commit 'a38239d39e2f71e54352001980863ca81cbbac41':
  bug fix: Allow enableSystemApps to be called by profile and device owner.
parents 3a4e05d1 ccfa1a97
Loading
Loading
Loading
Loading
+15 −13
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.devicepolicy;

import static android.Manifest.permission.MANAGE_CA_CERTIFICATES;
import static android.content.pm.PackageManager.GET_UNINSTALLED_PACKAGES;

import android.accessibilityservice.AccessibilityServiceInfo;
import android.accounts.AccountManager;
@@ -4801,17 +4802,17 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
            long id = Binder.clearCallingIdentity();

            try {
                UserManager um = UserManager.get(mContext);
                if (!um.getUserInfo(userId).isManagedProfile()) {
                    throw new IllegalStateException(
                            "Only call this method from a managed profile.");
                if (DBG) {
                    Slog.v(LOG_TAG, "installing " + packageName + " for "
                            + userId);
                }

                UserManager um = UserManager.get(mContext);
                UserInfo primaryUser = um.getProfileParent(userId);

                if (DBG) {
                    Slog.v(LOG_TAG, "installing " + packageName + " for "
                            + userId);
                // Call did not come from a managed profile
                if (primaryUser == null) {
                    primaryUser = um.getUserInfo(userId);
                }

                IPackageManager pm = AppGlobals.getPackageManager();
@@ -4847,13 +4848,13 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {

            try {
                UserManager um = UserManager.get(mContext);
                if (!um.getUserInfo(userId).isManagedProfile()) {
                    throw new IllegalStateException(
                            "Only call this method from a managed profile.");
                }

                UserInfo primaryUser = um.getProfileParent(userId);

                // Call did not come from a managed profile.
                if (primaryUser == null) {
                    primaryUser = um.getUserInfo(userId);
                }

                IPackageManager pm = AppGlobals.getPackageManager();
                List<ResolveInfo> activitiesToEnable = pm.queryIntentActivities(intent,
                        intent.resolveTypeIfNeeded(mContext.getContentResolver()),
@@ -4890,7 +4891,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {

    private boolean isSystemApp(IPackageManager pm, String packageName, int userId)
            throws RemoteException {
        ApplicationInfo appInfo = pm.getApplicationInfo(packageName, 0, userId);
        ApplicationInfo appInfo = pm.getApplicationInfo(packageName, GET_UNINSTALLED_PACKAGES,
                userId);
        return (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) > 0;
    }