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

Commit d47c6ed4 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Bite the bullet and add support for multiple device admins.

parent 9cf5b455
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -20399,6 +20399,17 @@
 deprecated="not deprecated"
 visibility="public"
>
<method name="getActiveAdmins"
 return="java.util.List&lt;android.content.ComponentName&gt;"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getCurrentFailedPasswordAttempts"
 return="int"
 abstract="false"
+1 −1
Original line number Diff line number Diff line
@@ -2518,7 +2518,7 @@ public class Activity extends ContextThemeWrapper
     * and restored for you.  Note that if the dialog is already created,
     * {@link #onCreateDialog(int, Bundle)} will not be called with the new
     * arguments but {@link #onPrepareDialog(int, Dialog, Bundle)} will be.
     * If you need to rebuild the dialog, call {@link #removeDialog(int)}Êfirst.
     * If you need to rebuild the dialog, call {@link #removeDialog(int)} first.
     * @return Returns true if the Dialog was created; false is returned if
     * it is not created because {@link #onCreateDialog(int, Bundle)} returns false.
     * 
+19 −25
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.os.ServiceManager;
import android.util.Log;

import java.io.IOException;
import java.util.List;

/**
 * Public interface for managing policies enforced on a device.  Most clients
@@ -65,10 +66,6 @@ public class DevicePolicyManager {
     * <p>You can optionally include the {@link #EXTRA_ADD_EXPLANATION}
     * field to provide the user with additional explanation (in addition
     * to your component's description) about what is being added.
     * 
     * <p>Note: the current platform can only have one device administrator
     * active at a time.  If you make this request while there is already
     * an active administrator, this new request will be canceled automatically.
     */
    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    public static final String ACTION_ADD_DEVICE_ADMIN
@@ -111,7 +108,7 @@ public class DevicePolicyManager {
    public boolean isAdminActive(ComponentName who) {
        if (mService != null) {
            try {
                return who.equals(mService.getActiveAdmin());
                return mService.isAdminActive(who);
            } catch (RemoteException e) {
                Log.w(TAG, "Failed talking with device policy service", e);
            }
@@ -119,6 +116,22 @@ public class DevicePolicyManager {
        return false;
    }
    
    /**
     * Return a list of all currently active device administrator's component
     * names.  Note that if there are no administrators than null may be
     * returned.
     */
    public List<ComponentName> getActiveAdmins() {
        if (mService != null) {
            try {
                return mService.getActiveAdmins();
            } catch (RemoteException e) {
                Log.w(TAG, "Failed talking with device policy service", e);
            }
        }
        return null;
    }
    
    /**
     * Remove a current administration component.  This can only be called
     * by the application that owns the administration component; if you
@@ -442,26 +455,7 @@ public class DevicePolicyManager {
    /**
     * @hide
     */
    public ComponentName getActiveAdmin() {
        if (mService != null) {
            try {
                return mService.getActiveAdmin();
            } catch (RemoteException e) {
                Log.w(TAG, "Failed talking with device policy service", e);
            }
        }
        return null;
    }
    
    /**
     * @hide
     */
    public DeviceAdminInfo getActiveAdminInfo() {
        ComponentName cn = getActiveAdmin();
        if (cn == null) {
            return null;
        }
        
    public DeviceAdminInfo getAdminInfo(ComponentName cn) {
        ActivityInfo ai;
        try {
            ai = mContext.getPackageManager().getReceiverInfo(cn,
+2 −1
Original line number Diff line number Diff line
@@ -45,7 +45,8 @@ interface IDevicePolicyManager {
    void wipeData(int flags);
    
    void setActiveAdmin(in ComponentName policyReceiver);
    ComponentName getActiveAdmin();
    boolean isAdminActive(in ComponentName policyReceiver);
    List<ComponentName> getActiveAdmins();
    void getRemoveWarning(in ComponentName policyReceiver, in RemoteCallback result);
    void removeActiveAdmin(in ComponentName policyReceiver);
    
+0 −5
Original line number Diff line number Diff line
@@ -121,11 +121,6 @@ public class LockPatternUtils {

    }

    public boolean isDevicePolicyActive() {
        ComponentName admin = mDevicePolicyManager.getActiveAdmin();
        return admin != null ? mDevicePolicyManager.isAdminActive(admin) : false;
    }

    public int getRequestedMinimumPasswordLength() {
        return mDevicePolicyManager.getMinimumPasswordLength();
    }
Loading