Merge "Allow killApplicationWithAppId() on secondary users" into mnc-dev
diff --git a/api/current.txt b/api/current.txt
index 835e836..92d349e 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -30615,9 +30615,11 @@
     field public static final java.lang.String KEY_CARRIER_VOLTE_AVAILABLE_BOOL = "carrier_volte_available_bool";
     field public static final java.lang.String KEY_CARRIER_VOLTE_PROVISIONED_BOOL = "carrier_volte_provisioned_bool";
     field public static final java.lang.String KEY_CARRIER_VOLTE_TTY_SUPPORTED_BOOL = "carrier_volte_tty_supported_bool";
+    field public static final java.lang.String KEY_CARRIER_WFC_IMS_AVAILABLE_BOOL = "carrier_wfc_ims_available_bool";
+    field public static final java.lang.String KEY_DEFAULT_SIM_CALL_MANAGER_STRING = "default_sim_call_manager_string";
     field public static final java.lang.String KEY_DISABLE_CDMA_ACTIVATION_CODE_BOOL = "disable_cdma_activation_code_bool";
     field public static final java.lang.String KEY_DTMF_TYPE_ENABLED_BOOL = "dtmf_type_enabled_bool";
-    field public static final java.lang.String KEY_ENABLE_DIALER_KEY_VIBRATION_BOOL = "key_enable_dialer_vibration_bool";
+    field public static final java.lang.String KEY_ENABLE_DIALER_KEY_VIBRATION_BOOL = "enable_dialer_vibration_bool";
     field public static final java.lang.String KEY_HAS_IN_CALL_NOISE_SUPPRESSION_BOOL = "has_in_call_noise_suppression_bool";
     field public static final java.lang.String KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL = "hide_carrier_network_settings_bool";
     field public static final java.lang.String KEY_IGNORE_SIM_NETWORK_LOCKED_EVENTS_BOOL = "ignore_sim_network_locked_events_bool";
diff --git a/api/system-current.txt b/api/system-current.txt
index e3978cb..c28f4353 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -32835,9 +32835,11 @@
     field public static final java.lang.String KEY_CARRIER_VOLTE_AVAILABLE_BOOL = "carrier_volte_available_bool";
     field public static final java.lang.String KEY_CARRIER_VOLTE_PROVISIONED_BOOL = "carrier_volte_provisioned_bool";
     field public static final java.lang.String KEY_CARRIER_VOLTE_TTY_SUPPORTED_BOOL = "carrier_volte_tty_supported_bool";
+    field public static final java.lang.String KEY_CARRIER_WFC_IMS_AVAILABLE_BOOL = "carrier_wfc_ims_available_bool";
+    field public static final java.lang.String KEY_DEFAULT_SIM_CALL_MANAGER_STRING = "default_sim_call_manager_string";
     field public static final java.lang.String KEY_DISABLE_CDMA_ACTIVATION_CODE_BOOL = "disable_cdma_activation_code_bool";
     field public static final java.lang.String KEY_DTMF_TYPE_ENABLED_BOOL = "dtmf_type_enabled_bool";
-    field public static final java.lang.String KEY_ENABLE_DIALER_KEY_VIBRATION_BOOL = "key_enable_dialer_vibration_bool";
+    field public static final java.lang.String KEY_ENABLE_DIALER_KEY_VIBRATION_BOOL = "enable_dialer_vibration_bool";
     field public static final java.lang.String KEY_HAS_IN_CALL_NOISE_SUPPRESSION_BOOL = "has_in_call_noise_suppression_bool";
     field public static final java.lang.String KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL = "hide_carrier_network_settings_bool";
     field public static final java.lang.String KEY_IGNORE_SIM_NETWORK_LOCKED_EVENTS_BOOL = "ignore_sim_network_locked_events_bool";
