Don't show developer options to secondary users

Show just a message that developer options are not available for the user.

Also fix silent exit of AddAccount operation by showing a toast that user
cannot add accounts.

Bug: 7409523
Bug: 8519646
Bug: 7304007

Change-Id: Id3f430d568d6b7151ac55f86dbc0ef91803fa10c
This commit is contained in:
Amith Yamasani
2013-04-13 18:30:59 -07:00
parent 34a62601ad
commit c39dcc1ce4
4 changed files with 39 additions and 2 deletions

View File

@@ -28,7 +28,9 @@ import android.content.Intent;
import android.os.Bundle;
import android.os.UserManager;
import android.util.Log;
import android.widget.Toast;
import com.android.settings.R;
import com.android.settings.Utils;
import java.io.IOException;
@@ -124,9 +126,15 @@ public class AddAccountSettings extends Activity {
}
final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
if (mAddAccountCalled || um.hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)) {
if (um.hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)) {
// We aren't allowed to add an account.
Toast.makeText(this, R.string.user_cannot_add_accounts_message, Toast.LENGTH_LONG)
.show();
finish();
return;
}
if (mAddAccountCalled) {
// We already called add account - maybe the callback was lost.
// Or we aren't allowed to add an account.
finish();
return;
}

View File

@@ -332,6 +332,7 @@ public class ManageAccountsSettings extends AccountPreferenceBase
getPreferenceScreen().addPreference(preference);
if (mFirstAccount == null) {
mFirstAccount = account;
getActivity().invalidateOptionsMenu();
}
}
}