Merge "Incorporate feedback on new wallpaper-related APIs" into nyc-dev
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index a1b7e0e..a30a606 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -102,7 +102,6 @@
 import android.view.WindowManager;
 import android.view.WindowManagerGlobal;
 import android.renderscript.RenderScriptCacheDir;
-import android.security.keystore.AndroidKeyStoreProvider;
 import android.system.Os;
 import android.system.OsConstants;
 import android.system.ErrnoException;
@@ -5991,8 +5990,6 @@
         // Set the reporter for event logging in libcore
         EventLogger.setReporter(new EventLoggingReporter());
 
-        AndroidKeyStoreProvider.install();
-
         // Make sure TrustedCertificateStore looks in the right place for CA certificates
         final File configDir = Environment.getUserConfigDirectory(UserHandle.myUserId());
         TrustedCertificateStore.setDefaultUserDirectory(configDir);
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java
index a3e41e4..006d1ec 100644
--- a/core/java/com/android/internal/os/ZygoteInit.java
+++ b/core/java/com/android/internal/os/ZygoteInit.java
@@ -28,6 +28,7 @@
 import android.os.SystemClock;
 import android.os.SystemProperties;
 import android.os.Trace;
+import android.security.keystore.AndroidKeyStoreProvider;
 import android.system.ErrnoException;
 import android.system.Os;
 import android.system.OsConstants;
@@ -223,7 +224,7 @@
     }
 
     /**
-     * Warm up the providers that are already registered.
+     * Register AndroidKeyStoreProvider and warm up the providers that are already registered.
      *
      * By doing it here we avoid that each app does it when requesting a service from the
      * provider for the first time.
@@ -231,12 +232,23 @@
     private static void warmUpJcaProviders() {
         long startTime = SystemClock.uptimeMillis();
         Trace.traceBegin(
+                Trace.TRACE_TAG_DALVIK, "Starting installation of AndroidKeyStoreProvider");
+        // AndroidKeyStoreProvider.install() manipulates the list of JCA providers to insert
+        // preferred providers. Note this is not done via security.properties as the JCA providers
+        // are not on the classpath in the case of, for example, raw dalvikvm runtimes.
+        AndroidKeyStoreProvider.install();
+        Log.i(TAG, "Installed AndroidKeyStoreProvider in "
+                + (SystemClock.uptimeMillis() - startTime) + "ms.");
+        Trace.traceEnd(Trace.TRACE_TAG_DALVIK);
+
+        startTime = SystemClock.uptimeMillis();
+        Trace.traceBegin(
                 Trace.TRACE_TAG_DALVIK, "Starting warm up of JCA providers");
         for (Provider p : Security.getProviders()) {
             p.warmUpServiceProvision();
         }
         Log.i(TAG, "Warmed up JCA providers in "
-                + (SystemClock.uptimeMillis()-startTime) + "ms.");
+                + (SystemClock.uptimeMillis() - startTime) + "ms.");
         Trace.traceEnd(Trace.TRACE_TAG_DALVIK);
     }
 
diff --git a/docs/html/guide/topics/graphics/hardware-accel.jd b/docs/html/guide/topics/graphics/hardware-accel.jd
index ca7255b..b82c56b 100644
--- a/docs/html/guide/topics/graphics/hardware-accel.jd
+++ b/docs/html/guide/topics/graphics/hardware-accel.jd
@@ -327,30 +327,6 @@
         <td class="value_pos">18</td>
     </tr>
     <tr>
-        <td class="label_pos">drawArc()</td>
-        <td class="value_pos">21</td>
-    </tr>
-    <tr>
-        <td class="label_pos">drawRoundRect()</td>
-        <td class="value_pos">21</td>
-    </tr>
-    <tr>
-        <td class="label_pos">saveLayer() with RectF dimensions</td>
-        <td class="value_pos">21</td>
-    </tr>
-    <tr>
-        <td class="label_pos">saveLayer() with float dimensions</td>
-        <td class="value_pos">21</td>
-    </tr>
-    <tr>
-        <td class="label_pos">saveLayerAlpha() with RectF dimensions</td>
-        <td class="value_pos">21</td>
-    </tr>
-    <tr>
-        <td class="label_pos">saveLayerAlpha() with float dimensions</td>
-        <td class="value_pos">21</td>
-    </tr>
-    <tr>
         <td colspan="5" class="s5">Paint</td>
     </tr>
     <tr>
@@ -398,26 +374,6 @@
         <td class="value_neg">&#10007;</td>
     </tr>
     <tr>
-        <td class="label_pos">getFontFeatureSettings()</td>
-        <td class="value_pos">21</td>
-    </tr>
-    <tr>
-        <td class="label_pos">isElegantTextHeight()</td>
-        <td class="value_pos">21</td>
-    </tr>
-    <tr>
-        <td class="label_pos">isElegantTextHeight()</td>
-        <td class="value_pos">21</td>
-    </tr>
-    <tr>
-        <td class="label_pos">setFontFeatureSettings()</td>
-        <td class="value_pos">21</td>
-    </tr>
-    <tr>
-        <td class="label_pos">setLetterSpacing()</td>
-        <td class="value_pos">21</td>
-    </tr>
-    <tr>
         <td colspan="5" class="s5">Xfermode</td>
     </tr>
     <tr>
diff --git a/location/java/android/location/GnssStatus.java b/location/java/android/location/GnssStatus.java
index e834c30..e68821b 100644
--- a/location/java/android/location/GnssStatus.java
+++ b/location/java/android/location/GnssStatus.java
@@ -146,13 +146,11 @@
      * <ul>
      * <li>GPS: 1-32</li>
      * <li>SBAS: 120-151, 183-192</li>
-     * <li>GLONASS:
+     * <li>GLONASS: One of: OSN, or FCN+100
      * <ul>
-     *   <li>The least significant 8 bits, signed, are the orbital slot number (OSN) in the range
-     *   from 1-24, if known, or -127 if unknown</li>
-     *   <li>The next least signficant 8 bits, signed, are the frequency channel number (FCN) in the
-     *   range from -7 to +6, if known, and -127, if unknown</li>
-     *   <li>At least one of the two (FCN &amp; OSN) shall be set to a known value</li>
+     *   <li>1-24 as the orbital slot number (OSN) (preferred, if known)</li>
+     *   <li>93-106 as the frequency channel number (FCN) (-7 to +6) plus 100.
+     *   i.e. encode FCN of -7 as 93, 0 as 100, and +6 as 106</li>
      * </ul></li>
      * <li>QZSS: 193-200</li>
      * <li>Galileo: 1-36</li>
diff --git a/location/java/android/location/GpsStatus.java b/location/java/android/location/GpsStatus.java
index 038247b..5561b22 100644
--- a/location/java/android/location/GpsStatus.java
+++ b/location/java/android/location/GpsStatus.java
@@ -32,6 +32,8 @@
 @Deprecated
 public final class GpsStatus {
     private static final int NUM_SATELLITES = 255;
+    private static final int GLONASS_SVID_OFFSET = 64;
+    private static final int BEIDOU_SVID_OFFSET = 200;
 
     /* These package private values are modified by the LocationManager class */
     private int mTimeToFirstFix;
