Merge "Eliminate useless 'isManagedProfile' utils method"

This commit is contained in:
TreeHugger Robot
2016-09-12 09:08:05 +00:00
committed by Android (Google) Code Review
12 changed files with 17 additions and 42 deletions

View File

@@ -182,7 +182,7 @@ public class ChooseLockGeneric extends SettingsActivity {
if (DevicePolicyManager.ACTION_SET_NEW_PASSWORD
.equals(getActivity().getIntent().getAction())
&& Utils.isManagedProfile(UserManager.get(getActivity()), mUserId)
&& UserManager.get(getActivity()).isManagedProfile(mUserId)
&& mLockPatternUtils.isSeparateProfileChallengeEnabled(mUserId)) {
getActivity().setTitle(R.string.lock_settings_picker_title_profile);
}
@@ -198,8 +198,8 @@ public class ChooseLockGeneric extends SettingsActivity {
} else if (!mWaitingForConfirmation) {
ChooseLockSettingsHelper helper =
new ChooseLockSettingsHelper(this.getActivity(), this);
boolean managedProfileWithUnifiedLock = Utils
.isManagedProfile(UserManager.get(getActivity()), mUserId)
boolean managedProfileWithUnifiedLock =
UserManager.get(getActivity()).isManagedProfile(mUserId)
&& !mLockPatternUtils.isSeparateProfileChallengeEnabled(mUserId);
if (managedProfileWithUnifiedLock
|| !helper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST,
@@ -733,14 +733,14 @@ public class ChooseLockGeneric extends SettingsActivity {
}
private int getResIdForFactoryResetProtectionWarningTitle() {
boolean isProfile = Utils.isManagedProfile(UserManager.get(getActivity()), mUserId);
boolean isProfile = UserManager.get(getActivity()).isManagedProfile(mUserId);
return isProfile ? R.string.unlock_disable_frp_warning_title_profile
: R.string.unlock_disable_frp_warning_title;
}
private int getResIdForFactoryResetProtectionWarningMessage() {
boolean hasFingerprints = mFingerprintManager.hasEnrolledFingerprints(mUserId);
boolean isProfile = Utils.isManagedProfile(UserManager.get(getActivity()), mUserId);
boolean isProfile = UserManager.get(getActivity()).isManagedProfile(mUserId);
switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(mUserId)) {
case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
if (hasFingerprints && isProfile) {

View File

@@ -73,7 +73,7 @@ public class ConfirmDeviceCredentialActivity extends Activity {
Log.e(TAG, "Invalid intent extra", se);
}
}
final boolean isManagedProfile = Utils.isManagedProfile(UserManager.get(this), userId);
final boolean isManagedProfile = UserManager.get(this).isManagedProfile(userId);
// if the client app did not hand in a title and we are about to show the work challenge,
// check whether there is a policy setting the organization name and use that as title
if ((title == null) && isManagedProfile) {

View File

@@ -37,7 +37,7 @@ public abstract class ConfirmDeviceCredentialBaseActivity extends SettingsActivi
protected void onCreate(Bundle savedState) {
int credentialOwnerUserId = Utils.getCredentialOwnerUserId(this,
Utils.getUserIdFromBundle(this, getIntent().getExtras()));
if (Utils.isManagedProfile(UserManager.get(this), credentialOwnerUserId)) {
if (UserManager.get(this).isManagedProfile(credentialOwnerUserId)) {
setTheme(R.style.Theme_ConfirmDeviceCredentialsWork);
} else if (getIntent().getBooleanExtra(
ConfirmDeviceCredentialBaseFragment.DARK_THEME, false)) {

View File

@@ -118,7 +118,7 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends OptionsMenuFra
Utils.getUserIdFromBundle(
getActivity(),
getActivity().getIntent().getExtras()));
if (Utils.isManagedProfile(UserManager.get(getActivity()), credentialOwnerUserId)) {
if (UserManager.get(getActivity()).isManagedProfile(credentialOwnerUserId)) {
setWorkChallengeBackground(view, credentialOwnerUserId);
}
}
@@ -259,7 +259,7 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends OptionsMenuFra
}
protected boolean isProfileChallenge() {
return Utils.isManagedProfile(UserManager.get(getContext()), mEffectiveUserId);
return UserManager.get(getContext()).isManagedProfile(mEffectiveUserId);
}
protected void reportSuccessfullAttempt() {

View File

@@ -184,8 +184,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
}
private int getDefaultDetails() {
boolean isProfile = Utils.isManagedProfile(
UserManager.get(getActivity()), mEffectiveUserId);
boolean isProfile = UserManager.get(getActivity()).isManagedProfile(mEffectiveUserId);
// Map boolean flags to an index by isStrongAuth << 2 + isProfile << 1 + isAlpha.
int index = ((mIsStrongAuthRequired ? 1 : 0) << 2) + ((isProfile ? 1 : 0) << 1)
+ (mIsAlpha ? 1 : 0);

View File

@@ -230,9 +230,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
}
private int getDefaultDetails() {
boolean isProfile = Utils.isManagedProfile(
UserManager.get(getActivity()), mEffectiveUserId);
if (isProfile) {
if (UserManager.get(getActivity()).isManagedProfile(mEffectiveUserId)) {
return mIsStrongAuthRequired
? R.string.lockpassword_strong_auth_required_reason_restart_work_pattern
: R.string.lockpassword_confirm_your_pattern_generic_profile;

View File

@@ -612,15 +612,6 @@ public final class Utils extends com.android.settingslib.Utils {
return null;
}
/**
* Returns true if the current profile is a managed one.
*
* @throws IllegalArgumentException if userManager is null.
*/
public static boolean isManagedProfile(@NonNull UserManager userManager) {
return isManagedProfile(userManager, UserHandle.myUserId());
}
/**
* Retrieves the id for the given user's managed profile.
*
@@ -636,19 +627,6 @@ public final class Utils extends com.android.settingslib.Utils {
return UserHandle.USER_NULL;
}
/**
* Returns true if the userId passed in is a managed profile.
*
* @throws IllegalArgumentException if userManager is null.
*/
public static boolean isManagedProfile(@NonNull UserManager userManager, int userId) {
if (userManager == null) {
throw new IllegalArgumentException("userManager must not be null");
}
UserInfo userInfo = userManager.getUserInfo(userId);
return (userInfo != null) ? userInfo.isManagedProfile() : false;
}
/**
* Returns the target user for a Settings activity.
*

View File

@@ -248,7 +248,7 @@ public class AccountSettings extends SettingsPreferenceFragment
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.account_settings);
if (Utils.isManagedProfile(mUm)) {
if (mUm.isManagedProfile()) {
// This should not happen
Log.e(TAG, "We should not be showing settings for a managed profile");
finish();

View File

@@ -850,7 +850,7 @@ public class InstalledAppDetails extends AppInfoBase
}
private void addDynamicPrefs() {
if (Utils.isManagedProfile(UserManager.get(getContext()))) {
if (UserManager.get(getContext()).isManagedProfile()) {
return;
}
final PreferenceScreen screen = getPreferenceScreen();

View File

@@ -62,7 +62,7 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver {
if (action.equals(BluetoothDevice.ACTION_CONNECTION_ACCESS_REQUEST)) {
UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
// skip the notification for managed profiles.
if (com.android.settings.Utils.isManagedProfile(um)) {
if (um.isManagedProfile()) {
if (DEBUG) Log.d(TAG, "Blocking notification for managed profile.");
return;
}

View File

@@ -643,7 +643,7 @@ public class FingerprintSettings extends SubSettings {
FingerprintSettingsFragment parent
= (FingerprintSettingsFragment) getTargetFragment();
final boolean isProfileChallengeUser =
Utils.isManagedProfile(UserManager.get(getContext()), parent.mUserId);
UserManager.get(getContext()).isManagedProfile(parent.mUserId);
if (parent.mFingerprintManager.getEnrolledFingerprints(parent.mUserId).size() > 1) {
parent.deleteFingerPrint(mFp);
} else {

View File

@@ -75,7 +75,7 @@ public class RedactionInterstitial extends SettingsActivity {
public static Intent createStartIntent(Context ctx, int userId) {
return new Intent(ctx, RedactionInterstitial.class)
.putExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID,
Utils.isManagedProfile(UserManager.get(ctx), userId)
UserManager.get(ctx).isManagedProfile(userId)
? R.string.lock_screen_notifications_interstitial_title_profile
: R.string.lock_screen_notifications_interstitial_title)
.putExtra(Intent.EXTRA_USER_ID, userId);
@@ -111,7 +111,7 @@ public class RedactionInterstitial extends SettingsActivity {
mRadioGroup.setOnCheckedChangeListener(this);
mUserId = Utils.getUserIdFromBundle(
getContext(), getActivity().getIntent().getExtras());
if (Utils.isManagedProfile(UserManager.get(getContext()), mUserId)) {
if (UserManager.get(getContext()).isManagedProfile(mUserId)) {
((TextView) view.findViewById(R.id.message))
.setText(R.string.lock_screen_notifications_interstitial_message_profile);
mShowAllButton.setText(R.string.lock_screen_notifications_summary_show_profile);