Merge "Part3 - Don't add padlock if the restriction is not set by admin." into nyc-dev

This commit is contained in:
Sudheer Shanka
2016-02-19 19:31:44 +00:00
committed by Android (Google) Code Review
21 changed files with 207 additions and 84 deletions

View File

@@ -81,7 +81,9 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
private UserManager mUm;
private EnforcedAdmin mFunDisallowedAdmin;
private boolean mFunDisallowedBySystem;
private EnforcedAdmin mDebuggingFeaturesDisallowedAdmin;
private boolean mDebuggingFeaturesDisallowedBySystem;
@Override
protected int getMetricsCategory() {
@@ -192,8 +194,12 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
mDevHitToast = null;
mFunDisallowedAdmin = RestrictedLockUtils.checkIfRestrictionEnforced(
getActivity(), UserManager.DISALLOW_FUN, UserHandle.myUserId());
mFunDisallowedBySystem = RestrictedLockUtils.hasBaseUserRestriction(
getActivity(), UserManager.DISALLOW_FUN, UserHandle.myUserId());
mDebuggingFeaturesDisallowedAdmin = RestrictedLockUtils.checkIfRestrictionEnforced(
getActivity(), UserManager.DISALLOW_DEBUGGING_FEATURES, UserHandle.myUserId());
mDebuggingFeaturesDisallowedBySystem = RestrictedLockUtils.hasBaseUserRestriction(
getActivity(), UserManager.DISALLOW_DEBUGGING_FEATURES, UserHandle.myUserId());
}
@Override
@@ -202,9 +208,11 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
System.arraycopy(mHits, 1, mHits, 0, mHits.length-1);
mHits[mHits.length-1] = SystemClock.uptimeMillis();
if (mHits[0] >= (SystemClock.uptimeMillis()-500)) {
if (mFunDisallowedAdmin != null) {
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getActivity(),
mFunDisallowedAdmin);
if (mUm.hasUserRestriction(UserManager.DISALLOW_FUN)) {
if (mFunDisallowedAdmin != null && !mFunDisallowedBySystem) {
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getActivity(),
mFunDisallowedAdmin);
}
Log.d(LOG_TAG, "Sorry, no fun for you!");
return false;
}
@@ -228,9 +236,12 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
return true;
}
if (mDebuggingFeaturesDisallowedAdmin != null) {
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getActivity(),
mDebuggingFeaturesDisallowedAdmin);
if (mUm.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES)) {
if (mDebuggingFeaturesDisallowedAdmin != null &&
!mDebuggingFeaturesDisallowedBySystem) {
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getActivity(),
mDebuggingFeaturesDisallowedAdmin);
}
return true;
}