Merge "Use the correct userId when checking if disabled by admin."
This commit is contained in:
committed by
Android (Google) Code Review
commit
91e0ba7d40
@@ -417,7 +417,7 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
|
||||
int adminEnforcedQuality = mDPM.getPasswordQuality(null);
|
||||
EnforcedAdmin enforcedAdmin = RestrictedLockUtils.checkIfPasswordQualityIsSet(
|
||||
getActivity());
|
||||
getActivity(), mUserId);
|
||||
for (int i = entries.getPreferenceCount() - 1; i >= 0; --i) {
|
||||
Preference pref = entries.getPreference(i);
|
||||
if (pref instanceof RestrictedPreference) {
|
||||
|
@@ -482,8 +482,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
boolean serviceAllowed =
|
||||
permittedServices == null || permittedServices.contains(packageName);
|
||||
if (!serviceAllowed && !serviceEnabled) {
|
||||
EnforcedAdmin admin =
|
||||
RestrictedLockUtils.getProfileOrDeviceOwnerOnCallingUser(getActivity());
|
||||
EnforcedAdmin admin = RestrictedLockUtils.checkIfAccessibilityServiceDisallowed(
|
||||
getActivity(), serviceInfo.packageName, UserHandle.myUserId());
|
||||
if (admin != null) {
|
||||
preference.setDisabledByAdmin(admin);
|
||||
} else {
|
||||
|
@@ -272,7 +272,7 @@ public class AccountSyncSettings extends AccountPreferenceBase {
|
||||
mUserHandle.getIdentifier());
|
||||
if (admin == null) {
|
||||
admin = RestrictedLockUtils.checkIfAccountManagementDisabled(
|
||||
getPrefContext(), mAccount.type);
|
||||
getPrefContext(), mAccount.type, mUserHandle.getIdentifier());
|
||||
}
|
||||
RestrictedLockUtils.setMenuItemAsDisabledByAdmin(getPrefContext(),
|
||||
removeAccount, admin);
|
||||
|
@@ -34,11 +34,14 @@ import android.widget.Toast;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static android.content.Intent.EXTRA_USER;
|
||||
|
||||
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
/**
|
||||
* Entry point Activity for account setup. Works as follows
|
||||
*
|
||||
@@ -171,6 +174,9 @@ public class AddAccountSettings extends Activity {
|
||||
switch (requestCode) {
|
||||
case CHOOSE_ACCOUNT_REQUEST:
|
||||
if (resultCode == RESULT_CANCELED) {
|
||||
if (data != null) {
|
||||
startActivityAsUser(data, mUserHandle);
|
||||
}
|
||||
setResult(resultCode);
|
||||
finish();
|
||||
return;
|
||||
|
@@ -39,6 +39,7 @@ import com.android.internal.util.CharSequences;
|
||||
import com.android.settings.InstrumentedPreferenceActivity;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -48,6 +49,8 @@ import java.util.Map;
|
||||
|
||||
import static android.content.Intent.EXTRA_USER;
|
||||
|
||||
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
/**
|
||||
* Activity asking a user to select an account to be set up.
|
||||
*
|
||||
@@ -160,9 +163,19 @@ public class ChooseAccountActivity extends InstrumentedPreferenceActivity {
|
||||
}
|
||||
}
|
||||
|
||||
final Context context = getPreferenceScreen().getContext();
|
||||
if (mProviderList.size() == 1) {
|
||||
// If there's only one provider that matches, just run it.
|
||||
finishWithAccountType(mProviderList.get(0).type);
|
||||
// There's only one provider that matches. If it is disabled by admin show the
|
||||
// support dialog otherwise run it.
|
||||
EnforcedAdmin admin = RestrictedLockUtils.checkIfAccountManagementDisabled(
|
||||
context, mProviderList.get(0).type, mUserHandle.getIdentifier());
|
||||
if (admin != null) {
|
||||
setResult(RESULT_CANCELED, RestrictedLockUtils.getShowAdminSupportDetailsIntent(
|
||||
context, admin));
|
||||
finish();
|
||||
} else {
|
||||
finishWithAccountType(mProviderList.get(0).type);
|
||||
}
|
||||
} else if (mProviderList.size() > 0) {
|
||||
Collections.sort(mProviderList);
|
||||
mAddAccountGroup.removeAll();
|
||||
@@ -170,7 +183,7 @@ public class ChooseAccountActivity extends InstrumentedPreferenceActivity {
|
||||
Drawable drawable = getDrawableForType(pref.type);
|
||||
ProviderPreference p = new ProviderPreference(getPreferenceScreen().getContext(),
|
||||
pref.type, drawable, pref.name);
|
||||
p.checkAccountManagementAndSetDisabled();
|
||||
p.checkAccountManagementAndSetDisabled(mUserHandle.getIdentifier());
|
||||
mAddAccountGroup.addPreference(p);
|
||||
}
|
||||
} else {
|
||||
|
@@ -46,9 +46,9 @@ public class ProviderPreference extends RestrictedPreference {
|
||||
return mAccountType;
|
||||
}
|
||||
|
||||
public void checkAccountManagementAndSetDisabled() {
|
||||
public void checkAccountManagementAndSetDisabled(int userId) {
|
||||
EnforcedAdmin admin = RestrictedLockUtils.checkIfAccountManagementDisabled(
|
||||
getContext(), getAccountType());
|
||||
getContext(), getAccountType(), userId);
|
||||
setDisabledByAdmin(admin);
|
||||
}
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@ import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.UserHandle;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
|
||||
@@ -121,11 +122,6 @@ class InputMethodPreference extends RestrictedSwitchPreference implements OnPref
|
||||
setOnPreferenceClickListener(this);
|
||||
setOnPreferenceChangeListener(this);
|
||||
useAdminDisabledSummary(true);
|
||||
if (!isAllowedByOrganization) {
|
||||
EnforcedAdmin admin =
|
||||
RestrictedLockUtils.getProfileOrDeviceOwnerOnCallingUser(context);
|
||||
setDisabledByAdmin(admin);
|
||||
}
|
||||
}
|
||||
|
||||
public InputMethodInfo getInputMethodInfo() {
|
||||
@@ -192,11 +188,23 @@ class InputMethodPreference extends RestrictedSwitchPreference implements OnPref
|
||||
void updatePreferenceViews() {
|
||||
final boolean isAlwaysChecked = mInputMethodSettingValues.isAlwaysCheckedIme(
|
||||
mImi, getContext());
|
||||
// Only when this preference has a switch and an input method should be always enabled,
|
||||
// When this preference has a switch and an input method should be always enabled,
|
||||
// this preference should be disabled to prevent accidentally disabling an input method.
|
||||
setEnabled(!((isAlwaysChecked && isImeEnabler()) || (!mIsAllowedByOrganization)));
|
||||
// This preference should also be disabled in case the admin does not allow this input
|
||||
// method.
|
||||
if (isAlwaysChecked && isImeEnabler()) {
|
||||
setDisabledByAdmin(null);
|
||||
setEnabled(false);
|
||||
} else if (!mIsAllowedByOrganization) {
|
||||
EnforcedAdmin admin =
|
||||
RestrictedLockUtils.checkIfInputMethodDisallowed(getContext(),
|
||||
mImi.getPackageName(), UserHandle.myUserId());
|
||||
setDisabledByAdmin(admin);
|
||||
} else {
|
||||
setEnabled(true);
|
||||
}
|
||||
setChecked(mInputMethodSettingValues.isEnabledImi(mImi));
|
||||
if (mIsAllowedByOrganization) {
|
||||
if (!isDisabledByAdmin()) {
|
||||
setSummary(getSummaryString());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user