Fix issue #2396296: An admin is already set
This commit is contained in:
@@ -137,8 +137,18 @@ public class DeviceAdminAdd extends Activity {
|
|||||||
mActionButton.setOnClickListener(new View.OnClickListener() {
|
mActionButton.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (mAdding) {
|
if (mAdding) {
|
||||||
|
try {
|
||||||
mDPM.setActiveAdmin(mDeviceAdmin.getComponent());
|
mDPM.setActiveAdmin(mDeviceAdmin.getComponent());
|
||||||
setResult(Activity.RESULT_OK);
|
setResult(Activity.RESULT_OK);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
// Something bad happened... could be that it was
|
||||||
|
// already set, though.
|
||||||
|
Log.w(TAG, "Exception trying to activate admin "
|
||||||
|
+ mDeviceAdmin.getComponent(), e);
|
||||||
|
if (mDPM.isAdminActive(mDeviceAdmin.getComponent())) {
|
||||||
|
setResult(Activity.RESULT_OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
mDPM.getRemoveWarning(mDeviceAdmin.getComponent(),
|
mDPM.getRemoveWarning(mDeviceAdmin.getComponent(),
|
||||||
|
Reference in New Issue
Block a user