Merge "Accessibility multi-user support." into jb-mr1-dev
diff --git a/res/layout/dream_info_row.xml b/res/layout/dream_info_row.xml
index 356a82a..c2d90fb 100644
--- a/res/layout/dream_info_row.xml
+++ b/res/layout/dream_info_row.xml
@@ -23,7 +23,7 @@
         android:id="@android:id/widget_frame"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_toLeftOf="@+id/divider"
+        android:layout_toStartOf="@+id/divider"
         android:background="?android:attr/selectableItemBackground" >
 
         <!-- Dream icon -->
@@ -34,8 +34,8 @@
             android:layout_height="@android:dimen/app_icon_size"
             android:layout_centerVertical="true"
             android:layout_marginBottom="10dp"
-            android:layout_marginLeft="0dp"
-            android:layout_marginRight="6dp"
+            android:layout_marginStart="0dp"
+            android:layout_marginEnd="6dp"
             android:layout_marginTop="10dp"
             android:contentDescription="@null"
             android:maxHeight="@android:dimen/app_icon_size"
@@ -49,11 +49,12 @@
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_centerVertical="true"
-            android:layout_toLeftOf="@android:id/button1"
-            android:layout_toRightOf="@android:id/icon"
+            android:layout_toStartOf="@android:id/button1"
+            android:layout_toEndOf="@android:id/icon"
             android:ellipsize="end"
             android:singleLine="true"
-            android:textAppearance="?android:attr/textAppearanceMedium" />
+            android:textAppearance="?android:attr/textAppearanceMedium"
+            android:textDirection="locale" />
 
         <!-- Dream radio button -->
 
@@ -61,7 +62,7 @@
             android:id="@android:id/button1"
             android:layout_width="wrap_content"
             android:layout_height="match_parent"
-            android:layout_alignParentRight="true"
+            android:layout_alignParentEnd="true"
             android:layout_centerVertical="true"
             android:duplicateParentState="true" />
     </RelativeLayout>
@@ -73,7 +74,7 @@
         android:layout_width="wrap_content"
         android:layout_height="match_parent"
         android:layout_centerVertical="true"
-        android:layout_toLeftOf="@android:id/button2"
+        android:layout_toStartOf="@android:id/button2"
         android:contentDescription="@null"
         android:src="@drawable/nav_divider" />
 
@@ -84,7 +85,7 @@
         android:layout_width="wrap_content"
         android:layout_height="match_parent"
         android:layout_alignBottom="@android:id/widget_frame"
-        android:layout_alignParentRight="true"
+        android:layout_alignParentEnd="true"
         android:layout_alignTop="@android:id/widget_frame"
         android:layout_centerVertical="true"
         android:layout_margin="0dip"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 97c0726..ee21fed 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -794,12 +794,18 @@
     <!--  Title for PreferenceScreen to launch picker for security method when there is none [CHAR LIMIT=22] -->
     <string name="unlock_set_unlock_launch_picker_title">Screen lock</string>
 
+    <!--  Title for PreferenceScreen to launch picker for a user-selected time & data widget that will live on lock screen [CHAR LIMIT=22] -->
+    <string name="choose_lockscreen_status_widget_picker_title">Status widget</string>
+
     <!--  Title for PreferenceScreen to launch picker for a user-selected widget that will live on lock screen [CHAR LIMIT=22] -->
-    <string name="choose_user_selected_lockscreen_widget_picker_title">Widget</string>
+    <string name="choose_user_selected_lockscreen_widget_picker_title">Other widget</string>
 
     <!--  String to display if there is no user-selected widget on lock screen [CHAR LIMIT=22] -->
     <string name="widget_none">None</string>
 
+    <!--  String to display if the default status widget is selected [CHAR LIMIT=22] -->
+    <string name="widget_default">Default</string>
+
     <!--  Title for PreferenceScreen to change security method: None/Pattern/PIN/Password [CHAR LIMIT=22] -->
     <string name="unlock_set_unlock_launch_picker_change_title">Change lock screen</string>
 
@@ -2700,6 +2706,8 @@
     <string name="service_process_name"><xliff:g id="process">%1$s</xliff:g></string>
     <!-- [CHAR LIMIT=NONE] Label of a running process that represents another user -->
     <string name="running_process_item_user_label">User: <xliff:g id="user_name">%1$s</xliff:g></string>