diff --git a/core/java/android/bluetooth/BluetoothActivityEnergyInfo.java b/core/java/android/bluetooth/BluetoothActivityEnergyInfo.java
index 161c339..834a587 100644
--- a/core/java/android/bluetooth/BluetoothActivityEnergyInfo.java
+++ b/core/java/android/bluetooth/BluetoothActivityEnergyInfo.java
@@ -28,10 +28,10 @@
 public final class BluetoothActivityEnergyInfo implements Parcelable {
     private final long mTimestamp;
     private final int mBluetoothStackState;
-    private final int mControllerTxTimeMs;
-    private final int mControllerRxTimeMs;
-    private final int mControllerIdleTimeMs;
-    private final int mControllerEnergyUsed;
+    private final long mControllerTxTimeMs;
+    private final long mControllerRxTimeMs;
+    private final long mControllerIdleTimeMs;
+    private final long mControllerEnergyUsed;
 
     public static final int BT_STACK_STATE_INVALID = 0;
     public static final int BT_STACK_STATE_STATE_ACTIVE = 1;
@@ -39,7 +39,7 @@
     public static final int BT_STACK_STATE_STATE_IDLE = 3;
 
     public BluetoothActivityEnergyInfo(long timestamp, int stackState,
-                                       int txTime, int rxTime, int idleTime, int energyUsed) {
+                                       long txTime, long rxTime, long idleTime, long energyUsed) {
         mTimestamp = timestamp;
         mBluetoothStackState = stackState;
         mControllerTxTimeMs = txTime;
@@ -65,10 +65,10 @@
         public BluetoothActivityEnergyInfo createFromParcel(Parcel in) {
             long timestamp = in.readLong();
             int stackState = in.readInt();
-            int txTime = in.readInt();
-            int rxTime = in.readInt();
-            int idleTime = in.readInt();
-            int energyUsed = in.readInt();
+            long txTime = in.readLong();
+            long rxTime = in.readLong();
+            long idleTime = in.readLong();
+            long energyUsed = in.readLong();
             return new BluetoothActivityEnergyInfo(timestamp, stackState,
                     txTime, rxTime, idleTime, energyUsed);
         }
@@ -80,10 +80,10 @@
     public void writeToParcel(Parcel out, int flags) {
         out.writeLong(mTimestamp);
         out.writeInt(mBluetoothStackState);
-        out.writeInt(mControllerTxTimeMs);
-        out.writeInt(mControllerRxTimeMs);
-        out.writeInt(mControllerIdleTimeMs);
-        out.writeInt(mControllerEnergyUsed);
+        out.writeLong(mControllerTxTimeMs);
+        out.writeLong(mControllerRxTimeMs);
+        out.writeLong(mControllerIdleTimeMs);
+        out.writeLong(mControllerEnergyUsed);
     }
 
     public int describeContents() {
@@ -100,21 +100,21 @@
     /**
      * @return tx time in ms
      */
-    public int getControllerTxTimeMillis() {
+    public long getControllerTxTimeMillis() {
         return mControllerTxTimeMs;
     }
 
     /**
      * @return rx time in ms
      */
-    public int getControllerRxTimeMillis() {
+    public long getControllerRxTimeMillis() {
         return mControllerRxTimeMs;
     }
 
     /**
      * @return idle time in ms
      */
-    public int getControllerIdleTimeMillis() {
+    public long getControllerIdleTimeMillis() {
         return mControllerIdleTimeMs;
     }
 
@@ -122,7 +122,7 @@
      * product of current(mA), voltage(V) and time(ms)
      * @return energy used
      */
-    public int getControllerEnergyUsed() {
+    public long getControllerEnergyUsed() {
         return mControllerEnergyUsed;
     }
 
@@ -137,8 +137,8 @@
      * @return if the record is valid
      */
     public boolean isValid() {
-        return ((getControllerTxTimeMillis() !=0) ||
-                (getControllerRxTimeMillis() !=0) ||
-                (getControllerIdleTimeMillis() !=0));
+        return ((mControllerTxTimeMs !=0) ||
+                (mControllerRxTimeMs !=0) ||
+                (mControllerIdleTimeMs !=0));
     }
 }
diff --git a/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java b/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java
index 8512b23..a1ebe6a 100644
--- a/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java
+++ b/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java
@@ -2053,8 +2053,10 @@
                 requestMetadata, /*reprocess*/false, CameraCaptureSession.SESSION_ID_NONE);
 
         // Overwrite the capture intent to make sure a good value is set.
-        Surface[] surfaces = (Surface[])outputSurfaces.toArray();
-        if (outputSurfaces.size() == 1 && SurfaceUtils.isSurfaceForHwVideoEncoder(surfaces[0])) {
+        Iterator<Surface> iterator = outputSurfaces.iterator();
+        Surface firstSurface = iterator.next();
+        Surface secondSurface = null;
+        if (outputSurfaces.size() == 1 && SurfaceUtils.isSurfaceForHwVideoEncoder(firstSurface)) {
             singleTargetRequestBuilder.set(CaptureRequest.CONTROL_CAPTURE_INTENT,
                     CaptureRequest.CONTROL_CAPTURE_INTENT_PREVIEW);
         } else {
@@ -2071,19 +2073,20 @@
                     requestMetadata, /*reprocess*/false, CameraCaptureSession.SESSION_ID_NONE);
             doubleTargetRequestBuilder.set(CaptureRequest.CONTROL_CAPTURE_INTENT,
                     CaptureRequest.CONTROL_CAPTURE_INTENT_VIDEO_RECORD);
-            doubleTargetRequestBuilder.addTarget(surfaces[0]);
-            doubleTargetRequestBuilder.addTarget(surfaces[1]);
+            doubleTargetRequestBuilder.addTarget(firstSurface);
+            secondSurface = iterator.next();
+            doubleTargetRequestBuilder.addTarget(secondSurface);
             doubleTargetRequestBuilder.setPartOfCHSRequestList(/*partOfCHSList*/true);
             // Make sure singleTargetRequestBuilder contains only recording surface for
             // preview + recording case.
-            Surface recordingSurface = surfaces[0];
+            Surface recordingSurface = firstSurface;
             if (!SurfaceUtils.isSurfaceForHwVideoEncoder(recordingSurface)) {
-                recordingSurface = surfaces[1];
+                recordingSurface = secondSurface;
             }
             singleTargetRequestBuilder.addTarget(recordingSurface);
         } else {
             // Single output case: either recording or preview.
-            singleTargetRequestBuilder.addTarget(surfaces[0]);
+            singleTargetRequestBuilder.addTarget(firstSurface);
         }
 
         // Generate the final request list.
diff --git a/core/java/android/text/style/TtsSpan.java b/core/java/android/text/style/TtsSpan.java
index c40f11f..93a156b 100644
--- a/core/java/android/text/style/TtsSpan.java
+++ b/core/java/android/text/style/TtsSpan.java
@@ -165,7 +165,7 @@
 
     /**
      * The text associated with this span is a series of characters that have to
-     * be read verbatim. The engine will attempt to ready out any character like
+     * be read verbatim. The engine will attempt to read out any character like
      * punctuation but excluding whitespace. {@link #ARG_VERBATIM} is required.
      * Also accepts the arguments {@link #ARG_GENDER},
      * {@link #ARG_ANIMACY}, {@link #ARG_MULTIPLICITY} and {@link #ARG_CASE}.
diff --git a/core/java/com/android/internal/app/AssistUtils.java b/core/java/com/android/internal/app/AssistUtils.java
new file mode 100644
index 0000000..b520384
--- /dev/null
+++ b/core/java/com/android/internal/app/AssistUtils.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2015 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
+ */
+
+package com.android.internal.app;
+
+import android.app.SearchManager;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.provider.Settings;
+import android.util.Log;
+
+/**
+ * Utility method for dealing with the assistant aspects of
+ * {@link com.android.internal.app.IVoiceInteractionManagerService IVoiceInteractionManagerService}.
+ */
+public class AssistUtils {
+
+    private static final String TAG = "AssistUtils";
+
+    private final Context mContext;
+    private final IVoiceInteractionManagerService mVoiceInteractionManagerService;
+
+    public AssistUtils(Context context) {
+        mContext = context;
+        mVoiceInteractionManagerService = IVoiceInteractionManagerService.Stub.asInterface(
+                ServiceManager.getService(Context.VOICE_INTERACTION_MANAGER_SERVICE));
+    }
+
+    public void showSessionForActiveService(IVoiceInteractionSessionShowCallback showCallback) {
+        try {
+            mVoiceInteractionManagerService.showSessionForActiveService(showCallback);
+        } catch (RemoteException e) {
+            Log.w(TAG, "Failed to call showSessionForActiveService", e);
+        }
+    }
+
+    public void launchVoiceAssistFromKeyguard() {
+        try {
+            mVoiceInteractionManagerService.launchVoiceAssistFromKeyguard();
+        } catch (RemoteException e) {
+            Log.w(TAG, "Failed to call launchVoiceAssistFromKeyguard", e);
+        }
+    }
+
+    public boolean activeServiceSupportsAssistGesture() {
+        try {
+            return mVoiceInteractionManagerService != null
+                    && mVoiceInteractionManagerService.activeServiceSupportsAssist();
+        } catch (RemoteException e) {
+            Log.w(TAG, "Failed to call activeServiceSupportsAssistGesture", e);
+            return false;
+        }
+    }
+
+    public boolean activeServiceSupportsLaunchFromKeyguard() {
+        try {
+            return mVoiceInteractionManagerService != null
+                    && mVoiceInteractionManagerService.activeServiceSupportsLaunchFromKeyguard();
+        } catch (RemoteException e) {
+            Log.w(TAG, "Failed to call activeServiceSupportsLaunchFromKeyguard", e);
+            return false;
+        }
+    }
+
+    public ComponentName getActiveServiceComponentName() {
+        try {
+            return mVoiceInteractionManagerService.getActiveServiceComponentName();
+        } catch (RemoteException e) {
+            Log.w(TAG, "Failed to call getActiveServiceComponentName", e);
+            return null;
+        }
+    }
+
+    public boolean isSessionRunning() {
+        try {
+            return mVoiceInteractionManagerService != null
+                    && mVoiceInteractionManagerService.isSessionRunning();
+        } catch (RemoteException e) {
+            Log.w(TAG, "Failed to call isSessionRunning", e);
+            return false;
+        }
+    }
+
+    public void hideCurrentSession() {
+        try {
+            mVoiceInteractionManagerService.hideCurrentSession();
+        } catch (RemoteException e) {
+            Log.w(TAG, "Failed to call hideCurrentSession", e);
+        }
+    }
+
+    public ComponentName getAssistComponentForUser(int userId) {
+        final String setting = Settings.Secure.getStringForUser(mContext.getContentResolver(),
+                Settings.Secure.ASSISTANT, userId);
+        if (setting != null) {
+            return ComponentName.unflattenFromString(setting);
+        }
+
+        // Fallback to keep backward compatible behavior when there is no user setting.
+        if (activeServiceSupportsAssistGesture()) {
+            return getActiveServiceComponentName();
+        }
+
+        Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE))
+                .getAssistIntent(mContext, false, userId);
+        if (intent != null) {
+            return intent.getComponent();
+        }
+
+        return null;
+    }
+
+}
diff --git a/docs/html/training/tv/publishing/checklist.jd b/docs/html/training/tv/publishing/checklist.jd
index 865a89b..6259721 100644
--- a/docs/html/training/tv/publishing/checklist.jd
+++ b/docs/html/training/tv/publishing/checklist.jd
@@ -67,12 +67,12 @@
 
 <li>
   Eliminate requirements for unsupported hardware in your app.
-  <p>See <a href="training/tv/start/hardware.html#declare-hardware-requirements">Declaring hardware requirements for TV</a>.</p>
+  <p>See <a href="{@docRoot}training/tv/start/hardware.html#declare-hardware-requirements">Declaring hardware requirements for TV</a>.</p>
 </li>
 
 <li>
   Ensure permissions do not imply hardware requirements
-  <p>See <a href="training/tv/start/hardware.html#hardware-permissions">Declaring permissions that imply hardware features</a>.</p>
+  <p>See <a href="{@docRoot}training/tv/start/hardware.html#hardware-permissions">Declaring permissions that imply hardware features</a>.</p>
 </li>
 
 </ol>
diff --git a/keystore/java/android/security/keystore/AndroidKeyStoreKeyPairGeneratorSpi.java b/keystore/java/android/security/keystore/AndroidKeyStoreKeyPairGeneratorSpi.java
index b93424d..2de60fd 100644
--- a/keystore/java/android/security/keystore/AndroidKeyStoreKeyPairGeneratorSpi.java
+++ b/keystore/java/android/security/keystore/AndroidKeyStoreKeyPairGeneratorSpi.java
@@ -624,7 +624,7 @@
             int keySizeBits,
             KeyGenParameterSpec spec) {
         // Constraints:
-        // 1. Key must be authorized for signing.
+        // 1. Key must be authorized for signing without user authentication.
         // 2. Signature digest must be one of key's authorized digests.
         // 3. For RSA keys, the digest output size must not exceed modulus size minus space needed
         //    for RSA PKCS#1 signature padding (about 29 bytes: minimum 10 bytes of padding + 15--19
@@ -636,6 +636,10 @@
             // Key not authorized for signing
             return null;
         }
+        if (spec.isUserAuthenticationRequired()) {
+            // Key not authorized for use without user authentication
+            return null;
+        }
         if (!spec.isDigestsSpecified()) {
             // Key not authorized for any digests -- can't sign
             return null;
diff --git a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
index 1e7ee98..445ecb6 100644
--- a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
+++ b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
@@ -16,7 +16,6 @@
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.RemoteException;
-import android.os.ServiceManager;
 import android.os.UserHandle;
 import android.provider.Settings;
 import android.util.Log;
@@ -28,12 +27,15 @@
 import android.view.WindowManager;
 import android.widget.ImageView;
 
-import com.android.internal.app.IVoiceInteractionManagerService;
+import com.android.internal.app.AssistUtils;
 import com.android.internal.app.IVoiceInteractionSessionShowCallback;
 import com.android.systemui.R;
 import com.android.systemui.statusbar.CommandQueue;
 import com.android.systemui.statusbar.phone.PhoneStatusBar;
 
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+
 /**
  * Class to manage everything related to assist in SystemUI.
  */
@@ -55,7 +57,7 @@
     private final WindowManager mWindowManager;
     private AssistOrbContainer mView;
     private final PhoneStatusBar mBar;
-    private final IVoiceInteractionManagerService mVoiceInteractionManagerService;
+    private final AssistUtils mAssistUtils;
 
     private ComponentName mAssistComponent;
 
@@ -92,8 +94,7 @@
         mContext = context;
         mBar = bar;
         mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
-        mVoiceInteractionManagerService = IVoiceInteractionManagerService.Stub.asInterface(
-                ServiceManager.getService(Context.VOICE_INTERACTION_MANAGER_SERVICE));
+        mAssistUtils = new AssistUtils(context);
 
         mContext.getContentResolver().registerContentObserver(
                 Settings.Secure.getUriFor(Settings.Secure.ASSISTANT), false,
@@ -140,11 +141,7 @@
     }
 
     public void hideAssist() {
-        try {
-            mVoiceInteractionManagerService.hideCurrentSession();
-        } catch (RemoteException e) {
-            Log.w(TAG, "Failed to call hideCurrentSession", e);
-        }
+        mAssistUtils.hideCurrentSession();
     }
 
     private WindowManager.LayoutParams getLayoutParams() {
@@ -216,58 +213,27 @@
     }
 
     private void startVoiceInteractor() {
-        try {
-            mVoiceInteractionManagerService.showSessionForActiveService(mShowCallback);
-        } catch (RemoteException e) {
-            Log.w(TAG, "Failed to call showSessionForActiveService", e);
-        }
+        mAssistUtils.showSessionForActiveService(mShowCallback);
     }
 
     public void launchVoiceAssistFromKeyguard() {
-        try {
-            mVoiceInteractionManagerService.launchVoiceAssistFromKeyguard();
-        } catch (RemoteException e) {
-            Log.w(TAG, "Failed to call launchVoiceAssistFromKeyguard", e);
-        }
+        mAssistUtils.launchVoiceAssistFromKeyguard();
     }
 
     private boolean getVoiceInteractorSupportsAssistGesture() {
-        try {
-            return mVoiceInteractionManagerService != null
-                    && mVoiceInteractionManagerService.activeServiceSupportsAssist();
-        } catch (RemoteException e) {
-            Log.w(TAG, "Failed to call activeServiceSupportsAssistGesture", e);
-            return false;
-        }
+        return mAssistUtils.activeServiceSupportsAssistGesture();
     }
 
     public boolean canVoiceAssistBeLaunchedFromKeyguard() {
-        try {
-            return mVoiceInteractionManagerService != null
-                    && mVoiceInteractionManagerService.activeServiceSupportsLaunchFromKeyguard();
-        } catch (RemoteException e) {
-            Log.w(TAG, "Failed to call activeServiceSupportsLaunchFromKeyguard", e);
-            return false;
-        }
+        return mAssistUtils.activeServiceSupportsLaunchFromKeyguard();
     }
 
     public ComponentName getVoiceInteractorComponentName() {
-        try {
-            return mVoiceInteractionManagerService.getActiveServiceComponentName();
-        } catch (RemoteException e) {
-            Log.w(TAG, "Failed to call getActiveServiceComponentName", e);
-            return null;
-        }
+        return mAssistUtils.getActiveServiceComponentName();
     }
 
     private boolean isVoiceSessionRunning() {
-        try {
-            return mVoiceInteractionManagerService != null
-                    && mVoiceInteractionManagerService.isSessionRunning();
-        } catch (RemoteException e) {
-            Log.w(TAG, "Failed to call isSessionRunning", e);
-            return false;
-        }
+        return mAssistUtils.isSessionRunning();
     }
 
     public void destroy() {
@@ -324,26 +290,11 @@
     }
 
     private void updateAssistInfo() {
-        final String setting = Settings.Secure.getStringForUser(mContext.getContentResolver(),
-                Settings.Secure.ASSISTANT, UserHandle.USER_CURRENT);
-        if (setting != null) {
-            mAssistComponent = ComponentName.unflattenFromString(setting);
-            return;
-        }
+        mAssistComponent = mAssistUtils.getAssistComponentForUser(UserHandle.USER_CURRENT);
+    }
 
-        // Fallback to keep backward compatible behavior when there is no user setting.
-        if (getVoiceInteractorSupportsAssistGesture()) {
-            mAssistComponent = getVoiceInteractorComponentName();
-            return;
-        }
-
-        Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE))
-                .getAssistIntent(mContext, false, UserHandle.USER_CURRENT);
-        if (intent != null) {
-            mAssistComponent = intent.getComponent();
-            return;
-        }
-
-        mAssistComponent = null;
+    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+        pw.println("AssistManager state:");
+        pw.print("  mAssistComponent="); pw.println(mAssistComponent);
     }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index f00fed5..c06b34f 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -371,7 +371,6 @@
         @Override
         public void onDeviceProvisioned() {
             sendUserPresentBroadcast();
-            updateInputRestricted();
         }
 
         @Override
