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

Commit e9a7684c authored by Ricardo Cerqueira's avatar Ricardo Cerqueira Committed by Gerrit Code Review
Browse files

DevicePolicy: Restore backup manager if the device owner is cleared

Change I3fe54e43324c15dabd56834a923e8e8cb4eea98d permanently disables
the backup manager when a device owner is set. Put the service back
if the owner is cleared

Addresses CYNGNOS-779
Fixes android.security.cts.ServicePermissionsTest#testDumpProtected when
run after com.android.cts.devicepolicy.DeviceOwnerTest#testKeyManagement

Change-Id: I1c5bc39f6feb6be03975cedc16185378bbc28473
parent 1071e94e
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -3880,6 +3880,14 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                if (mDeviceOwner != null) {
                    mDeviceOwner.clearDeviceOwner();
                    mDeviceOwner.writeOwnerFile();
                    // Restore backup manager.
                    try {
                        IBackupManager ibm = IBackupManager.Stub.asInterface(
                                ServiceManager.getService(Context.BACKUP_SERVICE));
                        ibm.setBackupServiceActive(UserHandle.USER_OWNER, true);
                    } catch (RemoteException e) {
                        throw new IllegalStateException("Failed activating backup service.", e);
                    }
                }
            } finally {
                Binder.restoreCallingIdentity(ident);