Merge "Tweak RT-animator scheduling" into lmp-mr1-dev
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 75411fe..27c1978 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -5942,8 +5942,7 @@
      * @hide
      */
     public void addClickableRectsForAccessibility(List<RectF> outRects) {
-        if (isClickable() || isLongClickable()
-                || (mListenerInfo != null && mListenerInfo.mOnTouchListener != null)) {
+        if (isClickable() || isLongClickable()) {
             RectF bounds = new RectF();
             bounds.set(0, 0, getWidth(), getHeight());
             outRects.add(bounds);
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index 8a543ce..1c10422 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -3248,7 +3248,10 @@
 
         TelecomManager telecomManager =
                 (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
+
+        final long ident = Binder.clearCallingIdentity();
         IsInCall = telecomManager.isInCall();
+        Binder.restoreCallingIdentity(ident);
 
         return (IsInCall || getMode() == AudioManager.MODE_IN_COMMUNICATION);
     }
diff --git a/services/core/java/com/android/server/SystemConfig.java b/services/core/java/com/android/server/SystemConfig.java
index 92fbc1e..eb89f21 100644
--- a/services/core/java/com/android/server/SystemConfig.java
+++ b/services/core/java/com/android/server/SystemConfig.java
@@ -25,7 +25,11 @@
 import android.util.Slog;
 import android.util.SparseArray;
 import android.util.Xml;
+
+import libcore.io.IoUtils;
+
 import com.android.internal.util.XmlUtils;
+
 import org.xmlpull.v1.XmlPullParser;
 import org.xmlpull.v1.XmlPullParserException;
 
@@ -60,6 +64,10 @@
     // system configuration files.
     final ArrayMap<String, FeatureInfo> mAvailableFeatures = new ArrayMap<>();
 
+    // These are the features which this device doesn't support; the OEM
+    // partition uses these to opt-out of features from the system image.
+    final ArraySet<String> mUnavailableFeatures = new ArraySet<>();
+
     public static final class PermissionEntry {
         public final String name;
         public int[] gids;
@@ -145,9 +153,11 @@
         }
 
         // Iterate over the files in the directory and scan .xml files
+        File platformFile = null;
         for (File f : libraryDir.listFiles()) {
             // We'll read platform.xml last
             if (f.getPath().endsWith("etc/permissions/platform.xml")) {
+                platformFile = f;
                 continue;
             }
 
@@ -163,10 +173,10 @@
             readPermissionsFromXml(f, onlyFeatures);
         }
 
-        // Read permissions from .../etc/permissions/platform.xml last so it will take precedence
-        final File permFile = new File(Environment.getRootDirectory(),
-                "etc/permissions/platform.xml");
-        readPermissionsFromXml(permFile, onlyFeatures);
+        // Read platform permissions last so it will take precedence
+        if (platformFile != null) {
+            readPermissionsFromXml(platformFile, onlyFeatures);
+        }
     }
 
     private void readPermissionsFromXml(File permFile, boolean onlyFeatures) {
@@ -298,7 +308,18 @@
                     XmlUtils.skipCurrentTag(parser);
                     continue;
 
-                } else if ("allow-in-power-save".equals(name)) {
+                } else if ("unavailable-feature".equals(name)) {
+                    String fname = parser.getAttributeValue(null, "name");
+                    if (fname == null) {
+                        Slog.w(TAG, "<unavailable-feature> without name at "
+                                + parser.getPositionDescription());
+                    } else {
+                        mUnavailableFeatures.add(fname);
+                    }
+                    XmlUtils.skipCurrentTag(parser);
+                    continue;
+
+                } else if ("allow-in-power-save".equals(name) && !onlyFeatures) {
                     String pkgname = parser.getAttributeValue(null, "package");
                     if (pkgname == null) {
                         Slog.w(TAG, "<allow-in-power-save> without package at "
@@ -309,7 +330,7 @@
                     XmlUtils.skipCurrentTag(parser);
                     continue;
 
-                } else if ("fixed-ime-app".equals(name)) {
+                } else if ("fixed-ime-app".equals(name) && !onlyFeatures) {
                     String pkgname = parser.getAttributeValue(null, "package");
                     if (pkgname == null) {
                         Slog.w(TAG, "<fixed-ime-app> without package at "
@@ -324,13 +345,19 @@
                     XmlUtils.skipCurrentTag(parser);
                     continue;
                 }
-
             }
-            permReader.close();
         } catch (XmlPullParserException e) {
-            Slog.w(TAG, "Got execption parsing permissions.", e);
+            Slog.w(TAG, "Got exception parsing permissions.", e);
         } catch (IOException e) {
-            Slog.w(TAG, "Got execption parsing permissions.", e);
+            Slog.w(TAG, "Got exception parsing permissions.", e);
+        } finally {
+            IoUtils.closeQuietly(permReader);
+        }
+
+        for (String fname : mUnavailableFeatures) {
+            if (mAvailableFeatures.remove(fname) != null) {
+                Slog.d(TAG, "Removed unavailable feature " + fname);
+            }
         }
     }
 
diff --git a/telephony/java/android/telephony/RadioAccessFamily.java b/telephony/java/android/telephony/RadioAccessFamily.java
index 734fc68..d10a7ea 100644
--- a/telephony/java/android/telephony/RadioAccessFamily.java
+++ b/telephony/java/android/telephony/RadioAccessFamily.java
@@ -136,16 +136,59 @@
     };
 
     public static int getRafFromNetworkType(int type) {
-        // TODO map from RILConstants.NETWORK_TYPE_* to RAF_*
+        final int GSM = RAF_GSM | RAF_GPRS | RAF_EDGE;
+        final int HS = RAF_HSUPA | RAF_HSDPA | RAF_HSPA | RAF_HSPAP;
+        final int CDMA = RAF_IS95A | RAF_IS95B | RAF_1xRTT;
+        final int EVDO = RAF_EVDO_0 | RAF_EVDO_A | RAF_EVDO_B;
+        final int WCDMA = HS | RAF_UMTS;
+
+        int raf;
+
         switch (type) {
             case RILConstants.NETWORK_MODE_WCDMA_PREF:
-            case RILConstants.NETWORK_MODE_GSM_UMTS:
-                return RAF_UMTS | RAF_GSM;
+                raf = GSM | WCDMA;
+                break;
             case RILConstants.NETWORK_MODE_GSM_ONLY:
-                return RAF_GSM;
+                raf = GSM;
+                break;
+            case RILConstants.NETWORK_MODE_WCDMA_ONLY:
+                raf = WCDMA;
+                break;
+            case RILConstants.NETWORK_MODE_GSM_UMTS:
+                raf = GSM | WCDMA;
+                break;
+            case RILConstants.NETWORK_MODE_CDMA:
+                raf = CDMA;
+                break;
+            case RILConstants.NETWORK_MODE_LTE_CDMA_EVDO:
+                raf = RAF_LTE | CDMA | EVDO;
+                break;
+            case RILConstants.NETWORK_MODE_LTE_GSM_WCDMA:
+                raf = RAF_LTE | GSM | WCDMA;
+                break;
+            case RILConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA:
+                raf = RAF_LTE | CDMA | EVDO | GSM | WCDMA;
+                break;
+            case RILConstants.NETWORK_MODE_LTE_ONLY:
+                raf = RAF_LTE;
+                break;
+            case RILConstants.NETWORK_MODE_LTE_WCDMA:
+                raf = RAF_LTE | WCDMA;
+                break;
+            case RILConstants.NETWORK_MODE_CDMA_NO_EVDO:
+                raf = CDMA;
+                break;
+            case RILConstants.NETWORK_MODE_EVDO_NO_CDMA:
+                raf = EVDO;
+                break;
+            case RILConstants.NETWORK_MODE_GLOBAL:
+                raf = GSM | WCDMA | CDMA | EVDO;
+                break;
             default:
-                return RAF_UNKNOWN;
+                raf = RAF_UNKNOWN;
+                break;
         }
+        return raf;
     }
 }