+    <!-- [CHAR LIMIT=NONE] Label of a running process that represents a removed -->
+    <string name="running_process_item_removed_user_label">Removed user</string>
     <!-- Descriptive text of a running process: singular process, singular service. -->
     <string name="running_processes_item_description_s_s"><xliff:g id="numprocess">%1$d</xliff:g>
         process and <xliff:g id="numservices">%2$d</xliff:g> service</string>
@@ -3946,15 +3954,6 @@
     <string name="show_all_anrs_summary">Show App Not Responding dialog
         for background apps</string>
 
-    <!-- Preference category for accessibility debugging development settings. [CHAR LIMIT=25] -->
-    <string name="debug_accessibility_category">Accessibility</string>
-
-    <!-- Accessibility debug setting: automatically update magnification state [CHAR LIMIT=50] -->
-    <string name="display_magnification_auto_update">Auto update magnification</string>
-    <!-- Accessibility debug setting: automatically update magnification state summary [CHAR LIMIT=100] -->
-    <string name="display_magnification_auto_update_summary">Zoom out on rotation or activity
-        start and pan to popped up windows.</string>
-
     <!-- Activity title for network data usage summary. [CHAR LIMIT=25] -->
     <string name="data_usage_summary_title">Data usage</string>
     <!-- Title for option to pick visible time range from a list available usage periods. [CHAR LIMIT=25] -->
diff --git a/res/xml/development_prefs.xml b/res/xml/development_prefs.xml
index 575f802..a4f6ee2 100644
--- a/res/xml/development_prefs.xml
+++ b/res/xml/development_prefs.xml
@@ -200,16 +200,6 @@
             android:title="@string/show_all_anrs"
             android:summary="@string/show_all_anrs_summary"/>
 
-    </PreferenceCategory>
-
-        <PreferenceCategory android:key="debug_accessibility_category"
-            android:title="@string/debug_accessibility_category">
-
-        <CheckBoxPreference
-            android:key="accessibility_display_magnification_auto_update"
-            android:title="@string/display_magnification_auto_update"
-            android:summary="@string/display_magnification_auto_update_summary"/>
-
-    </PreferenceCategory>
+     </PreferenceCategory>
 
 </PreferenceScreen>
diff --git a/res/xml/security_settings_biometric_weak.xml b/res/xml/security_settings_biometric_weak.xml
index 6593f07..590eb95 100644
--- a/res/xml/security_settings_biometric_weak.xml
+++ b/res/xml/security_settings_biometric_weak.xml
@@ -27,6 +27,18 @@
             android:persistent="false"/>
 
         <PreferenceScreen
+           android:key="choose_lockscreen_status_widget"
+           android:title="@string/choose_lockscreen_status_widget_picker_title"
+           android:summary=""
+           android:persistent="false"/>
+
+        <PreferenceScreen
+           android:key="choose_user_selected_lockscreen_widget"
+           android:title="@string/choose_user_selected_lockscreen_widget_picker_title"
+           android:summary=""
+           android:persistent="false"/>
+
+        <PreferenceScreen
             android:key="biometric_weak_improve_matching"
             android:title="@string/biometric_weak_improve_matching_title"/>
 
diff --git a/res/xml/security_settings_chooser.xml b/res/xml/security_settings_chooser.xml
index 98422ba..08428b0 100644
--- a/res/xml/security_settings_chooser.xml
+++ b/res/xml/security_settings_chooser.xml
@@ -27,6 +27,12 @@
             android:persistent="false"/>
 
         <PreferenceScreen
+           android:key="choose_lockscreen_status_widget"
+           android:title="@string/choose_lockscreen_status_widget_picker_title"
+           android:summary=""
+           android:persistent="false"/>
+
+        <PreferenceScreen
            android:key="choose_user_selected_lockscreen_widget"
            android:title="@string/choose_user_selected_lockscreen_widget_picker_title"
            android:summary=""
diff --git a/res/xml/security_settings_password.xml b/res/xml/security_settings_password.xml
index 4fb2606..5f8425c 100644
--- a/res/xml/security_settings_password.xml
+++ b/res/xml/security_settings_password.xml
@@ -27,6 +27,12 @@
             android:persistent="false"/>
 
         <PreferenceScreen
+           android:key="choose_lockscreen_status_widget"
+           android:title="@string/choose_lockscreen_status_widget_picker_title"
+           android:summary=""
+           android:persistent="false"/>
+
+        <PreferenceScreen
            android:key="choose_user_selected_lockscreen_widget"
            android:title="@string/choose_user_selected_lockscreen_widget_picker_title"
            android:summary=""
