Merge "Added isRemovingAdmin method" into lmp-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
22afe6261a
@@ -504,6 +504,22 @@ public class DevicePolicyManager {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Return true if the given administrator component is currently being removed
|
||||
* for the user.
|
||||
* @hide
|
||||
*/
|
||||
public boolean isRemovingAdmin(ComponentName who, int userId) {
|
||||
if (mService != null) {
|
||||
try {
|
||||
return mService.isRemovingAdmin(who, userId);
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Failed talking with device policy service", e);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a list of all currently active device administrator's component
|
||||
|
||||
@@ -196,4 +196,6 @@ interface IDevicePolicyManager {
|
||||
|
||||
void setAutoTimeRequired(in ComponentName who, int userHandle, boolean required);
|
||||
boolean getAutoTimeRequired();
|
||||
|
||||
boolean isRemovingAdmin(in ComponentName adminReceiver, int userHandle);
|
||||
}
|
||||
|
||||
@@ -120,7 +120,6 @@ import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.security.cert.CertificateEncodingException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.security.cert.X509Certificate;
|
||||
@@ -265,6 +264,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
|
||||
= new HashMap<ComponentName, ActiveAdmin>();
|
||||
final ArrayList<ActiveAdmin> mAdminList
|
||||
= new ArrayList<ActiveAdmin>();
|
||||
final ArrayList<ComponentName> mRemovingAdmins
|
||||
= new ArrayList<ComponentName>();
|
||||
|
||||
// This is the list of component allowed to start lock task mode.
|
||||
final List<String> mLockTaskPackages = new ArrayList<String>();
|
||||
@@ -1212,6 +1213,9 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
|
||||
void removeActiveAdminLocked(final ComponentName adminReceiver, int userHandle) {
|
||||
final ActiveAdmin admin = getActiveAdminUncheckedLocked(adminReceiver, userHandle);
|
||||
if (admin != null) {
|
||||
synchronized (this) {
|
||||
getUserData(userHandle).mRemovingAdmins.add(adminReceiver);
|
||||
}
|
||||
sendAdminCommandLocked(admin,
|
||||
DeviceAdminReceiver.ACTION_DEVICE_ADMIN_DISABLED,
|
||||
new BroadcastReceiver() {
|
||||
@@ -1231,9 +1235,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
|
||||
}
|
||||
saveSettingsLocked(userHandle);
|
||||
updateMaximumTimeToLockLocked(policy);
|
||||
policy.mRemovingAdmins.remove(adminReceiver);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1798,6 +1803,18 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRemovingAdmin(ComponentName adminReceiver, int userHandle) {
|
||||
if (!mHasFeature) {
|
||||
return false;
|
||||
}
|
||||
enforceCrossUserPermission(userHandle);
|
||||
synchronized (this) {
|
||||
DevicePolicyData policyData = getUserData(userHandle);
|
||||
return policyData.mRemovingAdmins.contains(adminReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasGrantedPolicy(ComponentName adminReceiver, int policyId, int userHandle) {
|
||||
if (!mHasFeature) {
|
||||
return false;
|
||||
@@ -4101,6 +4118,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
|
||||
ap.dump(" ", pw);
|
||||
}
|
||||
}
|
||||
if (!policy.mRemovingAdmins.isEmpty()) {
|
||||
p.println(" Removing Device Admins (User " + policy.mUserHandle + "): "
|
||||
+ policy.mRemovingAdmins);
|
||||
}
|
||||
|
||||
pw.println(" ");
|
||||
pw.print(" mPasswordOwner="); pw.println(policy.mPasswordOwner);
|
||||
|
||||
Reference in New Issue
Block a user