Merge "Fix 4462474: Fixes crash on 7" tablet due to using wrong resource" into honeycomb-mr2
diff --git a/api/current.xml b/api/current.xml
index 393e542..a44442a 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -57911,6 +57911,17 @@
visibility="public"
>
</field>
+<field name="CONFIG_SMALLEST_SCREEN_SIZE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="2048"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
<field name="CONFIG_TOUCHSCREEN"
type="int"
transient="false"
@@ -63995,6 +64006,17 @@
visibility="public"
>
</field>
+<field name="SMALLEST_SCREEN_WIDTH_DP_UNDEFINED"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="0"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
<field name="TOUCHSCREEN_FINGER"
type="int"
transient="false"
@@ -64268,6 +64290,16 @@
visibility="public"
>
</field>
+<field name="smallestScreenWidthDp"
+ type="int"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
<field name="touchscreen"
type="int"
transient="false"
diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java
index db8d5e9..9cb57be 100644
--- a/core/java/android/app/SearchDialog.java
+++ b/core/java/android/app/SearchDialog.java
@@ -29,12 +29,13 @@
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
-import android.os.SystemClock;
import android.speech.RecognizerIntent;
import android.text.InputType;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
+import android.util.TypedValue;
+import android.view.ActionMode;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -50,9 +51,6 @@
import android.widget.SearchView;
import android.widget.TextView;
-import java.util.WeakHashMap;
-import java.util.concurrent.atomic.AtomicLong;
-
/**
* Search dialog. This is controlled by the
* SearchManager and runs in the current foreground process.
@@ -110,13 +108,20 @@
}
};
+ static int resolveDialogTheme(Context context) {
+ TypedValue outValue = new TypedValue();
+ context.getTheme().resolveAttribute(com.android.internal.R.attr.searchDialogTheme,
+ outValue, true);
+ return outValue.resourceId;
+ }
+
/**
* Constructor - fires it up and makes it look like the search UI.
*
* @param context Application Context we can use for system acess
*/
public SearchDialog(Context context, SearchManager searchManager) {
- super(context, com.android.internal.R.style.Theme_SearchBar);
+ super(context, resolveDialogTheme(context));
// Save voice intent for later queries/launching
mVoiceWebSearchIntent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
@@ -642,6 +647,14 @@
}
return super.dispatchKeyEventPreIme(event);
}
+
+ /**
+ * Don't allow action modes in a SearchBar, it looks silly.
+ */
+ @Override
+ public ActionMode startActionModeForChild(View child, ActionMode.Callback callback) {
+ return null;
+ }
}
private boolean isEmpty(AutoCompleteTextView actv) {
diff --git a/core/java/android/content/pm/ActivityInfo.java b/core/java/android/content/pm/ActivityInfo.java
index 64c437d..4285388 100644
--- a/core/java/android/content/pm/ActivityInfo.java
+++ b/core/java/android/content/pm/ActivityInfo.java
@@ -340,6 +340,12 @@
public static final int CONFIG_SCREEN_SIZE = 0x0400;
/**
* Bit in {@link #configChanges} that indicates that the activity
+ * can itself handle the smallest screen size. Set from the
+ * {@link android.R.attr#configChanges} attribute.
+ */
+ public static final int CONFIG_SMALLEST_SCREEN_SIZE = 0x0800;
+ /**
+ * Bit in {@link #configChanges} that indicates that the activity
* can itself handle changes to the font scaling factor. Set from the
* {@link android.R.attr#configChanges} attribute. This is
* not a core resource configutation, but a higher-level value, so its
@@ -364,6 +370,7 @@
0x0800, // SCREEN LAYOUT
0x1000, // UI MODE
0x0200, // SCREEN SIZE
+ 0x2000, // SMALLEST SCREEN SIZE
};
/** @hide
* Convert Java change bits to native.
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 2a61c56..10799a4 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -396,7 +396,7 @@
int cookie = assmgr.addAssetPath(mArchiveSourcePath);
if (cookie != 0) {
res = new Resources(assmgr, metrics, null);
- assmgr.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ assmgr.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Build.VERSION.RESOURCES_SDK_INT);
parser = assmgr.openXmlResourceParser(cookie, "AndroidManifest.xml");
assetError = false;
@@ -596,7 +596,7 @@
AssetManager assmgr = null;
try {
assmgr = new AssetManager();
- assmgr.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ assmgr.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Build.VERSION.RESOURCES_SDK_INT);
int cookie = assmgr.addAssetPath(packageFilePath);
parser = assmgr.openXmlResourceParser(cookie, "AndroidManifest.xml");
@@ -1933,7 +1933,8 @@
0);
if (owner.applicationInfo.targetSdkVersion
< android.os.Build.VERSION_CODES.HONEYCOMB_MR2) {
- a.info.configChanges |= ActivityInfo.CONFIG_SCREEN_SIZE;
+ a.info.configChanges |= ActivityInfo.CONFIG_SCREEN_SIZE
+ | ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE;
}
a.info.softInputMode = sa.getInt(
com.android.internal.R.styleable.AndroidManifestActivity_windowSoftInputMode,
diff --git a/core/java/android/content/res/AssetManager.java b/core/java/android/content/res/AssetManager.java
index afa68c3..72fca0a 100644
--- a/core/java/android/content/res/AssetManager.java
+++ b/core/java/android/content/res/AssetManager.java
@@ -652,8 +652,8 @@
public native final void setConfiguration(int mcc, int mnc, String locale,
int orientation, int touchscreen, int density, int keyboard,
int keyboardHidden, int navigation, int screenWidth, int screenHeight,
- int screenWidthDp, int screenHeightDp, int screenLayout, int uiMode,
- int majorVersion);
+ int smallestScreenWidthDp, int screenWidthDp, int screenHeightDp,
+ int screenLayout, int uiMode, int majorVersion);
/**
* Retrieve the resource identifier for the given resource name.
diff --git a/core/java/android/content/res/Configuration.java b/core/java/android/content/res/Configuration.java
index 0de08f2..12ec258 100644
--- a/core/java/android/content/res/Configuration.java
+++ b/core/java/android/content/res/Configuration.java
@@ -259,6 +259,15 @@
*/
public int screenHeightDp;
+ public static final int SMALLEST_SCREEN_WIDTH_DP_UNDEFINED = 0;
+
+ /**
+ * The smallest screen size an application will see in normal operation.
+ * This is the smallest value of both screenWidthDp and screenHeightDp
+ * in both portrait and landscape.
+ */
+ public int smallestScreenWidthDp;
+
/**
* @hide Internal book-keeping.
*/
@@ -298,6 +307,7 @@
uiMode = o.uiMode;
screenWidthDp = o.screenWidthDp;
screenHeightDp = o.screenHeightDp;
+ smallestScreenWidthDp = o.smallestScreenWidthDp;
seq = o.seq;
}
@@ -315,6 +325,56 @@
} else {
sb.append(" (no locale)");
}
+ if (smallestScreenWidthDp != SMALLEST_SCREEN_WIDTH_DP_UNDEFINED) {
+ sb.append(" sw"); sb.append(smallestScreenWidthDp); sb.append("dp");
+ } else {
+ sb.append("?swdp");
+ }
+ if (screenWidthDp != SCREEN_WIDTH_DP_UNDEFINED) {
+ sb.append(" w"); sb.append(screenWidthDp); sb.append("dp");
+ } else {
+ sb.append("?wdp");
+ }
+ if (screenHeightDp != SCREEN_HEIGHT_DP_UNDEFINED) {
+ sb.append(" h"); sb.append(screenHeightDp); sb.append("dp");
+ } else {
+ sb.append("?hdp");
+ }
+ switch ((screenLayout&SCREENLAYOUT_SIZE_MASK)) {
+ case SCREENLAYOUT_SIZE_UNDEFINED: sb.append(" ?lsize"); break;
+ case SCREENLAYOUT_SIZE_SMALL: sb.append(" smll"); break;
+ case SCREENLAYOUT_SIZE_NORMAL: sb.append(" nrml"); break;
+ case SCREENLAYOUT_SIZE_LARGE: sb.append(" lrg"); break;
+ case SCREENLAYOUT_SIZE_XLARGE: sb.append(" xlrg"); break;
+ default: sb.append(" layoutSize=");
+ sb.append(screenLayout&SCREENLAYOUT_SIZE_MASK); break;
+ }
+ switch ((screenLayout&SCREENLAYOUT_LONG_MASK)) {
+ case SCREENLAYOUT_LONG_UNDEFINED: sb.append(" ?long"); break;
+ case SCREENLAYOUT_LONG_NO: /* not-long is not interesting to print */ break;
+ case SCREENLAYOUT_LONG_YES: sb.append(" long"); break;
+ default: sb.append(" layoutLong=");
+ sb.append(screenLayout&SCREENLAYOUT_LONG_MASK); break;
+ }
+ switch (orientation) {
+ case ORIENTATION_UNDEFINED: sb.append(" ?orien"); break;
+ case ORIENTATION_LANDSCAPE: sb.append(" land"); break;
+ case ORIENTATION_PORTRAIT: sb.append(" port"); break;
+ default: sb.append(" orien="); sb.append(orientation); break;
+ }
+ switch ((uiMode&UI_MODE_TYPE_MASK)) {
+ case UI_MODE_TYPE_UNDEFINED: sb.append(" ?uimode"); break;
+ case UI_MODE_TYPE_NORMAL: /* normal is not interesting to print */ break;
+ case UI_MODE_TYPE_DESK: sb.append(" desk"); break;
+ case UI_MODE_TYPE_CAR: sb.append(" car"); break;
+ default: sb.append(" uimode="); sb.append(uiMode&UI_MODE_TYPE_MASK); break;
+ }
+ switch ((uiMode&UI_MODE_NIGHT_MASK)) {
+ case UI_MODE_NIGHT_UNDEFINED: sb.append(" ?night"); break;
+ case UI_MODE_NIGHT_NO: /* not-night is not interesting to print */ break;
+ case UI_MODE_NIGHT_YES: sb.append(" night"); break;
+ default: sb.append(" night="); sb.append(uiMode&UI_MODE_NIGHT_MASK); break;
+ }
switch (touchscreen) {
case TOUCHSCREEN_UNDEFINED: sb.append(" ?touch"); break;
case TOUCHSCREEN_NOTOUCH: sb.append(" -touch"); break;
@@ -356,51 +416,6 @@
case NAVIGATIONHIDDEN_YES: sb.append("/h"); break;
default: sb.append("/"); sb.append(navigationHidden); break;
}
- switch (orientation) {
- case ORIENTATION_UNDEFINED: sb.append(" ?orien"); break;
- case ORIENTATION_LANDSCAPE: sb.append(" land"); break;
- case ORIENTATION_PORTRAIT: sb.append(" port"); break;
- default: sb.append(" orien="); sb.append(orientation); break;
- }
- switch ((screenLayout&SCREENLAYOUT_SIZE_MASK)) {
- case SCREENLAYOUT_SIZE_UNDEFINED: sb.append(" ?lsize"); break;
- case SCREENLAYOUT_SIZE_SMALL: sb.append(" smll"); break;
- case SCREENLAYOUT_SIZE_NORMAL: sb.append(" nrml"); break;
- case SCREENLAYOUT_SIZE_LARGE: sb.append(" lrg"); break;
- case SCREENLAYOUT_SIZE_XLARGE: sb.append(" xlrg"); break;
- default: sb.append(" layoutSize=");
- sb.append(screenLayout&SCREENLAYOUT_SIZE_MASK); break;
- }
- switch ((screenLayout&SCREENLAYOUT_LONG_MASK)) {
- case SCREENLAYOUT_LONG_UNDEFINED: sb.append(" ?long"); break;
- case SCREENLAYOUT_LONG_NO: /* not-long is not interesting to print */ break;
- case SCREENLAYOUT_LONG_YES: sb.append(" long"); break;
- default: sb.append(" layoutLong=");
- sb.append(screenLayout&SCREENLAYOUT_LONG_MASK); break;
- }
- switch ((uiMode&UI_MODE_TYPE_MASK)) {
- case UI_MODE_TYPE_UNDEFINED: sb.append(" ?uimode"); break;
- case UI_MODE_TYPE_NORMAL: /* normal is not interesting to print */ break;
- case UI_MODE_TYPE_DESK: sb.append(" desk"); break;
- case UI_MODE_TYPE_CAR: sb.append(" car"); break;
- default: sb.append(" uimode="); sb.append(uiMode&UI_MODE_TYPE_MASK); break;
- }
- switch ((uiMode&UI_MODE_NIGHT_MASK)) {
- case UI_MODE_NIGHT_UNDEFINED: sb.append(" ?night"); break;
- case UI_MODE_NIGHT_NO: /* not-night is not interesting to print */ break;
- case UI_MODE_NIGHT_YES: sb.append(" night"); break;
- default: sb.append(" night="); sb.append(uiMode&UI_MODE_NIGHT_MASK); break;
- }
- if (screenWidthDp != SCREEN_WIDTH_DP_UNDEFINED) {
- sb.append(" w"); sb.append(screenWidthDp); sb.append("dp");
- } else {
- sb.append("?wdp");
- }
- if (screenHeightDp != SCREEN_HEIGHT_DP_UNDEFINED) {
- sb.append(" h"); sb.append(screenHeightDp); sb.append("dp");
- } else {
- sb.append("?hdp");
- }
if (seq != 0) {
sb.append(" s.");
sb.append(seq);
@@ -428,6 +443,7 @@
uiMode = UI_MODE_TYPE_UNDEFINED;
screenWidthDp = SCREEN_WIDTH_DP_UNDEFINED;
screenHeightDp = SCREEN_HEIGHT_DP_UNDEFINED;
+ smallestScreenWidthDp = SMALLEST_SCREEN_WIDTH_DP_UNDEFINED;
seq = 0;
}
@@ -531,6 +547,11 @@
changed |= ActivityInfo.CONFIG_SCREEN_SIZE;
screenHeightDp = delta.screenHeightDp;
}
+ if (delta.smallestScreenWidthDp != SMALLEST_SCREEN_WIDTH_DP_UNDEFINED
+ && smallestScreenWidthDp != delta.smallestScreenWidthDp) {
+ changed |= ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE;
+ smallestScreenWidthDp = delta.smallestScreenWidthDp;
+ }
if (delta.seq != 0) {
seq = delta.seq;
@@ -564,7 +585,9 @@
* {@link android.content.pm.ActivityInfo#CONFIG_SCREEN_LAYOUT
* PackageManager.ActivityInfo.CONFIG_SCREEN_LAYOUT}, or
* {@link android.content.pm.ActivityInfo#CONFIG_SCREEN_SIZE
- * PackageManager.ActivityInfo.CONFIG_SCREEN_SIZE}.
+ * PackageManager.ActivityInfo.CONFIG_SCREEN_SIZE}, or
+ * {@link android.content.pm.ActivityInfo#CONFIG_SMALLEST_SCREEN_SIZE
+ * PackageManager.ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE}.
*/
public int diff(Configuration delta) {
int changed = 0;
@@ -625,6 +648,10 @@
&& screenHeightDp != delta.screenHeightDp) {
changed |= ActivityInfo.CONFIG_SCREEN_SIZE;
}
+ if (delta.smallestScreenWidthDp != SMALLEST_SCREEN_WIDTH_DP_UNDEFINED
+ && smallestScreenWidthDp != delta.smallestScreenWidthDp) {
+ changed |= ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE;
+ }
return changed;
}
@@ -708,6 +735,7 @@
dest.writeInt(uiMode);
dest.writeInt(screenWidthDp);
dest.writeInt(screenHeightDp);
+ dest.writeInt(smallestScreenWidthDp);
dest.writeInt(seq);
}
@@ -731,6 +759,7 @@
uiMode = source.readInt();
screenWidthDp = source.readInt();
screenHeightDp = source.readInt();
+ smallestScreenWidthDp = source.readInt();
seq = source.readInt();
}
@@ -795,6 +824,8 @@
n = this.screenWidthDp - that.screenWidthDp;
if (n != 0) return n;
n = this.screenHeightDp - that.screenHeightDp;
+ if (n != 0) return n;
+ n = this.smallestScreenWidthDp - that.smallestScreenWidthDp;
//if (n != 0) return n;
return n;
}
@@ -830,6 +861,7 @@
result = 31 * result + uiMode;
result = 31 * result + screenWidthDp;
result = 31 * result + screenHeightDp;
+ result = 31 * result + smallestScreenWidthDp;
return result;
}
}
diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java
index 540f704..a072e94 100755
--- a/core/java/android/content/res/Resources.java
+++ b/core/java/android/content/res/Resources.java
@@ -1458,6 +1458,7 @@
mConfiguration.touchscreen,
(int)(mMetrics.density*160), mConfiguration.keyboard,
keyboardHidden, mConfiguration.navigation, width, height,
+ mConfiguration.smallestScreenWidthDp,
mConfiguration.screenWidthDp, mConfiguration.screenHeightDp,
mConfiguration.screenLayout, mConfiguration.uiMode,
Build.VERSION.RESOURCES_SDK_INT);
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java
index c7cf459..086ed5a 100644
--- a/core/java/android/view/WindowManagerPolicy.java
+++ b/core/java/android/view/WindowManagerPolicy.java
@@ -464,16 +464,34 @@
public int getMaxWallpaperLayer();
/**
- * Return the display width available after excluding the window
- * decor.
+ * Return the display width available after excluding any screen
+ * decorations that can never be removed. That is, system bar or
+ * button bar.
*/
- public int getNonDecorDisplayWidth(int fullWidth);
+ public int getNonDecorDisplayWidth(int rotation, int fullWidth);
/**
- * Return the display height available after excluding the screen
- * decor.
+ * Return the display height available after excluding any screen
+ * decorations that can never be removed. That is, system bar or
+ * button bar.
*/
- public int getNonDecorDisplayHeight(int fullHeight);
+ public int getNonDecorDisplayHeight(int rotation, int fullHeight);
+
+ /**
+ * Return the available screen width that we should report for the
+ * configuration. This must be no larger than
+ * {@link #getNonDecorDisplayWidth(int, int)}; it may be smaller than
+ * that to account for more transient decoration like a status bar.
+ */
+ public int getConfigDisplayWidth(int rotation, int fullWidth);
+
+ /**
+ * Return the available screen height that we should report for the
+ * configuration. This must be no larger than
+ * {@link #getNonDecorDisplayHeight(int, int)}; it may be smaller than
+ * that to account for more transient decoration like a status bar.
+ */
+ public int getConfigDisplayHeight(int rotation, int fullHeight);
/**
* Return whether the given window should forcibly hide everything
diff --git a/core/java/android/view/inputmethod/InputMethodSubtype.java b/core/java/android/view/inputmethod/InputMethodSubtype.java
index 25f2229..807f6ce 100644
--- a/core/java/android/view/inputmethod/InputMethodSubtype.java
+++ b/core/java/android/view/inputmethod/InputMethodSubtype.java
@@ -60,8 +60,7 @@
mSubtypeLocale = locale != null ? locale : "";
mSubtypeMode = mode != null ? mode : "";
mSubtypeExtraValue = extraValue != null ? extraValue : "";
- mSubtypeHashCode = hashCodeInternal(mSubtypeNameResId, mSubtypeIconResId, mSubtypeLocale,
- mSubtypeMode, mSubtypeExtraValue);
+ mSubtypeHashCode = hashCodeInternal(mSubtypeLocale, mSubtypeMode, mSubtypeExtraValue);
}
InputMethodSubtype(Parcel source) {
@@ -74,8 +73,7 @@
mSubtypeMode = s != null ? s : "";
s = source.readString();
mSubtypeExtraValue = s != null ? s : "";
- mSubtypeHashCode = hashCodeInternal(mSubtypeNameResId, mSubtypeIconResId, mSubtypeLocale,
- mSubtypeMode, mSubtypeExtraValue);
+ mSubtypeHashCode = hashCodeInternal(mSubtypeLocale, mSubtypeMode, mSubtypeExtraValue);
}
/**
@@ -195,9 +193,8 @@
}
};
- private static int hashCodeInternal(int nameResId, int iconResId, String locale,
- String mode, String extraValue) {
- return Arrays.hashCode(new Object[] {nameResId, iconResId, locale, mode, extraValue});
+ private static int hashCodeInternal(String locale, String mode, String extraValue) {
+ return Arrays.hashCode(new Object[] {locale, mode, extraValue});
}
/**
diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java
index cc51911..891557d 100644
--- a/core/java/com/android/internal/widget/ActionBarView.java
+++ b/core/java/com/android/internal/widget/ActionBarView.java
@@ -28,6 +28,8 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.res.Configuration;
+import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
@@ -980,6 +982,21 @@
}
@Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+
+ // Make sure we reload positioning elements that may change with configuration.
+ Resources res = getContext().getResources();
+ final int imagePadding = res.getDimensionPixelSize(
+ com.android.internal.R.dimen.action_bar_home_image_padding);
+ final int upMargin = res.getDimensionPixelSize(
+ com.android.internal.R.dimen.action_bar_home_up_margin);
+ mIconView.setPadding(imagePadding, getPaddingTop(), imagePadding, getPaddingBottom());
+ ((LayoutParams) mUpView.getLayoutParams()).rightMargin = upMargin;
+ mUpView.requestLayout();
+ }
+
+ @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
measureChildWithMargins(mUpView, widthMeasureSpec, 0, heightMeasureSpec, 0);
final LayoutParams upLp = (LayoutParams) mUpView.getLayoutParams();
diff --git a/core/jni/android_content_res_Configuration.cpp b/core/jni/android_content_res_Configuration.cpp
index 28a43ab..5e09b38 100644
--- a/core/jni/android_content_res_Configuration.cpp
+++ b/core/jni/android_content_res_Configuration.cpp
@@ -40,6 +40,9 @@
jfieldID navigationHidden;
jfieldID orientation;
jfieldID uiMode;
+ jfieldID screenWidthDp;
+ jfieldID screenHeightDp;
+ jfieldID smallestScreenWidthDp;
} gConfigurationClassInfo;
void android_Configuration_getFromJava(
@@ -62,6 +65,11 @@
out->orientation = env->GetIntField(clazz, gConfigurationClassInfo.orientation);
out->uiMode = env->GetIntField(clazz, gConfigurationClassInfo.uiMode);
+
+ out->screenWidthDp = env->GetIntField(clazz, gConfigurationClassInfo.screenWidthDp);
+ out->screenHeightDp = env->GetIntField(clazz, gConfigurationClassInfo.screenHeightDp);
+ out->smallestScreenWidthDp = env->GetIntField(clazz,
+ gConfigurationClassInfo.smallestScreenWidthDp);
}
/*
@@ -110,6 +118,12 @@
"orientation", "I");
GET_FIELD_ID(gConfigurationClassInfo.uiMode, gConfigurationClassInfo.clazz,
"uiMode", "I");
+ GET_FIELD_ID(gConfigurationClassInfo.screenWidthDp, gConfigurationClassInfo.clazz,
+ "screenWidthDp", "I");
+ GET_FIELD_ID(gConfigurationClassInfo.screenHeightDp, gConfigurationClassInfo.clazz,
+ "screenHeightDp", "I");
+ GET_FIELD_ID(gConfigurationClassInfo.smallestScreenWidthDp, gConfigurationClassInfo.clazz,
+ "smallestScreenWidthDp", "I");
return AndroidRuntime::registerNativeMethods(env, "android/content/res/Configuration", gMethods,
NELEM(gMethods));
diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp
index 7a2d020..636d257 100644
--- a/core/jni/android_util_AssetManager.cpp
+++ b/core/jni/android_util_AssetManager.cpp
@@ -532,6 +532,7 @@
jint keyboard, jint keyboardHidden,
jint navigation,
jint screenWidth, jint screenHeight,
+ jint smallestScreenWidthDp,
jint screenWidthDp, jint screenHeightDp,
jint screenLayout, jint uiMode,
jint sdkVersion)
@@ -556,6 +557,7 @@
config.navigation = (uint8_t)navigation;
config.screenWidth = (uint16_t)screenWidth;
config.screenHeight = (uint16_t)screenHeight;
+ config.smallestScreenWidthDp = (uint16_t)smallestScreenWidthDp;
config.screenWidthDp = (uint16_t)screenWidthDp;
config.screenHeightDp = (uint16_t)screenHeightDp;
config.screenLayout = (uint8_t)screenLayout;
@@ -1696,7 +1698,7 @@
(void*) android_content_AssetManager_setLocale },
{ "getLocales", "()[Ljava/lang/String;",
(void*) android_content_AssetManager_getLocales },
- { "setConfiguration", "(IILjava/lang/String;IIIIIIIIIIIII)V",
+ { "setConfiguration", "(IILjava/lang/String;IIIIIIIIIIIIII)V",
(void*) android_content_AssetManager_setConfiguration },
{ "getResourceIdentifier","(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I",
(void*) android_content_AssetManager_getResourceIdentifier },
diff --git a/core/res/res/drawable-hdpi/cab_background_dark.9.png b/core/res/res/drawable-hdpi/cab_background_dark.9.png
deleted file mode 100644
index bc5db49..0000000
--- a/core/res/res/drawable-hdpi/cab_background_dark.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/cab_background_light.9.png b/core/res/res/drawable-hdpi/cab_background_light.9.png
deleted file mode 100644
index 1f45bc9..0000000
--- a/core/res/res/drawable-hdpi/cab_background_light.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/cab_background_opaque_holo_dark.9.png b/core/res/res/drawable-hdpi/cab_background_opaque_holo_dark.9.png
new file mode 100644
index 0000000..0f4c3c3
--- /dev/null
+++ b/core/res/res/drawable-hdpi/cab_background_opaque_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/cab_background_opaque_holo_light.9.png b/core/res/res/drawable-hdpi/cab_background_opaque_holo_light.9.png
new file mode 100644
index 0000000..fb9b831
--- /dev/null
+++ b/core/res/res/drawable-hdpi/cab_background_opaque_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/cab_background_dark.9.png b/core/res/res/drawable-mdpi/cab_background_dark.9.png
deleted file mode 100644
index 253b12c..0000000
--- a/core/res/res/drawable-mdpi/cab_background_dark.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/cab_background_light.9.png b/core/res/res/drawable-mdpi/cab_background_light.9.png
deleted file mode 100644
index aaccdfb..0000000
--- a/core/res/res/drawable-mdpi/cab_background_light.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/cab_background_opaque_holo_dark.9.png b/core/res/res/drawable-mdpi/cab_background_opaque_holo_dark.9.png
new file mode 100644
index 0000000..013319c
--- /dev/null
+++ b/core/res/res/drawable-mdpi/cab_background_opaque_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/cab_background_opaque_holo_light.9.png b/core/res/res/drawable-mdpi/cab_background_opaque_holo_light.9.png
new file mode 100644
index 0000000..6d8861a
--- /dev/null
+++ b/core/res/res/drawable-mdpi/cab_background_opaque_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/cab_background_opaque_holo_dark.9.png b/core/res/res/drawable-xhdpi/cab_background_opaque_holo_dark.9.png
new file mode 100644
index 0000000..e2b604b
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/cab_background_opaque_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/cab_background_opaque_holo_light.9.png b/core/res/res/drawable-xhdpi/cab_background_opaque_holo_light.9.png
new file mode 100644
index 0000000..0c1aeaa
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/cab_background_opaque_holo_light.9.png
Binary files differ
diff --git a/core/res/res/layout-w720dp/action_bar_home.xml b/core/res/res/layout-w720dp/action_bar_home.xml
deleted file mode 100644
index ece1a34..0000000
--- a/core/res/res/layout-w720dp/action_bar_home.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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.
--->
-
-<view xmlns:android="http://schemas.android.com/apk/res/android"
- class="com.android.internal.widget.ActionBarView$HomeView"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:background="?android:attr/selectableItemBackground" >
- <ImageView android:id="@android:id/up"
- android:src="?android:attr/homeAsUpIndicator"
- android:layout_gravity="center_vertical|left"
- android:visibility="gone"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginRight="-12dip" />
- <ImageView android:id="@android:id/home"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingLeft="16dip"
- android:paddingRight="16dip"
- android:layout_gravity="center"
- android:scaleType="center" />
-</view>
diff --git a/core/res/res/layout/action_bar_home.xml b/core/res/res/layout/action_bar_home.xml
index a45432a..a4c0962 100644
--- a/core/res/res/layout/action_bar_home.xml
+++ b/core/res/res/layout/action_bar_home.xml
@@ -25,12 +25,12 @@
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginRight="-4dip" />
+ android:layout_marginRight="@dimen/action_bar_home_up_margin" />
<ImageView android:id="@android:id/home"
android:layout_width="wrap_content"
android:layout_height="match_parent"
- android:paddingLeft="8dip"
- android:paddingRight="8dip"
+ android:paddingLeft="@dimen/action_bar_home_image_padding"
+ android:paddingRight="@dimen/action_bar_home_image_padding"
android:layout_gravity="center"
android:scaleType="center" />
</view>
diff --git a/core/res/res/layout/search_bar.xml b/core/res/res/layout/search_bar.xml
index 9cf08ea..7918a3f 100644
--- a/core/res/res/layout/search_bar.xml
+++ b/core/res/res/layout/search_bar.xml
@@ -25,7 +25,7 @@
android:layout_height="wrap_content"
android:orientation="horizontal"
android:focusable="true"
- android:background="@drawable/cab_background_light"
+ android:background="?android:attr/actionModeBackground"
android:descendantFocusability="afterDescendants">
<RelativeLayout
diff --git a/core/res/res/values-large/dimens.xml b/core/res/res/values-large/dimens.xml
index ab6e36d..1944029 100644
--- a/core/res/res/values-large/dimens.xml
+++ b/core/res/res/values-large/dimens.xml
@@ -24,10 +24,6 @@
<!-- Size of the giant number (unread count) in the notifications -->
<dimen name="status_bar_content_number_size">48sp</dimen>
- <!-- Margin at the edge of the screen to ignore touch events for in the windowshade. -->
- <!-- Margin for permanent screen decorations at the bottom. -->
- <dimen name="screen_margin_bottom">48dip</dimen>
-
<!-- Default height of a key in the password keyboard for alpha -->
<dimen name="password_keyboard_key_height_alpha">75dip</dimen>
<!-- Default height of a key in the password keyboard for numeric -->
diff --git a/core/res/res/values-w720dp/dimens.xml b/core/res/res/values-w720dp/dimens.xml
new file mode 100644
index 0000000..a74c41c
--- /dev/null
+++ b/core/res/res/values-w720dp/dimens.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<resources>
+ <!-- Size of the margin between the 'up' visual and the image in
+ the action bar home section. -->
+ <dimen name="action_bar_home_up_margin">-12dip</dimen>
+ <!-- Size of the padding on either side of the app-supplied image
+ in the action bar home section. -->
+ <dimen name="action_bar_home_image_padding">16dip</dimen>
+</resources>
diff --git a/core/res/res/values/arrays.xml b/core/res/res/values/arrays.xml
index 9073531..810c3b2 100644
--- a/core/res/res/values/arrays.xml
+++ b/core/res/res/values/arrays.xml
@@ -233,7 +233,10 @@
<item>@drawable/btn_cab_done_focused_holo</item>
<item>@drawable/btn_cab_done_holo</item>
<item>@drawable/btn_cab_done_pressed_holo</item>
- <item>@drawable/cab_background_light</item>
+ <item>@drawable/cab_background_holo_dark</item>
+ <item>@drawable/cab_background_holo_light</item>
+ <item>@drawable/cab_background_opaque_holo_dark</item>
+ <item>@drawable/cab_background_opaque_holo_light</item>
<item>@drawable/cab_ic_close_focused_holo</item>
<item>@drawable/cab_ic_close_holo</item>
<item>@drawable/cab_ic_close_normal_holo</item>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 004b755..0d9190f 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -734,6 +734,9 @@
<!-- SearchView text field background for the right section -->
<attr name="searchViewTextFieldRight" format="reference" />
+ <!-- Theme to use for Search Dialogs -->
+ <attr name="searchDialogTheme" format="reference" />
+
<!-- Specifies a drawable to use for the 'home as up' indicator. -->
<attr name="homeAsUpIndicator" format="reference" />
diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml
index 70c4c86..ceb7752 100644
--- a/core/res/res/values/attrs_manifest.xml
+++ b/core/res/res/values/attrs_manifest.xml
@@ -590,11 +590,21 @@
<!-- The global user interface mode has changed. For example,
going in or out of car mode, night mode changing, etc. -->
<flag name="uiMode" value="0x0200" />
+ <!-- The current available screen size has changed. If applications don't
+ target at least {@link android.os.Build.VERSION_CODES#HONEYCOMB_MR2}
+ then the activity will always handle this itself (the change
+ will not result in a restart). This represents a change in the
+ currently available size, so will change when the user switches
+ between landscape and portrait. -->
+ <flag name="screenSize" value="0x0400" />
<!-- The physical screen size has changed. If applications don't
target at least {@link android.os.Build.VERSION_CODES#HONEYCOMB_MR2}
then the activity will always handle this itself (the change
- will not result in a restart). -->
- <flag name="screenSize" value="0x0400" />
+ will not result in a restart). This represents a change in size
+ regardless of orientation, so will only change when the actual
+ physical screen size has changed such as switching to an external
+ display. -->
+ <flag name="smallestScreenSize" value="0x0800" />
<!-- The font scaling factor has changed, that is the user has
selected a new global font size. -->
<flag name="fontScale" value="0x40000000" />
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 05840a4..1782f02 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -36,8 +36,6 @@
<dimen name="status_bar_icon_size">25dip</dimen>
<!-- Margin at the edge of the screen to ignore touch events for in the windowshade. -->
<dimen name="status_bar_edge_ignore">5dp</dimen>
- <!-- Margin for permanent screen decorations at the bottom. -->
- <dimen name="screen_margin_bottom">0dip</dimen>
<!-- Size of the fastscroll hint letter -->
<dimen name="fastscroll_overlay_size">104dp</dimen>
<!-- Width of the fastscroll thumb -->
@@ -81,4 +79,12 @@
<dimen name="alert_dialog_title_height">48dip</dimen>
<!-- Dialog button bar height -->
<dimen name="alert_dialog_button_bar_height">48dip</dimen>
+
+ <!-- Size of the margin between the 'up' visual and the image in
+ the action bar home section. -->
+ <dimen name="action_bar_home_up_margin">-4dip</dimen>
+ <!-- Size of the padding on either side of the app-supplied image
+ in the action bar home section. -->
+ <dimen name="action_bar_home_image_padding">8dip</dimen>
+
</resources>
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index b127747..2f434ec 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -258,7 +258,7 @@
<item name="actionDropDownStyle">@android:style/Widget.Spinner.DropDown</item>
<item name="actionButtonStyle">@android:style/Widget.ActionButton</item>
<item name="actionOverflowButtonStyle">@android:style/Widget.ActionButton.Overflow</item>
- <item name="actionModeBackground">@android:drawable/cab_background_dark</item>
+ <item name="actionModeBackground">@android:drawable/cab_background_opaque_holo_dark</item>
<item name="actionModeCloseDrawable">@android:drawable/ic_menu_close_clear_cancel</item>
<item name="actionModeCutDrawable">@android:drawable/ic_menu_cut_holo_dark</item>
<item name="actionModeCopyDrawable">@android:drawable/ic_menu_copy_holo_dark</item>
@@ -294,6 +294,8 @@
<item name="searchViewEditQuery">@android:drawable/ic_commit</item>
<item name="searchViewEditQueryBackground">?attr/selectableItemBackground</item>
+ <item name="searchDialogTheme">@style/Theme.SearchBar</item>
+
<!-- PreferenceFrameLayout attributes -->
<item name="preferenceFrameLayoutStyle">@android:style/Widget.PreferenceFrameLayout</item>
@@ -391,7 +393,7 @@
<item name="actionModeShareDrawable">@android:drawable/ic_menu_share_holo_light</item>
<item name="actionModeFindDrawable">@android:drawable/ic_menu_find_holo_light</item>
<item name="actionModeWebSearchDrawable">@android:drawable/ic_menu_search_holo_light</item>
- <item name="actionModeBackground">@android:drawable/cab_background_light</item>
+ <item name="actionModeBackground">@android:drawable/cab_background_opaque_holo_light</item>
<!-- SearchView attributes -->
<item name="searchDropdownBackground">@android:drawable/search_dropdown_light</item>
@@ -681,12 +683,24 @@
<!-- Theme for the search input bar. -->
<style name="Theme.SearchBar" parent="Theme.Holo.Light.Panel">
<item name="windowContentOverlay">@null</item>
+ <item name="actionModeBackground">@android:drawable/cab_background_opaque_holo_light</item>
</style>
-
+
+ <style name="Theme.Holo.SearchBar" parent="Theme.Holo.Panel">
+ <item name="windowContentOverlay">@null</item>
+ <item name="actionModeBackground">@android:drawable/cab_background_opaque_holo_dark</item>
+ </style>
+
+ <style name="Theme.Holo.Light.SearchBar" parent="Theme.Holo.Light.Panel">
+ <item name="windowContentOverlay">@null</item>
+ <item name="actionModeBackground">@android:drawable/cab_background_opaque_holo_light</item>
+ </style>
+
<!-- Theme for the search input bar when doing global search. The only
difference from non-global search is that we do not dim the background. -->
<style name="Theme.GlobalSearchBar" parent="Theme.Panel">
<item name="windowContentOverlay">@null</item>
+ <item name="actionModeBackground">@android:drawable/cab_background_opaque_holo_light</item>
</style>
<!-- Menu Themes -->
@@ -1020,6 +1034,8 @@
<!-- SearchView attributes -->
<item name="searchDropdownBackground">@android:drawable/search_dropdown_dark</item>
+ <item name="searchDialogTheme">@style/Theme.Holo.SearchBar</item>
+
<!-- PreferenceFrameLayout attributes -->
<item name="preferenceFrameLayoutStyle">@android:style/Widget.Holo.PreferenceFrameLayout</item>
@@ -1303,6 +1319,8 @@
<!-- SearchView attributes -->
<item name="searchDropdownBackground">@android:drawable/search_dropdown_light</item>
+ <item name="searchDialogTheme">@style/Theme.Holo.Light.SearchBar</item>
+
<!-- NumberPicker attributes and styles-->
<item name="numberPickerUpButtonStyle">@style/Widget.Holo.Light.ImageButton.NumberPickerUpButton</item>
<item name="numberPickerDownButtonStyle">@style/Widget.Holo.Light.ImageButton.NumberPickerDownButton</item>
diff --git a/include/utils/ResourceTypes.h b/include/utils/ResourceTypes.h
index 35792dc..1604c13 100644
--- a/include/utils/ResourceTypes.h
+++ b/include/utils/ResourceTypes.h
@@ -966,8 +966,7 @@
struct {
uint8_t screenLayout;
uint8_t uiMode;
- uint8_t screenConfigPad1;
- uint8_t screenConfigPad2;
+ uint16_t smallestScreenWidthDp;
};
uint32_t screenConfig;
};
@@ -1000,6 +999,7 @@
screenHeight = dtohs(screenHeight);
sdkVersion = dtohs(sdkVersion);
minorVersion = dtohs(minorVersion);
+ smallestScreenWidthDp = dtohs(smallestScreenWidthDp);
screenWidthDp = dtohs(screenWidthDp);
screenHeightDp = dtohs(screenHeightDp);
}
@@ -1013,6 +1013,7 @@
screenHeight = htods(screenHeight);
sdkVersion = htods(sdkVersion);
minorVersion = htods(minorVersion);
+ smallestScreenWidthDp = htods(smallestScreenWidthDp);
screenWidthDp = htods(screenWidthDp);
screenHeightDp = htods(screenHeightDp);
}
@@ -1034,6 +1035,8 @@
if (diff != 0) return diff;
diff = (int32_t)(uiMode - o.uiMode);
if (diff != 0) return diff;
+ diff = (int32_t)(smallestScreenWidthDp - o.smallestScreenWidthDp);
+ if (diff != 0) return diff;
diff = (int32_t)(screenSizeDp - o.screenSizeDp);
return (int)diff;
}
@@ -1052,6 +1055,7 @@
CONFIG_ORIENTATION = ACONFIGURATION_ORIENTATION,
CONFIG_DENSITY = ACONFIGURATION_DENSITY,
CONFIG_SCREEN_SIZE = ACONFIGURATION_SCREEN_SIZE,
+ CONFIG_SMALLEST_SCREEN_SIZE = ACONFIGURATION_SMALLEST_SCREEN_SIZE,
CONFIG_VERSION = ACONFIGURATION_VERSION,
CONFIG_SCREEN_LAYOUT = ACONFIGURATION_SCREEN_LAYOUT,
CONFIG_UI_MODE = ACONFIGURATION_UI_MODE
@@ -1075,6 +1079,7 @@
if (version != o.version) diffs |= CONFIG_VERSION;
if (screenLayout != o.screenLayout) diffs |= CONFIG_SCREEN_LAYOUT;
if (uiMode != o.uiMode) diffs |= CONFIG_UI_MODE;
+ if (smallestScreenWidthDp != o.smallestScreenWidthDp) diffs |= CONFIG_SMALLEST_SCREEN_SIZE;
if (screenSizeDp != o.screenSizeDp) diffs |= CONFIG_SCREEN_SIZE;
return diffs;
}
@@ -1109,14 +1114,10 @@
}
}
- if (screenLayout || o.screenLayout) {
- if (((screenLayout^o.screenLayout) & MASK_SCREENSIZE) != 0) {
- if (!(screenLayout & MASK_SCREENSIZE)) return false;
- if (!(o.screenLayout & MASK_SCREENSIZE)) return true;
- }
- if (((screenLayout^o.screenLayout) & MASK_SCREENLONG) != 0) {
- if (!(screenLayout & MASK_SCREENLONG)) return false;
- if (!(o.screenLayout & MASK_SCREENLONG)) return true;
+ if (smallestScreenWidthDp || o.smallestScreenWidthDp) {
+ if (smallestScreenWidthDp != o.smallestScreenWidthDp) {
+ if (!smallestScreenWidthDp) return false;
+ if (!o.smallestScreenWidthDp) return true;
}
}
@@ -1132,6 +1133,17 @@
}
}
+ if (screenLayout || o.screenLayout) {
+ if (((screenLayout^o.screenLayout) & MASK_SCREENSIZE) != 0) {
+ if (!(screenLayout & MASK_SCREENSIZE)) return false;
+ if (!(o.screenLayout & MASK_SCREENSIZE)) return true;
+ }
+ if (((screenLayout^o.screenLayout) & MASK_SCREENLONG) != 0) {
+ if (!(screenLayout & MASK_SCREENLONG)) return false;
+ if (!(o.screenLayout & MASK_SCREENLONG)) return true;
+ }
+ }
+
if (orientation != o.orientation) {
if (!orientation) return false;
if (!o.orientation) return true;
@@ -1238,6 +1250,37 @@
}
}
+ if (smallestScreenWidthDp || o.smallestScreenWidthDp) {
+ // The configuration closest to the actual size is best.
+ // We assume that larger configs have already been filtered
+ // out at this point. That means we just want the largest one.
+ return smallestScreenWidthDp >= o.smallestScreenWidthDp;
+ }
+
+ if (screenSizeDp || o.screenSizeDp) {
+ // "Better" is based on the sum of the difference between both
+ // width and height from the requested dimensions. We are
+ // assuming the invalid configs (with smaller dimens) have
+ // already been filtered. Note that if a particular dimension
+ // is unspecified, we will end up with a large value (the
+ // difference between 0 and the requested dimension), which is
+ // good since we will prefer a config that has specified a
+ // dimension value.
+ int myDelta = 0, otherDelta = 0;
+ if (requested->screenWidthDp) {
+ myDelta += requested->screenWidthDp - screenWidthDp;
+ otherDelta += requested->screenWidthDp - o.screenWidthDp;
+ }
+ if (requested->screenHeightDp) {
+ myDelta += requested->screenHeightDp - screenHeightDp;
+ otherDelta += requested->screenHeightDp - o.screenHeightDp;
+ }
+ //LOGI("Comparing this %dx%d to other %dx%d in %dx%d: myDelta=%d otherDelta=%d",
+ // screenWidthDp, screenHeightDp, o.screenWidthDp, o.screenHeightDp,
+ // requested->screenWidthDp, requested->screenHeightDp, myDelta, otherDelta);
+ return (myDelta <= otherDelta);
+ }
+
if (screenLayout || o.screenLayout) {
if (((screenLayout^o.screenLayout) & MASK_SCREENSIZE) != 0
&& (requested->screenLayout & MASK_SCREENSIZE)) {
@@ -1270,30 +1313,6 @@
}
}
- if (screenSizeDp || o.screenSizeDp) {
- // Better is based on the sum of the difference between both
- // width and height from the requested dimensions. We are
- // assuming the invalid configs (with smaller dimens) have
- // already been filtered. Note that if a particular dimension
- // is unspecified, we will end up with a large value (the
- // difference between 0 and the requested dimension), which is
- // good since we will prefer a config that has specified a
- // dimension value.
- int myDelta = 0, otherDelta = 0;
- if (requested->screenWidthDp) {
- myDelta += requested->screenWidthDp - screenWidthDp;
- otherDelta += requested->screenWidthDp - o.screenWidthDp;
- }
- if (requested->screenHeightDp) {
- myDelta += requested->screenHeightDp - screenHeightDp;
- otherDelta += requested->screenHeightDp - o.screenHeightDp;
- }
- //LOGI("Comparing this %dx%d to other %dx%d in %dx%d: myDelta=%d otherDelta=%d",
- // screenWidthDp, screenHeightDp, o.screenWidthDp, o.screenHeightDp,
- // requested->screenWidthDp, requested->screenHeightDp, myDelta, otherDelta);
- return (myDelta <= otherDelta);
- }
-
if ((orientation != o.orientation) && requested->orientation) {
return (orientation);
}
@@ -1388,14 +1407,24 @@
}
if (screenSize || o.screenSize) {
- if ((screenWidth != o.screenWidth) && requested->screenWidth) {
- return (screenWidth);
+ // "Better" is based on the sum of the difference between both
+ // width and height from the requested dimensions. We are
+ // assuming the invalid configs (with smaller sizes) have
+ // already been filtered. Note that if a particular dimension
+ // is unspecified, we will end up with a large value (the
+ // difference between 0 and the requested dimension), which is
+ // good since we will prefer a config that has specified a
+ // size value.
+ int myDelta = 0, otherDelta = 0;
+ if (requested->screenWidth) {
+ myDelta += requested->screenWidth - screenWidth;
+ otherDelta += requested->screenWidth - o.screenWidth;
}
-
- if ((screenHeight != o.screenHeight) &&
- requested->screenHeight) {
- return (screenHeight);
+ if (requested->screenHeight) {
+ myDelta += requested->screenHeight - screenHeight;
+ otherDelta += requested->screenHeight - o.screenHeight;
}
+ return (myDelta <= otherDelta);
}
if (version || o.version) {
@@ -1476,15 +1505,20 @@
&& uiModeNight != setUiModeNight) {
return false;
}
+
+ if (settings.smallestScreenWidthDp != 0 && smallestScreenWidthDp != 0
+ && smallestScreenWidthDp > settings.smallestScreenWidthDp) {
+ return false;
+ }
}
if (screenSizeDp != 0) {
if (settings.screenWidthDp != 0 && screenWidthDp != 0
- && screenWidthDp > settings.screenWidthDp) {
+ && screenWidthDp > settings.screenWidthDp) {
//LOGI("Filtering out width %d in requested %d", screenWidthDp, settings.screenWidthDp);
return false;
}
if (settings.screenHeightDp != 0 && screenHeightDp != 0
- && screenHeightDp > settings.screenHeightDp) {
+ && screenHeightDp > settings.screenHeightDp) {
//LOGI("Filtering out height %d in requested %d", screenHeightDp, settings.screenHeightDp);
return false;
}
@@ -1531,11 +1565,11 @@
}
if (screenSize != 0) {
if (settings.screenWidth != 0 && screenWidth != 0
- && screenWidth != settings.screenWidth) {
+ && screenWidth > settings.screenWidth) {
return false;
}
if (settings.screenHeight != 0 && screenHeight != 0
- && screenHeight != settings.screenHeight) {
+ && screenHeight > settings.screenHeight) {
return false;
}
}
@@ -1568,13 +1602,13 @@
String8 toString() const {
char buf[200];
sprintf(buf, "imsi=%d/%d lang=%c%c reg=%c%c orient=%d touch=%d dens=%d "
- "kbd=%d nav=%d input=%d ssz=%dx%d %ddp x %ddp sz=%d long=%d "
+ "kbd=%d nav=%d input=%d ssz=%dx%d sw%ddp w%ddp h%ddp sz=%d long=%d "
"ui=%d night=%d vers=%d.%d",
mcc, mnc,
language[0] ? language[0] : '-', language[1] ? language[1] : '-',
country[0] ? country[0] : '-', country[1] ? country[1] : '-',
orientation, touchscreen, density, keyboard, navigation, inputFlags,
- screenWidth, screenHeight, screenWidthDp, screenHeightDp,
+ screenWidth, screenHeight, smallestScreenWidthDp, screenWidthDp, screenHeightDp,
screenLayout&MASK_SCREENSIZE, screenLayout&MASK_SCREENLONG,
uiMode&MASK_UI_MODE_TYPE, uiMode&MASK_UI_MODE_NIGHT,
sdkVersion, minorVersion);
diff --git a/libs/utils/ResourceTypes.cpp b/libs/utils/ResourceTypes.cpp
index ac9cdf9..a64918d 100644
--- a/libs/utils/ResourceTypes.cpp
+++ b/libs/utils/ResourceTypes.cpp
@@ -2424,7 +2424,7 @@
{
mLock.lock();
TABLE_GETENTRY(LOGI("Setting parameters: imsi:%d/%d lang:%c%c cnt:%c%c "
- "orien:%d touch:%d density:%d key:%d inp:%d nav:%d sz:%dx%d %ddp x %ddp\n",
+ "orien:%d touch:%d density:%d key:%d inp:%d nav:%d sz:%dx%d sw%ddp w%ddp h%ddp\n",
params->mcc, params->mnc,
params->language[0] ? params->language[0] : '-',
params->language[1] ? params->language[1] : '-',
@@ -2438,6 +2438,7 @@
params->navigation,
params->screenWidth,
params->screenHeight,
+ params->smallestScreenWidthDp,
params->screenWidthDp,
params->screenHeightDp));
mParams = *params;
@@ -3763,7 +3764,7 @@
TABLE_GETENTRY(LOGI("Match entry 0x%x in type 0x%x (sz 0x%x): imsi:%d/%d=%d/%d "
"lang:%c%c=%c%c cnt:%c%c=%c%c orien:%d=%d touch:%d=%d "
"density:%d=%d key:%d=%d inp:%d=%d nav:%d=%d w:%d=%d h:%d=%d "
- "wdp:%d=%d hdp:%d=%d\n",
+ "swdp:%d=%d wdp:%d=%d hdp:%d=%d\n",
entryIndex, typeIndex+1, dtohl(thisType->config.size),
thisConfig.mcc, thisConfig.mnc,
config ? config->mcc : 0, config ? config->mnc : 0,
@@ -3791,6 +3792,8 @@
config ? config->screenWidth : 0,
thisConfig.screenHeight,
config ? config->screenHeight : 0,
+ thisConfig.smallestScreenWidthDp,
+ config ? config->smallestScreenWidthDp : 0,
thisConfig.screenWidthDp,
config ? config->screenWidthDp : 0,
thisConfig.screenHeightDp,
@@ -4076,7 +4079,7 @@
thisConfig.copyFromDtoH(type->config);
LOGI("Adding config to type %d: imsi:%d/%d lang:%c%c cnt:%c%c "
"orien:%d touch:%d density:%d key:%d inp:%d nav:%d w:%d h:%d "
- "wdp:%d hdp:%d\n",
+ "swdp:%d wdp:%d hdp:%d\n",
type->id,
thisConfig.mcc, thisConfig.mnc,
thisConfig.language[0] ? thisConfig.language[0] : '-',
@@ -4091,6 +4094,7 @@
thisConfig.navigation,
thisConfig.screenWidth,
thisConfig.screenHeight,
+ thisConfig.smallestScreenWidthDp,
thisConfig.screenWidthDp,
thisConfig.screenHeightDp));
t->configs.add(type);
@@ -4455,6 +4459,9 @@
if (type->config.screenHeight != 0) {
printf(" h=%d", dtohs(type->config.screenHeight));
}
+ if (type->config.smallestScreenWidthDp != 0) {
+ printf(" swdp=%d", dtohs(type->config.smallestScreenWidthDp));
+ }
if (type->config.screenWidthDp != 0) {
printf(" wdp=%d", dtohs(type->config.screenWidthDp));
}
diff --git a/media/libstagefright/NuHTTPDataSource.cpp b/media/libstagefright/NuHTTPDataSource.cpp
index 62fb732..dd29c84 100644
--- a/media/libstagefright/NuHTTPDataSource.cpp
+++ b/media/libstagefright/NuHTTPDataSource.cpp
@@ -383,6 +383,13 @@
Mutex::Autolock autoLock(mLock);
+ // if it's a DRM container based streaming, call pread() of the DRM plugin
+ // to get the decrypted data
+ if (mDecryptHandle != NULL && DecryptApiType::CONTAINER_BASED
+ == mDecryptHandle->decryptApiType) {
+ return mDrmManagerClient->pread(mDecryptHandle, data, size, offset);
+ }
+
if (offset != mOffset) {
String8 host = mHost;
String8 path = mPath;
diff --git a/native/android/configuration.cpp b/native/android/configuration.cpp
index d76164f..687924b 100644
--- a/native/android/configuration.cpp
+++ b/native/android/configuration.cpp
@@ -111,6 +111,18 @@
}
+int32_t AConfiguration_getScreenWidthDp(AConfiguration* config) {
+ return config->screenWidthDp;
+}
+
+int32_t AConfiguration_getScreenHeightDp(AConfiguration* config) {
+ return config->screenHeightDp;
+}
+
+int32_t AConfiguration_getSmallestScreenWidthDp(AConfiguration* config) {
+ return config->smallestScreenWidthDp;
+}
+
// ----------------------------------------------------------------------
void AConfiguration_setMcc(AConfiguration* config, int32_t mcc) {
@@ -186,6 +198,18 @@
}
+void AConfiguration_setScreenWidthDp(AConfiguration* config, int32_t value) {
+ config->screenWidthDp = value;
+}
+
+void AConfiguration_setScreenHeightDp(AConfiguration* config, int32_t value) {
+ config->screenHeightDp = value;
+}
+
+void AConfiguration_setSmallestScreenWidthDp(AConfiguration* config, int32_t value) {
+ config->smallestScreenWidthDp = value;
+}
+
// ----------------------------------------------------------------------
int32_t AConfiguration_diff(AConfiguration* config1, AConfiguration* config2) {
diff --git a/native/include/android/configuration.h b/native/include/android/configuration.h
index 99e8f97..91533c8 100644
--- a/native/include/android/configuration.h
+++ b/native/include/android/configuration.h
@@ -82,6 +82,12 @@
ACONFIGURATION_UI_MODE_NIGHT_NO = 0x1,
ACONFIGURATION_UI_MODE_NIGHT_YES = 0x2,
+ ACONFIGURATION_SCREEN_WIDTH_DP_ANY = 0x0000,
+
+ ACONFIGURATION_SCREEN_HEIGHT_DP_ANY = 0x0000,
+
+ ACONFIGURATION_SMALLEST_SCREEN_WIDTH_DP_ANY = 0x0000,
+
ACONFIGURATION_MCC = 0x0001,
ACONFIGURATION_MNC = 0x0002,
ACONFIGURATION_LOCALE = 0x0004,
@@ -95,6 +101,7 @@
ACONFIGURATION_VERSION = 0x0400,
ACONFIGURATION_SCREEN_LAYOUT = 0x0800,
ACONFIGURATION_UI_MODE = 0x1000,
+ ACONFIGURATION_SMALLEST_SCREEN_SIZE = 0x2000,
};
/**
@@ -286,6 +293,39 @@
void AConfiguration_setUiModeNight(AConfiguration* config, int32_t uiModeNight);
/**
+ * Return the current configuration screen width in dp units, or
+ * ACONFIGURATION_SCREEN_WIDTH_DP_ANY if not set.
+ */
+int32_t AConfiguration_getScreenWidthDp(AConfiguration* config);
+
+/**
+ * Set the configuration's current screen width in dp units.
+ */
+void AConfiguration_setScreenWidthDp(AConfiguration* config, int32_t value);
+
+/**
+ * Return the current configuration screen height in dp units, or
+ * ACONFIGURATION_SCREEN_HEIGHT_DP_ANY if not set.
+ */
+int32_t AConfiguration_getScreenHeightDp(AConfiguration* config);
+
+/**
+ * Set the configuration's current screen width in dp units.
+ */
+void AConfiguration_setScreenHeightDp(AConfiguration* config, int32_t value);
+
+/**
+ * Return the configuration's smallest screen width in dp units, or
+ * ACONFIGURATION_SMALLEST_SCREEN_WIDTH_DP_ANY if not set.
+ */
+int32_t AConfiguration_getSmallestScreenWidthDp(AConfiguration* config);
+
+/**
+ * Set the configuration's smallest screen width in dp units.
+ */
+void AConfiguration_setSmallestScreenWidthDp(AConfiguration* config, int32_t value);
+
+/**
* Perform a diff between two configurations. Returns a bit mask of
* ACONFIGURATION_* constants, each bit set meaning that configuration element
* is different between them.
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 2d68667..6e367d6 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -227,7 +227,7 @@
boolean mSafeMode;
WindowState mStatusBar = null;
boolean mStatusBarCanHide;
- int mScreenMarginBottom;
+ int mStatusBarHeight;
final ArrayList<WindowState> mStatusBarPanels = new ArrayList<WindowState>();
WindowState mKeyguard = null;
KeyguardViewMediator mKeyguardMediator;
@@ -1055,12 +1055,20 @@
return STATUS_BAR_LAYER;
}
- public int getNonDecorDisplayWidth(int fullWidth) {
+ public int getNonDecorDisplayWidth(int rotation, int fullWidth) {
return fullWidth;
}
- public int getNonDecorDisplayHeight(int fullHeight) {
- return fullHeight - mScreenMarginBottom;
+ public int getNonDecorDisplayHeight(int rotation, int fullHeight) {
+ return mStatusBarCanHide ? fullHeight : (fullHeight - mStatusBarHeight);
+ }
+
+ public int getConfigDisplayWidth(int rotation, int fullWidth) {
+ return fullWidth;
+ }
+
+ public int getConfigDisplayHeight(int rotation, int fullHeight) {
+ return fullHeight - mStatusBarHeight;
}
public boolean doesForceHide(WindowState win, WindowManager.LayoutParams attrs) {
@@ -1212,8 +1220,8 @@
// The Configuration will be stable by now, so we can load this
mStatusBarCanHide = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_statusBarCanHide);
- mScreenMarginBottom = mContext.getResources().getDimensionPixelSize(
- com.android.internal.R.dimen.screen_margin_bottom);
+ mStatusBarHeight = mContext.getResources().getDimensionPixelSize(
+ com.android.internal.R.dimen.status_bar_height);
break;
case TYPE_STATUS_BAR_PANEL:
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java
index 1455764..7a0dc3e 100644
--- a/services/java/com/android/server/InputMethodManagerService.java
+++ b/services/java/com/android/server/InputMethodManagerService.java
@@ -1371,31 +1371,70 @@
}
}
+ @Override
public boolean switchToLastInputMethod(IBinder token) {
synchronized (mMethodMap) {
final Pair<String, String> lastIme = mSettings.getLastInputMethodAndSubtypeLocked();
- if (lastIme == null) return false;
- final InputMethodInfo lastImi = mMethodMap.get(lastIme.first);
- if (lastImi == null) return false;
-
- final boolean imiIdIsSame = lastImi.getId().equals(mCurMethodId);
- final int lastSubtypeHash = Integer.valueOf(lastIme.second);
- // If the last IME is the same as the current IME and the last subtype is not defined,
- // there is no need to switch to the last IME.
- if (imiIdIsSame && lastSubtypeHash == NOT_A_SUBTYPE_ID) return false;
-
- int currentSubtypeHash = mCurrentSubtype == null ? NOT_A_SUBTYPE_ID
- : mCurrentSubtype.hashCode();
- if (!imiIdIsSame || lastSubtypeHash != currentSubtypeHash) {
- if (DEBUG) {
- Slog.d(TAG, "Switch to: " + lastImi.getId() + ", " + lastIme.second + ", from: "
- + mCurMethodId + ", " + currentSubtypeHash);
- }
- setInputMethodWithSubtypeId(token, lastIme.first, getSubtypeIdFromHashCode(
- lastImi, lastSubtypeHash));
- return true;
+ final InputMethodInfo lastImi;
+ if (lastIme != null) {
+ lastImi = mMethodMap.get(lastIme.first);
+ } else {
+ lastImi = null;
}
- return false;
+ String targetLastImiId = null;
+ int subtypeId = NOT_A_SUBTYPE_ID;
+ if (lastIme != null && lastImi != null) {
+ final boolean imiIdIsSame = lastImi.getId().equals(mCurMethodId);
+ final int lastSubtypeHash = Integer.valueOf(lastIme.second);
+ final int currentSubtypeHash = mCurrentSubtype == null ? NOT_A_SUBTYPE_ID
+ : mCurrentSubtype.hashCode();
+ // If the last IME is the same as the current IME and the last subtype is not
+ // defined, there is no need to switch to the last IME.
+ if (!imiIdIsSame || lastSubtypeHash != currentSubtypeHash) {
+ targetLastImiId = lastIme.first;
+ subtypeId = getSubtypeIdFromHashCode(lastImi, lastSubtypeHash);
+ }
+ }
+
+ if (TextUtils.isEmpty(targetLastImiId) && !canAddToLastInputMethod(mCurrentSubtype)) {
+ // This is a safety net. If the currentSubtype can't be added to the history
+ // and the framework couldn't find the last ime, we will make the last ime be
+ // the most applicable enabled keyboard subtype of the system imes.
+ final List<InputMethodInfo> enabled = mSettings.getEnabledInputMethodListLocked();
+ if (enabled != null) {
+ final int N = enabled.size();
+ final String locale = mCurrentSubtype == null
+ ? mRes.getConfiguration().locale.toString()
+ : mCurrentSubtype.getLocale();
+ for (int i = 0; i < N; ++i) {
+ final InputMethodInfo imi = enabled.get(i);
+ if (imi.getSubtypeCount() > 0 && isSystemIme(imi)) {
+ InputMethodSubtype keyboardSubtype =
+ findLastResortApplicableSubtypeLocked(mRes, getSubtypes(imi),
+ SUBTYPE_MODE_KEYBOARD, locale, true);
+ if (keyboardSubtype != null) {
+ targetLastImiId = imi.getId();
+ subtypeId = getSubtypeIdFromHashCode(
+ imi, keyboardSubtype.hashCode());
+ if(keyboardSubtype.getLocale().equals(locale)) {
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!TextUtils.isEmpty(targetLastImiId)) {
+ if (DEBUG) {
+ Slog.d(TAG, "Switch to: " + lastImi.getId() + ", " + lastIme.second
+ + ", from: " + mCurMethodId + ", " + subtypeId);
+ }
+ setInputMethodWithSubtypeId(token, targetLastImiId, subtypeId);
+ return true;
+ } else {
+ return false;
+ }
}
}
@@ -2601,7 +2640,7 @@
List<Pair<String, ArrayList<String>>> enabledImes =
getEnabledInputMethodsAndSubtypeListLocked();
List<Pair<String, String>> subtypeHistory = loadInputMethodAndSubtypeHistoryLocked();
- for (Pair<String, String> imeAndSubtype: subtypeHistory) {
+ for (Pair<String, String> imeAndSubtype : subtypeHistory) {
final String imeInTheHistory = imeAndSubtype.first;
// If imeId is empty, returns the first IME and subtype in the history
if (TextUtils.isEmpty(imeId) || imeInTheHistory.equals(imeId)) {
diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java
index 0000237..6acc32f 100644
--- a/services/java/com/android/server/WifiService.java
+++ b/services/java/com/android/server/WifiService.java
@@ -559,31 +559,10 @@
* @param wifiConfig SSID, security and channel details as
* part of WifiConfiguration
* @param enabled true to enable and false to disable
- * @return {@code true} if the start operation was
- * started or is already in the queue.
*/
- public synchronized boolean setWifiApEnabled(WifiConfiguration wifiConfig, boolean enabled) {
+ public void setWifiApEnabled(WifiConfiguration wifiConfig, boolean enabled) {
enforceChangePermission();
-
- if (enabled) {
- /* Use default config if there is no existing config */
- if (wifiConfig == null && ((wifiConfig = getWifiApConfiguration()) == null)) {
- wifiConfig = new WifiConfiguration();
- wifiConfig.SSID = mContext.getString(R.string.wifi_tether_configure_ssid_default);
- wifiConfig.allowedKeyManagement.set(KeyMgmt.NONE);
- }
- /*
- * Caller might not have WRITE_SECURE_SETTINGS,
- * only CHANGE_WIFI_STATE is enforced
- */
- long ident = Binder.clearCallingIdentity();
- setWifiApConfiguration(wifiConfig);
- Binder.restoreCallingIdentity(ident);
- }
-
mWifiStateMachine.setWifiApEnabled(wifiConfig, enabled);
-
- return true;
}
/**
@@ -603,38 +582,20 @@
* see {@link WifiManager#getWifiApConfiguration()}
* @return soft access point configuration
*/
- public synchronized WifiConfiguration getWifiApConfiguration() {
- final ContentResolver cr = mContext.getContentResolver();
- WifiConfiguration wifiConfig = new WifiConfiguration();
- int authType;
- try {
- wifiConfig.SSID = Settings.Secure.getString(cr, Settings.Secure.WIFI_AP_SSID);
- if (wifiConfig.SSID == null)
- return null;
- authType = Settings.Secure.getInt(cr, Settings.Secure.WIFI_AP_SECURITY);
- wifiConfig.allowedKeyManagement.set(authType);
- wifiConfig.preSharedKey = Settings.Secure.getString(cr, Settings.Secure.WIFI_AP_PASSWD);
- return wifiConfig;
- } catch (Settings.SettingNotFoundException e) {
- Slog.e(TAG,"AP settings not found, returning");
- return null;
- }
+ public WifiConfiguration getWifiApConfiguration() {
+ enforceAccessPermission();
+ return mWifiStateMachine.syncGetWifiApConfiguration(mWifiStateMachineChannel);
}
/**
* see {@link WifiManager#setWifiApConfiguration(WifiConfiguration)}
* @param wifiConfig WifiConfiguration details for soft access point
*/
- public synchronized void setWifiApConfiguration(WifiConfiguration wifiConfig) {
+ public void setWifiApConfiguration(WifiConfiguration wifiConfig) {
enforceChangePermission();
- final ContentResolver cr = mContext.getContentResolver();
if (wifiConfig == null)
return;
- int authType = wifiConfig.getAuthType();
- Settings.Secure.putString(cr, Settings.Secure.WIFI_AP_SSID, wifiConfig.SSID);
- Settings.Secure.putInt(cr, Settings.Secure.WIFI_AP_SECURITY, authType);
- if (authType != KeyMgmt.NONE)
- Settings.Secure.putString(cr, Settings.Secure.WIFI_AP_PASSWD, wifiConfig.preSharedKey);
+ mWifiStateMachine.setWifiApConfiguration(wifiConfig);
}
/**
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index 607c60a..5c49ef09 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -4779,8 +4779,8 @@
synchronized(mWindowMap) {
long ident = Binder.clearCallingIdentity();
- dw = mPolicy.getNonDecorDisplayWidth(mCurDisplayWidth);
- dh = mPolicy.getNonDecorDisplayHeight(mCurDisplayHeight);
+ dw = mPolicy.getNonDecorDisplayWidth(mRotation, mCurDisplayWidth);
+ dh = mPolicy.getNonDecorDisplayHeight(mRotation, mCurDisplayHeight);
int aboveAppLayer = mPolicy.windowTypeToLayerLw(
WindowManager.LayoutParams.TYPE_APPLICATION) * TYPE_LAYER_MULTIPLIER
@@ -5497,6 +5497,14 @@
return config;
}
+ private int reduceConfigWidthSize(int curSize, int rotation, float density, int dw) {
+ int size = (int)(mPolicy.getConfigDisplayWidth(rotation, dw) / density);
+ if (size < curSize) {
+ curSize = size;
+ }
+ return curSize;
+ }
+
boolean computeNewConfigurationLocked(Configuration config) {
if (mDisplay == null) {
return false;
@@ -5547,14 +5555,37 @@
// Override display width and height with what we are computing,
// to be sure they remain consistent.
- dm.widthPixels = dm.realWidthPixels = mPolicy.getNonDecorDisplayWidth(dw);
- dm.heightPixels = dm.realHeightPixels = mPolicy.getNonDecorDisplayHeight(dh);
+ dm.widthPixels = dm.realWidthPixels = mPolicy.getNonDecorDisplayWidth(
+ mRotation, dw);
+ dm.heightPixels = dm.realHeightPixels = mPolicy.getNonDecorDisplayHeight(
+ mRotation, dh);
mCompatibleScreenScale = CompatibilityInfo.updateCompatibleScreenFrame(
dm, mCompatibleScreenFrame, null);
- config.screenWidthDp = (int)(dm.widthPixels / dm.density);
- config.screenHeightDp = (int)(dm.heightPixels / dm.density);
+ config.screenWidthDp = (int)(mPolicy.getConfigDisplayWidth(mRotation, dw) / dm.density);
+ config.screenHeightDp = (int)(mPolicy.getConfigDisplayHeight(mRotation, dh) / dm.density);
+
+ // We need to determine the smallest width that will occur under normal
+ // operation. To this, start with the base screen size and compute the
+ // width under the different possible rotations. We need to un-rotate
+ // the current screen dimensions before doing this.
+ int unrotDw, unrotDh;
+ if (rotated) {
+ unrotDw = dh;
+ unrotDh = dw;
+ } else {
+ unrotDw = dw;
+ unrotDh = dh;
+ }
+ config.smallestScreenWidthDp = reduceConfigWidthSize(unrotDw,
+ Surface.ROTATION_0, dm.density, unrotDw);
+ config.smallestScreenWidthDp = reduceConfigWidthSize(config.smallestScreenWidthDp,
+ Surface.ROTATION_90, dm.density, unrotDh);
+ config.smallestScreenWidthDp = reduceConfigWidthSize(config.smallestScreenWidthDp,
+ Surface.ROTATION_180, dm.density, unrotDw);
+ config.smallestScreenWidthDp = reduceConfigWidthSize(config.smallestScreenWidthDp,
+ Surface.ROTATION_270, dm.density, unrotDh);
// Compute the screen layout size class.
int screenLayout;
@@ -6806,9 +6837,6 @@
final int dw = mCurDisplayWidth;
final int dh = mCurDisplayHeight;
- final int innerDw = mPolicy.getNonDecorDisplayWidth(dw);
- final int innerDh = mPolicy.getNonDecorDisplayHeight(dh);
-
final int N = mWindows.size();
int i;
@@ -6929,8 +6957,8 @@
final int dw = mCurDisplayWidth;
final int dh = mCurDisplayHeight;
- final int innerDw = mPolicy.getNonDecorDisplayWidth(dw);
- final int innerDh = mPolicy.getNonDecorDisplayHeight(dh);
+ final int innerDw = mPolicy.getNonDecorDisplayWidth(mRotation, dw);
+ final int innerDh = mPolicy.getNonDecorDisplayHeight(mRotation, dh);
int i;
diff --git a/tools/aapt/AaptAssets.cpp b/tools/aapt/AaptAssets.cpp
index a2271d9..75535f8 100644
--- a/tools/aapt/AaptAssets.cpp
+++ b/tools/aapt/AaptAssets.cpp
@@ -142,17 +142,10 @@
return 0;
}
- // screen layout size
- if (getScreenLayoutSizeName(part.string(), &config)) {
- *axis = AXIS_SCREENLAYOUTSIZE;
- *value = (config.screenLayout&ResTable_config::MASK_SCREENSIZE);
- return 0;
- }
-
- // screen layout long
- if (getScreenLayoutLongName(part.string(), &config)) {
- *axis = AXIS_SCREENLAYOUTLONG;
- *value = (config.screenLayout&ResTable_config::MASK_SCREENLONG);
+ // smallest screen dp width
+ if (getSmallestScreenWidthDpName(part.string(), &config)) {
+ *axis = AXIS_SMALLESTSCREENWIDTHDP;
+ *value = config.smallestScreenWidthDp;
return 0;
}
@@ -170,6 +163,20 @@
return 0;
}
+ // screen layout size
+ if (getScreenLayoutSizeName(part.string(), &config)) {
+ *axis = AXIS_SCREENLAYOUTSIZE;
+ *value = (config.screenLayout&ResTable_config::MASK_SCREENSIZE);
+ return 0;
+ }
+
+ // screen layout long
+ if (getScreenLayoutLongName(part.string(), &config)) {
+ *axis = AXIS_SCREENLAYOUTLONG;
+ *value = (config.screenLayout&ResTable_config::MASK_SCREENLONG);
+ return 0;
+ }
+
// orientation
if (getOrientationName(part.string(), &config)) {
*axis = AXIS_ORIENTATION;
@@ -257,7 +264,7 @@
String8 mcc, mnc, loc, layoutsize, layoutlong, orient, den;
String8 touch, key, keysHidden, nav, navHidden, size, vers;
- String8 uiModeType, uiModeNight, widthdp, heightdp;
+ String8 uiModeType, uiModeNight, smallestwidthdp, widthdp, heightdp;
const char *p = dir;
const char *q;
@@ -344,8 +351,8 @@
//printf("not region: %s\n", part.string());
}
- if (getScreenLayoutSizeName(part.string())) {
- layoutsize = part;
+ if (getSmallestScreenWidthDpName(part.string())) {
+ smallestwidthdp = part;
index++;
if (index == N) {
@@ -353,19 +360,7 @@
}
part = parts[index];
} else {
- //printf("not screen layout size: %s\n", part.string());
- }
-
- if (getScreenLayoutLongName(part.string())) {
- layoutlong = part;
-
- index++;
- if (index == N) {
- goto success;
- }
- part = parts[index];
- } else {
- //printf("not screen layout long: %s\n", part.string());
+ //printf("not smallest screen width dp: %s\n", part.string());
}
if (getScreenWidthDpName(part.string())) {
@@ -392,6 +387,30 @@
//printf("not screen height dp: %s\n", part.string());
}
+ if (getScreenLayoutSizeName(part.string())) {
+ layoutsize = part;
+
+ index++;
+ if (index == N) {
+ goto success;
+ }
+ part = parts[index];
+ } else {
+ //printf("not screen layout size: %s\n", part.string());
+ }
+
+ if (getScreenLayoutLongName(part.string())) {
+ layoutlong = part;
+
+ index++;
+ if (index == N) {
+ goto success;
+ }
+ part = parts[index];
+ } else {
+ //printf("not screen layout long: %s\n", part.string());
+ }
+
// orientation
if (getOrientationName(part.string())) {
orient = part;
@@ -541,6 +560,7 @@
this->locale = loc;
this->screenLayoutSize = layoutsize;
this->screenLayoutLong = layoutlong;
+ this->smallestScreenWidthDp = smallestwidthdp;
this->screenWidthDp = widthdp;
this->screenHeightDp = heightdp;
this->orientation = orient;
@@ -570,14 +590,16 @@
s += ",";
s += this->locale;
s += ",";
- s += screenLayoutSize;
- s += ",";
- s += screenLayoutLong;
+ s += smallestScreenWidthDp;
s += ",";
s += screenWidthDp;
s += ",";
s += screenHeightDp;
s += ",";
+ s += screenLayoutSize;
+ s += ",";
+ s += screenLayoutLong;
+ s += ",";
s += this->orientation;
s += ",";
s += uiModeType;
@@ -618,13 +640,9 @@
s += "-";
s += locale;
}
- if (this->screenLayoutSize != "") {
+ if (this->smallestScreenWidthDp != "") {
s += "-";
- s += screenLayoutSize;
- }
- if (this->screenLayoutLong != "") {
- s += "-";
- s += screenLayoutLong;
+ s += smallestScreenWidthDp;
}
if (this->screenWidthDp != "") {
s += "-";
@@ -634,6 +652,14 @@
s += "-";
s += screenHeightDp;
}
+ if (this->screenLayoutSize != "") {
+ s += "-";
+ s += screenLayoutSize;
+ }
+ if (this->screenLayoutLong != "") {
+ s += "-";
+ s += screenLayoutLong;
+ }
if (this->orientation != "") {
s += "-";
s += orientation;
@@ -1126,6 +1152,31 @@
return true;
}
+bool AaptGroupEntry::getSmallestScreenWidthDpName(const char* name, ResTable_config* out)
+{
+ if (strcmp(name, kWildcardName) == 0) {
+ if (out) {
+ out->smallestScreenWidthDp = out->SCREENWIDTH_ANY;
+ }
+ return true;
+ }
+
+ if (*name != 's') return false;
+ name++;
+ if (*name != 'w') return false;
+ name++;
+ const char* x = name;
+ while (*x >= '0' && *x <= '9') x++;
+ if (x == name || x[0] != 'd' || x[1] != 'p' || x[2] != 0) return false;
+ String8 xName(name, x-name);
+
+ if (out) {
+ out->smallestScreenWidthDp = (uint16_t)atoi(xName.string());
+ }
+
+ return true;
+}
+
bool AaptGroupEntry::getScreenWidthDpName(const char* name, ResTable_config* out)
{
if (strcmp(name, kWildcardName) == 0) {
@@ -1206,10 +1257,11 @@
if (v == 0) v = mnc.compare(o.mnc);
if (v == 0) v = locale.compare(o.locale);
if (v == 0) v = vendor.compare(o.vendor);
- if (v == 0) v = screenLayoutSize.compare(o.screenLayoutSize);
- if (v == 0) v = screenLayoutLong.compare(o.screenLayoutLong);
+ if (v == 0) v = smallestScreenWidthDp.compare(o.smallestScreenWidthDp);
if (v == 0) v = screenWidthDp.compare(o.screenWidthDp);
if (v == 0) v = screenHeightDp.compare(o.screenHeightDp);
+ if (v == 0) v = screenLayoutSize.compare(o.screenLayoutSize);
+ if (v == 0) v = screenLayoutLong.compare(o.screenLayoutLong);
if (v == 0) v = orientation.compare(o.orientation);
if (v == 0) v = uiModeType.compare(o.uiModeType);
if (v == 0) v = uiModeNight.compare(o.uiModeNight);
@@ -1231,10 +1283,11 @@
getMccName(mcc.string(), ¶ms);
getMncName(mnc.string(), ¶ms);
getLocaleName(locale.string(), ¶ms);
- getScreenLayoutSizeName(screenLayoutSize.string(), ¶ms);
- getScreenLayoutLongName(screenLayoutLong.string(), ¶ms);
+ getSmallestScreenWidthDpName(smallestScreenWidthDp.string(), ¶ms);
getScreenWidthDpName(screenWidthDp.string(), ¶ms);
getScreenHeightDpName(screenHeightDp.string(), ¶ms);
+ getScreenLayoutSizeName(screenLayoutSize.string(), ¶ms);
+ getScreenLayoutLongName(screenLayoutLong.string(), ¶ms);
getOrientationName(orientation.string(), ¶ms);
getUiModeTypeName(uiModeType.string(), ¶ms);
getUiModeNightName(uiModeNight.string(), ¶ms);
@@ -1249,9 +1302,10 @@
// Fix up version number based on specified parameters.
int minSdk = 0;
- if (params.screenWidthDp != ResTable_config::SCREENWIDTH_ANY
+ if (params.smallestScreenWidthDp != ResTable_config::SCREENWIDTH_ANY
+ || params.screenWidthDp != ResTable_config::SCREENWIDTH_ANY
|| params.screenHeightDp != ResTable_config::SCREENHEIGHT_ANY) {
- minSdk = SDK_ICS;
+ minSdk = SDK_HONEYCOMB_MR2;
} else if ((params.uiMode&ResTable_config::MASK_UI_MODE_TYPE)
!= ResTable_config::UI_MODE_TYPE_ANY
|| (params.uiMode&ResTable_config::MASK_UI_MODE_NIGHT)
diff --git a/tools/aapt/AaptAssets.h b/tools/aapt/AaptAssets.h
index e5afd1b..65743d8 100644
--- a/tools/aapt/AaptAssets.h
+++ b/tools/aapt/AaptAssets.h
@@ -42,6 +42,7 @@
AXIS_NAVHIDDEN,
AXIS_NAVIGATION,
AXIS_SCREENSIZE,
+ AXIS_SMALLESTSCREENWIDTHDP,
AXIS_SCREENWIDTHDP,
AXIS_SCREENHEIGHTDP,
AXIS_VERSION
@@ -54,7 +55,7 @@
SDK_ECLAIR_0_1 = 6,
SDK_MR1 = 7,
SDK_FROYO = 8,
- SDK_ICS = 13,
+ SDK_HONEYCOMB_MR2 = 13,
};
/**
@@ -72,10 +73,11 @@
String8 mnc;
String8 locale;
String8 vendor;
- String8 screenLayoutSize;
- String8 screenLayoutLong;
+ String8 smallestScreenWidthDp;
String8 screenWidthDp;
String8 screenHeightDp;
+ String8 screenLayoutSize;
+ String8 screenLayoutLong;
String8 orientation;
String8 uiModeType;
String8 uiModeNight;
@@ -107,6 +109,7 @@
static bool getNavigationName(const char* name, ResTable_config* out = NULL);
static bool getNavHiddenName(const char* name, ResTable_config* out = NULL);
static bool getScreenSizeName(const char* name, ResTable_config* out = NULL);
+ static bool getSmallestScreenWidthDpName(const char* name, ResTable_config* out = NULL);
static bool getScreenWidthDpName(const char* name, ResTable_config* out = NULL);
static bool getScreenHeightDpName(const char* name, ResTable_config* out = NULL);
static bool getVersionName(const char* name, ResTable_config* out = NULL);
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index 3dcc093..68c3892 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -2607,6 +2607,9 @@
if (!match(AXIS_SCREENSIZE, config.screenSize)) {
return false;
}
+ if (!match(AXIS_SMALLESTSCREENWIDTHDP, config.smallestScreenWidthDp)) {
+ return false;
+ }
if (!match(AXIS_SCREENWIDTHDP, config.screenWidthDp)) {
return false;
}
@@ -2809,7 +2812,8 @@
ConfigDescription config = t->getUniqueConfigs().itemAt(ci);
NOISY(printf("Writing config %d config: imsi:%d/%d lang:%c%c cnt:%c%c "
- "orien:%d ui:%d touch:%d density:%d key:%d inp:%d nav:%d sz:%dx%d %ddp x %ddp\n",
+ "orien:%d ui:%d touch:%d density:%d key:%d inp:%d nav:%d sz:%dx%d "
+ "sw%ddp w%ddp h%ddp\n",
ti+1,
config.mcc, config.mnc,
config.language[0] ? config.language[0] : '-',
@@ -2825,6 +2829,7 @@
config.navigation,
config.screenWidth,
config.screenHeight,
+ config.smallestScreenWidthDp,
config.screenWidthDp,
config.screenHeightDp));
@@ -2849,7 +2854,8 @@
tHeader->entriesStart = htodl(typeSize);
tHeader->config = config;
NOISY(printf("Writing type %d config: imsi:%d/%d lang:%c%c cnt:%c%c "
- "orien:%d ui:%d touch:%d density:%d key:%d inp:%d nav:%d sz:%dx%d %ddp x %ddp\n",
+ "orien:%d ui:%d touch:%d density:%d key:%d inp:%d nav:%d sz:%dx%d "
+ "sw%ddp w%ddp h%ddp\n",
ti+1,
tHeader->config.mcc, tHeader->config.mnc,
tHeader->config.language[0] ? tHeader->config.language[0] : '-',
@@ -2865,6 +2871,7 @@
tHeader->config.navigation,
tHeader->config.screenWidth,
tHeader->config.screenHeight,
+ tHeader->config.smallestScreenWidthDp,
tHeader->config.screenWidthDp,
tHeader->config.screenHeightDp));
tHeader->config.swapHtoD();
@@ -3448,7 +3455,8 @@
if (e == NULL) {
if (config != NULL) {
NOISY(printf("New entry at %s:%d: imsi:%d/%d lang:%c%c cnt:%c%c "
- "orien:%d touch:%d density:%d key:%d inp:%d nav:%d sz:%dx%d %ddp x %ddp\n",
+ "orien:%d touch:%d density:%d key:%d inp:%d nav:%d sz:%dx%d "
+ "sw%ddp w%ddp h%ddp\n",
sourcePos.file.string(), sourcePos.line,
config->mcc, config->mnc,
config->language[0] ? config->language[0] : '-',
@@ -3463,6 +3471,7 @@
config->navigation,
config->screenWidth,
config->screenHeight,
+ config->smallestScreenWidthDp,
config->screenWidthDp,
config->screenHeightDp));
} else {
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl
index 16a61db..0757efd 100644
--- a/wifi/java/android/net/wifi/IWifiManager.aidl
+++ b/wifi/java/android/net/wifi/IWifiManager.aidl
@@ -87,7 +87,7 @@
void releaseMulticastLock();
- boolean setWifiApEnabled(in WifiConfiguration wifiConfig, boolean enable);
+ void setWifiApEnabled(in WifiConfiguration wifiConfig, boolean enable);
int getWifiApEnabledState();
diff --git a/wifi/java/android/net/wifi/WifiApConfigStore.java b/wifi/java/android/net/wifi/WifiApConfigStore.java
new file mode 100644
index 0000000..bb5427d
--- /dev/null
+++ b/wifi/java/android/net/wifi/WifiApConfigStore.java
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2010 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 android.net.wifi;
+
+import android.content.Context;
+import android.net.wifi.WifiConfiguration.KeyMgmt;
+import android.os.Environment;
+import android.os.Message;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.util.Log;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.util.UUID;
+
+import com.android.internal.R;
+
+
+/**
+ * Provides API to the WifiStateMachine for doing read/write access
+ * to soft access point configuration
+ */
+class WifiApConfigStore {
+
+ private static Context sContext;
+ private static final String TAG = "WifiApConfigStore";
+
+ private static final String AP_CONFIG_FILE = Environment.getDataDirectory() +
+ "/misc/wifi/softap.conf";
+
+ private static final int AP_CONFIG_FILE_VERSION = 1;
+
+ private static WifiConfiguration sApConfig = new WifiConfiguration();
+ private static final Object sApConfigLock = new Object();
+
+ private static FileReadWriteHandler sFileReadWriteHandler;
+ private static final int READ_AP_CONFIG = 1;
+ private static final int WRITE_AP_CONFIG = 2;
+
+ static void initialize(Context context) {
+ sContext = context;
+
+ /* File operations happen on a seperate thread */
+ HandlerThread configThread = new HandlerThread("WifiApConfigStore");
+ configThread.start();
+ sFileReadWriteHandler = new FileReadWriteHandler(configThread.getLooper());
+ Message.obtain(sFileReadWriteHandler, READ_AP_CONFIG).sendToTarget();
+ }
+
+
+ static void setApConfiguration(WifiConfiguration config) {
+ synchronized (sApConfigLock) {
+ sApConfig = config;
+ }
+ Message.obtain(sFileReadWriteHandler, WRITE_AP_CONFIG, new WifiConfiguration(config))
+ .sendToTarget();
+ }
+
+ static WifiConfiguration getApConfiguration() {
+ synchronized (sApConfigLock) {
+ return new WifiConfiguration(sApConfig);
+ }
+ }
+
+ /**
+ * File read/write handler
+ */
+ private static class FileReadWriteHandler extends Handler {
+
+ public FileReadWriteHandler(android.os.Looper looper) {
+ super(looper);
+ }
+
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case WRITE_AP_CONFIG:
+ writeApConfiguration((WifiConfiguration) msg.obj);
+ break;
+ case READ_AP_CONFIG:
+ readApConfiguration();
+ break;
+ default:
+ Log.e(TAG, "Unknown command in FileReadWriteHandler: " + msg);
+ break;
+ }
+ }
+
+ private static void writeApConfiguration(final WifiConfiguration config) {
+ DataOutputStream out = null;
+ try {
+ out = new DataOutputStream(new BufferedOutputStream(
+ new FileOutputStream(AP_CONFIG_FILE)));
+
+ out.writeInt(AP_CONFIG_FILE_VERSION);
+ out.writeUTF(config.SSID);
+ int authType = config.getAuthType();
+ out.writeInt(authType);
+ if(authType != KeyMgmt.NONE) {
+ out.writeUTF(config.preSharedKey);
+ }
+ } catch (IOException e) {
+ Log.e(TAG, "Error writing hotspot configuration" + e);
+ } finally {
+ if (out != null) {
+ try {
+ out.close();
+ } catch (IOException e) {}
+ }
+ }
+ }
+
+ private static void readApConfiguration() {
+ DataInputStream in = null;
+ try {
+ WifiConfiguration config = new WifiConfiguration();
+ in = new DataInputStream(new BufferedInputStream(new FileInputStream(
+ AP_CONFIG_FILE)));
+
+ int version = in.readInt();
+ if (version != 1) {
+ Log.e(TAG, "Bad version on hotspot configuration file, set defaults");
+ setDefaultApConfiguration();
+ return;
+ }
+ config.SSID = in.readUTF();
+ int authType = in.readInt();
+ config.allowedKeyManagement.set(authType);
+ if (authType != KeyMgmt.NONE) {
+ config.preSharedKey = in.readUTF();
+ }
+ synchronized (sApConfigLock) {
+ sApConfig = config;
+ }
+ } catch (IOException ignore) {
+ setDefaultApConfiguration();
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {}
+ }
+ }
+ }
+
+ /* Generate a default WPA2 based configuration with a random password.
+ We are changing the Wifi Ap configuration storage from secure settings to a
+ flat file accessible only by the system. A WPA2 based default configuration
+ will keep the device secure after the update */
+ private static void setDefaultApConfiguration() {
+ WifiConfiguration config = new WifiConfiguration();
+ config.SSID = sContext.getString(R.string.wifi_tether_configure_ssid_default);
+ config.allowedKeyManagement.set(KeyMgmt.WPA2_PSK);
+ String randomUUID = UUID.randomUUID().toString();
+ //first 12 chars from xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
+ config.preSharedKey = randomUUID.substring(0, 8) + randomUUID.substring(9,13);
+ setApConfiguration(config);
+ }
+ }
+}
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 2e49a77..949e80f 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -898,7 +898,8 @@
*/
public boolean setWifiApEnabled(WifiConfiguration wifiConfig, boolean enabled) {
try {
- return mService.setWifiApEnabled(wifiConfig, enabled);
+ mService.setWifiApEnabled(wifiConfig, enabled);
+ return true;
} catch (RemoteException e) {
return false;
}
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index a87ee9a..0c0e2534 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -200,8 +200,12 @@
static final int CMD_START_AP = BASE + 21;
/* Stop the soft access point */
static final int CMD_STOP_AP = BASE + 22;
+ /* Set the soft access point configuration */
+ static final int CMD_SET_AP_CONFIG = BASE + 23;
+ /* Get the soft access point configuration */
+ static final int CMD_GET_AP_CONFIG = BASE + 24;
- static final int CMD_BLUETOOTH_ADAPTER_STATE_CHANGE = BASE + 23;
+ static final int CMD_BLUETOOTH_ADAPTER_STATE_CHANGE = BASE + 25;
/* Supplicant events */
/* Connection to supplicant established */
@@ -355,6 +359,10 @@
private static final int MIN_RSSI = -200;
private static final int MAX_RSSI = 256;
+ /* Constants to indicate if soft ap is running or stopped */
+ private static final int SOFT_AP_STOPPED = 0;
+ private static final int SOFT_AP_RUNNING = 1;
+
/* Default parent state */
private HierarchicalState mDefaultState = new DefaultState();
/* Temporary initial state */
@@ -593,6 +601,17 @@
}
}
+ public void setWifiApConfiguration(WifiConfiguration config) {
+ sendMessage(obtainMessage(CMD_SET_AP_CONFIG, config));
+ }
+
+ public WifiConfiguration syncGetWifiApConfiguration(AsyncChannel channel) {
+ Message resultMsg = channel.sendMessageSynchronously(CMD_GET_AP_CONFIG);
+ WifiConfiguration ret = (WifiConfiguration) resultMsg.obj;
+ resultMsg.recycle();
+ return ret;
+ }
+
/**
* TODO: doc
*/
@@ -1517,7 +1536,31 @@
*/
WifiNative.disconnectCommand();
WifiNative.reconnectCommand();
+ }
+ private boolean startSoftApWithConfig(WifiConfiguration config, int currentStatus) {
+ if (config == null) {
+ config = WifiApConfigStore.getApConfiguration();
+ } else {
+ WifiApConfigStore.setApConfiguration(config);
+ }
+ try {
+ if (currentStatus == SOFT_AP_STOPPED) {
+ nwService.startAccessPoint(config, mInterfaceName, SOFTAP_IFACE);
+ } else if (currentStatus == SOFT_AP_RUNNING) {
+ nwService.setAccessPoint(config, mInterfaceName, SOFTAP_IFACE);
+ }
+ } catch (Exception e) {
+ Log.e(TAG, "Exception in softap start " + e);
+ try {
+ nwService.stopAccessPoint();
+ nwService.startAccessPoint(config, mInterfaceName, SOFTAP_IFACE);
+ } catch (Exception ee) {
+ Log.e(TAG, "Exception during softap restart : " + ee);
+ return false;
+ }
+ }
+ return true;
}
@@ -1655,6 +1698,13 @@
case CMD_ENABLE_BACKGROUND_SCAN:
mEnableBackgroundScan = (message.arg1 == 1);
break;
+ case CMD_SET_AP_CONFIG:
+ WifiApConfigStore.setApConfiguration((WifiConfiguration) message.obj);
+ break;
+ case CMD_GET_AP_CONFIG:
+ WifiConfiguration config = WifiApConfigStore.getApConfiguration();
+ mReplyChannel.replyToMessage(message, message.what, config);
+ break;
/* Discard */
case CMD_LOAD_DRIVER:
case CMD_UNLOAD_DRIVER:
@@ -1717,6 +1767,8 @@
// 50021 wifi_state_changed (custom|1|5)
EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName());
+ WifiApConfigStore.initialize(mContext);
+
if (WifiNative.isDriverLoaded()) {
transitionTo(mDriverLoadedState);
}
@@ -1829,26 +1881,14 @@
}
break;
case CMD_START_AP:
- try {
- nwService.startAccessPoint((WifiConfiguration) message.obj,
- mInterfaceName,
- SOFTAP_IFACE);
- } catch (Exception e) {
- Log.e(TAG, "Exception in softap start " + e);
- try {
- nwService.stopAccessPoint();
- nwService.startAccessPoint((WifiConfiguration) message.obj,
- mInterfaceName,
- SOFTAP_IFACE);
- } catch (Exception ee) {
- Log.e(TAG, "Exception during softap restart : " + ee);
- sendMessage(obtainMessage(CMD_UNLOAD_DRIVER, WIFI_AP_STATE_FAILED, 0));
- break;
- }
+ if (startSoftApWithConfig((WifiConfiguration) message.obj, SOFT_AP_STOPPED)) {
+ Log.d(TAG, "Soft AP start successful");
+ setWifiApState(WIFI_AP_STATE_ENABLED);
+ transitionTo(mSoftApStartedState);
+ } else {
+ Log.d(TAG, "Soft AP start failed");
+ sendMessage(obtainMessage(CMD_UNLOAD_DRIVER, WIFI_AP_STATE_FAILED, 0));
}
- Log.d(TAG, "Soft AP start successful");
- setWifiApState(WIFI_AP_STATE_ENABLED);
- transitionTo(mSoftApStartedState);
break;
default:
return NOT_HANDLED;
@@ -2999,21 +3039,13 @@
break;
case CMD_START_AP:
Log.d(TAG,"SoftAP set on a running access point");
- try {
- nwService.setAccessPoint((WifiConfiguration) message.obj,
- mInterfaceName,
- SOFTAP_IFACE);
- } catch(Exception e) {
- Log.e(TAG, "Exception in softap set " + e);
- try {
- nwService.stopAccessPoint();
- nwService.startAccessPoint((WifiConfiguration) message.obj,
- mInterfaceName,
- SOFTAP_IFACE);
- } catch (Exception ee) {
- Log.e(TAG, "Could not restart softap after set failed " + ee);
- sendMessage(obtainMessage(CMD_UNLOAD_DRIVER, WIFI_AP_STATE_FAILED, 0));
- }
+ if (startSoftApWithConfig((WifiConfiguration) message.obj, SOFT_AP_RUNNING)) {
+ Log.d(TAG, "Soft AP start successful");
+ setWifiApState(WIFI_AP_STATE_ENABLED);
+ transitionTo(mSoftApStartedState);
+ } else {
+ Log.d(TAG, "Soft AP start failed");
+ sendMessage(obtainMessage(CMD_UNLOAD_DRIVER, WIFI_AP_STATE_FAILED, 0));
}
break;
/* Fail client mode operation when soft AP is enabled */