diff --git a/res/xml/security_settings_pattern.xml b/res/xml/security_settings_pattern.xml
index ebc9c41..f8f2ee7 100644
--- a/res/xml/security_settings_pattern.xml
+++ b/res/xml/security_settings_pattern.xml
@@ -25,6 +25,13 @@
             android:title="@string/unlock_set_unlock_launch_picker_title"
             android:summary="@string/unlock_set_unlock_mode_pattern"
             android:persistent="false"/>
+
+        <PreferenceScreen
+           android:key="choose_lockscreen_status_widget"
+           android:title="@string/choose_lockscreen_status_widget_picker_title"
+           android:summary=""
+           android:persistent="false"/>
+
         <PreferenceScreen
            android:key="choose_user_selected_lockscreen_widget"
            android:title="@string/choose_user_selected_lockscreen_widget_picker_title"
diff --git a/res/xml/security_settings_pin.xml b/res/xml/security_settings_pin.xml
index b908140..8f5cdc2 100644
--- a/res/xml/security_settings_pin.xml
+++ b/res/xml/security_settings_pin.xml
@@ -25,11 +25,19 @@
             android:title="@string/unlock_set_unlock_launch_picker_title"
             android:summary="@string/unlock_set_unlock_mode_pin"
             android:persistent="false"/>
+
+        <PreferenceScreen
+           android:key="choose_lockscreen_status_widget"
+           android:title="@string/choose_lockscreen_status_widget_picker_title"
+           android:summary=""
+           android:persistent="false"/>
+
         <PreferenceScreen
            android:key="choose_user_selected_lockscreen_widget"
            android:title="@string/choose_user_selected_lockscreen_widget_picker_title"
            android:summary=""
            android:persistent="false"/>
+
         <ListPreference
             android:key="lock_after_timeout"
             android:title="@string/lock_after_timeout"
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index f590ea6..09d7f9b 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -98,8 +98,6 @@
     private static final String TRANSITION_ANIMATION_SCALE_KEY = "transition_animation_scale";
     private static final String ANIMATOR_DURATION_SCALE_KEY = "animator_duration_scale";
     private static final String OVERLAY_DISPLAY_DEVICES_KEY = "overlay_display_devices";
-    private static final String ACCESSIBILITY_DISPLAY_MAGNIFICATION_AUTO_UPDATE_KEY =
-            "accessibility_display_magnification_auto_update";
 
     private static final String ENABLE_TRACES_KEY = "enable_traces";
 
@@ -144,7 +142,6 @@
     private CheckBoxPreference mShowHwScreenUpdates;
     private CheckBoxPreference mShowHwLayersUpdates;
     private CheckBoxPreference mDebugLayout;
-    private CheckBoxPreference mDisplayMangificationAutoUpdate;
     private ListPreference mWindowAnimationScale;
     private ListPreference mTransitionAnimationScale;
     private ListPreference mAnimatorDurationScale;
@@ -240,9 +237,6 @@
             mAllPrefs.add(hdcpChecking);
         }
         removeHdcpOptionsForProduction();
-
-        mDisplayMangificationAutoUpdate = findAndInitCheckboxPref(
-                ACCESSIBILITY_DISPLAY_MAGNIFICATION_AUTO_UPDATE_KEY);
     }
 
     private CheckBoxPreference findAndInitCheckboxPref(String key) {
@@ -376,7 +370,6 @@
         updateImmediatelyDestroyActivitiesOptions();
         updateAppProcessLimitOptions();
         updateShowAllANRsOptions();
-        updateDisplayMagnificationAutoUpdate();
     }
 
     private void resetDangerousOptions() {
@@ -630,12 +623,6 @@
         pokeSystemProperties();
     }
 
-    private void writeDisplayMagnificationAutoUpdate() {
-        Settings.Secure.putInt(getActivity().getContentResolver(),
-                Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_AUTO_UPDATE,
-                mDisplayMangificationAutoUpdate.isChecked() ?  1 : 0);
-    }
-
     private void updateCpuUsageOptions() {
         updateCheckBox(mShowCpuUsage, Settings.System.getInt(getActivity().getContentResolver(),
                 Settings.System.SHOW_PROCESSES, 0) != 0);
@@ -769,12 +756,6 @@
             getActivity().getContentResolver(), Settings.Secure.ANR_SHOW_BACKGROUND, 0) != 0);
     }
 
