am 9217185d: am c39dcc1c: Don\'t show developer options to secondary users

* commit '9217185d74dad396ea87e4b82597c0fe2d949efe':
  Don't show developer options to secondary users
This commit is contained in:
Amith Yamasani
2013-04-13 18:51:53 -07:00
committed by Android Git Automerger
4 changed files with 39 additions and 2 deletions

View File

@@ -3036,6 +3036,8 @@
<!-- Development Settings summary. The summary of the item to take the user to Development settings. Development settings are settings meant for application developers. -->
<string name="development_settings_summary">Set options for app development</string>
<!-- Setting checkbox title for Whether to enable USB debugging support on the phone. -->
<!-- Error message for users that aren't allowed to modify developer options [CHAR LIMIT=none] -->
<string name="development_settings_not_available">Developer options are not available for this user</string>
<string name="enable_adb">USB debugging</string>
<!-- Setting checkbox summary for Whether to enable USB debugging support on the phone -->
<string name="enable_adb_summary">Debug mode when USB is connected</string>
@@ -4374,6 +4376,8 @@
<string name="user_cannot_manage_message" product="tablet">Only the tablet\'s owner can manage users.</string>
<!-- Message to secondary users that only owner can manage users [CHAR LIMIT=none] -->
<string name="user_cannot_manage_message" product="default">Only the phone\'s owner can manage users.</string>
<!-- Message to limited users that they cannot add accounts [CHAR LIMIT=100] -->
<string name="user_cannot_add_accounts_message">Limited users cannot add accounts</string>
<!-- User details remove user menu [CHAR LIMIT=20] -->
<string name="user_remove_user_menu">Delete <xliff:g id="user_name">%1$s</xliff:g> from this device</string>

View File

@@ -48,6 +48,7 @@ import android.os.ServiceManager;
import android.os.StrictMode;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
@@ -65,6 +66,7 @@ import android.view.IWindowManager;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.HashSet;
@@ -207,6 +209,8 @@ public class DevelopmentSettings extends PreferenceFragment
private Dialog mAdbDialog;
private Dialog mAdbKeysDialog;
private boolean mUnavailable;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
@@ -216,6 +220,12 @@ public class DevelopmentSettings extends PreferenceFragment
ServiceManager.getService(Context.BACKUP_SERVICE));
mDpm = (DevicePolicyManager)getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
if (android.os.Process.myUserHandle().getIdentifier() != UserHandle.USER_OWNER) {
mUnavailable = true;
setPreferenceScreen(new PreferenceScreen(getActivity(), null));
return;
}
addPreferencesFromResource(R.xml.development_prefs);
final PreferenceGroup debugDebuggingCategory = (PreferenceGroup)
@@ -343,6 +353,10 @@ public class DevelopmentSettings extends PreferenceFragment
final int padding = activity.getResources().getDimensionPixelSize(
R.dimen.action_bar_switch_padding);
mEnabledSwitch.setPaddingRelative(0, 0, padding, 0);
if (mUnavailable) {
mEnabledSwitch.setEnabled(false);
return;
}
mEnabledSwitch.setOnCheckedChangeListener(this);
}
@@ -389,6 +403,16 @@ public class DevelopmentSettings extends PreferenceFragment
public void onResume() {
super.onResume();
if (mUnavailable) {
// Show error message
TextView emptyView = (TextView) getView().findViewById(android.R.id.empty);
getListView().setEmptyView(emptyView);
if (emptyView != null) {
emptyView.setText(R.string.development_settings_not_available);
}
return;
}
if (mDpm.getMaximumTimeToLock(null) > 0) {
// A DeviceAdmin has specified a maximum time until the device
// will lock... in this case we can't allow the user to turn

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();
}
}
}