Merge "Don\'t allow removing admin to be added again" into nyc-dev am: 547fc39

am: 513c783

* commit '513c783b39eb52eb77295f1a0c3b3b3e38a9d919':
  Don't allow removing admin to be added again

Change-Id: I05a3d7915d502c9535a6f62effce854a0dffb466
This commit is contained in:
Makoto Onuki
2016-04-15 16:10:45 +00:00
committed by android-build-merger

View File

@@ -245,6 +245,12 @@ public class DeviceAdminAdd extends Activity {
if (DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN.equals(getIntent().getAction())) {
mRefreshing = false;
if (mDPM.isAdminActive(who)) {
if (mDPM.isRemovingAdmin(who, android.os.Process.myUserHandle().getIdentifier())) {
Log.w(TAG, "Requested admin is already being removed: " + who);
finish();
return;
}
ArrayList<DeviceAdminInfo.PolicyInfo> newPolicies = mDeviceAdmin.getUsedPolicies();
for (int i = 0; i < newPolicies.size(); i++) {
DeviceAdminInfo.PolicyInfo pi = newPolicies.get(i);