-    private void updateDisplayMagnificationAutoUpdate() {
-        updateCheckBox(mDisplayMangificationAutoUpdate,
-                Settings.Secure.getInt(getActivity().getContentResolver(),
-                        Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_AUTO_UPDATE, 0) != 0);
-    }
-
     private void updateEnableTracesOptions() {
         long flags = SystemProperties.getLong(Trace.PROPERTY_TRACE_TAG_ENABLEFLAGS, 0);
         String[] values = mEnableTracesPref.getEntryValues();
@@ -928,8 +909,6 @@
             writeShowHwLayersUpdatesOptions();
         } else if (preference == mDebugLayout) {
             writeDebugLayoutOptions();
-        } else if (preference == mDisplayMangificationAutoUpdate) {
-            writeDisplayMagnificationAutoUpdate();
         }
 
         return false;
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index 64e2ec3..a3f3486 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -61,6 +61,8 @@
 
     // Lock Settings
     private static final String KEY_UNLOCK_SET_OR_CHANGE = "unlock_set_or_change";
+    private static final String KEY_CHOOSE_LOCKSCREEN_STATUS_WIDGET =
+            "choose_lockscreen_status_widget";
     private static final String KEY_CHOOSE_USER_SELECTED_LOCKSCREEN_WIDGET =
             "choose_user_selected_lockscreen_widget";
     private static final String KEY_BIOMETRIC_WEAK_IMPROVE_MATCHING =
@@ -72,11 +74,14 @@
     private static final String KEY_SECURITY_CATEGORY = "security_category";
     private static final String KEY_LOCK_AFTER_TIMEOUT = "lock_after_timeout";
     private static final String EXTRA_NO_WIDGET = "com.android.settings.NO_WIDGET";
+    private static final String EXTRA_DEFAULT_WIDGET = "com.android.settings.DEFAULT_WIDGET";
     private static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST = 123;
     private static final int CONFIRM_EXISTING_FOR_BIOMETRIC_WEAK_IMPROVE_REQUEST = 124;
     private static final int CONFIRM_EXISTING_FOR_BIOMETRIC_WEAK_LIVELINESS_OFF = 125;
-    private static final int REQUEST_PICK_APPWIDGET = 126;
-    private static final int REQUEST_CREATE_APPWIDGET = 127;
+    private static final int REQUEST_PICK_USER_SELECTED_APPWIDGET = 126;
+    private static final int REQUEST_PICK_STATUS_APPWIDGET = 127;
+    private static final int REQUEST_CREATE_USER_SELECTED_APPWIDGET = 128;
+    private static final int REQUEST_CREATE_STATUS_APPWIDGET = 129;
 
     // Misc Settings
     private static final String KEY_SIM_LOCK = "sim_lock";
@@ -254,6 +259,20 @@
             }
         }
 
+        mUserSelectedWidget = root.findPreference(KEY_CHOOSE_LOCKSCREEN_STATUS_WIDGET);
+        if (mUserSelectedWidget != null) {
+            AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getActivity());
+            int appWidgetId = getStatusAppWidgetId();
+            if (appWidgetId == -1) {
+                mUserSelectedWidget.setSummary(getResources().getString(R.string.widget_default));
+            } else {
+                AppWidgetProviderInfo appWidget = appWidgetManager.getAppWidgetInfo(appWidgetId);
+                if (appWidget != null) {
+                    mUserSelectedWidget.setSummary(appWidget.label);
+                }
+            }
+        }
+
         mUserSelectedWidget = root.findPreference(KEY_CHOOSE_USER_SELECTED_LOCKSCREEN_WIDGET);
         if (mUserSelectedWidget != null) {
             AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getActivity());
@@ -271,6 +290,16 @@
         return root;
     }
 
