Fix issue #2396296: An admin is already set

This commit is contained in:
Dianne Hackborn
2010-02-22 12:51:42 -08:00
parent a110a718ba
commit 3e04288198

View File

@@ -137,8 +137,18 @@ public class DeviceAdminAdd extends Activity {
mActionButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (mAdding) {
mDPM.setActiveAdmin(mDeviceAdmin.getComponent());
setResult(Activity.RESULT_OK);
try {
mDPM.setActiveAdmin(mDeviceAdmin.getComponent());
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();
} else {
mDPM.getRemoveWarning(mDeviceAdmin.getComponent(),