Merge "Eliminate useless 'isManagedProfile' utils method"
This commit is contained in:
committed by
Android (Google) Code Review
commit
24e673b0d2
@@ -182,7 +182,7 @@ public class ChooseLockGeneric extends SettingsActivity {
|
|||||||
|
|
||||||
if (DevicePolicyManager.ACTION_SET_NEW_PASSWORD
|
if (DevicePolicyManager.ACTION_SET_NEW_PASSWORD
|
||||||
.equals(getActivity().getIntent().getAction())
|
.equals(getActivity().getIntent().getAction())
|
||||||
&& Utils.isManagedProfile(UserManager.get(getActivity()), mUserId)
|
&& UserManager.get(getActivity()).isManagedProfile(mUserId)
|
||||||
&& mLockPatternUtils.isSeparateProfileChallengeEnabled(mUserId)) {
|
&& mLockPatternUtils.isSeparateProfileChallengeEnabled(mUserId)) {
|
||||||
getActivity().setTitle(R.string.lock_settings_picker_title_profile);
|
getActivity().setTitle(R.string.lock_settings_picker_title_profile);
|
||||||
}
|
}
|
||||||
@@ -198,8 +198,8 @@ public class ChooseLockGeneric extends SettingsActivity {
|
|||||||
} else if (!mWaitingForConfirmation) {
|
} else if (!mWaitingForConfirmation) {
|
||||||
ChooseLockSettingsHelper helper =
|
ChooseLockSettingsHelper helper =
|
||||||
new ChooseLockSettingsHelper(this.getActivity(), this);
|
new ChooseLockSettingsHelper(this.getActivity(), this);
|
||||||
boolean managedProfileWithUnifiedLock = Utils
|
boolean managedProfileWithUnifiedLock =
|
||||||
.isManagedProfile(UserManager.get(getActivity()), mUserId)
|
UserManager.get(getActivity()).isManagedProfile(mUserId)
|
||||||
&& !mLockPatternUtils.isSeparateProfileChallengeEnabled(mUserId);
|
&& !mLockPatternUtils.isSeparateProfileChallengeEnabled(mUserId);
|
||||||
if (managedProfileWithUnifiedLock
|
if (managedProfileWithUnifiedLock
|
||||||
|| !helper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST,
|
|| !helper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST,
|
||||||
@@ -733,14 +733,14 @@ public class ChooseLockGeneric extends SettingsActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getResIdForFactoryResetProtectionWarningTitle() {
|
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
|
return isProfile ? R.string.unlock_disable_frp_warning_title_profile
|
||||||
: R.string.unlock_disable_frp_warning_title;
|
: R.string.unlock_disable_frp_warning_title;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getResIdForFactoryResetProtectionWarningMessage() {
|
private int getResIdForFactoryResetProtectionWarningMessage() {
|
||||||
boolean hasFingerprints = mFingerprintManager.hasEnrolledFingerprints(mUserId);
|
boolean hasFingerprints = mFingerprintManager.hasEnrolledFingerprints(mUserId);
|
||||||
boolean isProfile = Utils.isManagedProfile(UserManager.get(getActivity()), mUserId);
|
boolean isProfile = UserManager.get(getActivity()).isManagedProfile(mUserId);
|
||||||
switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(mUserId)) {
|
switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(mUserId)) {
|
||||||
case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
|
case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
|
||||||
if (hasFingerprints && isProfile) {
|
if (hasFingerprints && isProfile) {
|
||||||
|
@@ -73,7 +73,7 @@ public class ConfirmDeviceCredentialActivity extends Activity {
|
|||||||
Log.e(TAG, "Invalid intent extra", se);
|
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,
|
// 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
|
// check whether there is a policy setting the organization name and use that as title
|
||||||
if ((title == null) && isManagedProfile) {
|
if ((title == null) && isManagedProfile) {
|
||||||
|
@@ -37,7 +37,7 @@ public abstract class ConfirmDeviceCredentialBaseActivity extends SettingsActivi
|
|||||||
protected void onCreate(Bundle savedState) {
|
protected void onCreate(Bundle savedState) {
|
||||||
int credentialOwnerUserId = Utils.getCredentialOwnerUserId(this,
|
int credentialOwnerUserId = Utils.getCredentialOwnerUserId(this,
|
||||||
Utils.getUserIdFromBundle(this, getIntent().getExtras()));
|
Utils.getUserIdFromBundle(this, getIntent().getExtras()));
|
||||||
if (Utils.isManagedProfile(UserManager.get(this), credentialOwnerUserId)) {
|
if (UserManager.get(this).isManagedProfile(credentialOwnerUserId)) {
|
||||||
setTheme(R.style.Theme_ConfirmDeviceCredentialsWork);
|
setTheme(R.style.Theme_ConfirmDeviceCredentialsWork);
|
||||||
} else if (getIntent().getBooleanExtra(
|
} else if (getIntent().getBooleanExtra(
|
||||||
ConfirmDeviceCredentialBaseFragment.DARK_THEME, false)) {
|
ConfirmDeviceCredentialBaseFragment.DARK_THEME, false)) {
|
||||||
|
@@ -118,7 +118,7 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends OptionsMenuFra
|
|||||||
Utils.getUserIdFromBundle(
|
Utils.getUserIdFromBundle(
|
||||||
getActivity(),
|
getActivity(),
|
||||||
getActivity().getIntent().getExtras()));
|
getActivity().getIntent().getExtras()));
|
||||||
if (Utils.isManagedProfile(UserManager.get(getActivity()), credentialOwnerUserId)) {
|
if (UserManager.get(getActivity()).isManagedProfile(credentialOwnerUserId)) {
|
||||||
setWorkChallengeBackground(view, credentialOwnerUserId);
|
setWorkChallengeBackground(view, credentialOwnerUserId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,7 +259,7 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends OptionsMenuFra
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isProfileChallenge() {
|
protected boolean isProfileChallenge() {
|
||||||
return Utils.isManagedProfile(UserManager.get(getContext()), mEffectiveUserId);
|
return UserManager.get(getContext()).isManagedProfile(mEffectiveUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void reportSuccessfullAttempt() {
|
protected void reportSuccessfullAttempt() {
|
||||||
|
@@ -184,8 +184,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getDefaultDetails() {
|
private int getDefaultDetails() {
|
||||||
boolean isProfile = Utils.isManagedProfile(
|
boolean isProfile = UserManager.get(getActivity()).isManagedProfile(mEffectiveUserId);
|
||||||
UserManager.get(getActivity()), mEffectiveUserId);
|
|
||||||
// Map boolean flags to an index by isStrongAuth << 2 + isProfile << 1 + isAlpha.
|
// Map boolean flags to an index by isStrongAuth << 2 + isProfile << 1 + isAlpha.
|
||||||
int index = ((mIsStrongAuthRequired ? 1 : 0) << 2) + ((isProfile ? 1 : 0) << 1)
|
int index = ((mIsStrongAuthRequired ? 1 : 0) << 2) + ((isProfile ? 1 : 0) << 1)
|
||||||
+ (mIsAlpha ? 1 : 0);
|
+ (mIsAlpha ? 1 : 0);
|
||||||
|
@@ -230,9 +230,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getDefaultDetails() {
|
private int getDefaultDetails() {
|
||||||
boolean isProfile = Utils.isManagedProfile(
|
if (UserManager.get(getActivity()).isManagedProfile(mEffectiveUserId)) {
|
||||||
UserManager.get(getActivity()), mEffectiveUserId);
|
|
||||||
if (isProfile) {
|
|
||||||
return mIsStrongAuthRequired
|
return mIsStrongAuthRequired
|
||||||
? R.string.lockpassword_strong_auth_required_reason_restart_work_pattern
|
? R.string.lockpassword_strong_auth_required_reason_restart_work_pattern
|
||||||
: R.string.lockpassword_confirm_your_pattern_generic_profile;
|
: R.string.lockpassword_confirm_your_pattern_generic_profile;
|
||||||
|
@@ -612,15 +612,6 @@ public final class Utils extends com.android.settingslib.Utils {
|
|||||||
return null;
|
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.
|
* 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;
|
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.
|
* Returns the target user for a Settings activity.
|
||||||
*
|
*
|
||||||
|
@@ -248,7 +248,7 @@ public class AccountSettings extends SettingsPreferenceFragment
|
|||||||
// Load the preferences from an XML resource
|
// Load the preferences from an XML resource
|
||||||
addPreferencesFromResource(R.xml.account_settings);
|
addPreferencesFromResource(R.xml.account_settings);
|
||||||
|
|
||||||
if (Utils.isManagedProfile(mUm)) {
|
if (mUm.isManagedProfile()) {
|
||||||
// This should not happen
|
// This should not happen
|
||||||
Log.e(TAG, "We should not be showing settings for a managed profile");
|
Log.e(TAG, "We should not be showing settings for a managed profile");
|
||||||
finish();
|
finish();
|
||||||
|
@@ -850,7 +850,7 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addDynamicPrefs() {
|
private void addDynamicPrefs() {
|
||||||
if (Utils.isManagedProfile(UserManager.get(getContext()))) {
|
if (UserManager.get(getContext()).isManagedProfile()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PreferenceScreen screen = getPreferenceScreen();
|
final PreferenceScreen screen = getPreferenceScreen();
|
||||||
|
@@ -62,7 +62,7 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver {
|
|||||||
if (action.equals(BluetoothDevice.ACTION_CONNECTION_ACCESS_REQUEST)) {
|
if (action.equals(BluetoothDevice.ACTION_CONNECTION_ACCESS_REQUEST)) {
|
||||||
UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||||
// skip the notification for managed profiles.
|
// 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.");
|
if (DEBUG) Log.d(TAG, "Blocking notification for managed profile.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -643,7 +643,7 @@ public class FingerprintSettings extends SubSettings {
|
|||||||
FingerprintSettingsFragment parent
|
FingerprintSettingsFragment parent
|
||||||
= (FingerprintSettingsFragment) getTargetFragment();
|
= (FingerprintSettingsFragment) getTargetFragment();
|
||||||
final boolean isProfileChallengeUser =
|
final boolean isProfileChallengeUser =
|
||||||
Utils.isManagedProfile(UserManager.get(getContext()), parent.mUserId);
|
UserManager.get(getContext()).isManagedProfile(parent.mUserId);
|
||||||
if (parent.mFingerprintManager.getEnrolledFingerprints(parent.mUserId).size() > 1) {
|
if (parent.mFingerprintManager.getEnrolledFingerprints(parent.mUserId).size() > 1) {
|
||||||
parent.deleteFingerPrint(mFp);
|
parent.deleteFingerPrint(mFp);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -75,7 +75,7 @@ public class RedactionInterstitial extends SettingsActivity {
|
|||||||
public static Intent createStartIntent(Context ctx, int userId) {
|
public static Intent createStartIntent(Context ctx, int userId) {
|
||||||
return new Intent(ctx, RedactionInterstitial.class)
|
return new Intent(ctx, RedactionInterstitial.class)
|
||||||
.putExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID,
|
.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_profile
|
||||||
: R.string.lock_screen_notifications_interstitial_title)
|
: R.string.lock_screen_notifications_interstitial_title)
|
||||||
.putExtra(Intent.EXTRA_USER_ID, userId);
|
.putExtra(Intent.EXTRA_USER_ID, userId);
|
||||||
@@ -111,7 +111,7 @@ public class RedactionInterstitial extends SettingsActivity {
|
|||||||
mRadioGroup.setOnCheckedChangeListener(this);
|
mRadioGroup.setOnCheckedChangeListener(this);
|
||||||
mUserId = Utils.getUserIdFromBundle(
|
mUserId = Utils.getUserIdFromBundle(
|
||||||
getContext(), getActivity().getIntent().getExtras());
|
getContext(), getActivity().getIntent().getExtras());
|
||||||
if (Utils.isManagedProfile(UserManager.get(getContext()), mUserId)) {
|
if (UserManager.get(getContext()).isManagedProfile(mUserId)) {
|
||||||
((TextView) view.findViewById(R.id.message))
|
((TextView) view.findViewById(R.id.message))
|
||||||
.setText(R.string.lock_screen_notifications_interstitial_message_profile);
|
.setText(R.string.lock_screen_notifications_interstitial_message_profile);
|
||||||
mShowAllButton.setText(R.string.lock_screen_notifications_summary_show_profile);
|
mShowAllButton.setText(R.string.lock_screen_notifications_summary_show_profile);
|
||||||
|
Reference in New Issue
Block a user