+    private int getStatusAppWidgetId() {
+        int appWidgetId = -1;
+        String appWidgetIdString = Settings.Secure.getString(
+                getContentResolver(), Settings.Secure.LOCK_SCREEN_STATUS_APPWIDGET_ID);
+        if (appWidgetIdString != null) {;
+            appWidgetId = (int) Integer.decode(appWidgetIdString);
+        }
+        return appWidgetId;
+    }
+
     private int getUserSelectedAppWidgetId() {
         int appWidgetId = -1;
         String appWidgetIdString = Settings.Secure.getString(
@@ -457,6 +486,7 @@
         } else if (KEY_CHOOSE_USER_SELECTED_LOCKSCREEN_WIDGET.equals(key)) {
             // Create intent to pick widget
             Intent pickIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_PICK);
+
             // Found in KeyguardHostView.java
             final int KEYGUARD_HOST_ID = 0x4B455947;
             int appWidgetId = AppWidgetHost.allocateAppWidgetIdForSystem(KEYGUARD_HOST_ID);
@@ -481,7 +511,41 @@
                 // Launch the widget picker
                 pickIntent.putExtra(AppWidgetManager.EXTRA_CUSTOM_INFO, extraInfos);
                 pickIntent.putExtra(AppWidgetManager.EXTRA_CUSTOM_EXTRAS, extraExtras);
-                startActivityForResult(pickIntent, REQUEST_PICK_APPWIDGET);
+                startActivityForResult(pickIntent, REQUEST_PICK_USER_SELECTED_APPWIDGET);
+            } else {
+                Log.e(TAG, "Unable to allocate an AppWidget id in lock screen");
+            }
+        } else if (KEY_CHOOSE_LOCKSCREEN_STATUS_WIDGET.equals(key)) {
+            // Create intent to pick widget
+            Intent pickIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_PICK);
+
+            // Found in KeyguardHostView.java
+            final int KEYGUARD_HOST_ID = 0x4B455947;
+            int appWidgetId = AppWidgetHost.allocateAppWidgetIdForSystem(KEYGUARD_HOST_ID);
+            if (appWidgetId != -1) {
+                pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
+                pickIntent.putExtra(AppWidgetManager.EXTRA_CUSTOM_SORT, false);
+                pickIntent.putExtra(AppWidgetManager.EXTRA_CATEGORY_FILTER,
+                        AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD);
+                pickIntent.putExtra(AppWidgetManager.EXTRA_FEATURES_FILTER,
+                        AppWidgetProviderInfo.WIDGET_FEATURES_STATUS);
+
+                // Add an entry for "none" to let someone select no widget
+                AppWidgetProviderInfo noneInfo = new AppWidgetProviderInfo();
+                ArrayList<AppWidgetProviderInfo> extraInfos = new ArrayList<AppWidgetProviderInfo>();
+                noneInfo.label = getResources().getString(R.string.widget_default);
+                noneInfo.provider = new ComponentName("", "");
+                extraInfos.add(noneInfo);
+
+                ArrayList<Bundle> extraExtras = new ArrayList<Bundle>();
+                Bundle b = new Bundle();
+                b.putBoolean(EXTRA_DEFAULT_WIDGET, true);
+                extraExtras.add(b);
+
+                // Launch the widget picker
+                pickIntent.putExtra(AppWidgetManager.EXTRA_CUSTOM_INFO, extraInfos);
+                pickIntent.putExtra(AppWidgetManager.EXTRA_CUSTOM_EXTRAS, extraExtras);
+                startActivityForResult(pickIntent, REQUEST_PICK_STATUS_APPWIDGET);
             } else {
                 Log.e(TAG, "Unable to allocate an AppWidget id in lock screen");
             }
@@ -567,44 +631,56 @@
             // is called by grabbing the value from lockPatternUtils.  We can't set it here
             // because mBiometricWeakLiveliness could be null
             return;
