Merge "Fix bug #15890188 wifi toggle on-off switch missing after skipping setup wizard" into lmp-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 1e5a14f..fe704a4 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -98,6 +98,7 @@
         <receiver android:name="ManagedProfileSetup">
             <intent-filter>
                 <action android:name="android.intent.action.USER_INITIALIZE"/>
+                <action android:name="android.intent.action.PRE_BOOT_COMPLETED"/>
             </intent-filter>
         </receiver>
 
@@ -137,18 +138,6 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="AirplaneModeVoiceActivity"
-                android:label="@string/wireless_networks_settings_title"
-                android:theme="@android:style/Theme.Material.Light.Voice"
-                android:exported="true"
-                android:taskAffinity="">
-            <intent-filter>
-                <action android:name="android.settings.VOICE_CONTROL_AIRPLANE_MODE" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <category android:name="android.intent.category.VOICE" />
-            </intent-filter>
-        </activity>
-
         <!-- Top-level settings -->
 
         <activity android:name="Settings$WifiSettingsActivity"
diff --git a/res/layout/bluetooth_device_settings.xml b/res/layout/bluetooth_device_settings.xml
index cc2cc09..b87551a 100644
--- a/res/layout/bluetooth_device_settings.xml
+++ b/res/layout/bluetooth_device_settings.xml
@@ -31,8 +31,9 @@
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:text="@string/bluetooth_preference_paired_dialog_name_label"
+                    android:textAppearance="@android:style/TextAppearance.Material.Body1"
+                    android:textColor="?android:attr/textColorSecondary"
                     android:textDirection="locale"
-                    android:textColor="?android:attr/colorAccent"
                     style="@style/bt_item_label" />
 
             <EditText android:id="@+id/name"
diff --git a/res/layout/bluetooth_preference_category.xml b/res/layout/bluetooth_preference_category.xml
new file mode 100644
index 0000000..59a3e87
--- /dev/null
+++ b/res/layout/bluetooth_preference_category.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- Layout used for Bluetooth PreferenceCategory in a DeviceProfilesSettings. -->
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+android:id/title"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:textAppearance="@android:style/TextAppearance.Material.Body1"
+    android:textColor="?android:attr/textColorSecondary"
+    android:paddingTop="16dip"
+    android:paddingBottom="16dip" />
diff --git a/res/layout/confirm_lock_pattern.xml b/res/layout/confirm_lock_pattern.xml
index f11f5ae..4426242 100644
--- a/res/layout/confirm_lock_pattern.xml
+++ b/res/layout/confirm_lock_pattern.xml
@@ -27,21 +27,11 @@
         android:gravity="center"
         android:textSize="18sp"/>
 
-    <View
-         android:background="@*android:drawable/code_lock_top"
-         android:layout_width="match_parent"
-         android:layout_height="2dip" />
-
     <com.android.internal.widget.LockPatternView android:id="@+id/lockPattern"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="@color/lock_pattern_background" />
 
-    <View
-         android:background="@*android:drawable/code_lock_bottom"
-         android:layout_width="match_parent"
-         android:layout_height="8dip" />
-
     <TextView android:id="@+id/footerText"
         android:layout_width="match_parent"
         android:layout_height="0dip"
@@ -49,5 +39,4 @@
         android:gravity="center"
         android:textSize="14sp"/>
 
-
 </com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
diff --git a/src/com/android/settings/DeviceAdminSettings.java b/src/com/android/settings/DeviceAdminSettings.java
index 1ea9859..a70984d 100644
--- a/src/com/android/settings/DeviceAdminSettings.java
+++ b/src/com/android/settings/DeviceAdminSettings.java
@@ -20,7 +20,6 @@
 import org.xmlpull.v1.XmlPullParserException;
 
 import android.app.Activity;
-import android.app.Dialog;
 import android.app.AlertDialog;
 import android.app.ListFragment;
 import android.app.admin.DeviceAdminInfo;
@@ -305,8 +304,8 @@
             final Activity activity = getActivity();
             ViewHolder vh = (ViewHolder) view.getTag();
             Drawable activityIcon = item.loadIcon(activity.getPackageManager());
-            Drawable badgedIcon = mUm.getBadgedDrawableForUser(activityIcon,
-                    new UserHandle(getUserId(item)));
+            Drawable badgedIcon = activity.getPackageManager().getUserBadgedDrawableForDensity(
+                    activityIcon, new UserHandle(getUserId(item)), null, 0);
             vh.icon.setImageDrawable(badgedIcon);
             vh.name.setText(item.loadLabel(activity.getPackageManager()));
             vh.checkbox.setChecked(isActiveAdmin(item));