@@ -947,7 +946,7 @@
      * was suppressed by an app that disabled the keyguard or we haven't been provisioned yet.
      */
     public boolean isInputRestricted() {
-        return mShowing || mNeedToReshowWhenReenabled || shouldWaitForProvisioning();
+        return mShowing || mNeedToReshowWhenReenabled;
     }
 
     private void updateInputRestricted() {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
index c8212c2..9761cd1 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
@@ -242,6 +242,9 @@
     }
 
     private void handleSetTileVisibility(View v, int visibility) {
+        if (visibility == VISIBLE && !mGridContentVisible) {
+            visibility = INVISIBLE;
+        }
         if (visibility == v.getVisibility()) return;
         v.setVisibility(visibility);
     }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index c77e7f0..69198ed 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -2687,6 +2687,9 @@
         if (mNextAlarmController != null) {
             mNextAlarmController.dump(fd, pw, args);
         }
+        if (mAssistManager != null) {
+            mAssistManager.dump(fd, pw, args);
+        }
         if (mSecurityController != null) {
             mSecurityController.dump(fd, pw, args);
         }
diff --git a/services/core/java/com/android/server/am/BatteryStatsService.java b/services/core/java/com/android/server/am/BatteryStatsService.java
index b56e326..c973386 100644
--- a/services/core/java/com/android/server/am/BatteryStatsService.java
+++ b/services/core/java/com/android/server/am/BatteryStatsService.java
@@ -1167,6 +1167,10 @@
             BluetoothActivityEnergyInfo info = adapter.getControllerActivityEnergyInfo(
                     BluetoothAdapter.ACTIVITY_ENERGY_INFO_REFRESHED);
             if (info != null && info.isValid()) {
+                if (info.getControllerEnergyUsed() < 0 || info.getControllerIdleTimeMillis() < 0 ||
+                        info.getControllerRxTimeMillis() < 0 || info.getControllerTxTimeMillis() < 0) {
+                    Slog.wtf(TAG, "Bluetooth energy data is invalid: " + info);
+                }
                 return info;
             }
         }
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index 7303298..bcfee30 100644
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -84,7 +84,7 @@
      * from config.xml under apps/Contacts.
      */
     public static final String
