am 02e8ca3e
: Merge "Respect user restrictions about adding/removing accounts, sideloading" into jb-mr2-dev
* commit '02e8ca3e9ad966bd523241aaa1eecf58865027a8': Respect user restrictions about adding/removing accounts, sideloading
This commit is contained in:
@@ -96,7 +96,7 @@ public class LocationSettings extends SettingsPreferenceFragment
|
|||||||
// Only enable these controls if this user is allowed to change location
|
// Only enable these controls if this user is allowed to change location
|
||||||
// sharing settings.
|
// sharing settings.
|
||||||
final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
|
final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
|
||||||
boolean isToggleAllowed = um.isLocationSharingToggleAllowed();
|
boolean isToggleAllowed = !um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION);
|
||||||
if (mLocationAccess != null) mLocationAccess.setEnabled(isToggleAllowed);
|
if (mLocationAccess != null) mLocationAccess.setEnabled(isToggleAllowed);
|
||||||
if (mNetwork != null) mNetwork.setEnabled(isToggleAllowed);
|
if (mNetwork != null) mNetwork.setEnabled(isToggleAllowed);
|
||||||
if (mGps != null) mGps.setEnabled(isToggleAllowed);
|
if (mGps != null) mGps.setEnabled(isToggleAllowed);
|
||||||
@@ -117,6 +117,7 @@ public class LocationSettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
if (mSettingsObserver == null) {
|
if (mSettingsObserver == null) {
|
||||||
mSettingsObserver = new Observer() {
|
mSettingsObserver = new Observer() {
|
||||||
|
@Override
|
||||||
public void update(Observable o, Object arg) {
|
public void update(Observable o, Object arg) {
|
||||||
updateLocationToggles();
|
updateLocationToggles();
|
||||||
}
|
}
|
||||||
@@ -131,13 +132,13 @@ public class LocationSettings extends SettingsPreferenceFragment
|
|||||||
final ContentResolver cr = getContentResolver();
|
final ContentResolver cr = getContentResolver();
|
||||||
final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
|
final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
|
||||||
if (preference == mNetwork) {
|
if (preference == mNetwork) {
|
||||||
if (um.isLocationSharingToggleAllowed()) {
|
if (!um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION)) {
|
||||||
Settings.Secure.setLocationProviderEnabled(cr,
|
Settings.Secure.setLocationProviderEnabled(cr,
|
||||||
LocationManager.NETWORK_PROVIDER, mNetwork.isChecked());
|
LocationManager.NETWORK_PROVIDER, mNetwork.isChecked());
|
||||||
}
|
}
|
||||||
} else if (preference == mGps) {
|
} else if (preference == mGps) {
|
||||||
boolean enabled = mGps.isChecked();
|
boolean enabled = mGps.isChecked();
|
||||||
if (um.isLocationSharingToggleAllowed()) {
|
if (!um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION)) {
|
||||||
Settings.Secure.setLocationProviderEnabled(cr,
|
Settings.Secure.setLocationProviderEnabled(cr,
|
||||||
LocationManager.GPS_PROVIDER, enabled);
|
LocationManager.GPS_PROVIDER, enabled);
|
||||||
if (mAssistedGps != null) {
|
if (mAssistedGps != null) {
|
||||||
@@ -186,7 +187,7 @@ public class LocationSettings extends SettingsPreferenceFragment
|
|||||||
/** Enable or disable all providers when the master toggle is changed. */
|
/** Enable or disable all providers when the master toggle is changed. */
|
||||||
private void onToggleLocationAccess(boolean checked) {
|
private void onToggleLocationAccess(boolean checked) {
|
||||||
final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
|
final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
|
||||||
if (! um.isLocationSharingToggleAllowed()) {
|
if (um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ContentResolver cr = getContentResolver();
|
final ContentResolver cr = getContentResolver();
|
||||||
|
@@ -236,10 +236,26 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
removePreference(KEY_CREDENTIALS_MANAGER);
|
removePreference(KEY_CREDENTIALS_MANAGER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PreferenceGroup deviceAdminCategory= (PreferenceGroup)
|
||||||
|
root.findPreference(KEY_DEVICE_ADMIN_CATEGORY);
|
||||||
mToggleAppInstallation = (CheckBoxPreference) findPreference(
|
mToggleAppInstallation = (CheckBoxPreference) findPreference(
|
||||||
KEY_TOGGLE_INSTALL_APPLICATIONS);
|
KEY_TOGGLE_INSTALL_APPLICATIONS);
|
||||||
mToggleAppInstallation.setChecked(isNonMarketAppsAllowed());
|
mToggleAppInstallation.setChecked(isNonMarketAppsAllowed());
|
||||||
|
|
||||||
|
final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
|
||||||
|
boolean isSideloadingAllowed =
|
||||||
|
!um.hasUserRestriction(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES);
|
||||||
|
// Side loading of apps.
|
||||||
|
if (isSideloadingAllowed) {
|
||||||
|
mToggleAppInstallation.setEnabled(isSideloadingAllowed);
|
||||||
|
} else {
|
||||||
|
if (deviceAdminCategory != null) {
|
||||||
|
deviceAdminCategory.removePreference(mToggleAppInstallation);
|
||||||
|
} else {
|
||||||
|
mToggleAppInstallation.setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Package verification, only visible to primary user and if enabled
|
// Package verification, only visible to primary user and if enabled
|
||||||
mToggleVerifyApps = (CheckBoxPreference) findPreference(KEY_TOGGLE_VERIFY_APPLICATIONS);
|
mToggleVerifyApps = (CheckBoxPreference) findPreference(KEY_TOGGLE_VERIFY_APPLICATIONS);
|
||||||
if (mIsPrimary && showVerifierSetting()) {
|
if (mIsPrimary && showVerifierSetting()) {
|
||||||
@@ -250,8 +266,6 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
mToggleVerifyApps.setEnabled(false);
|
mToggleVerifyApps.setEnabled(false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PreferenceGroup deviceAdminCategory= (PreferenceGroup)
|
|
||||||
root.findPreference(KEY_DEVICE_ADMIN_CATEGORY);
|
|
||||||
if (deviceAdminCategory != null) {
|
if (deviceAdminCategory != null) {
|
||||||
deviceAdminCategory.removePreference(mToggleVerifyApps);
|
deviceAdminCategory.removePreference(mToggleVerifyApps);
|
||||||
} else {
|
} else {
|
||||||
@@ -268,6 +282,10 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setNonMarketAppsAllowed(boolean enabled) {
|
private void setNonMarketAppsAllowed(boolean enabled) {
|
||||||
|
final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
|
||||||
|
if (um.hasUserRestriction(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Change the system setting
|
// Change the system setting
|
||||||
Settings.Global.putInt(getContentResolver(), Settings.Global.INSTALL_NON_MARKET_APPS,
|
Settings.Global.putInt(getContentResolver(), Settings.Global.INSTALL_NON_MARKET_APPS,
|
||||||
enabled ? 1 : 0);
|
enabled ? 1 : 0);
|
||||||
@@ -303,6 +321,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if (dialog == mWarnInstallApps && which == DialogInterface.BUTTON_POSITIVE) {
|
if (dialog == mWarnInstallApps && which == DialogInterface.BUTTON_POSITIVE) {
|
||||||
setNonMarketAppsAllowed(true);
|
setNonMarketAppsAllowed(true);
|
||||||
@@ -505,6 +524,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
createPreferenceHierarchy();
|
createPreferenceHierarchy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object value) {
|
public boolean onPreferenceChange(Preference preference, Object value) {
|
||||||
if (preference == mLockAfter) {
|
if (preference == mLockAfter) {
|
||||||
int timeout = Integer.parseInt((String) value);
|
int timeout = Integer.parseInt((String) value);
|
||||||
|
@@ -178,6 +178,7 @@ public class Settings extends PreferenceActivity
|
|||||||
|
|
||||||
if (mParentHeader != null) {
|
if (mParentHeader != null) {
|
||||||
setParentTitle(mParentHeader.title, null, new OnClickListener() {
|
setParentTitle(mParentHeader.title, null, new OnClickListener() {
|
||||||
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
switchToParent(mParentHeader.fragment);
|
switchToParent(mParentHeader.fragment);
|
||||||
}
|
}
|
||||||
@@ -405,7 +406,6 @@ public class Settings extends PreferenceActivity
|
|||||||
@Override
|
@Override
|
||||||
public void onBuildHeaders(List<Header> headers) {
|
public void onBuildHeaders(List<Header> headers) {
|
||||||
loadHeadersFromResource(R.xml.settings_headers, headers);
|
loadHeadersFromResource(R.xml.settings_headers, headers);
|
||||||
|
|
||||||
updateHeaderList(headers);
|
updateHeaderList(headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,6 +414,8 @@ public class Settings extends PreferenceActivity
|
|||||||
DevelopmentSettings.PREF_SHOW,
|
DevelopmentSettings.PREF_SHOW,
|
||||||
android.os.Build.TYPE.equals("eng"));
|
android.os.Build.TYPE.equals("eng"));
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
|
||||||
mHeaderIndexMap.clear();
|
mHeaderIndexMap.clear();
|
||||||
while (i < target.size()) {
|
while (i < target.size()) {
|
||||||
Header header = target.get(i);
|
Header header = target.get(i);
|
||||||
@@ -464,6 +466,10 @@ public class Settings extends PreferenceActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (id == R.id.account_add) {
|
||||||
|
if (um.hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)) {
|
||||||
|
target.remove(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < target.size() && target.get(i) == header
|
if (i < target.size() && target.get(i) == header
|
||||||
@@ -778,6 +784,7 @@ public class Settings extends PreferenceActivity
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean shouldUpRecreateTask(Intent targetIntent) {
|
public boolean shouldUpRecreateTask(Intent targetIntent) {
|
||||||
return super.shouldUpRecreateTask(new Intent(this, Settings.class));
|
return super.shouldUpRecreateTask(new Intent(this, Settings.class));
|
||||||
}
|
}
|
||||||
|
@@ -28,17 +28,16 @@ import android.app.Dialog;
|
|||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SyncAdapterType;
|
import android.content.SyncAdapterType;
|
||||||
import android.content.SyncInfo;
|
import android.content.SyncInfo;
|
||||||
import android.content.SyncStatusInfo;
|
import android.content.SyncStatusInfo;
|
||||||
import android.content.pm.ProviderInfo;
|
import android.content.pm.ProviderInfo;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.UserManager;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.format.DateFormat;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@@ -93,10 +92,12 @@ public class AccountSyncSettings extends AccountPreferenceBase {
|
|||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
.setPositiveButton(R.string.remove_account_label,
|
.setPositiveButton(R.string.remove_account_label,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
AccountManager.get(AccountSyncSettings.this.getActivity())
|
AccountManager.get(AccountSyncSettings.this.getActivity())
|
||||||
.removeAccount(mAccount,
|
.removeAccount(mAccount,
|
||||||
new AccountManagerCallback<Boolean>() {
|
new AccountManagerCallback<Boolean>() {
|
||||||
|
@Override
|
||||||
public void run(AccountManagerFuture<Boolean> future) {
|
public void run(AccountManagerFuture<Boolean> future) {
|
||||||
// If already out of this screen, don't proceed.
|
// If already out of this screen, don't proceed.
|
||||||
if (!AccountSyncSettings.this.isResumed()) {
|
if (!AccountSyncSettings.this.isResumed()) {
|
||||||
@@ -233,12 +234,15 @@ public class AccountSyncSettings extends AccountPreferenceBase {
|
|||||||
MenuItem syncCancel = menu.add(0, MENU_SYNC_CANCEL_ID, 0,
|
MenuItem syncCancel = menu.add(0, MENU_SYNC_CANCEL_ID, 0,
|
||||||
getString(R.string.sync_menu_sync_cancel))
|
getString(R.string.sync_menu_sync_cancel))
|
||||||
.setIcon(com.android.internal.R.drawable.ic_menu_close_clear_cancel);
|
.setIcon(com.android.internal.R.drawable.ic_menu_close_clear_cancel);
|
||||||
MenuItem removeAccount = menu.add(0, MENU_REMOVE_ACCOUNT_ID, 0,
|
|
||||||
getString(R.string.remove_account_label))
|
|
||||||
.setIcon(R.drawable.ic_menu_delete_holo_dark);
|
|
||||||
|
|
||||||
removeAccount.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER |
|
final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
|
||||||
MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
if (!um.hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)) {
|
||||||
|
MenuItem removeAccount = menu.add(0, MENU_REMOVE_ACCOUNT_ID, 0,
|
||||||
|
getString(R.string.remove_account_label))
|
||||||
|
.setIcon(R.drawable.ic_menu_delete_holo_dark);
|
||||||
|
removeAccount.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER |
|
||||||
|
MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||||
|
}
|
||||||
syncNow.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER |
|
syncNow.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER |
|
||||||
MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||||
syncCancel.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER |
|
syncCancel.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER |
|
||||||
|
@@ -23,8 +23,10 @@ import android.accounts.AuthenticatorException;
|
|||||||
import android.accounts.OperationCanceledException;
|
import android.accounts.OperationCanceledException;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.UserManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
@@ -71,7 +73,8 @@ public class AddAccountSettings extends Activity {
|
|||||||
|
|
||||||
private PendingIntent mPendingIntent;
|
private PendingIntent mPendingIntent;
|
||||||
|
|
||||||
private AccountManagerCallback<Bundle> mCallback = new AccountManagerCallback<Bundle>() {
|
private final AccountManagerCallback<Bundle> mCallback = new AccountManagerCallback<Bundle>() {
|
||||||
|
@Override
|
||||||
public void run(AccountManagerFuture<Bundle> future) {
|
public void run(AccountManagerFuture<Bundle> future) {
|
||||||
boolean done = true;
|
boolean done = true;
|
||||||
try {
|
try {
|
||||||
@@ -120,8 +123,10 @@ public class AddAccountSettings extends Activity {
|
|||||||
if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "restored");
|
if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "restored");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mAddAccountCalled) {
|
final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
|
||||||
|
if (mAddAccountCalled || um.hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)) {
|
||||||
// We already called add account - maybe the callback was lost.
|
// We already called add account - maybe the callback was lost.
|
||||||
|
// Or we aren't allowed to add an account.
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -162,6 +167,7 @@ public class AddAccountSettings extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putBoolean(KEY_ADD_CALLED, mAddAccountCalled);
|
outState.putBoolean(KEY_ADD_CALLED, mAddAccountCalled);
|
||||||
|
@@ -541,7 +541,7 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
|
|||||||
protected Boolean doInBackground(Void... args) {
|
protected Boolean doInBackground(Void... args) {
|
||||||
final UserManager um =
|
final UserManager um =
|
||||||
(UserManager) context.getSystemService(Context.USER_SERVICE);
|
(UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||||
if (um.isLocationSharingToggleAllowed()) {
|
if (!um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION)) {
|
||||||
Settings.Secure.setLocationProviderEnabled(
|
Settings.Secure.setLocationProviderEnabled(
|
||||||
resolver,
|
resolver,
|
||||||
LocationManager.GPS_PROVIDER,
|
LocationManager.GPS_PROVIDER,
|
||||||
|
Reference in New Issue
Block a user