@@ -153,11 +155,22 @@
             final int constellationType =
                     (svidWithFlags[i] >> GnssStatus.CONSTELLATION_TYPE_SHIFT_WIDTH)
                     & GnssStatus.CONSTELLATION_TYPE_MASK;
-            // Skip all non-GPS satellites.
-            if (constellationType != GnssStatus.CONSTELLATION_GPS) {
+            int prn = svidWithFlags[i] >> GnssStatus.SVID_SHIFT_WIDTH;
+            // Other satellites passed through these APIs before GnssSvStatus was availble.
+            // GPS, SBAS & QZSS can pass through at their nominally
+            // assigned prn number (as long as it fits in the valid 0-255 range below.)
+            // Glonass, and Beidou are passed through with the defacto standard offsets
+            // Other future constellation reporting (e.g. Galileo) needs to use
+            // GnssSvStatus on (N level) HAL & Java layers.
+            if (constellationType == GnssStatus.CONSTELLATION_GLONASS) {
+                prn += GLONASS_SVID_OFFSET;
+            } else if (constellationType == GnssStatus.CONSTELLATION_BEIDOU) {
+                prn += BEIDOU_SVID_OFFSET;
+            } else if ((constellationType != GnssStatus.CONSTELLATION_GPS) &&
+                    (constellationType != GnssStatus.CONSTELLATION_QZSS) &&
+                    (constellationType != GnssStatus.CONSTELLATION_SBAS)) {
                 continue;
             }
-            int prn = svidWithFlags[i] >> GnssStatus.SVID_SHIFT_WIDTH;
             if (prn > 0 && prn <= NUM_SATELLITES) {
                 GpsSatellite satellite = mSatellites.get(prn);
                 if (satellite == null) {
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothAdapter.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothAdapter.java
index 9c5abf3..2683609 100755
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothAdapter.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothAdapter.java
@@ -208,7 +208,7 @@
         return false;
     }
 
-    public void setBluetoothEnabled(boolean enabled) {
+    public boolean setBluetoothEnabled(boolean enabled) {
         boolean success = enabled
                 ? mAdapter.enable()
                 : mAdapter.disable();
@@ -225,6 +225,7 @@
 
             syncBluetoothState();
         }
+        return success;
     }
 
     public BluetoothDevice getRemoteDevice(String address) {
diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java
index 0a814ab..5e8687a 100644
--- a/services/core/java/com/android/server/BluetoothManagerService.java
+++ b/services/core/java/com/android/server/BluetoothManagerService.java
@@ -613,7 +613,20 @@
                                                 "Need BLUETOOTH ADMIN permission");
         if (DBG) {
             Slog.d(TAG,"enable():  mBluetooth =" + mBluetooth +
-                    " mBinding = " + mBinding);
+                    " mBinding = " + mBinding + " mState = " + mState);
+        }
+        // We do not honor ON requests when the adapter is already turned ON or in the process of
+        // turning ON.
+        // As a protective mechanism to make sure that the native stack gets cleaned up properly
+        // before turning it back ON we ignore requests while the bluetooth is turning OFF.
+        // Bug: b/28318203
+        if (mState == BluetoothAdapter.STATE_BLE_TURNING_OFF ||
+            mState == BluetoothAdapter.STATE_TURNING_OFF ||
+            mState == BluetoothAdapter.STATE_ON ||
+            mState == BluetoothAdapter.STATE_BLE_ON ||
+            mState == BluetoothAdapter.STATE_TURNING_ON ||
+            mState == BluetoothAdapter.STATE_BLE_TURNING_ON) {
+            return false;
         }
 
         synchronized(mReceiver) {
diff --git a/services/core/jni/com_android_server_location_GnssLocationProvider.cpp b/services/core/jni/com_android_server_location_GnssLocationProvider.cpp
index c5c90e0..e29452a 100644
--- a/services/core/jni/com_android_server_location_GnssLocationProvider.cpp
+++ b/services/core/jni/com_android_server_location_GnssLocationProvider.cpp
@@ -72,6 +72,18 @@
 #define GPS_MAX_SATELLITE_COUNT 32
 #define GNSS_MAX_SATELLITE_COUNT 64
 
+// Let these through, with ID remapped by offset
+#define GLONASS_SVID_OFFSET 64
+#define GLONASS_SVID_COUNT 24
+#define BEIDOU_SVID_OFFSET 200
+#define BEIDOU_SVID_COUNT 35
+
+// Let these through, with no ID remapping
+#define SBAS_SVID_MIN 120
+#define SBAS_SVID_MAX 151
+#define QZSS_SVID_MIN 193
+#define QZSS_SVID_MAX 200
+
 #define SVID_SHIFT_WIDTH 7
 #define CONSTELLATION_TYPE_SHIFT_WIDTH 3
 
@@ -134,8 +146,21 @@
     for (size_t i = 0; i < sGnssSvListSize; i++) {
         GnssSvInfo& info = sGnssSvList[i];
         info.svid = sv_status->sv_list[i].prn;
+        // Defacto mapping from the overused API that was designed for GPS-only
         if (info.svid >=1 && info.svid <= 32) {
             info.constellation = GNSS_CONSTELLATION_GPS;
+        } else if (info.svid > GLONASS_SVID_OFFSET &&
+                   info.svid <= GLONASS_SVID_OFFSET + GLONASS_SVID_COUNT) {
+            info.constellation = GNSS_CONSTELLATION_GLONASS;
+            info.svid -= GLONASS_SVID_OFFSET;
+        } else if (info.svid > BEIDOU_SVID_OFFSET &&
+                   info.svid <= BEIDOU_SVID_OFFSET + BEIDOU_SVID_COUNT) {
+            info.constellation = GNSS_CONSTELLATION_BEIDOU;
+            info.svid -= BEIDOU_SVID_OFFSET;
+        } else if (info.svid >= SBAS_SVID_MIN && info.svid <= SBAS_SVID_MAX) {
+            info.constellation = GNSS_CONSTELLATION_SBAS;
+        } else if (info.svid >= QZSS_SVID_MIN && info.svid <= QZSS_SVID_MAX) {
+            info.constellation = GNSS_CONSTELLATION_QZSS;
         } else {
             ALOGD("Unknown constellation type with Svid = %d.", info.svid);
             info.constellation = GNSS_CONSTELLATION_UNKNOWN;
@@ -144,7 +169,8 @@
         info.elevation = sv_status->sv_list[i].elevation;
         info.azimuth = sv_status->sv_list[i].azimuth;
         info.flags = GNSS_SV_FLAGS_NONE;
-        if (info.svid > 0 && info.svid <= 32) {
+        // Only GPS info is valid for these fields, as these masks are just 32 bits, by GPS prn
+        if (info.constellation == GNSS_CONSTELLATION_GPS) {
             int32_t this_svid_mask = (1 << (info.svid - 1));
             if ((ephemeris_mask & this_svid_mask) != 0) {
                 info.flags |= GNSS_SV_FLAGS_HAS_EPHEMERIS_DATA;