diff --git a/src/com/android/settings/RestrictedSettingsFragment.java b/src/com/android/settings/RestrictedSettingsFragment.java
index 142a42c..7d7599f 100644
--- a/src/com/android/settings/RestrictedSettingsFragment.java
+++ b/src/com/android/settings/RestrictedSettingsFragment.java
@@ -141,7 +141,7 @@
     private void ensurePin() {
         if (!mChallengeSucceeded && !mChallengeRequested
                 && mRestrictionsManager.hasRestrictionsProvider()) {
-            Intent intent = mRestrictionsManager.getLocalApprovalIntent();
+            Intent intent = mRestrictionsManager.createLocalApprovalIntent();
             if (intent != null) {
                 mChallengeRequested = true;
                 mChallengeSucceeded = false;
diff --git a/src/com/android/settings/accounts/AuthenticatorHelper.java b/src/com/android/settings/accounts/AuthenticatorHelper.java
index 7ea2f12..c9c6ac4 100644
--- a/src/com/android/settings/accounts/AuthenticatorHelper.java
+++ b/src/com/android/settings/accounts/AuthenticatorHelper.java
@@ -104,8 +104,8 @@
                 AuthenticatorDescription desc = mTypeToAuthDescription.get(accountType);
                 Context authContext = context.createPackageContextAsUser(desc.packageName, 0,
                         mUserHandle);
-                icon = mUm.getBadgedDrawableForUser(
-                        authContext.getResources().getDrawable(desc.iconId), mUserHandle);
+                icon = mContext.getPackageManager().getUserBadgedDrawableForDensity(
+                        authContext.getResources().getDrawable(desc.iconId), mUserHandle, null, 0);
                 synchronized (mAccTypeIconCache) {
                     mAccTypeIconCache.put(accountType, icon);
                 }
diff --git a/src/com/android/settings/accounts/ChooseAccountActivity.java b/src/com/android/settings/accounts/ChooseAccountActivity.java
index 7c0dbdb..27edca1 100644
--- a/src/com/android/settings/accounts/ChooseAccountActivity.java
+++ b/src/com/android/settings/accounts/ChooseAccountActivity.java
@@ -18,7 +18,6 @@
 
 import android.accounts.AccountManager;
 import android.accounts.AuthenticatorDescription;
-import android.app.ActivityManagerNative;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.Intent;
@@ -216,8 +215,8 @@
             try {
                 AuthenticatorDescription desc = mTypeToAuthDescription.get(accountType);
                 Context authContext = createPackageContextAsUser(desc.packageName, 0, mUserHandle);
-                icon = mUm.getBadgedDrawableForUser(
-                        authContext.getResources().getDrawable(desc.iconId), mUserHandle);
+                icon = getPackageManager().getUserBadgedDrawableForDensity(
+                        authContext.getResources().getDrawable(desc.iconId), mUserHandle, null, 0);
             } catch (PackageManager.NameNotFoundException e) {
                 // TODO: place holder icon for missing account icons?
                 Log.w(TAG, "No icon name for account type " + accountType);
diff --git a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
index 64c807f..110432b 100755
--- a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
+++ b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
@@ -78,6 +78,7 @@
         addPreferencesFromResource(R.xml.bluetooth_device_advanced);
         getPreferenceScreen().setOrderingAsAdded(false);
         mProfileContainer = (PreferenceGroup) findPreference(KEY_PROFILE_CONTAINER);
+        mProfileContainer.setLayoutResource(R.layout.bluetooth_preference_category);
 
         mManager = LocalBluetoothManager.getInstance(getActivity());
         CachedBluetoothDeviceManager deviceManager =
diff --git a/src/com/android/settings/location/RecentLocationApps.java b/src/com/android/settings/location/RecentLocationApps.java
index e28f96b..6a40d66 100644
--- a/src/com/android/settings/location/RecentLocationApps.java
+++ b/src/com/android/settings/location/RecentLocationApps.java
@@ -212,7 +212,8 @@
 
             final UserHandle userHandle = new UserHandle(userId);
             Drawable appIcon = mPackageManager.getApplicationIcon(appInfo);
-            Drawable icon = um.getBadgedDrawableForUser(appIcon, userHandle);
+            Drawable icon = mPackageManager.getUserBadgedDrawableForDensity(appIcon, userHandle,
+                    null, 0);
             CharSequence appLabel = mPackageManager.getApplicationLabel(appInfo);
             CharSequence badgedAppLabel = um.getBadgedLabelForUser(appLabel.toString(), userHandle);
             preference = createRecentLocationEntry(icon,
diff --git a/src/com/android/settings/notification/NotificationSettings.java b/src/com/android/settings/notification/NotificationSettings.java
index 3094032..6899440 100644
--- a/src/com/android/settings/notification/NotificationSettings.java
+++ b/src/com/android/settings/notification/NotificationSettings.java
@@ -37,6 +37,7 @@
 import android.preference.SeekBarVolumizer;
 import android.preference.TwoStatePreference;
 import android.provider.MediaStore;
+import android.provider.OpenableColumns;
 import android.provider.SearchIndexableResource;
 import android.provider.Settings;
 import android.util.Log;
@@ -238,11 +239,16 @@
         if (ringtoneUri == null) {
             summary = context.getString(com.android.internal.R.string.ringtone_silent);
         } else {
-            // Fetch the ringtone title from the media provider
             Cursor cursor = null;
             try {
-                cursor = context.getContentResolver().query(ringtoneUri,
-                        new String[] { MediaStore.Audio.Media.TITLE }, null, null, null);
+                if (MediaStore.AUTHORITY.equals(ringtoneUri.getAuthority())) {
+                    // Fetch the ringtone title from the media provider
+                    cursor = context.getContentResolver().query(ringtoneUri,
+                            new String[] { MediaStore.Audio.Media.TITLE }, null, null, null);
+                } else if (ContentResolver.SCHEME_CONTENT.equals(ringtoneUri.getScheme())) {
+                    cursor = context.getContentResolver().query(ringtoneUri,
+                            new String[] { OpenableColumns.DISPLAY_NAME }, null, null, null);
+                }
                 if (cursor != null) {
                     if (cursor.moveToFirst()) {
                         summary = cursor.getString(0);
@@ -250,6 +256,8 @@
                 }
             } catch (SQLiteException sqle) {
                 // Unknown title for the ringtone
+            } catch (IllegalArgumentException iae) {
+                // Some other error retrieving the column from the provider
             } finally {
                 if (cursor != null) {
                     cursor.close();
diff --git a/src/com/android/settings/print/PrintJobSettingsFragment.java b/src/com/android/settings/print/PrintJobSettingsFragment.java
index cbe70ae..5af7f9d 100644
--- a/src/com/android/settings/print/PrintJobSettingsFragment.java
+++ b/src/com/android/settings/print/PrintJobSettingsFragment.java
@@ -153,18 +153,19 @@
     }
 
     private void updateUi() {
-        mPrintJob = mPrintManager.getPrintJob(mPrintJobId);
+        PrintJob printJob = mPrintManager.getPrintJob(mPrintJobId);
 
-        if (mPrintJob == null) {
+        if (printJob == null) {
             finish();
             return;
         }
 
-        if (mPrintJob.isCancelled() || mPrintJob.isCompleted()) {
+        if (printJob.isCancelled() || printJob.isCompleted()) {
             finish();
             return;
         }
 
+        mPrintJob = printJob;
         PrintJobInfo info = mPrintJob.getInfo();
 
         switch (info.getState()) {
diff --git a/src/com/android/settings/sim/SimSettings.java b/src/com/android/settings/sim/SimSettings.java
index abfeccb..259ebf1 100644
--- a/src/com/android/settings/sim/SimSettings.java
+++ b/src/com/android/settings/sim/SimSettings.java
@@ -167,7 +167,7 @@
 
         for (int i = 0; i < availableSubInfoLength; ++i) {
             final SubInfoRecord sir = mAvailableSubInfos.get(i);
-            if (sir != null && sir.mSubId == subId) {
+            if (sir != null && sir.subId == subId) {
                 return sir;
             }
         }
@@ -185,7 +185,7 @@
 
             for (int i = 0; i < availableSubInfoLength; ++i) {
                 final SubInfoRecord sir = mSubInfoList.get(i);
-                if (sir.mSlotId == slotId) {
+                if (sir.slotId == slotId) {
                     //Right now we take the first subscription on a SIM.
                     return sir;
                 }
@@ -199,7 +199,7 @@
         final DropDownPreference simPref = (DropDownPreference) findPreference(KEY_SMS);
         final SubInfoRecord sir = findRecordBySubId(SubscriptionManager.getDefaultSmsSubId());
         if (sir != null) {
-            simPref.setSelectedItem(sir.mSlotId + 1);
+            simPref.setSelectedItem(sir.slotId + 1);
         }
         simPref.setEnabled(mNumSims > 1);
     }
@@ -208,7 +208,7 @@
         final DropDownPreference simPref = (DropDownPreference) findPreference(KEY_CELLULAR_DATA);
         final SubInfoRecord sir = findRecordBySubId(SubscriptionManager.getDefaultDataSubId());
         if (sir != null) {
-            simPref.setSelectedItem(sir.mSlotId);
+            simPref.setSelectedItem(sir.slotId);
         }
         simPref.setEnabled(mNumSims > 1);
     }
@@ -217,7 +217,7 @@
         final DropDownPreference simPref = (DropDownPreference) findPreference(KEY_CALLS);
         final SubInfoRecord sir = findRecordBySubId(SubscriptionManager.getDefaultVoiceSubId());
         if (sir != null) {
-            simPref.setSelectedItem(sir.mSlotId + 1);
+            simPref.setSelectedItem(sir.slotId + 1);
         }
         simPref.setEnabled(mNumSims > 1);
     }
@@ -254,14 +254,14 @@
         for (int i = 0; i < subAvailableSize; ++i) {
             final SubInfoRecord sir = mAvailableSubInfos.get(i);
             if(sir != null){
-                simPref.addItem(sir.mDisplayName, sir);
+                simPref.addItem(sir.displayName, sir);
             }
         }
 
         simPref.setCallback(new DropDownPreference.Callback() {
             @Override
             public boolean onItemSelected(int pos, Object value) {
-                final long subId = value == null ? 0 : ((SubInfoRecord)value).mSubId;
+                final long subId = value == null ? 0 : ((SubInfoRecord)value).subId;
 
                 if (simPref.getKey().equals(KEY_CELLULAR_DATA)) {
                     SubscriptionManager.setDefaultDataSubId(subId);
@@ -310,7 +310,7 @@
             setTitle(res.getString(R.string.sim_card_number_title, mSlotId + 1));
             if (mSubInfoRecord != null) {
                 setSummary(res.getString(R.string.sim_settings_summary,
-                            mSubInfoRecord.mDisplayName, mSubInfoRecord.mNumber));
+                            mSubInfoRecord.displayName, mSubInfoRecord.number));
                 setEnabled(true);
             } else {
                 setSummary(R.string.sim_slot_empty);
@@ -327,13 +327,13 @@
             builder.setView(dialogLayout);
 
             EditText nameText = (EditText)dialogLayout.findViewById(R.id.sim_name);
-            nameText.setText(mSubInfoRecord.mDisplayName);
+            nameText.setText(mSubInfoRecord.displayName);
 
             TextView numberView = (TextView)dialogLayout.findViewById(R.id.number);
-            numberView.setText(mSubInfoRecord.mNumber);
+            numberView.setText(mSubInfoRecord.number);
 
             TextView carrierView = (TextView)dialogLayout.findViewById(R.id.carrier);
-            carrierView.setText(mSubInfoRecord.mDisplayName);
+            carrierView.setText(mSubInfoRecord.displayName);
 
             builder.setTitle(R.string.sim_editor_title);
 
@@ -347,11 +347,11 @@
                     SubscriptionManager.setDisplayNumberFormat(
                         displayNumbers.getSelectedItemPosition() == 0
                             ? SubscriptionManager.DISPLAY_NUMBER_LAST
-                            : SubscriptionManager.DISPLAY_NUMBER_FIRST, mSubInfoRecord.mSubId);
+                            : SubscriptionManager.DISPLAY_NUMBER_FIRST, mSubInfoRecord.subId);
 
-                    mSubInfoRecord.mDisplayName = nameText.getText().toString();
-                    SubscriptionManager.setDisplayName(mSubInfoRecord.mDisplayName,
-                        mSubInfoRecord.mSubId);
+                    mSubInfoRecord.displayName = nameText.getText().toString();
+                    SubscriptionManager.setDisplayName(mSubInfoRecord.displayName,
+                        mSubInfoRecord.subId);
 
                     updateAllOptions();
                     update();