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

Commit ab489cab authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Don't crash when there is no admin."

parents 6e6393c2 4141d035
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import android.app.DeviceAdminInfo;
import android.app.DevicePolicyManager;
import android.app.IDevicePolicyManager;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -36,11 +35,9 @@ import android.content.pm.ResolveInfo;
import android.os.Binder;
import android.os.IBinder;
import android.os.IPowerManager;
import android.os.PowerManager;
import android.os.RecoverySystem;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.provider.Settings;
import android.util.Log;
import android.util.Xml;

@@ -114,6 +111,12 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        mContext.sendBroadcast(intent);
    }
    
    void sendAdminCommandLocked(String action) {
        if (mActiveAdmin != null) {
            sendAdminCommandLocked(mActiveAdmin, action);
        }
    }
    
    ComponentName getActiveAdminLocked() {
        if (mActiveAdmin != null) {
            return mActiveAdmin.info.getComponent();
@@ -498,8 +501,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                    mActivePasswordMode = mode;
                    mActivePasswordLength = length;
                    mFailedPasswordAttempts = 0;
                    sendAdminCommandLocked(mActiveAdmin,
                            DeviceAdmin.ACTION_PASSWORD_CHANGED);
                    sendAdminCommandLocked(DeviceAdmin.ACTION_PASSWORD_CHANGED);
                } finally {
                    Binder.restoreCallingIdentity(ident);
                }
@@ -515,8 +517,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
            long ident = Binder.clearCallingIdentity();
            try {
                mFailedPasswordAttempts++;
                sendAdminCommandLocked(mActiveAdmin,
                        DeviceAdmin.ACTION_PASSWORD_FAILED);
                sendAdminCommandLocked(DeviceAdmin.ACTION_PASSWORD_FAILED);
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
@@ -532,8 +533,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                long ident = Binder.clearCallingIdentity();
                try {
                    mFailedPasswordAttempts = 0;
                    sendAdminCommandLocked(mActiveAdmin,
                            DeviceAdmin.ACTION_PASSWORD_SUCCEEDED);
                    sendAdminCommandLocked(DeviceAdmin.ACTION_PASSWORD_SUCCEEDED);
                } finally {
                    Binder.restoreCallingIdentity(ident);
                }