Single-user restrictions

New restrictions panel for restricting list of available apps for the user.
Apps that support restrictions can also be configured here.
Restrictions screen is PIN protected and will ask you to create a PIN the
first time you use it.

Change-Id: I7a5267df4272521ad80e6a8b6a18932d07179eb8
This commit is contained in:
Amith Yamasani
2013-06-03 16:41:03 -07:00
parent c911bbe247
commit 0ca80fe4cd
7 changed files with 712 additions and 451 deletions

View File

@@ -134,7 +134,6 @@ public class UserSettings extends SettingsPreferenceFragment
private final Object mUserLock = new Object();
private UserManager mUserManager;
private SparseArray<Bitmap> mUserIcons = new SparseArray<Bitmap>();
private Drawable mDefaultCircleAvatar;
private boolean mIsOwner = UserHandle.myUserId() == UserHandle.USER_OWNER;
@@ -201,10 +200,15 @@ public class UserSettings extends SettingsPreferenceFragment
loadProfile();
setHasOptionsMenu(true);
IntentFilter filter = new IntentFilter(Intent.ACTION_USER_REMOVED);
filter.addAction(Intent.ACTION_USER_ADDED);
filter.addAction(Intent.ACTION_USER_INFO_CHANGED);
getActivity().registerReceiverAsUser(mUserChangeReceiver, UserHandle.ALL, filter, null,
mHandler);
}
@Override
public void onResume() {
super.onResume();
loadProfile();
updateUserList();
}
@@ -279,13 +283,6 @@ public class UserSettings extends SettingsPreferenceFragment
}
}
private Drawable getDefaultCircleAvatar() {
if (mDefaultCircleAvatar == null) {
mDefaultCircleAvatar = encircle(R.drawable.avatar_default_1);
}
return mDefaultCircleAvatar;
}
private boolean hasLockscreenSecurity() {
LockPatternUtils lpu = new LockPatternUtils(getActivity());
return lpu.isLockPasswordEnabled() || lpu.isLockPatternEnabled();
@@ -377,10 +374,10 @@ public class UserSettings extends SettingsPreferenceFragment
UserInfo info = mUserManager.getUserInfo(userId);
if (info.isRestricted() && mIsOwner) {
Bundle extras = new Bundle();
extras.putInt(AppRestrictionsFragment.EXTRA_USER_ID, userId);
extras.putBoolean(AppRestrictionsFragment.EXTRA_NEW_USER, newUser);
extras.putInt(RestrictedProfileSettings.EXTRA_USER_ID, userId);
extras.putBoolean(RestrictedProfileSettings.EXTRA_NEW_USER, newUser);
((PreferenceActivity) getActivity()).startPreferencePanel(
AppRestrictionsFragment.class.getName(),
RestrictedProfileSettings.class.getName(),
extras, R.string.user_restrictions_title, null,
null, 0);
} else if (info.id == UserHandle.myUserId()) {
@@ -641,7 +638,7 @@ public class UserSettings extends SettingsPreferenceFragment
if (user.iconPath != null) {
if (mUserIcons.get(user.id) == null) {
missingIcons.add(user.id);
pref.setIcon(getDefaultCircleAvatar());
pref.setIcon(encircle(R.drawable.avatar_default_1));
} else {
setPhotoId(pref, user);
}
@@ -653,7 +650,7 @@ public class UserSettings extends SettingsPreferenceFragment
null, null);
pref.setEnabled(false);
pref.setTitle(R.string.user_new_user_name);
pref.setIcon(getDefaultCircleAvatar());
pref.setIcon(encircle(R.drawable.avatar_default_1));
mUserListCategory.addPreference(pref);
}
getActivity().invalidateOptionsMenu();