-            KEY_ENABLE_DIALER_KEY_VIBRATION_BOOL = "key_enable_dialer_vibration_bool";
+            KEY_ENABLE_DIALER_KEY_VIBRATION_BOOL = "enable_dialer_vibration_bool";
 
     /** Flag indicating if dtmf tone type is enabled */
     public static final String KEY_DTMF_TYPE_ENABLED_BOOL = "dtmf_type_enabled_bool";
@@ -185,6 +185,13 @@
      */
     public static final String KEY_CARRIER_VOLTE_AVAILABLE_BOOL = "carrier_volte_available_bool";
 
+    /**
+     * Flag specifying whether WFC over IMS should be available for carrier: independent of
+     * carrier provisioning. If false: hard disabled. If true: then depends on carrier
+     * provisioning, availability etc.
+     */
+    public static final String KEY_CARRIER_WFC_IMS_AVAILABLE_BOOL = "carrier_wfc_ims_available_bool";
+
     /** Flag specifying whether VoLTE availability is based on provisioning. */
     public static final String KEY_CARRIER_VOLTE_PROVISIONED_BOOL = "carrier_volte_provisioned_bool";
 
@@ -200,6 +207,13 @@
      */
     public static final String KEY_VOLTE_REPLACEMENT_RAT_INT = "volte_replacement_rat_int";
 
