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

Unverified Commit 158a581d authored by Michael Bestas's avatar Michael Bestas
Browse files

Merge tag 'android-security-14.0.0_r15' of...

Merge tag 'android-security-14.0.0_r15' of https://android.googlesource.com/platform/frameworks/base into lineage-21.0

Android Security 14.0.0 Release 15 (12496787)

* tag 'android-security-14.0.0_r15' of https://android.googlesource.com/platform/frameworks/base:
  Allow uninstalling DMRH when not used for management
  Properly handle onNullBinding() in appwidget service.
  Block clipboard UI when device is locked

 Conflicts:
	packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardListener.java
	packages/SystemUI/tests/src/com/android/systemui/clipboardoverlay/ClipboardListenerTest.java

Change-Id: I2bb529d8999199a655f970bff4aa80deac94d6ec
parents 2031865f 6ad2d597
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -240,6 +240,11 @@ public class RemoteViewsAdapter extends BaseAdapter implements Handler.Callback
            }
        }

        @Override
        public void onNullBinding(ComponentName name) {
            enqueueDeferredUnbindServiceMessage();
        }

        @Override
        public void handleMessage(Message msg) {
            RemoteViewsAdapter adapter = mAdapter.get();
+10 −0
Original line number Diff line number Diff line
@@ -1959,6 +1959,11 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
                mContext.unbindService(this);
            }

            @Override
            public void onNullBinding(ComponentName name) {
                mContext.unbindService(this);
            }

            @Override
            public void onServiceDisconnected(ComponentName name) {
                // Do nothing
@@ -2104,6 +2109,11 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
                                mContext.unbindService(this);
                            }

                            @Override
                            public void onNullBinding(ComponentName name) {
                                mContext.unbindService(this);
                            }

                            @Override
                            public void onServiceDisconnected(android.content.ComponentName name) {
                                // Do nothing
+24 −7
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ import android.app.ApplicationExitInfo;
import android.app.ApplicationPackageManager;
import android.app.BroadcastOptions;
import android.app.IActivityManager;
import android.app.admin.DevicePolicyManagerInternal;
import android.app.admin.IDevicePolicyManager;
import android.app.admin.SecurityLog;
import android.app.backup.IBackupManager;
@@ -3417,8 +3418,10 @@ public class PackageManagerService implements PackageSender, TestUtilityService
    // TODO(b/261957226): centralise this logic in DPM
    boolean isPackageDeviceAdmin(String packageName, int userId) {
        final IDevicePolicyManager dpm = getDevicePolicyManager();
        final DevicePolicyManagerInternal dpmi =
                mInjector.getLocalService(DevicePolicyManagerInternal.class);
        try {
            if (dpm != null) {
            if (dpm != null && dpmi != null) {
                final ComponentName deviceOwnerComponentName = dpm.getDeviceOwnerComponent(
                        /* callingUserOnly =*/ false);
                final String deviceOwnerPackageName = deviceOwnerComponentName == null ? null
@@ -3431,17 +3434,31 @@ public class PackageManagerService implements PackageSender, TestUtilityService
                    return true;
                }
                // Does it contain a device admin for any user?
                int[] users;
                int[] allUsers = mUserManager.getUserIds();
                int[] targetUsers;
                if (userId == UserHandle.USER_ALL) {
                    users = mUserManager.getUserIds();
                    targetUsers = allUsers;
                } else {
                    users = new int[]{userId};
                    targetUsers = new int[]{userId};
                }
                for (int i = 0; i < users.length; ++i) {
                    if (dpm.packageHasActiveAdmins(packageName, users[i])) {

                for (int i = 0; i < targetUsers.length; ++i) {
                    if (dpm.packageHasActiveAdmins(packageName, targetUsers[i])) {
                        return true;
                    }
                    if (isDeviceManagementRoleHolder(packageName, users[i])) {
                }

                // If a package is DMRH on a managed user, it should also be treated as an admin on
                // that user. If that package is also a system package, it should also be protected
                // on other users otherwise "uninstall updates" on an unmanaged user may break
                // management on other users because apk version is shared between all users.
                var packageState = snapshotComputer().getPackageStateInternal(packageName);
                if (packageState == null) {
                    return false;
                }
                for (int user : packageState.isSystem() ? allUsers : targetUsers) {
                    if (isDeviceManagementRoleHolder(packageName, user)
                            && dpmi.isUserOrganizationManaged(user)) {
                        return true;
                    }
                }