Use UserManager instead of PackageManager for user management
Show Accounts in secondary settings Move Users & restrictions to Device section Change-Id: Idcd7ed44801fe92c847cff81d11f3d6f6d06ba81
This commit is contained in:
@@ -19,7 +19,8 @@
|
||||
|
||||
|
||||
<!-- WIRELESS and NETWORKS -->
|
||||
<header android:title="@string/header_category_wireless_networks" />
|
||||
<header android:id="@+id/wireless_section"
|
||||
android:title="@string/header_category_wireless_networks" />
|
||||
|
||||
<!-- Wifi -->
|
||||
<header
|
||||
@@ -58,7 +59,8 @@
|
||||
android:icon="@drawable/empty_icon" />
|
||||
|
||||
<!-- DEVICE -->
|
||||
<header android:title="@string/header_category_device" />
|
||||
<header android:id="@+id/device_section"
|
||||
android:title="@string/header_category_device" />
|
||||
|
||||
<!-- Sound -->
|
||||
<header
|
||||
@@ -95,6 +97,13 @@
|
||||
android:title="@string/applications_settings"
|
||||
android:id="@+id/application_settings" />
|
||||
|
||||
<!-- Manage users -->
|
||||
<header
|
||||
android:fragment="com.android.settings.users.UserSettings"
|
||||
android:icon="@drawable/ic_settings_sync"
|
||||
android:title="@string/user_settings_title"
|
||||
android:id="@+id/user_settings" />
|
||||
|
||||
<!-- Manufacturer hook -->
|
||||
<header
|
||||
android:fragment="com.android.settings.WirelessSettings"
|
||||
@@ -104,7 +113,8 @@
|
||||
|
||||
|
||||
<!-- PERSONAL -->
|
||||
<header android:title="@string/header_category_personal" />
|
||||
<header android:id="@+id/personal_section"
|
||||
android:title="@string/header_category_personal" />
|
||||
|
||||
<!-- Location -->
|
||||
<header
|
||||
@@ -139,13 +149,6 @@
|
||||
android:id="@+id/account_settings"
|
||||
android:title="@string/account_settings" />
|
||||
|
||||
<!-- Manage users -->
|
||||
<header
|
||||
android:fragment="com.android.settings.users.UserSettings"
|
||||
android:icon="@drawable/ic_settings_sync"
|
||||
android:title="@string/user_settings_title"
|
||||
android:id="@+id/user_settings" />
|
||||
|
||||
<header
|
||||
android:id="@+id/account_add"
|
||||
android:title="@string/add_account_label"
|
||||
@@ -155,7 +158,8 @@
|
||||
</header>
|
||||
|
||||
<!-- SYSTEM -->
|
||||
<header android:title="@string/header_category_system" />
|
||||
<header android:id="@+id/system_section"
|
||||
android:title="@string/header_category_system" />
|
||||
|
||||
<!-- Dock -->
|
||||
<header
|
||||
|
@@ -96,12 +96,17 @@ public class Settings extends PreferenceActivity
|
||||
|
||||
// Show only these settings for restricted users
|
||||
private int[] SETTINGS_FOR_RESTRICTED = {
|
||||
R.id.wireless_section,
|
||||
R.id.wifi_settings,
|
||||
R.id.bluetooth_settings,
|
||||
R.id.device_section,
|
||||
R.id.sound_settings,
|
||||
R.id.display_settings,
|
||||
R.id.personal_section,
|
||||
R.id.security_settings,
|
||||
R.id.account_settings,
|
||||
R.id.account_add,
|
||||
R.id.system_section,
|
||||
R.id.about_settings
|
||||
};
|
||||
|
||||
|
@@ -19,6 +19,7 @@ package com.android.settings.users;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
@@ -35,6 +36,7 @@ import android.os.Bundle;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.UserManager;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.EditTextPreference;
|
||||
import android.preference.Preference;
|
||||
@@ -91,6 +93,7 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
|
||||
|
||||
private IPackageManager mIPm;
|
||||
private PackageManager mPm;
|
||||
private UserManager mUm;
|
||||
private int mUserId;
|
||||
private boolean mNewUser;
|
||||
|
||||
@@ -102,12 +105,10 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
|
||||
mNewUser = args == null || args.getInt(EXTRA_USER_ID, -1) == -1;
|
||||
mUserId = mNewUser ? -1 : args.getInt(EXTRA_USER_ID, -1);
|
||||
mIPm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
|
||||
mUm = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
|
||||
|
||||
if (mUserId == -1) {
|
||||
try {
|
||||
mUserId = mIPm.createUser(getString(R.string.user_new_user_name), 0).id;
|
||||
} catch (RemoteException re) {
|
||||
}
|
||||
mUserId = mUm.createUser(getString(R.string.user_new_user_name), 0).id;
|
||||
}
|
||||
mSystemAppGroup = (PreferenceGroup) findPreference(KEY_SYSTEM_APPS);
|
||||
mInstalledAppGroup = (PreferenceGroup) findPreference(KEY_INSTALLED_APPS);
|
||||
@@ -161,7 +162,7 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
|
||||
}
|
||||
|
||||
private void initExistingUser() {
|
||||
List<UserInfo> users = mPm.getUsers();
|
||||
List<UserInfo> users = mUm.getUsers();
|
||||
UserInfo foundUser = null;
|
||||
for (UserInfo user : users) {
|
||||
if (user.id == mUserId) {
|
||||
@@ -193,12 +194,7 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
|
||||
}
|
||||
|
||||
private void removeUserNow() {
|
||||
try {
|
||||
mIPm.removeUser(mUserId);
|
||||
} catch (RemoteException re) {
|
||||
// Couldn't remove user. Shouldn't happen
|
||||
Log.e(TAG, "Couldn't remove user " + mUserId + "\n" + re);
|
||||
}
|
||||
mUm.removeUser(mUserId);
|
||||
finish();
|
||||
}
|
||||
|
||||
@@ -276,12 +272,8 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
mIPm.setUserName(mUserId, (String) newValue);
|
||||
mNamePref.setSummary((String) newValue);
|
||||
} catch (RemoteException re) {
|
||||
return false;
|
||||
}
|
||||
mUm.setUserName(mUserId, (String) newValue);
|
||||
mNamePref.setSummary((String) newValue);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -354,17 +346,14 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
|
||||
}
|
||||
|
||||
private void saveCroppedImage(Intent data) {
|
||||
try {
|
||||
if (data.hasExtra("data")) {
|
||||
Bitmap bitmap = (Bitmap) data.getParcelableExtra("data");
|
||||
ParcelFileDescriptor fd = mIPm.setUserIcon(mUserId);
|
||||
if (fd != null) {
|
||||
bitmap.compress(CompressFormat.PNG, 100,
|
||||
new ParcelFileDescriptor.AutoCloseOutputStream(fd));
|
||||
setPhotoId(mPm.getUser(mUserId).iconPath);
|
||||
}
|
||||
if (data.hasExtra("data")) {
|
||||
Bitmap bitmap = (Bitmap) data.getParcelableExtra("data");
|
||||
ParcelFileDescriptor fd = mUm.setUserIcon(mUserId);
|
||||
if (fd != null) {
|
||||
bitmap.compress(CompressFormat.PNG, 100,
|
||||
new ParcelFileDescriptor.AutoCloseOutputStream(fd));
|
||||
setPhotoId(mUm.getUserInfo(mUserId).iconPath);
|
||||
}
|
||||
} catch (RemoteException re) {
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -16,9 +16,11 @@
|
||||
|
||||
package com.android.settings.users;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserManager;
|
||||
import android.preference.Preference;
|
||||
import android.preference.Preference.OnPreferenceClickListener;
|
||||
import android.preference.PreferenceActivity;
|
||||
@@ -80,7 +82,8 @@ public class UserSettings extends SettingsPreferenceFragment
|
||||
}
|
||||
|
||||
private void updateUserList() {
|
||||
List<UserInfo> users = getActivity().getPackageManager().getUsers();
|
||||
List<UserInfo> users = ((UserManager) getActivity().getSystemService(Context.USER_SERVICE))
|
||||
.getUsers();
|
||||
|
||||
mUserListCategory.removeAll();
|
||||
for (UserInfo user : users) {
|
||||
|
Reference in New Issue
Block a user