+    /**
+     * The default sim call manager to use when the default dialer doesn't implement one. A sim call
+     * manager can control and route outgoing and incoming phone calls, even if they're placed
+     * using another connection service (PSTN, for example).
+     */
+    public static final String KEY_DEFAULT_SIM_CALL_MANAGER_STRING = "default_sim_call_manager_string";
+
     /* The following 3 fields are related to carrier visual voicemail. */
 
     /**
@@ -306,6 +320,7 @@
         sDefaults.putBoolean(KEY_AUTO_RETRY_ENABLED_BOOL, false);
         sDefaults.putBoolean(KEY_CARRIER_SETTINGS_ENABLE_BOOL, false);
         sDefaults.putBoolean(KEY_CARRIER_VOLTE_AVAILABLE_BOOL, false);
+        sDefaults.putBoolean(KEY_CARRIER_WFC_IMS_AVAILABLE_BOOL, false);
         sDefaults.putBoolean(KEY_CARRIER_VOLTE_PROVISIONED_BOOL, false);
         sDefaults.putBoolean(KEY_CARRIER_VOLTE_TTY_SUPPORTED_BOOL, true);
         sDefaults.putBoolean(KEY_DISABLE_CDMA_ACTIVATION_CODE_BOOL, false);
@@ -328,6 +343,7 @@
         sDefaults.putBoolean(KEY_VOICE_PRIVACY_DISABLE_UI_BOOL, false);
         sDefaults.putBoolean(KEY_WORLD_PHONE_BOOL, false);
         sDefaults.putInt(KEY_VOLTE_REPLACEMENT_RAT_INT, 0);
+        sDefaults.putString(KEY_DEFAULT_SIM_CALL_MANAGER_STRING, "");
         sDefaults.putString(KEY_VVM_DESTINATION_NUMBER_STRING, "");
         sDefaults.putInt(KEY_VVM_PORT_NUMBER_INT, 0);
         sDefaults.putString(KEY_VVM_TYPE_STRING, "");
diff --git a/wifi/java/android/net/wifi/WifiActivityEnergyInfo.java b/wifi/java/android/net/wifi/WifiActivityEnergyInfo.java
index 0f73342..035317e 100644
--- a/wifi/java/android/net/wifi/WifiActivityEnergyInfo.java
+++ b/wifi/java/android/net/wifi/WifiActivityEnergyInfo.java
@@ -39,22 +39,22 @@
     /**
      * @hide
      */