-        } else if (requestCode == REQUEST_PICK_APPWIDGET ||
-                requestCode == REQUEST_CREATE_APPWIDGET) {
+        } else if (requestCode == REQUEST_PICK_USER_SELECTED_APPWIDGET ||
+                requestCode == REQUEST_PICK_STATUS_APPWIDGET ||
+                requestCode == REQUEST_CREATE_USER_SELECTED_APPWIDGET ||
+                requestCode == REQUEST_CREATE_STATUS_APPWIDGET) {
             int appWidgetId = (data == null) ? -1 : data.getIntExtra(
                     AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
-            if (requestCode == REQUEST_PICK_APPWIDGET && resultCode == Activity.RESULT_OK) {
+            if ((requestCode == REQUEST_PICK_USER_SELECTED_APPWIDGET ||
+                 requestCode == REQUEST_PICK_STATUS_APPWIDGET) &&
+                resultCode == Activity.RESULT_OK) {
                 AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getActivity());
-                boolean noWidget = data.getBooleanExtra(EXTRA_NO_WIDGET, false);
+                boolean defaultOrNoWidget = data.getBooleanExtra(EXTRA_NO_WIDGET, false) ||
+                        data.getBooleanExtra(EXTRA_DEFAULT_WIDGET, false);
 
                 AppWidgetProviderInfo appWidget = null;
-                if (!noWidget) {
+                if (!defaultOrNoWidget) {
                     appWidget = appWidgetManager.getAppWidgetInfo(appWidgetId);
                 }
 
-                if (!noWidget && appWidget.configure != null) {
+                int newRequestCode = requestCode == REQUEST_PICK_USER_SELECTED_APPWIDGET ?
+                    REQUEST_CREATE_USER_SELECTED_APPWIDGET :
+                    REQUEST_CREATE_STATUS_APPWIDGET;
+                if (!defaultOrNoWidget && appWidget.configure != null) {
                     // Launch over to configure widget, if needed
                     Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
                     intent.setComponent(appWidget.configure);
                     intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
 
-                    startActivityForResultSafely(intent, REQUEST_CREATE_APPWIDGET);
+                    startActivityForResultSafely(intent, newRequestCode);
                 } else {
                     // Otherwise just add it
-                    if (noWidget) {
+                    if (defaultOrNoWidget) {
                         // If we selected "none", delete the allocated id
                         AppWidgetHost.deleteAppWidgetIdForSystem(appWidgetId);
                         data.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
                     }
-                    onActivityResult(REQUEST_CREATE_APPWIDGET, Activity.RESULT_OK, data);
+                    onActivityResult(newRequestCode, Activity.RESULT_OK, data);
                 }
-            } else if (
-                    requestCode == REQUEST_CREATE_APPWIDGET && resultCode == Activity.RESULT_OK) {
+            } else if ((requestCode == REQUEST_CREATE_USER_SELECTED_APPWIDGET ||
+                        requestCode == REQUEST_CREATE_STATUS_APPWIDGET) &&
+                       resultCode == Activity.RESULT_OK) {
                 // If a widget existed before, delete it
-                int oldAppWidgetId = getUserSelectedAppWidgetId();
+                int oldAppWidgetId = requestCode == REQUEST_CREATE_USER_SELECTED_APPWIDGET ?
+                        getUserSelectedAppWidgetId() : getStatusAppWidgetId();
                 if (oldAppWidgetId != -1) {
                     AppWidgetHost.deleteAppWidgetIdForSystem(oldAppWidgetId);
                 }
                 Settings.Secure.putString(getContentResolver(),
-                        Settings.Secure.LOCK_SCREEN_USER_SELECTED_APPWIDGET_ID,
+                        (requestCode == REQUEST_CREATE_USER_SELECTED_APPWIDGET ?
+                                Settings.Secure.LOCK_SCREEN_USER_SELECTED_APPWIDGET_ID :
+                                Settings.Secure.LOCK_SCREEN_STATUS_APPWIDGET_ID),
                         Integer.toString(appWidgetId));
             } else {
                 AppWidgetHost.deleteAppWidgetIdForSystem(appWidgetId);
diff --git a/src/com/android/settings/applications/ApplicationsState.java b/src/com/android/settings/applications/ApplicationsState.java
index 2ce6779..e87d7cf 100644
--- a/src/com/android/settings/applications/ApplicationsState.java
+++ b/src/com/android/settings/applications/ApplicationsState.java
@@ -18,6 +18,7 @@
 import android.os.Message;
 import android.os.Process;
 import android.os.SystemClock;
+import android.os.UserHandle;
 import android.text.format.Formatter;
 import android.util.Log;
 
@@ -238,6 +239,7 @@
 
     final Context mContext;
     final PackageManager mPm;
+    final int mRetrieveFlags;
     PackageIntentReceiver mPackageIntentReceiver;
 
     boolean mResumed;
@@ -401,7 +403,15 @@
                 Process.THREAD_PRIORITY_BACKGROUND);
         mThread.start();
         mBackgroundHandler = new BackgroundHandler(mThread.getLooper());
-        
+
+        // Only the owner can see all apps.
+        if (UserHandle.myUserId() == 0) {
+            mRetrieveFlags = PackageManager.GET_UNINSTALLED_PACKAGES |
+                    PackageManager.GET_DISABLED_COMPONENTS;
+        } else {
+            mRetrieveFlags = PackageManager.GET_DISABLED_COMPONENTS;
+        }
+
         /**
          * This is a trick to prevent the foreground thread from being delayed.
          * The problem is that Dalvik monitors are initially spin locks, to keep
@@ -591,9 +601,7 @@
             mPackageIntentReceiver = new PackageIntentReceiver();
             mPackageIntentReceiver.registerReceiver();
         }
-        mApplications = mPm.getInstalledApplications(
-                PackageManager.GET_UNINSTALLED_PACKAGES |
-                PackageManager.GET_DISABLED_COMPONENTS);
+        mApplications = mPm.getInstalledApplications(mRetrieveFlags);
         if (mApplications == null) {
             mApplications = new ArrayList<ApplicationInfo>();
         }
@@ -723,9 +731,7 @@
                     if (DEBUG_LOCKING) Log.v(TAG, "addPackage release lock: already exists");
                     return;
                 }
-                ApplicationInfo info = mPm.getApplicationInfo(pkgName,
-                        PackageManager.GET_UNINSTALLED_PACKAGES |
-                        PackageManager.GET_DISABLED_COMPONENTS);
+                ApplicationInfo info = mPm.getApplicationInfo(pkgName, mRetrieveFlags);
                 mApplications.add(info);
                 if (!mBackgroundHandler.hasMessages(BackgroundHandler.MSG_LOAD_ENTRIES)) {
                     mBackgroundHandler.sendEmptyMessage(BackgroundHandler.MSG_LOAD_ENTRIES);
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index 97d7b75..7588c1a 100644
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -340,7 +340,8 @@
                 }
             } else if ((mPackageInfo.applicationInfo.flags
                     & ApplicationInfo.FLAG_INSTALLED) == 0) {
-                mUninstallButton.setText(R.string.install_text);
+                mUninstallButton.setText(R.string.uninstall_text);
+                enabled = false;
             } else {
                 mUninstallButton.setText(R.string.uninstall_text);
             }
@@ -392,6 +393,9 @@
 
         mCanBeOnSdCardChecker = new CanBeOnSdCardChecker();
 
+        // Need to make sure we have loaded applications at this point.
+        mSession.resume();
+
         retrieveAppEntry();
 
         setHasOptionsMenu(true);
@@ -1134,6 +1138,7 @@
                     Uri.fromParts("package", mAppEntry.info.packageName, null));
             intent.putExtra(Intent.EXTRA_PACKAGES, new String[] { mAppEntry.info.packageName });
             intent.putExtra(Intent.EXTRA_UID, mAppEntry.info.uid);
+            intent.putExtra(Intent.EXTRA_USER_HANDLE, UserHandle.getUserId(mAppEntry.info.uid));
             getActivity().sendOrderedBroadcast(intent, null, mCheckKillProcessesReceiver, null,
                     Activity.RESULT_CANCELED, null, null);
         }
diff --git a/src/com/android/settings/applications/RunningState.java b/src/com/android/settings/applications/RunningState.java
index 838e4fe..e4d34f7 100644
--- a/src/com/android/settings/applications/RunningState.java
+++ b/src/com/android/settings/applications/RunningState.java
@@ -17,6 +17,7 @@
 package com.android.settings.applications;
 
 import com.android.settings.R;
+import com.android.settings.users.UserUtils;
 
 import android.app.ActivityManager;
 import android.app.ActivityManagerNative;
@@ -377,7 +378,8 @@
             }
             
             try {
-                ApplicationInfo ai = pm.getApplicationInfo(mProcessName, 0);
+                ApplicationInfo ai = pm.getApplicationInfo(mProcessName,
+                        PackageManager.GET_UNINSTALLED_PACKAGES);
                 if (ai.uid == mUid) {
                     mDisplayLabel = ai.loadLabel(pm);
                     mLabel = mDisplayLabel.toString();
@@ -394,7 +396,8 @@
             // If there is one package with this uid, that is what we want.
             if (pkgs.length == 1) {
                 try {
-                    ApplicationInfo ai = pm.getApplicationInfo(pkgs[0], 0);
+                    ApplicationInfo ai = pm.getApplicationInfo(pkgs[0],
+                            PackageManager.GET_UNINSTALLED_PACKAGES);
                     mDisplayLabel = ai.loadLabel(pm);
                     mLabel = mDisplayLabel.toString();
                     mPackageInfo = ai;
@@ -435,7 +438,8 @@
             
             // Finally... whatever, just pick the first package's name.
             try {
-                ApplicationInfo ai = pm.getApplicationInfo(pkgs[0], 0);
+                ApplicationInfo ai = pm.getApplicationInfo(pkgs[0],
+                        PackageManager.GET_UNINSTALLED_PACKAGES);
                 mDisplayLabel = ai.loadLabel(pm);
                 mLabel = mDisplayLabel.toString();
                 mPackageInfo = ai;
@@ -455,7 +459,8 @@
                 si = new ServiceItem(mUserId);
                 si.mRunningService = service;
                 try {
-                    si.mServiceInfo = pm.getServiceInfo(service.service, 0);
+                    si.mServiceInfo = pm.getServiceInfo(service.service,
+                            PackageManager.GET_UNINSTALLED_PACKAGES);
                 } catch (PackageManager.NameNotFoundException e) {
                 }
                 si.mDisplayLabel = makeLabel(pm,
@@ -818,12 +823,9 @@
                 userItem.mUser = new UserState();
                 UserInfo info = mUm.getUserInfo(newItem.mUserId);
                 userItem.mUser.mInfo = info;
-                if (info != null && info.iconPath != null) {
-                    try {
-                        userItem.mUser.mIcon = Drawable.createFromPath(info.iconPath);
-                    } catch (Exception e) {
-                        Log.w(TAG, "Failure loading user picture " + info.iconPath, e);
-                    }
+                if (info != null) {
+                    userItem.mUser.mIcon = UserUtils.getUserIcon(mUm, info,
+                            context.getResources());
                 }
                 String name = info != null ? info.name : null;
                 if (name == null) {
diff --git a/src/com/android/settings/fuelgauge/PowerUsageDetail.java b/src/com/android/settings/fuelgauge/PowerUsageDetail.java
index bb96ca9..0cc58be 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageDetail.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageDetail.java
@@ -34,6 +34,7 @@
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.Process;
+import android.os.UserHandle;
 import android.preference.PreferenceActivity;
 import android.provider.Settings;
 import android.text.TextUtils;
@@ -455,6 +456,7 @@
                 Uri.fromParts("package", mPackages[0], null));
         intent.putExtra(Intent.EXTRA_PACKAGES, mPackages);
         intent.putExtra(Intent.EXTRA_UID, mUid);
+        intent.putExtra(Intent.EXTRA_USER_HANDLE, mUid);
         getActivity().sendOrderedBroadcast(intent, null, mCheckKillProcessesReceiver, null,
                 Activity.RESULT_CANCELED, null, null);
     }
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index 5704163..4a79d9d 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -767,15 +767,23 @@
             final int userId = mUserSippers.keyAt(i);
             final List<BatterySipper> sippers = mUserSippers.valueAt(i);
             UserInfo info = mUm.getUserInfo(userId);
-            Drawable icon = UserUtils.getUserIcon(mUm, info, getResources());
-            String name = info != null ? info.name : null;
-            if (name == null) {
-                name = Integer.toString(info.id);
+            Drawable icon;
+            String name;
+            if (info != null) {
+                icon = UserUtils.getUserIcon(mUm, info, getResources());
+                name = info != null ? info.name : null;
+                if (name == null) {
+                    name = Integer.toString(info.id);
+                }
+                name = getActivity().getResources().getString(
+                        R.string.running_process_item_user_label, name);
+            } else {
+                icon = null;
+                name = getActivity().getResources().getString(
+                        R.string.running_process_item_removed_user_label);
             }
             double power = mUserPower.get(userId);
-            String label = getActivity().getResources().getString(
-                    R.string.running_process_item_user_label, name);
-            BatterySipper bs = addEntry(label, DrainType.USER, 0, 0, power);
+            BatterySipper bs = addEntry(name, DrainType.USER, 0, 0, power);
             bs.icon = icon;
             aggregateSippers(bs, sippers, "User");
         }
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index 079996e..6996a3a 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -184,7 +184,7 @@
     @Override
     public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
         if (UserHandle.myUserId() == UserHandle.USER_OWNER) {
-            if (mUserManager.getMaxSupportedUsers() > mUserManager.getUsers().size()) {
+            if (mUserManager.getMaxSupportedUsers() > mUserManager.getUsers(false).size()) {
                 MenuItem addUserItem = menu.add(0, MENU_ADD_USER, 0, R.string.user_add_user_menu);
                 addUserItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM
                         | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
@@ -373,7 +373,7 @@
 
     private void updateUserList() {
         if (getActivity() == null) return;
-        List<UserInfo> users = mUserManager.getUsers();
+        List<UserInfo> users = mUserManager.getUsers(true);
 
         mUserListCategory.removeAll();
         mUserListCategory.setOrderingAsAdded(false);