Merge "Fix bug 5159736 - Make DeviceDefault the default"
diff --git a/api/current.txt b/api/current.txt
index 903b084..c70cea8 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -2853,6 +2853,8 @@
     method public void setMessage(java.lang.CharSequence);
     method public void setView(android.view.View);
     method public void setView(android.view.View, int, int, int, int);
+    field public static final int THEME_DEVICE_DEFAULT_DARK = 4; // 0x4
+    field public static final int THEME_DEVICE_DEFAULT_LIGHT = 5; // 0x5
     field public static final int THEME_HOLO_DARK = 2; // 0x2
     field public static final int THEME_HOLO_LIGHT = 3; // 0x3
     field public static final int THEME_TRADITIONAL = 1; // 0x1
diff --git a/core/java/android/app/AlertDialog.java b/core/java/android/app/AlertDialog.java
index 491fcfe..c09e87f 100644
--- a/core/java/android/app/AlertDialog.java
+++ b/core/java/android/app/AlertDialog.java
@@ -75,6 +75,18 @@
      * the holographic alert theme with a light background.
      */
     public static final int THEME_HOLO_LIGHT = 3;
+
+    /**
+     * Special theme constant for {@link #AlertDialog(Context, int)}: use
+     * the device's default alert theme with a dark background.
+     */
+    public static final int THEME_DEVICE_DEFAULT_DARK = 4;
+
+    /**
+     * Special theme constant for {@link #AlertDialog(Context, int)}: use
+     * the device's default alert theme with a dark background.
+     */
+    public static final int THEME_DEVICE_DEFAULT_LIGHT = 5;
     
     protected AlertDialog(Context context) {
         this(context, resolveDialogTheme(context, 0), true);
@@ -113,6 +125,10 @@
             return com.android.internal.R.style.Theme_Holo_Dialog_Alert;
         } else if (resid == THEME_HOLO_LIGHT) {
             return com.android.internal.R.style.Theme_Holo_Light_Dialog_Alert;
+        } else if (resid == THEME_DEVICE_DEFAULT_DARK) {
+            return com.android.internal.R.style.Theme_DeviceDefault_Dialog_Alert;
+        } else if (resid == THEME_DEVICE_DEFAULT_LIGHT) {
+            return com.android.internal.R.style.Theme_DeviceDefault_Light_Dialog_Alert;
         } else if (resid >= 0x01000000) {   // start of real resource IDs.
             return resid;
         } else {
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index b4bdb2f..2139704 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -364,7 +364,8 @@
                                 Resources.selectSystemTheme(0,
                                         outerContext.getApplicationInfo().targetSdkVersion,
                                         com.android.internal.R.style.Theme_Dialog,
-                                        com.android.internal.R.style.Theme_Holo_Dialog)),
+                                        com.android.internal.R.style.Theme_Holo_Dialog,
+                                        com.android.internal.R.style.Theme_DeviceDefault_Dialog)),
                         ctx.mMainThread.getHandler());
                 }});
 
diff --git a/core/java/android/app/DialogFragment.java b/core/java/android/app/DialogFragment.java
index cce7cd6..8921578 100644
--- a/core/java/android/app/DialogFragment.java
+++ b/core/java/android/app/DialogFragment.java
@@ -204,7 +204,7 @@
     public void setStyle(int style, int theme) {
         mStyle = style;
         if (mStyle == STYLE_NO_FRAME || mStyle == STYLE_NO_INPUT) {
-            mTheme = com.android.internal.R.style.Theme_Holo_Dialog_NoFrame;
+            mTheme = com.android.internal.R.style.Theme_DeviceDefault_Dialog_NoFrame;
         }
         if (theme != 0) {
             mTheme = theme;
diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java
index f526923..24f8319 100755
--- a/core/java/android/content/res/Resources.java
+++ b/core/java/android/content/res/Resources.java
@@ -134,18 +134,24 @@
     /** @hide */
     public static int selectDefaultTheme(int curTheme, int targetSdkVersion) {
         return selectSystemTheme(curTheme, targetSdkVersion,
-                com.android.internal.R.style.Theme, com.android.internal.R.style.Theme_Holo);
+                com.android.internal.R.style.Theme,
+                com.android.internal.R.style.Theme_Holo,
+                com.android.internal.R.style.Theme_DeviceDefault);
     }
     
     /** @hide */
-    public static int selectSystemTheme(int curTheme, int targetSdkVersion, int orig, int holo) {
+    public static int selectSystemTheme(int curTheme, int targetSdkVersion,
+            int orig, int holo, int deviceDefault) {
         if (curTheme != 0) {
             return curTheme;
         }
         if (targetSdkVersion < Build.VERSION_CODES.HONEYCOMB) {
             return orig;
         }
-        return holo;
+        if (targetSdkVersion < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+            return holo;
+        }
+        return deviceDefault;
     }
     
     /**
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index 9481a88..370e22a 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -617,7 +617,9 @@
     @Override public void onCreate() {
         mTheme = Resources.selectSystemTheme(mTheme,
                 getApplicationInfo().targetSdkVersion,
-                android.R.style.Theme_InputMethod, android.R.style.Theme_Holo_InputMethod);
+                android.R.style.Theme_InputMethod,
+                android.R.style.Theme_Holo,
+                android.R.style.Theme_DeviceDefault_InputMethod);
         super.setTheme(mTheme);
         super.onCreate();
         mImm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index 6c7c58d..1e9ee7c 100644
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -287,6 +287,15 @@
          * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated}
          * to turn it off if needed, although this is strongly discouraged since
          * it will result in poor performance on larger screen devices.
+         * <li> The default theme for applications is now the "device default" theme:
+         *      {@link android.R.style#Theme_DeviceDefault}. This may be the
+         *      holo dark theme or a different dark theme defined by the specific device.
+         *      The {@link android.R.style#Theme_Holo} family must not be modified
+         *      for a device to be considered compatible. Applications that explicitly
+         *      request a theme from the Holo family will be guaranteed that these themes
+         *      will not change character within the same platform version. Applications
+         *      that wish to blend in with the device should use a theme from the
+         *      {@link android.R.style#Theme_DeviceDefault} family.
          * </ul>
          */
         public static final int ICE_CREAM_SANDWICH = CUR_DEVELOPMENT;
diff --git a/core/res/res/values/themes_device_defaults.xml b/core/res/res/values/themes_device_defaults.xml
index bf6329d..94d2c38 100644
--- a/core/res/res/values/themes_device_defaults.xml
+++ b/core/res/res/values/themes_device_defaults.xml
@@ -420,4 +420,8 @@
     <style name="Theme.DeviceDefault.Light.SearchBar" parent="Theme.DeviceDefault.Light.SearchBar">
 
     </style>
+
+    <style name="Theme.DeviceDefault.Dialog.NoFrame" parent="Theme.Holo.Dialog.NoFrame">
+    </style>
+
 </resources>