-    public int mControllerTxTimeMs;
+    public long mControllerTxTimeMs;
 
     /**
      * @hide
      */
-    public int mControllerRxTimeMs;
+    public long mControllerRxTimeMs;
 
     /**
      * @hide
      */
-    public int mControllerIdleTimeMs;
+    public long mControllerIdleTimeMs;
 
     /**
      * @hide
      */
-    public int mControllerEnergyUsed;
+    public long mControllerEnergyUsed;
 
     public static final int STACK_STATE_INVALID = 0;
     public static final int STACK_STATE_STATE_ACTIVE = 1;
@@ -62,7 +62,7 @@
     public static final int STACK_STATE_STATE_IDLE = 3;
 
     public WifiActivityEnergyInfo(long timestamp, int stackState,
-                                  int txTime, int rxTime, int idleTime, int energyUsed) {
+                                  long txTime, long rxTime, long idleTime, long energyUsed) {
         mTimestamp = timestamp;
         mStackState = stackState;
         mControllerTxTimeMs = txTime;
@@ -88,10 +88,10 @@
         public WifiActivityEnergyInfo createFromParcel(Parcel in) {
             long timestamp = in.readLong();
             int stackState = in.readInt();
-            int txTime = in.readInt();
-            int rxTime = in.readInt();
-            int idleTime = in.readInt();
-            int energyUsed = in.readInt();
+            long txTime = in.readLong();
+            long rxTime = in.readLong();
+            long idleTime = in.readLong();
+            long energyUsed = in.readLong();
             return new WifiActivityEnergyInfo(timestamp, stackState,
                     txTime, rxTime, idleTime, energyUsed);
         }
@@ -103,10 +103,10 @@
     public void writeToParcel(Parcel out, int flags) {
         out.writeLong(mTimestamp);
         out.writeInt(mStackState);
-        out.writeInt(mControllerTxTimeMs);
-        out.writeInt(mControllerRxTimeMs);
-        out.writeInt(mControllerIdleTimeMs);
-        out.writeInt(mControllerEnergyUsed);
+        out.writeLong(mControllerTxTimeMs);
+        out.writeLong(mControllerRxTimeMs);
+        out.writeLong(mControllerIdleTimeMs);
+        out.writeLong(mControllerEnergyUsed);
     }
 
     public int describeContents() {
@@ -123,30 +123,29 @@
     /**
      * @return tx time in ms
      */
-    public int getControllerTxTimeMillis() {
-        return (int)mControllerTxTimeMs;
+    public long getControllerTxTimeMillis() {
+        return mControllerTxTimeMs;
     }
 
     /**
      * @return rx time in ms
      */
-    public int getControllerRxTimeMillis() {
-        return (int)mControllerRxTimeMs;
+    public long getControllerRxTimeMillis() {
+        return mControllerRxTimeMs;
     }
 
     /**
      * @return idle time in ms
      */
-    public int getControllerIdleTimeMillis() {
-        return (int)mControllerIdleTimeMs;
+    public long getControllerIdleTimeMillis() {
+        return mControllerIdleTimeMs;
     }
 
-
     /**
      * product of current(mA), voltage(V) and time(ms)
      * @return energy used
      */
-    public int getControllerEnergyUsed() {
+    public long getControllerEnergyUsed() {
         return mControllerEnergyUsed;
     }
     /**
@@ -160,8 +159,8 @@
      * @return if the record is valid
      */
     public boolean isValid() {
-        return ((getControllerTxTimeMillis() !=0) ||
-                (getControllerRxTimeMillis() !=0) ||
-                (getControllerIdleTimeMillis() !=0));
+        return ((mControllerTxTimeMs !=0) ||
+                (mControllerRxTimeMs !=0) ||
+                (mControllerIdleTimeMs !=0));
     }
 }