Merge "Clarify documentation of Bitmap.createScaledBitmap/createBitmap Bug #6015472"
diff --git a/api/current.txt b/api/current.txt
index 7edfa53..97be454 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -992,6 +992,7 @@
field public static final int textColorTertiary = 16843282; // 0x1010212
field public static final int textColorTertiaryInverse = 16843283; // 0x1010213
field public static final int textCursorDrawable = 16843618; // 0x1010362
+ field public static final int textDirection = 16843688; // 0x10103a8
field public static final int textEditNoPasteWindowLayout = 16843541; // 0x1010315
field public static final int textEditPasteWindowLayout = 16843540; // 0x1010314
field public static final int textEditSideNoPasteWindowLayout = 16843615; // 0x101035f
@@ -20478,6 +20479,19 @@
method public int getTopPadding();
}
+ public abstract interface TextDirectionHeuristic {
+ }
+
+ public class TextDirectionHeuristics {
+ ctor public TextDirectionHeuristics();
+ field public static final android.text.TextDirectionHeuristic ANYRTL_LTR;
+ field public static final android.text.TextDirectionHeuristic FIRSTSTRONG_LTR;
+ field public static final android.text.TextDirectionHeuristic FIRSTSTRONG_RTL;
+ field public static final android.text.TextDirectionHeuristic LOCALE;
+ field public static final android.text.TextDirectionHeuristic LTR;
+ field public static final android.text.TextDirectionHeuristic RTL;
+ }
+
public class TextPaint extends android.graphics.Paint {
ctor public TextPaint();
ctor public TextPaint(int);
@@ -23171,6 +23185,7 @@
method public final android.view.ViewParent getParent();
method public float getPivotX();
method public float getPivotY();
+ method public int getResolvedTextDirection();
method public android.content.res.Resources getResources();
method public final int getRight();
method protected float getRightFadingEdgeStrength();
@@ -23190,6 +23205,7 @@
method public int getSystemUiVisibility();
method public java.lang.Object getTag();
method public java.lang.Object getTag(int);
+ method public int getTextDirection();
method public final int getTop();
method protected float getTopFadingEdgeStrength();
method protected int getTopPaddingOffset();
@@ -23321,8 +23337,10 @@
method public void requestLayout();
method public boolean requestRectangleOnScreen(android.graphics.Rect);
method public boolean requestRectangleOnScreen(android.graphics.Rect, boolean);
+ method protected void resetResolvedTextDirection();
method public static int resolveSize(int, int);
method public static int resolveSizeAndState(int, int, int);
+ method protected void resolveTextDirection();
method public void restoreHierarchyState(android.util.SparseArray<android.os.Parcelable>);
method public void saveHierarchyState(android.util.SparseArray<android.os.Parcelable>);
method public void scheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable, long);
@@ -23402,6 +23420,7 @@
method public void setSystemUiVisibility(int);
method public void setTag(java.lang.Object);
method public void setTag(int, java.lang.Object);
+ method public void setTextDirection(int);
method public final void setTop(int);
method public void setTouchDelegate(android.view.TouchDelegate);
method public void setTranslationX(float);
@@ -23424,6 +23443,7 @@
method public boolean willNotCacheDrawing();
method public boolean willNotDraw();
field public static final android.util.Property ALPHA;
+ field protected static int DEFAULT_TEXT_DIRECTION;
field public static final int DRAWING_CACHE_QUALITY_AUTO = 0; // 0x0
field public static final int DRAWING_CACHE_QUALITY_HIGH = 1048576; // 0x100000
field public static final int DRAWING_CACHE_QUALITY_LOW = 524288; // 0x80000
@@ -23500,6 +23520,12 @@
field public static final int SYSTEM_UI_FLAG_HIDE_NAVIGATION = 2; // 0x2
field public static final int SYSTEM_UI_FLAG_LOW_PROFILE = 1; // 0x1
field public static final int SYSTEM_UI_FLAG_VISIBLE = 0; // 0x0
+ field public static final int TEXT_DIRECTION_ANY_RTL = 2; // 0x2
+ field public static final int TEXT_DIRECTION_FIRST_STRONG = 1; // 0x1
+ field public static final int TEXT_DIRECTION_INHERIT = 0; // 0x0
+ field public static final int TEXT_DIRECTION_LOCALE = 5; // 0x5
+ field public static final int TEXT_DIRECTION_LTR = 3; // 0x3
+ field public static final int TEXT_DIRECTION_RTL = 4; // 0x4
field public static final android.util.Property TRANSLATION_X;
field public static final android.util.Property TRANSLATION_Y;
field protected static final java.lang.String VIEW_LOG_TAG = "View";
@@ -23766,7 +23792,6 @@
method public boolean requestSendAccessibilityEvent(android.view.View, android.view.accessibility.AccessibilityEvent);
method public void requestTransparentRegion(android.view.View);
method protected void resetResolvedLayoutDirection();
- method protected void resetResolvedTextDirection();
method public void scheduleLayoutAnimation();
method public void setAddStatesFromChildren(boolean);
method public void setAlwaysDrawnWithCacheEnabled(boolean);
@@ -27595,7 +27620,6 @@
method protected void resetResolvedDrawables();
method protected void resetResolvedLayoutDirection();
method protected void resolveDrawables();
- method protected void resolveTextDirection();
method public void setAllCaps(boolean);
method public final void setAutoLinkMask(int);
method public void setCompoundDrawablePadding(int);
diff --git a/core/java/android/text/TextDirectionHeuristics.java b/core/java/android/text/TextDirectionHeuristics.java
index e5c1e5b..ae41eab 100644
--- a/core/java/android/text/TextDirectionHeuristics.java
+++ b/core/java/android/text/TextDirectionHeuristics.java
@@ -17,13 +17,10 @@
package android.text;
-import java.util.Locale;
-
import android.util.LocaleUtil;
/**
* Some objects that implement TextDirectionHeuristic.
- * @hide
*/
public class TextDirectionHeuristics {
@@ -74,9 +71,8 @@
* Computes the text direction based on an algorithm. Subclasses implement
* {@link #defaultIsRtl} to handle cases where the algorithm cannot determine the
* direction from the text alone.
- * @hide
*/
- public static abstract class TextDirectionHeuristicImpl implements TextDirectionHeuristic {
+ private static abstract class TextDirectionHeuristicImpl implements TextDirectionHeuristic {
private final TextDirectionAlgorithm mAlgorithm;
public TextDirectionHeuristicImpl(TextDirectionAlgorithm algorithm) {
@@ -157,13 +153,11 @@
/**
* Interface for an algorithm to guess the direction of a paragraph of text.
*
- * @hide
*/
- public static interface TextDirectionAlgorithm {
+ private static interface TextDirectionAlgorithm {
/**
* Returns whether the range of text is RTL according to the algorithm.
*
- * @hide
*/
TriState checkRtl(char[] text, int start, int count);
}
@@ -173,9 +167,8 @@
* the paragraph direction. This is the standard Unicode Bidirectional
* algorithm.
*
- * @hide
*/
- public static class FirstStrong implements TextDirectionAlgorithm {
+ private static class FirstStrong implements TextDirectionAlgorithm {
@Override
public TriState checkRtl(char[] text, int start, int count) {
TriState result = TriState.UNKNOWN;
@@ -196,9 +189,8 @@
* character (e.g. excludes LRE, LRO, RLE, RLO) to determine the
* direction of text.
*
- * @hide
*/
- public static class AnyStrong implements TextDirectionAlgorithm {
+ private static class AnyStrong implements TextDirectionAlgorithm {
private final boolean mLookForRtl;
@Override
@@ -239,7 +231,7 @@
/**
* Algorithm that uses the Locale direction to force the direction of a paragraph.
*/
- public static class TextDirectionHeuristicLocale extends TextDirectionHeuristicImpl {
+ private static class TextDirectionHeuristicLocale extends TextDirectionHeuristicImpl {
public TextDirectionHeuristicLocale() {
super(null);
diff --git a/core/java/android/text/method/KeyListener.java b/core/java/android/text/method/KeyListener.java
index 8594852..318149a 100644
--- a/core/java/android/text/method/KeyListener.java
+++ b/core/java/android/text/method/KeyListener.java
@@ -22,7 +22,7 @@
/**
* Interface for converting text key events into edit operations on an
- * Editable class. Note that for must cases this interface has been
+ * Editable class. Note that for most cases this interface has been
* superceded by general soft input methods as defined by
* {@link android.view.inputmethod.InputMethod}; it should only be used
* for cases where an application has its own on-screen keypad and also wants
diff --git a/core/java/android/text/method/TransformationMethod.java b/core/java/android/text/method/TransformationMethod.java
index 9f51c2a..b542109 100644
--- a/core/java/android/text/method/TransformationMethod.java
+++ b/core/java/android/text/method/TransformationMethod.java
@@ -18,7 +18,6 @@
import android.graphics.Rect;
import android.view.View;
-import android.widget.TextView;
/**
* TextView uses TransformationMethods to do things like replacing the
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 056be7f..87104f4 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -2618,7 +2618,6 @@
/**
* Text direction is inherited thru {@link ViewGroup}
- * @hide
*/
public static final int TEXT_DIRECTION_INHERIT = 0;
@@ -2627,7 +2626,6 @@
* determines the paragraph direction. If there is no strong directional character, the
* paragraph direction is the view's resolved layout direction.
*
- * @hide
*/
public static final int TEXT_DIRECTION_FIRST_STRONG = 1;
@@ -2636,42 +2634,36 @@
* any strong RTL character, otherwise it is LTR if it contains any strong LTR characters.
* If there are neither, the paragraph direction is the view's resolved layout direction.
*
- * @hide
*/
public static final int TEXT_DIRECTION_ANY_RTL = 2;
/**
* Text direction is forced to LTR.
*
- * @hide
*/
public static final int TEXT_DIRECTION_LTR = 3;
/**
* Text direction is forced to RTL.
*
- * @hide
*/
public static final int TEXT_DIRECTION_RTL = 4;
/**
* Text direction is coming from the system Locale.
*
- * @hide
*/
public static final int TEXT_DIRECTION_LOCALE = 5;
/**
* Default text direction is inherited
*
- * @hide
*/
protected static int DEFAULT_TEXT_DIRECTION = TEXT_DIRECTION_INHERIT;
/**
* The text direction that has been defined by {@link #setTextDirection(int)}.
*
- * {@hide}
*/
@ViewDebug.ExportedProperty(category = "text", mapping = {
@ViewDebug.IntToString(from = TEXT_DIRECTION_INHERIT, to = "INHERIT"),
@@ -2689,7 +2681,6 @@
* not TEXT_DIRECTION_INHERIT, otherwise resolution proceeds up the parent
* chain of the view.
*
- * {@hide}
*/
@ViewDebug.ExportedProperty(category = "text", mapping = {
@ViewDebug.IntToString(from = TEXT_DIRECTION_INHERIT, to = "INHERIT"),
@@ -3775,14 +3766,6 @@
}
if ((mPrivateFlags & FOCUSED) != 0) {
- // If this is the first focusable do not clear focus since the we
- // try to give it focus every time a view clears its focus. Hence,
- // the view that would gain focus already has it.
- View firstFocusable = getFirstFocusable();
- if (firstFocusable == this) {
- return;
- }
-
mPrivateFlags &= ~FOCUSED;
if (mParent != null) {
@@ -3791,24 +3774,9 @@
onFocusChanged(false, 0, null);
refreshDrawableState();
-
- // The view cleared focus and invoked the callbacks, so now is the
- // time to give focus to the the first focusable to ensure that the
- // gain focus is announced after clear focus.
- if (firstFocusable != null) {
- firstFocusable.requestFocus(FOCUS_FORWARD);
- }
}
}
- private View getFirstFocusable() {
- ViewRootImpl viewRoot = getViewRootImpl();
- if (viewRoot != null) {
- return viewRoot.focusSearch(null, FOCUS_FORWARD);
- }
- return null;
- }
-
/**
* Called to clear the focus of a view that is about to be removed.
* Doesn't call clearChildFocus, which prevents this view from taking
@@ -14106,7 +14074,6 @@
* {@link #TEXT_DIRECTION_RTL},
* {@link #TEXT_DIRECTION_LOCALE},
*
- * @hide
*/
public int getTextDirection() {
return mTextDirection;
@@ -14124,7 +14091,6 @@
* {@link #TEXT_DIRECTION_RTL},
* {@link #TEXT_DIRECTION_LOCALE},
*
- * @hide
*/
public void setTextDirection(int textDirection) {
if (textDirection != mTextDirection) {
@@ -14145,7 +14111,6 @@
* {@link #TEXT_DIRECTION_RTL},
* {@link #TEXT_DIRECTION_LOCALE},
*
- * @hide
*/
public int getResolvedTextDirection() {
if (mResolvedTextDirection == TEXT_DIRECTION_INHERIT) {
@@ -14157,7 +14122,6 @@
/**
* Resolve the text direction.
*
- * @hide
*/
protected void resolveTextDirection() {
if (mTextDirection != TEXT_DIRECTION_INHERIT) {
@@ -14174,7 +14138,6 @@
/**
* Reset resolved text direction. Will be resolved during a call to getResolvedTextDirection().
*
- * @hide
*/
protected void resetResolvedTextDirection() {
mResolvedTextDirection = TEXT_DIRECTION_INHERIT;
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index a2e85a3..bc147ac 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -675,14 +675,11 @@
*/
@Override
public void clearFocus() {
- if (DBG) {
- System.out.println(this + " clearFocus()");
- }
- if (mFocused == null) {
- super.clearFocus();
- } else {
+ super.clearFocus();
+
+ // clear any child focus if it exists
+ if (mFocused != null) {
mFocused.clearFocus();
- mFocused = null;
}
}
@@ -694,12 +691,12 @@
if (DBG) {
System.out.println(this + " unFocus()");
}
- if (mFocused == null) {
- super.unFocus();
- } else {
+
+ super.unFocus();
+ if (mFocused != null) {
mFocused.unFocus();
- mFocused = null;
}
+ mFocused = null;
}
/**
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 1930a5e..1c3bbfa 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -174,7 +174,6 @@
View mView;
View mFocusedView;
View mRealFocusedView; // this is not set to null in touch mode
- View mOldFocusedView;
int mViewVisibility;
boolean mAppVisible = true;
int mOrigWindowType = -1;
@@ -2273,34 +2272,33 @@
public void requestChildFocus(View child, View focused) {
checkThread();
-
- if (DEBUG_INPUT_RESIZE) {
- Log.v(TAG, "Request child focus: focus now " + focused);
+ if (mFocusedView != focused) {
+ mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(mFocusedView, focused);
+ scheduleTraversals();
}
-
- mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(mOldFocusedView, focused);
- scheduleTraversals();
-
mFocusedView = mRealFocusedView = focused;
+ if (DEBUG_INPUT_RESIZE) Log.v(TAG, "Request child focus: focus now "
+ + mFocusedView);
}
public void clearChildFocus(View child) {
checkThread();
- if (DEBUG_INPUT_RESIZE) {
- Log.v(TAG, "Clearing child focus");
- }
+ View oldFocus = mFocusedView;
- mOldFocusedView = mFocusedView;
-
- // Invoke the listener only if there is no view to take focus
- if (focusSearch(null, View.FOCUS_FORWARD) == null) {
- mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(mOldFocusedView, null);
- }
-
+ if (DEBUG_INPUT_RESIZE) Log.v(TAG, "Clearing child focus");
mFocusedView = mRealFocusedView = null;
+ if (mView != null && !mView.hasFocus()) {
+ // If a view gets the focus, the listener will be invoked from requestChildFocus()
+ if (!mView.requestFocus(View.FOCUS_FORWARD)) {
+ mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(oldFocus, null);
+ }
+ } else if (oldFocus != null) {
+ mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(oldFocus, null);
+ }
}
+
public void focusableViewAvailable(View v) {
checkThread();
@@ -2772,7 +2770,6 @@
mView.unFocus();
mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(focused, null);
mFocusedView = null;
- mOldFocusedView = null;
return true;
}
}
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index fbafc64..332a0eb 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -4803,7 +4803,9 @@
if (layer == 0 || isPictureAfterFirstLayout) {
mWebViewCore.resumeWebKitDraw();
} else if (queueFull) {
- mWebViewCore.pauseWebKitDraw();
+ // temporarily disable webkit draw throttling
+ // TODO: re-enable
+ // mWebViewCore.pauseWebKitDraw();
}
if (mHTML5VideoViewProxy != null) {
@@ -6111,7 +6113,7 @@
calcOurContentVisibleRectF(mVisibleContentRect);
nativeUpdateDrawGLFunction(mGLViewportEmpty ? null : mGLRectViewport,
mGLViewportEmpty ? null : mViewRectViewport,
- mVisibleContentRect);
+ mVisibleContentRect, getScale());
}
/**
@@ -9885,7 +9887,7 @@
private native int nativeGetDrawGLFunction(int nativeInstance, Rect rect,
Rect viewRect, RectF visibleRect, float scale, int extras);
private native void nativeUpdateDrawGLFunction(Rect rect, Rect viewRect,
- RectF visibleRect);
+ RectF visibleRect, float scale);
private native void nativeExtendSelection(int x, int y);
private native int nativeFindAll(String findLower, String findUpper,
boolean sameAsLastSearch);
diff --git a/core/java/android/widget/SpellChecker.java b/core/java/android/widget/SpellChecker.java
index 570f0f9..909f383 100644
--- a/core/java/android/widget/SpellChecker.java
+++ b/core/java/android/widget/SpellChecker.java
@@ -426,7 +426,8 @@
}
// A new word has been created across the interval boundaries with this edit.
- // Previous spans (ended on start / started on end) removed, not valid anymore
+ // The previous spans (that ended on start / started on end) are not valid
+ // anymore and must be removed.
if (wordStart < start && wordEnd > start) {
removeSpansAt(editable, start, spellCheckSpans);
removeSpansAt(editable, start, suggestionSpans);
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 99349b0..7db8a1e 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -3472,6 +3472,9 @@
if (mText.length() == 0) {
invalidate();
}
+
+ // Invalidate display list if hint will be used
+ if (mText.length() == 0 && mHint != null) mTextDisplayListIsValid = false;
}
/**
diff --git a/core/jni/android_net_wifi_Wifi.cpp b/core/jni/android_net_wifi_Wifi.cpp
index 2ac3ca8..c5ff16e 100644
--- a/core/jni/android_net_wifi_Wifi.cpp
+++ b/core/jni/android_net_wifi_Wifi.cpp
@@ -116,14 +116,9 @@
return (jboolean)(::wifi_unload_driver() == 0);
}
-static jboolean android_net_wifi_startSupplicant(JNIEnv* env, jobject)
+static jboolean android_net_wifi_startSupplicant(JNIEnv* env, jobject, jboolean p2pSupported)
{
- return (jboolean)(::wifi_start_supplicant() == 0);
-}
-
-static jboolean android_net_wifi_startP2pSupplicant(JNIEnv* env, jobject)
-{
- return (jboolean)(::wifi_start_p2p_supplicant() == 0);
+ return (jboolean)(::wifi_start_supplicant(p2pSupported) == 0);
}
static jboolean android_net_wifi_killSupplicant(JNIEnv* env, jobject)
@@ -207,8 +202,7 @@
{ "loadDriver", "()Z", (void *)android_net_wifi_loadDriver },
{ "isDriverLoaded", "()Z", (void *)android_net_wifi_isDriverLoaded },
{ "unloadDriver", "()Z", (void *)android_net_wifi_unloadDriver },
- { "startSupplicant", "()Z", (void *)android_net_wifi_startSupplicant },
- { "startP2pSupplicant", "()Z", (void *)android_net_wifi_startP2pSupplicant },
+ { "startSupplicant", "(Z)Z", (void *)android_net_wifi_startSupplicant },
{ "killSupplicant", "()Z", (void *)android_net_wifi_killSupplicant },
{ "connectToSupplicant", "(Ljava/lang/String;)Z",
(void *)android_net_wifi_connectToSupplicant },
diff --git a/core/res/res/anim/recents_fade_in.xml b/core/res/res/anim/recents_fade_in.xml
new file mode 100644
index 0000000..c516fadb
--- /dev/null
+++ b/core/res/res/anim/recents_fade_in.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/* //device/apps/common/res/anim/recents_fade_in.xml
+**
+** Copyright 2012, 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.
+*/
+-->
+
+<alpha xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@interpolator/decelerate_quad"
+ android:fromAlpha="0.0" android:toAlpha="1.0"
+ android:duration="150" />
diff --git a/core/res/res/anim/recents_fade_out.xml b/core/res/res/anim/recents_fade_out.xml
new file mode 100644
index 0000000..7468cc19
--- /dev/null
+++ b/core/res/res/anim/recents_fade_out.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/* //device/apps/common/res/anim/recents_fade_out.xml
+**
+** Copyright 2012, 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.
+*/
+-->
+
+<alpha xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@interpolator/accelerate_quad"
+ android:fromAlpha="1.0"
+ android:toAlpha="0.0"
+ android:duration="150" />
diff --git a/core/res/res/values-bg/strings.xml b/core/res/res/values-bg/strings.xml
index 23ae6c2..0a22133 100644
--- a/core/res/res/values-bg/strings.xml
+++ b/core/res/res/values-bg/strings.xml
@@ -215,10 +215,8 @@
<string name="permdesc_reorderTasks" msgid="4175137612205663399">"Разрешава на приложението да прехвърля задачи на преден и на заден план. Злонамерените приложения могат сами да се изведат на преден план без ваша намеса."</string>
<string name="permlab_removeTasks" msgid="6821513401870377403">"спиране на изпълняваните приложения"</string>
<string name="permdesc_removeTasks" msgid="1394714352062635493">"Разрешава на приложението да премахва задачи и да прекратява приложенията им. Злонамерените приложения могат да нарушат поведението на други приложения."</string>
- <!-- no translation found for permlab_setScreenCompatibility (6975387118861842061) -->
- <skip />
- <!-- no translation found for permdesc_setScreenCompatibility (692043618693917374) -->
- <skip />
+ <string name="permlab_setScreenCompatibility" msgid="6975387118861842061">"задаване на съвместимост на екрана"</string>
+ <string name="permdesc_setScreenCompatibility" msgid="692043618693917374">"Разрешава на приложението да контролира режима на съвместимост на екрана на други приложения. Злонамерените програми могат да нарушат поведението на други приложения."</string>
<string name="permlab_setDebugApp" msgid="3022107198686584052">"активиране на отстраняването на грешки в приложения"</string>
<string name="permdesc_setDebugApp" msgid="4474512416299013256">"Разрешава на приложението да включва отстраняването на грешки за друго приложение. Злонамерените приложения могат да използват това, за да прекратят други приложения."</string>
<string name="permlab_changeConfiguration" msgid="8214475779521218295">"промяна на настройките ви за потребителския интерфейс"</string>
diff --git a/core/res/res/values-cs/strings.xml b/core/res/res/values-cs/strings.xml
index c801fb4..545d957 100644
--- a/core/res/res/values-cs/strings.xml
+++ b/core/res/res/values-cs/strings.xml
@@ -215,10 +215,8 @@
<string name="permdesc_reorderTasks" msgid="4175137612205663399">"Umožňuje aplikaci přesunout úlohy na popředí nebo pozadí. Škodlivé aplikace mohou vynutit zobrazení na popředí bez vašeho svolení."</string>
<string name="permlab_removeTasks" msgid="6821513401870377403">"zastavení činnosti aplikací"</string>
<string name="permdesc_removeTasks" msgid="1394714352062635493">"Umožňuje aplikaci odstranit úlohy a ukončit jejich aplikace. Škodlivé aplikace mohou narušit chování ostatních aplikací."</string>
- <!-- no translation found for permlab_setScreenCompatibility (6975387118861842061) -->
- <skip />
- <!-- no translation found for permdesc_setScreenCompatibility (692043618693917374) -->
- <skip />
+ <string name="permlab_setScreenCompatibility" msgid="6975387118861842061">"nastavit kompatibilitu obrazovky"</string>
+ <string name="permdesc_setScreenCompatibility" msgid="692043618693917374">"Umožňuje aplikaci ovládat režim kompatibility obrazovky v ostatních aplikacích. Škodlivé aplikace mohou narušit chování ostatních aplikací."</string>
<string name="permlab_setDebugApp" msgid="3022107198686584052">"povolení ladění aplikací"</string>
<string name="permdesc_setDebugApp" msgid="4474512416299013256">"Umožňuje aplikaci zapnout ladění jiné aplikace. Škodlivé aplikace mohou toto oprávnění použít k ukončení ostatních aplikací."</string>
<string name="permlab_changeConfiguration" msgid="8214475779521218295">"změna vašeho nastavení uživatelského rozhraní"</string>
diff --git a/core/res/res/values-ja/strings.xml b/core/res/res/values-ja/strings.xml
index ea4af66..cadf935 100644
--- a/core/res/res/values-ja/strings.xml
+++ b/core/res/res/values-ja/strings.xml
@@ -215,10 +215,8 @@
<string name="permdesc_reorderTasks" msgid="4175137612205663399">"タスクをフォアグラウンドやバックグラウンドに移動することをアプリに許可します。この許可を悪意のあるアプリに利用されると、悪意のあるアプリが強制的に優先される恐れがあります。"</string>
<string name="permlab_removeTasks" msgid="6821513401870377403">"実行中のアプリの停止"</string>
<string name="permdesc_removeTasks" msgid="1394714352062635493">"タスクの削除とアプリの終了をアプリに許可します。この許可を悪意のあるアプリケーションに利用されると、他のアプリの動作が妨害される恐れがあります。"</string>
- <!-- no translation found for permlab_setScreenCompatibility (6975387118861842061) -->
- <skip />
- <!-- no translation found for permdesc_setScreenCompatibility (692043618693917374) -->
- <skip />
+ <string name="permlab_setScreenCompatibility" msgid="6975387118861842061">"画面互換性の設定"</string>
+ <string name="permdesc_setScreenCompatibility" msgid="692043618693917374">"他のアプリケーションの画面互換性モードをコントロールすることをアプリに許可します。この許可を悪意のあるアプリケーションに利用されると、他のアプリケーションの動作が中断される恐れがあります。"</string>
<string name="permlab_setDebugApp" msgid="3022107198686584052">"アプリのデバッグの有効化"</string>
<string name="permdesc_setDebugApp" msgid="4474512416299013256">"別のアプリをデバッグモードにすることをアプリに許可します。この許可を悪意のあるアプリに利用されると、他のアプリが強制終了される恐れがあります。"</string>
<string name="permlab_changeConfiguration" msgid="8214475779521218295">"UI設定の変更"</string>
diff --git a/core/res/res/values-ko/strings.xml b/core/res/res/values-ko/strings.xml
index 2c664c9..031e9f5 100644
--- a/core/res/res/values-ko/strings.xml
+++ b/core/res/res/values-ko/strings.xml
@@ -215,10 +215,8 @@
<string name="permdesc_reorderTasks" msgid="4175137612205663399">"앱이 작업을 포그라운드나 백그라운드로 이동할 수 있도록 허용합니다. 이 경우 악성 앱이 사용자의 조작 없이 앞으로 이동할 수 있습니다."</string>
<string name="permlab_removeTasks" msgid="6821513401870377403">"실행 중인 앱 중지"</string>
<string name="permdesc_removeTasks" msgid="1394714352062635493">"애플리케이션이 작업을 삭제하거나 다른 애플리케이션을 중지시킬 수 있도록 허용합니다. 이 경우 악성 애플리케이션이 다른 애플리케이션의 동작을 멈추게 할 수 있습니다."</string>
- <!-- no translation found for permlab_setScreenCompatibility (6975387118861842061) -->
- <skip />
- <!-- no translation found for permdesc_setScreenCompatibility (692043618693917374) -->
- <skip />
+ <string name="permlab_setScreenCompatibility" msgid="6975387118861842061">"화면 호환성 설정"</string>
+ <string name="permdesc_setScreenCompatibility" msgid="692043618693917374">"앱이 다른 애플리케이션의 화면 호환성 모드를 제어할 수 있도록 허용합니다. 이 경우 악성 애플리케이션이 다른 애플리케이션의 동작을 멈추게 할 수 있습니다."</string>
<string name="permlab_setDebugApp" msgid="3022107198686584052">"앱 디버깅 사용"</string>
<string name="permdesc_setDebugApp" msgid="4474512416299013256">"애플리케이션이 다른 애플리케이션에 대해 디버깅을 사용할 수 있도록 허용합니다. 이 경우 악성 애플리케이션이 다른 애플리케이션을 중지시킬 수 있습니다."</string>
<string name="permlab_changeConfiguration" msgid="8214475779521218295">"UI 설정 변경"</string>
diff --git a/core/res/res/values-ms/strings.xml b/core/res/res/values-ms/strings.xml
index 659a7ad..6aa9e4c 100644
--- a/core/res/res/values-ms/strings.xml
+++ b/core/res/res/values-ms/strings.xml
@@ -215,10 +215,8 @@
<string name="permdesc_reorderTasks" msgid="4175137612205663399">"Membenarkan apl untuk memindahkan tugasan ke latar depan dan latar belakang. Apl hasad boleh memaksa diri mereka ke hadapan tanpa kawalan anda."</string>
<string name="permlab_removeTasks" msgid="6821513401870377403">"hentikan apl yang sedang dijalankan"</string>
<string name="permdesc_removeTasks" msgid="1394714352062635493">"Membenarkan apl untuk mengalih keluar tugasan dan melupuskan aplnya. Apl hasad boleh mengganggu tingkah laku apl lain."</string>
- <!-- no translation found for permlab_setScreenCompatibility (6975387118861842061) -->
- <skip />
- <!-- no translation found for permdesc_setScreenCompatibility (692043618693917374) -->
- <skip />
+ <string name="permlab_setScreenCompatibility" msgid="6975387118861842061">"tetapkan keserasian skrin"</string>
+ <string name="permdesc_setScreenCompatibility" msgid="692043618693917374">"Membenarkan apl mengawal mod keserasian skrin aplikasi lain. Aplikasi hasad mungkin mematahkan kelakuan aplikasi lain."</string>
<string name="permlab_setDebugApp" msgid="3022107198686584052">"dayakan penyahpepijatan apl"</string>
<string name="permdesc_setDebugApp" msgid="4474512416299013256">"Membenarkan apl untuk menghidupkan penyahpepijatan untuk apl lain. Apl hasad boleh menggunakannya untuk menghapuskan apl lain."</string>
<string name="permlab_changeConfiguration" msgid="8214475779521218295">"tukar tetapan UI anda"</string>
diff --git a/core/res/res/values-pt/strings.xml b/core/res/res/values-pt/strings.xml
index 4915a233..5c16708 100644
--- a/core/res/res/values-pt/strings.xml
+++ b/core/res/res/values-pt/strings.xml
@@ -215,10 +215,8 @@
<string name="permdesc_reorderTasks" msgid="4175137612205663399">"Permite que o aplicativo mova tarefas para o primeiro plano e para o plano de fundo. Aplicativos maliciosos podem forçar-se para a primeiro plano sem que você tenha controle sobre a ação."</string>
<string name="permlab_removeTasks" msgid="6821513401870377403">"parar os aplicativos em execução"</string>
<string name="permdesc_removeTasks" msgid="1394714352062635493">"Permite que um aplicativo remova tarefas e elimine seus aplicativos. Aplicativos maliciosos podem interferir no comportamento de outros aplicativos."</string>
- <!-- no translation found for permlab_setScreenCompatibility (6975387118861842061) -->
- <skip />
- <!-- no translation found for permdesc_setScreenCompatibility (692043618693917374) -->
- <skip />
+ <string name="permlab_setScreenCompatibility" msgid="6975387118861842061">"definir a compatibilidade de tela"</string>
+ <string name="permdesc_setScreenCompatibility" msgid="692043618693917374">"Permite que o aplicativo controle o modo de compatibilidade de tela de outros aplicativos. Aplicativos maliciosos podem interromper o comportamento de outros aplicativos."</string>
<string name="permlab_setDebugApp" msgid="3022107198686584052">"ativar depuração do aplicativo"</string>
<string name="permdesc_setDebugApp" msgid="4474512416299013256">"Permite que o aplicativo ative a depuração para outro aplicativo. Aplicativos maliciosos podem usar esse recurso para cancelar outros aplicativos."</string>
<string name="permlab_changeConfiguration" msgid="8214475779521218295">"alterar as suas configurações de UI"</string>
diff --git a/core/res/res/values-sk/strings.xml b/core/res/res/values-sk/strings.xml
index 69bc4b8..7d1aa78 100644
--- a/core/res/res/values-sk/strings.xml
+++ b/core/res/res/values-sk/strings.xml
@@ -215,10 +215,8 @@
<string name="permdesc_reorderTasks" msgid="4175137612205663399">"Umožňuje aplikácii presúvať úlohy do popredia a pozadia. Škodlivé aplikácie sa môžu pretlačiť do popredia bez vášho vedomia."</string>
<string name="permlab_removeTasks" msgid="6821513401870377403">"zastaviť spustené aplikácie"</string>
<string name="permdesc_removeTasks" msgid="1394714352062635493">"Umožňuje aplikácii odstrániť úlohy a ukončiť ich aplikácie. Škodlivé aplikácie môžu narušiť správanie iných aplikácií."</string>
- <!-- no translation found for permlab_setScreenCompatibility (6975387118861842061) -->
- <skip />
- <!-- no translation found for permdesc_setScreenCompatibility (692043618693917374) -->
- <skip />
+ <string name="permlab_setScreenCompatibility" msgid="6975387118861842061">"nastaviť kompatibilitu obrazovky"</string>
+ <string name="permdesc_setScreenCompatibility" msgid="692043618693917374">"Umožňuje aplikácii ovládať režim kompatibility obrazovky v ostatných aplikáciách. Škodlivé aplikácie môžu narušiť správanie ostatných aplikácií."</string>
<string name="permlab_setDebugApp" msgid="3022107198686584052">"povoliť ladenie aplikácií"</string>
<string name="permdesc_setDebugApp" msgid="4474512416299013256">"Umožňuje aplikácii zapnúť ladenie inej aplikácie. Škodlivé aplikácie môžu pomocou tohto nastavenia ukončiť iné aplikácie."</string>
<string name="permlab_changeConfiguration" msgid="8214475779521218295">"zmeny vašich nastavení používateľského rozhrania"</string>
diff --git a/core/res/res/values-tr/strings.xml b/core/res/res/values-tr/strings.xml
index 20d3e15..8d52c8c 100644
--- a/core/res/res/values-tr/strings.xml
+++ b/core/res/res/values-tr/strings.xml
@@ -215,10 +215,8 @@
<string name="permdesc_reorderTasks" msgid="4175137612205663399">"Uygulamaya, görevleri ön plana ve arka plana taşıma izni verir. Kötü amaçlı uygulamalar kendilerini sizin denetiminiz dışında ön plana taşıyabilir."</string>
<string name="permlab_removeTasks" msgid="6821513401870377403">"çalışan uygulamaları durdur"</string>
<string name="permdesc_removeTasks" msgid="1394714352062635493">"Uygulamaya, görevleri kaldırma ve bunlara ait uygulamaları kapatma izni verir. Kötü amaçlı uygulamalar diğer uygulamaların çalışmasını bozabilir."</string>
- <!-- no translation found for permlab_setScreenCompatibility (6975387118861842061) -->
- <skip />
- <!-- no translation found for permdesc_setScreenCompatibility (692043618693917374) -->
- <skip />
+ <string name="permlab_setScreenCompatibility" msgid="6975387118861842061">"ekran uyumluluğunu ayarla"</string>
+ <string name="permdesc_setScreenCompatibility" msgid="692043618693917374">"Uygulamaya diğer uygulamaların ekran uyumluluk modunu denetleme izni verir. Kötü amaçlı uygulamalar diğer uygulamaların çalışma şeklini bozabilir."</string>
<string name="permlab_setDebugApp" msgid="3022107198686584052">"uygulama hata ayıklamayı etkinleştir"</string>
<string name="permdesc_setDebugApp" msgid="4474512416299013256">"Uygulamaya, başka bir uygulama için hata ayıklamayı açma izni verir. Kötü amaçlı uygulamalar diğer uygulamaları kaldırmak için bunu kullanabilir."</string>
<string name="permlab_changeConfiguration" msgid="8214475779521218295">"kullanıcı arayüzü ayarlarınızı değiştirin"</string>
diff --git a/core/res/res/values-zh-rCN/strings.xml b/core/res/res/values-zh-rCN/strings.xml
index 1065183..a9f431c 100644
--- a/core/res/res/values-zh-rCN/strings.xml
+++ b/core/res/res/values-zh-rCN/strings.xml
@@ -215,10 +215,8 @@
<string name="permdesc_reorderTasks" msgid="4175137612205663399">"允许应用程序将任务移动到前台和后台。恶意应用程序可能会不受您的控制,强行让自己处于前台。"</string>
<string name="permlab_removeTasks" msgid="6821513401870377403">"停止正在运行的应用程序"</string>
<string name="permdesc_removeTasks" msgid="1394714352062635493">"允许该应用程序删除任务并终止这些任务的应用程序。恶意应用程序可以籍此影响其他应用程序的行为。"</string>
- <!-- no translation found for permlab_setScreenCompatibility (6975387118861842061) -->
- <skip />
- <!-- no translation found for permdesc_setScreenCompatibility (692043618693917374) -->
- <skip />
+ <string name="permlab_setScreenCompatibility" msgid="6975387118861842061">"设置屏幕兼容性"</string>
+ <string name="permdesc_setScreenCompatibility" msgid="692043618693917374">"允许应用程序控制其他应用程序的屏幕兼容模式。恶意应用程序可以籍此影响其他应用程序的行为。"</string>
<string name="permlab_setDebugApp" msgid="3022107198686584052">"启用应用程序调试"</string>
<string name="permdesc_setDebugApp" msgid="4474512416299013256">"允许该应用程序对其他应用程序启用调试。恶意应用程序可以籍此终止其他的应用程序。"</string>
<string name="permlab_changeConfiguration" msgid="8214475779521218295">"更改用户界面设置"</string>
diff --git a/core/res/res/values-zh-rTW/strings.xml b/core/res/res/values-zh-rTW/strings.xml
index 659c2de..5aee830 100644
--- a/core/res/res/values-zh-rTW/strings.xml
+++ b/core/res/res/values-zh-rTW/strings.xml
@@ -215,10 +215,8 @@
<string name="permdesc_reorderTasks" msgid="4175137612205663399">"允許應用程式將工作移至前景或背景。請注意,惡意應用程式可能利用此功能自行移動至前景。"</string>
<string name="permlab_removeTasks" msgid="6821513401870377403">"停止執行中的應用程式"</string>
<string name="permdesc_removeTasks" msgid="1394714352062635493">"允許應用程式移除工作並終止執行工作的應用程式。請注意,惡意應用程式可能利用此功能干擾其他應用程式的行為。"</string>
- <!-- no translation found for permlab_setScreenCompatibility (6975387118861842061) -->
- <skip />
- <!-- no translation found for permdesc_setScreenCompatibility (692043618693917374) -->
- <skip />
+ <string name="permlab_setScreenCompatibility" msgid="6975387118861842061">"設定螢幕相容性"</string>
+ <string name="permdesc_setScreenCompatibility" msgid="692043618693917374">"允許應用程式控制其他應用程式的螢幕相容性模式。惡意應用程式可能藉此破壞其他應用程式的正常運作。"</string>
<string name="permlab_setDebugApp" msgid="3022107198686584052">"啟用應用程式偵錯"</string>
<string name="permdesc_setDebugApp" msgid="4474512416299013256">"允許應用程式為其他程式開啟偵錯功能。提醒您,惡意應用程式可能會利用這個功能終止其他應用程式。"</string>
<string name="permlab_changeConfiguration" msgid="8214475779521218295">"變更介面設定"</string>
diff --git a/core/res/res/values-zu/strings.xml b/core/res/res/values-zu/strings.xml
index 84f4319..36da63d 100644
--- a/core/res/res/values-zu/strings.xml
+++ b/core/res/res/values-zu/strings.xml
@@ -215,10 +215,8 @@
<string name="permdesc_reorderTasks" msgid="4175137612205663399">"Ivumela insiza ukuthi ihambise izenzo ziye ngaphambili kanye nasemumva. Izinsiza ezinobungozi zingaziphoqelela ukuth iziye phambili ngaphandle kokulawula kwakho."</string>
<string name="permlab_removeTasks" msgid="6821513401870377403">"misa izinsiza ezisebenzayo"</string>
<string name="permdesc_removeTasks" msgid="1394714352062635493">"Vumela ukuthi insiza isuse okumele kwenziwe ibulale nezinsiza zakho. Izinsiza eziwubungozi zingaphazamisa ukusebenza kwezinye izinsiza."</string>
- <!-- no translation found for permlab_setScreenCompatibility (6975387118861842061) -->
- <skip />
- <!-- no translation found for permdesc_setScreenCompatibility (692043618693917374) -->
- <skip />
+ <string name="permlab_setScreenCompatibility" msgid="6975387118861842061">"misa ukuhambelana kwesikrini"</string>
+ <string name="permdesc_setScreenCompatibility" msgid="692043618693917374">"Ivumela uhlelo lokusebenza ukulawula imodi yokuhambelana kwesikrini kwezinye izinhlelo zokusebenza. Izinhlelo zokusebenza ezinonya zingase zephule ukuziphatha kwezinye izinhlelo zokusebenza."</string>
<string name="permlab_setDebugApp" msgid="3022107198686584052">"vumela insiza ilungise inkinga"</string>
<string name="permdesc_setDebugApp" msgid="4474512416299013256">"Ivumela insiza ukuthi ivule uhlelo lokulungisa lwenye insiza. Izinsiza ezinobungozi zingasebenzisa lokhu ukubulala ezinye izinsiza."</string>
<string name="permlab_changeConfiguration" msgid="8214475779521218295">"shintsha izilungiselelo zakho ze-UI"</string>
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index e84cb5c..4e55b4f 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -218,6 +218,7 @@
<java-symbol type="bool" name="config_allowActionMenuItemTextWithIcon" />
<java-symbol type="bool" name="config_bluetooth_adapter_quick_switch" />
<java-symbol type="bool" name="config_bluetooth_sco_off_call" />
+ <java-symbol type="bool" name="config_alwaysUseCdmaRssi" />
<java-symbol type="bool" name="config_duplicate_port_omadm_wappush" />
<java-symbol type="bool" name="config_enable_emergency_call_while_sim_locked" />
<java-symbol type="bool" name="config_enable_puk_unlock_screen" />
@@ -1083,6 +1084,7 @@
<java-symbol type="style" name="ActiveWallpaperSettings" />
<java-symbol type="style" name="Animation.InputMethodFancy" />
<java-symbol type="style" name="Animation.Wallpaper" />
+ <java-symbol type="style" name="Animation.RecentApplications" />
<java-symbol type="style" name="Animation.ZoomButtons" />
<java-symbol type="style" name="PreviewWallpaperSettings" />
<java-symbol type="style" name="TextAppearance.SlidingTabActive" />
@@ -3494,4 +3496,6 @@
=============================================================== -->
<public type="attr" name="isolatedProcess" id="0x010103a7" />
+ <public type="attr" name="textDirection"/>
+
</resources>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 4995d2c..c95dddd 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -2708,11 +2708,6 @@
<!-- Do not translate. Default access point SSID used for tethering -->
<string name="wifi_tether_configure_ssid_default" translatable="false">AndroidAP</string>
- <!-- Wi-Fi p2p dialog title-->
- <string name="wifi_p2p_dialog_title">Wi-Fi Direct</string>
- <string name="wifi_p2p_turnon_message">Start Wi-Fi Direct. This will turn off Wi-Fi client/hotspot.</string>
- <string name="wifi_p2p_failed_message">Couldn\'t start Wi-Fi Direct.</string>
-
<string name="accept">Accept</string>
<string name="decline">Decline</string>
<string name="wifi_p2p_invitation_sent_title">Invitation sent</string>
@@ -2723,9 +2718,6 @@
<string name="wifi_p2p_enter_pin_message">Type the required PIN: </string>
<string name="wifi_p2p_show_pin_message">PIN: </string>
- <string name="wifi_p2p_enabled_notification_title">Wi-Fi Direct is on</string>
- <string name="wifi_p2p_enabled_notification_message">Touch for settings</string>
-
<!-- Name of the dialog that lets the user choose an accented character to insert -->
<string name="select_character">Insert character</string>
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index 571c4ad..610bad8 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -198,8 +198,10 @@
<!-- A special animation we can use for recent applications,
for devices that can support it (do alpha transformations). -->
<style name="Animation.RecentApplications">
- <item name="windowEnterAnimation">@anim/fade_in</item>
- <item name="windowExitAnimation">@anim/fade_out</item>
+ <item name="windowEnterAnimation">@anim/recents_fade_in</item>
+ <item name="windowShowAnimation">@anim/recents_fade_in</item>
+ <item name="windowExitAnimation">@anim/recents_fade_out</item>
+ <item name="windowHideAnimation">@anim/recents_fade_out</item>
</style>
<!-- A special animation value used internally for popup windows. -->
diff --git a/core/tests/coretests/src/android/widget/focus/RequestFocus.java b/core/tests/coretests/src/android/widget/focus/RequestFocus.java
index 21d762a..af9ee17 100644
--- a/core/tests/coretests/src/android/widget/focus/RequestFocus.java
+++ b/core/tests/coretests/src/android/widget/focus/RequestFocus.java
@@ -21,7 +21,9 @@
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
+import android.widget.LinearLayout;
import android.widget.Button;
+import android.view.View;
/**
* Exercises cases where elements of the UI are requestFocus()ed.
diff --git a/core/tests/coretests/src/android/widget/focus/RequestFocusTest.java b/core/tests/coretests/src/android/widget/focus/RequestFocusTest.java
index baf587e..a78b0c9 100644
--- a/core/tests/coretests/src/android/widget/focus/RequestFocusTest.java
+++ b/core/tests/coretests/src/android/widget/focus/RequestFocusTest.java
@@ -16,27 +16,21 @@
package android.widget.focus;
-import android.os.Handler;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.UiThreadTest;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.util.AndroidRuntimeException;
-import android.view.View;
-import android.view.View.OnFocusChangeListener;
-import android.view.ViewTreeObserver.OnGlobalFocusChangeListener;
-import android.widget.Button;
-
+import android.widget.focus.RequestFocus;
import com.android.frameworks.coretests.R;
-import java.util.ArrayList;
-import java.util.List;
+import android.os.Handler;
+import android.test.ActivityInstrumentationTestCase;
+import android.test.suitebuilder.annotation.LargeTest;
+import android.test.suitebuilder.annotation.MediumTest;
+import android.widget.Button;
+import android.util.AndroidRuntimeException;
/**
* {@link RequestFocusTest} is set up to exercise cases where the views that
* have focus become invisible or GONE.
*/
-public class RequestFocusTest extends ActivityInstrumentationTestCase2<RequestFocus> {
+public class RequestFocusTest extends ActivityInstrumentationTestCase<RequestFocus> {
private Button mTopLeftButton;
private Button mBottomLeftButton;
@@ -45,7 +39,7 @@
private Handler mHandler;
public RequestFocusTest() {
- super(RequestFocus.class);
+ super("com.android.frameworks.coretests", RequestFocus.class);
}
@Override
@@ -100,145 +94,4 @@
e.getClass().getName());
}
}
-
- /**
- * This tests checks the case in which the first focusable View clears focus.
- * In such a case the framework tries to give the focus to another View starting
- * from the top. Hence, the framework will try to give focus to the view that
- * wants to clear its focus. From a client perspective, the view does not loose
- * focus after the call, therefore no callback for focus change should be invoked.
- *
- * @throws Exception If an error occurs.
- */
- @UiThreadTest
- public void testOnFocusChangeNotCalledIfFocusDoesNotMove() throws Exception {
- // Get the first focusable.
- Button button = mTopLeftButton;
-
- // Make sure that the button is the first focusable and focus it.
- button.getRootView().requestFocus(View.FOCUS_DOWN);
- assertTrue(button.hasFocus());
-
- // Attach on focus change listener that should not be called.
- button.setOnFocusChangeListener(new OnFocusChangeListener() {
- @Override
- public void onFocusChange(View v, boolean hasFocus) {
- throw new IllegalStateException("Unexpeced call to"
- + "OnFocusChangeListener#onFocusChange");
- }
- });
-
- // Attach on global focus change listener that should not be called.
- button.getViewTreeObserver().addOnGlobalFocusChangeListener(
- new OnGlobalFocusChangeListener() {
- @Override
- public void onGlobalFocusChanged(View oldFocus, View newFocus) {
- throw new IllegalStateException("Unexpeced call to"
- + "OnFocusChangeListener#onFocusChange");
- }
- });
-
- // Try to clear focus.
- button.clearFocus();
- }
-
- /**
- * This tests check whether the on focus change callbacks are invoked in
- * the proper order when a View loses focus and the framework gives it to
- * the fist focusable one.
- *
- * @throws Exception
- */
- @UiThreadTest
- public void testOnFocusChangeCallbackOrder() throws Exception {
- // Get the first focusable.
- Button clearingFocusButton = mTopRightButton;
- Button gainingFocusButton = mTopLeftButton;
-
- // Make sure that the clearing focus is not the first focusable.
- View focusCandidate = clearingFocusButton.getRootView().getParent().focusSearch(null,
- View.FOCUS_FORWARD);
- assertNotSame("The clearing focus button is not the first focusable.",
- clearingFocusButton, focusCandidate);
- assertSame("The gaining focus button is the first focusable.",
- gainingFocusButton, focusCandidate);
-
- // Focus the clearing focus button.
- clearingFocusButton.requestFocus();
- assertTrue(clearingFocusButton.hasFocus());
-
- // Register the invocation order checker.
- CallbackOrderChecker checker = new CallbackOrderChecker(clearingFocusButton,
- gainingFocusButton);
- clearingFocusButton.setOnFocusChangeListener(checker);
- gainingFocusButton.setOnFocusChangeListener(checker);
- clearingFocusButton.getViewTreeObserver().addOnGlobalFocusChangeListener(checker);
-
- // Try to clear focus.
- clearingFocusButton.clearFocus();
-
- // Check that no callback was invoked since focus did not move.
- checker.verify();
- }
-
- /**
- * This class check whether the focus change callback are invoked in order.
- */
- private class CallbackOrderChecker implements OnFocusChangeListener,
- OnGlobalFocusChangeListener {
-
- private class CallbackInvocation {
- final String mMethodName;
- final Object[] mArguments;
-
- CallbackInvocation(String methodName, Object[] arguments) {
- mMethodName = methodName;
- mArguments = arguments;
- }
- }
-
- private final View mClearingFocusView;
- private final View mGainingFocusView;
-
- private final List<CallbackInvocation> mInvocations = new ArrayList<CallbackInvocation>();
-
- public CallbackOrderChecker(View clearingFocusView, View gainingFocusView) {
- mClearingFocusView = clearingFocusView;
- mGainingFocusView = gainingFocusView;
- }
-
- @Override
- public void onFocusChange(View view, boolean hasFocus) {
- CallbackInvocation invocation = new CallbackInvocation(
- "OnFocusChangeListener#onFocusChange", new Object[] {view, hasFocus});
- mInvocations.add(invocation);
- }
-
- @Override
- public void onGlobalFocusChanged(View oldFocus, View newFocus) {
- CallbackInvocation invocation = new CallbackInvocation(
- "OnFocusChangeListener#onFocusChange", new Object[] {oldFocus, newFocus});
- mInvocations.add(invocation);
- }
-
- public void verify() {
- assertSame("All focus change callback should be invoked.", 3, mInvocations.size());
- assertInvioked("Callback for View clearing focus explected.", 0,
- "OnFocusChangeListener#onFocusChange",
- new Object[] {mClearingFocusView, false});
- assertInvioked("Callback for View global focus change explected.", 1,
- "OnFocusChangeListener#onFocusChange", new Object[] {mClearingFocusView,
- mGainingFocusView});
- assertInvioked("Callback for View gaining focus explected.", 2,
- "OnFocusChangeListener#onFocusChange", new Object[] {mGainingFocusView, true});
- }
-
- private void assertInvioked(String message, int order, String methodName,
- Object[] arguments) {
- CallbackInvocation invocation = mInvocations.get(order);
- assertEquals(message, methodName, invocation.mMethodName);
- assertEquals(message, arguments[0], invocation.mArguments[0]);
- assertEquals(message, arguments[1], invocation.mArguments[1]);
- }
- }
}
diff --git a/docs/html/sdk/ndk/index.jd b/docs/html/sdk/ndk/index.jd
index afbad57..29f0749 100644
--- a/docs/html/sdk/ndk/index.jd
+++ b/docs/html/sdk/ndk/index.jd
@@ -1,16 +1,16 @@
ndk=true
-ndk.win_download=android-ndk-r7-windows.zip
-ndk.win_bytes=81270552
-ndk.win_checksum=55483482cf2b75e8dd1a5d9a7caeb6e5
+ndk.win_download=android-ndk-r7b-windows.zip
+ndk.win_bytes=80346206
+ndk.win_checksum=c42b0c9c14428397337421d5e4999380
-ndk.mac_download=android-ndk-r7-darwin-x86.tar.bz2
-ndk.mac_bytes=71262092
-ndk.mac_checksum=817ca5675a1dd44078098e43070f19b6
+ndk.mac_download=android-ndk-r7b-darwin-x86.tar.bz2
+ndk.mac_bytes=73817184
+ndk.mac_checksum=6daa82ca6b73bc0614c9997430079c7a
-ndk.linux_download=android-ndk-r7-linux-x86.tar.bz2
-ndk.linux_bytes=64884365
-ndk.linux_checksum=bf15e6b47bf50824c4b96849bf003ca3
+ndk.linux_download=android-ndk-r7b-linux-x86.tar.bz2
+ndk.linux_bytes=64349733
+ndk.linux_checksum=0eb8af18796cdaa082df8f7c54ad7f9a
page.title=Android NDK
@@ -62,6 +62,116 @@
<div class="toggleable open">
<a href="#" onclick="return toggleDiv(this)"><img src=
"{@docRoot}assets/images/triangle-opened.png" class="toggle-img" height="9px" width="9px">
+ Android NDK, Revision 7b</a> <em>(February 2012)</em>
+
+ <div class="toggleme">
+ <p>This release of the NDK includes fixes for native Windows builds, Cygwin and many other
+ improvements:</p>
+
+ <dl>
+ <dt>Important bug fixes:</dt>
+
+ <dd>
+ <ul>
+ <li>Updated {@code sys/atomics.h} to avoid correctness issues
+ on some multi-core ARM-based devices. Rebuild your unmodified sources with this
+ version of the NDK and this problem should be completely eliminated.
+ For more details, read {@code docs/ANDROID-ATOMICS.html}.</li>
+ <li>Reverted to {@code binutils} 2.19 to fix debugging issues that
+ appeared in NDK r7 (which switched to {@code binutils} 2.20.1).</li>
+ <li>Fixed {@code ndk-build} on 32-bit Linux. A packaging error put a 64-bit version
+ of the {@code awk} executable under {@code prebuilt/linux-x86/bin} in NDK r7.</li>
+ <li>Fixed native Windows build ({@code ndk-build.cmd}). Other build modes were not
+ affected. The fixes include:
+ <ul>
+ <li>Removed an infinite loop / stack overflow bug that happened when trying
+ to call {@code ndk-build.cmd} from a directory that was <em>not</em> the top of
+ your project path (e.g., in any sub-directory of it).</li>
+ <li>Fixed a problem where the auto-generated dependency files were ignored. This
+ meant that updating a header didn't trigger recompilation of sources that included
+ it.</li>
+ <li>Fixed a problem where special characters in files or paths, other than spaces and
+ quotes, were not correctly handled.</li>
+ </ul>
+ </li>
+ <li>Fixed the standalone toolchain to generate proper binaries when using
+ {@code -lstdc++} (i.e., linking against the GNU {@code libstdc++} C++ runtime). You
+ should use {@code -lgnustl_shared} if you want to link against the shared library
+ version or {@code -lstdc++} for the static version.
+
+ <p>See {@code docs/STANDALONE-TOOLCHAIN.html} for more details about this fix.</p>
+ </li>
+ <li>Fixed {@code gnustl_shared} on Cygwin. The linker complained that it couldn't find
+ {@code libsupc++.a} even though the file was at the right location.</li>
+ <li>Fixed Cygwin C++ link when not using any specific C++ runtime through
+ {@code APP_STL}.</li>
+ </ul>
+ </dd>
+ </dl>
+
+ <dl>
+ <dt>Other changes:</dt>
+
+ <dd>
+ <ul>
+ <li>When your application uses the GNU {@code libstdc++} runtime, the compiler will
+ no longer forcibly enable exceptions and RTTI. This change results in smaller code.
+ <p>If you need these features, you must do one of the following:</p>
+ <ul>
+ <li>Enable exceptions and/or RTTI explicitly in your modules or
+ {@code Application.mk}. (recommended)</li>
+ <li>Define {@code APP_GNUSTL_FORCE_CPP_FEATURES} to {@code 'exceptions'},
+ {@code 'rtti'} or both in your {@code Application.mk}. See
+ {@code docs/APPLICATION-MK.html} for more details.</li>
+ </ul>
+ </li>
+ <li>{@code ndk-gdb} now works properly when your application has private services
+ running in independent processes. It debugs the main application process, instead of the
+ first process listed by {@code ps}, which is usually a service process.</li>
+ <li>Fixed a rare bug where NDK r7 would fail to honor the {@code LOCAL_ARM_MODE} value
+ and always compile certain source files (but not all) to 32-bit instructions.</li>
+ <li>{@code stlport}: Refresh the sources to match the Android platform version. This
+ update fixes a few minor bugs:
+ <ul>
+ <li>Fixed instantiation of an incomplete type</li>
+ <li>Fixed minor "==" versus "=" typo</li>
+ <li>Used {@code memmove} instead of {@code memcpy} in {@code string::assign}</li>
+ <li>Added better handling of {@code IsNANorINF}, {@code IsINF}, {@code IsNegNAN},
+ etc.</li>
+ </ul>
+ <p>For complete details, see the commit log.</p>
+ </li>
+ <li>{@code stlport}: Removed 5 unnecessary static initializers from the library.</li>
+ <li>The GNU libstdc++ libraries for armeabi-v7a were mistakenly compiled for
+ armeabi instead. This change had no impact on correctness, but using the right
+ ABI should provide slightly better performance.</li>
+ <li>The {@code cpu-features} helper library was updated to report three optional
+ x86 CPU features ({@code SSSE3}, {@code MOVBE} and {@code POPCNT}). See
+ {@code docs/CPU-FEATURES.html} for more details.</li>
+ <li>{@code docs/NDK-BUILD.html} was updated to mention {@code NDK_APPLICATION_MK} instead
+ of {@code NDK_APP_APPLICATION_MK} to select a custom {@code Application.mk} file.</li>
+ <li>Cygwin: {@code ndk-build} no longer creates an empty "NUL" file in the current
+ directory when invoked.</li>
+ <li>Cygwin: Added better automatic dependency detection. In the previous version, it
+ didn't work properly in the following cases:
+ <ul>
+ <li>When the Cygwin drive prefix was not {@code /cygdrive}.</li>
+ <li>When using drive-less mounts, for example, when Cygwin would translate
+ {@code /home} to {@code \\server\subdir} instead of {@code C:\Some\Dir}.</li>
+ </ul>
+ </li>
+ <li>Cygwin: {@code ndk-build} does not try to use the native Windows tools under
+ {@code $NDK/prebuilt/windows/bin} with certain versions of Cygwin and/or GNU Make.</li>
+ </ul>
+ </dd>
+ </dl>
+ </div>
+</div>
+
+
+<div class="toggleable closed">
+ <a href="#" onclick="return toggleDiv(this)"><img src=
+ "{@docRoot}assets/images/triangle-closed.png" class="toggle-img" height="9px" width="9px">
Android NDK, Revision 7</a> <em>(November 2011)</em>
<div class="toggleme">
diff --git a/docs/html/sdk/sdk_toc.cs b/docs/html/sdk/sdk_toc.cs
index 0de477a..f7541f7 100644
--- a/docs/html/sdk/sdk_toc.cs
+++ b/docs/html/sdk/sdk_toc.cs
@@ -195,7 +195,7 @@
<span style="display:none" class="zh-TW"></span>
</span>
<ul>
- <li><a href="<?cs var:toroot ?>sdk/ndk/index.html">Android NDK, r7</a>
+ <li><a href="<?cs var:toroot ?>sdk/ndk/index.html">Android NDK, r7b</a>
<span class="new">new!</span>
</li>
<li><a href="<?cs var:toroot ?>sdk/ndk/overview.html">What is the NDK?</a></li>
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java
index 88ee362..44401c8 100644
--- a/graphics/java/android/renderscript/Allocation.java
+++ b/graphics/java/android/renderscript/Allocation.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2008-2012 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.
@@ -131,7 +131,7 @@
public static final int USAGE_GRAPHICS_RENDER_TARGET = 0x0010;
/**
- * USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT The allcation will be
+ * USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT The allocation will be
* used with a SurfaceTexture object. This usage will cause the
* allocation to be created read only.
*
@@ -140,18 +140,18 @@
public static final int USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE = 0x0020;
/**
- * USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT The allcation will be
+ * USAGE_IO_INPUT The allocation will be
* used with a SurfaceTexture object. This usage will cause the
* allocation to be created read only.
*
* @hide
*/
-
public static final int USAGE_IO_INPUT = 0x0040;
+
/**
- * USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT The allcation will be
+ * USAGE_IO_OUTPUT The allocation will be
* used with a SurfaceTexture object. This usage will cause the
- * allocation to be created read only.
+ * allocation to be created write only.
*
* @hide
*/
diff --git a/include/gui/BufferQueue.h b/include/gui/BufferQueue.h
index 991a181..ae99160 100644
--- a/include/gui/BufferQueue.h
+++ b/include/gui/BufferQueue.h
@@ -60,6 +60,8 @@
BufferQueue(bool allowSynchronousMode = true);
virtual ~BufferQueue();
+ virtual int query(int what, int* value);
+
// setBufferCount updates the number of available buffer slots. After
// calling this all buffer slots are both unallocated and owned by the
// BufferQueue object (i.e. they are not owned by the client).
diff --git a/include/gui/SurfaceTexture.h b/include/gui/SurfaceTexture.h
index 4318f0f..dcab049 100644
--- a/include/gui/SurfaceTexture.h
+++ b/include/gui/SurfaceTexture.h
@@ -55,7 +55,7 @@
virtual ~SurfaceTexture();
- virtual int query(int what, int* value);
+
// updateTexImage sets the image contents of the target texture to that of
// the most recently queued buffer.
diff --git a/libs/gui/BufferQueue.cpp b/libs/gui/BufferQueue.cpp
index c7e2c0f..0791de2 100644
--- a/libs/gui/BufferQueue.cpp
+++ b/libs/gui/BufferQueue.cpp
@@ -166,6 +166,37 @@
return OK;
}
+int BufferQueue::query(int what, int* outValue)
+{
+ Mutex::Autolock lock(mMutex);
+
+ if (mAbandoned) {
+ ST_LOGE("query: SurfaceTexture has been abandoned!");
+ return NO_INIT;
+ }
+
+ int value;
+ switch (what) {
+ case NATIVE_WINDOW_WIDTH:
+ value = mDefaultWidth;
+ break;
+ case NATIVE_WINDOW_HEIGHT:
+ value = mDefaultHeight;
+ break;
+ case NATIVE_WINDOW_FORMAT:
+ value = mPixelFormat;
+ break;
+ case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS:
+ value = mSynchronousMode ?
+ (MIN_UNDEQUEUED_BUFFERS-1) : MIN_UNDEQUEUED_BUFFERS;
+ break;
+ default:
+ return BAD_VALUE;
+ }
+ outValue[0] = value;
+ return NO_ERROR;
+}
+
status_t BufferQueue::requestBuffer(int slot, sp<GraphicBuffer>* buf) {
ST_LOGV("requestBuffer: slot=%d", slot);
Mutex::Autolock lock(mMutex);
diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp
index be1bcd1..a7bfc61 100644
--- a/libs/gui/SurfaceTexture.cpp
+++ b/libs/gui/SurfaceTexture.cpp
@@ -416,36 +416,7 @@
return mSynchronousMode;
}
-int SurfaceTexture::query(int what, int* outValue)
-{
- Mutex::Autolock lock(mMutex);
- if (mAbandoned) {
- ST_LOGE("query: SurfaceTexture has been abandoned!");
- return NO_INIT;
- }
-
- int value;
- switch (what) {
- case NATIVE_WINDOW_WIDTH:
- value = mDefaultWidth;
- break;
- case NATIVE_WINDOW_HEIGHT:
- value = mDefaultHeight;
- break;
- case NATIVE_WINDOW_FORMAT:
- value = mPixelFormat;
- break;
- case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS:
- value = mSynchronousMode ?
- (MIN_UNDEQUEUED_BUFFERS-1) : MIN_UNDEQUEUED_BUFFERS;
- break;
- default:
- return BAD_VALUE;
- }
- outValue[0] = value;
- return NO_ERROR;
-}
void SurfaceTexture::abandon() {
Mutex::Autolock lock(mMutex);
diff --git a/libs/rs/driver/rsdShaderCache.h b/libs/rs/driver/rsdShaderCache.h
index d64780b..0beecae 100644
--- a/libs/rs/driver/rsdShaderCache.h
+++ b/libs/rs/driver/rsdShaderCache.h
@@ -98,7 +98,8 @@
struct ProgramEntry {
ProgramEntry(uint32_t numVtxAttr, uint32_t numVtxUnis,
uint32_t numFragUnis) : vtx(0), frag(0), program(0), vtxAttrCount(0),
- vtxAttrs(0), vtxUniforms(0), fragUniforms(0) {
+ vtxAttrs(0), vtxUniforms(0), fragUniforms(0),
+ fragUniformIsSTO(0) {
vtxAttrCount = numVtxAttr;
if (numVtxAttr) {
vtxAttrs = new AttrData[numVtxAttr];
diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp
index 06be2ef..0b1016c 100644
--- a/opengl/libs/EGL/Loader.cpp
+++ b/opengl/libs/EGL/Loader.cpp
@@ -118,12 +118,6 @@
// ----------------------------------------------------------------------------
-Loader::entry_t::entry_t(int dpy, int impl, const char* tag)
- : dpy(dpy), impl(impl), tag(tag) {
-}
-
-// ----------------------------------------------------------------------------
-
Loader::Loader()
{
char line[256];
@@ -131,8 +125,9 @@
/* Special case for GLES emulation */
if (checkGlesEmulationStatus() == 0) {
- ALOGD("Emulator without GPU support detected. Fallback to software renderer.");
- gConfig.add( entry_t(0, 0, "android") );
+ ALOGD("Emulator without GPU support detected. "
+ "Fallback to software renderer.");
+ mDriverTag.setTo("android");
return;
}
@@ -141,14 +136,16 @@
if (cfg == NULL) {
// default config
ALOGD("egl.cfg not found, using default config");
- gConfig.add( entry_t(0, 0, "android") );
+ mDriverTag.setTo("android");
} else {
while (fgets(line, 256, cfg)) {
- int dpy;
- int impl;
+ int dpy, impl;
if (sscanf(line, "%u %u %s", &dpy, &impl, tag) == 3) {
//ALOGD(">>> %u %u %s", dpy, impl, tag);
- gConfig.add( entry_t(dpy, impl, tag) );
+ // We only load the h/w accelerated implementation
+ if (tag != String8("android")) {
+ mDriverTag = tag;
+ }
}
}
fclose(cfg);
@@ -160,30 +157,12 @@
GLTrace_stop();
}
-const char* Loader::getTag(int dpy, int impl)
+void* Loader::open(egl_connection_t* cnx)
{
- const Vector<entry_t>& cfgs(gConfig);
- const size_t c = cfgs.size();
- for (size_t i=0 ; i<c ; i++) {
- if (dpy == cfgs[i].dpy)
- if (impl == cfgs[i].impl)
- return cfgs[i].tag.string();
- }
- return 0;
-}
-
-void* Loader::open(EGLNativeDisplayType display, int impl, egl_connection_t* cnx)
-{
- /*
- * TODO: if we don't find display/0, then use 0/0
- * (0/0 should always work)
- */
-
void* dso;
- int index = int(display);
driver_t* hnd = 0;
- char const* tag = getTag(index, impl);
+ char const* tag = mDriverTag.string();
if (tag) {
dso = load_driver("GLES", tag, cnx, EGL | GLESv1_CM | GLESv2);
if (dso) {
@@ -193,16 +172,14 @@
dso = load_driver("EGL", tag, cnx, EGL);
if (dso) {
hnd = new driver_t(dso);
-
// TODO: make this more automated
hnd->set( load_driver("GLESv1_CM", tag, cnx, GLESv1_CM), GLESv1_CM );
-
- hnd->set( load_driver("GLESv2", tag, cnx, GLESv2), GLESv2 );
+ hnd->set( load_driver("GLESv2", tag, cnx, GLESv2), GLESv2 );
}
}
}
- LOG_FATAL_IF(!index && !impl && !hnd,
+ LOG_FATAL_IF(!index && !hnd,
"couldn't find the default OpenGL ES implementation "
"for default display");
@@ -221,7 +198,7 @@
__eglMustCastToProperFunctionPointerType* curr,
getProcAddressType getProcAddress)
{
- const size_t SIZE = 256;
+ const ssize_t SIZE = 256;
char scrap[SIZE];
while (*api) {
char const * name = *api;
@@ -326,14 +303,14 @@
if (mask & GLESv1_CM) {
init_api(dso, gl_names,
(__eglMustCastToProperFunctionPointerType*)
- &cnx->hooks[GLESv1_INDEX]->gl,
+ &cnx->hooks[egl_connection_t::GLESv1_INDEX]->gl,
getProcAddress);
}
if (mask & GLESv2) {
init_api(dso, gl_names,
(__eglMustCastToProperFunctionPointerType*)
- &cnx->hooks[GLESv2_INDEX]->gl,
+ &cnx->hooks[egl_connection_t::GLESv2_INDEX]->gl,
getProcAddress);
}
diff --git a/opengl/libs/EGL/Loader.h b/opengl/libs/EGL/Loader.h
index 580d6e4..30773cb 100644
--- a/opengl/libs/EGL/Loader.h
+++ b/opengl/libs/EGL/Loader.h
@@ -24,7 +24,6 @@
#include <utils/Errors.h>
#include <utils/Singleton.h>
#include <utils/String8.h>
-#include <utils/Vector.h>
#include <EGL/egl.h>
@@ -53,23 +52,13 @@
void* dso[3];
};
- struct entry_t {
- entry_t() { }
- entry_t(int dpy, int impl, const char* tag);
- int dpy;
- int impl;
- String8 tag;
- };
-
- Vector<entry_t> gConfig;
+ String8 mDriverTag;
getProcAddressType getProcAddress;
- const char* getTag(int dpy, int impl);
-
public:
~Loader();
- void* open(EGLNativeDisplayType display, int impl, egl_connection_t* cnx);
+ void* open(egl_connection_t* cnx);
status_t close(void* driver);
private:
diff --git a/opengl/libs/EGL/egl.cpp b/opengl/libs/EGL/egl.cpp
index 83933e5..4a56dcf 100644
--- a/opengl/libs/EGL/egl.cpp
+++ b/opengl/libs/EGL/egl.cpp
@@ -48,8 +48,8 @@
namespace android {
// ----------------------------------------------------------------------------
-egl_connection_t gEGLImpl[IMPL_NUM_IMPLEMENTATIONS];
-gl_hooks_t gHooks[2][IMPL_NUM_IMPLEMENTATIONS];
+egl_connection_t gEGLImpl;
+gl_hooks_t gHooks[2];
gl_hooks_t gHooksNoContext;
pthread_key_t gGLWrapperKey = -1;
@@ -187,16 +187,13 @@
return dp;
}
-egl_connection_t* validate_display_config(EGLDisplay dpy, EGLConfig config,
+egl_connection_t* validate_display_config(EGLDisplay dpy, EGLConfig,
egl_display_t const*& dp) {
dp = validate_display(dpy);
if (!dp)
return (egl_connection_t*) NULL;
- if (intptr_t(config) >= dp->numTotalConfigs) {
- return setError(EGL_BAD_CONFIG, (egl_connection_t*)NULL);
- }
- egl_connection_t* const cnx = &gEGLImpl[dp->configs[intptr_t(config)].impl];
+ egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso == 0) {
return setError(EGL_BAD_CONFIG, (egl_connection_t*)NULL);
}
@@ -228,7 +225,7 @@
// EGL.
egl_image_t const * const i = get_image(image);
- return i->images[c->impl];
+ return i->image;
}
// ----------------------------------------------------------------------------
@@ -266,34 +263,17 @@
// get our driver loader
Loader& loader(Loader::getInstance());
- // dynamically load all our EGL implementations
- egl_connection_t* cnx;
-
- cnx = &gEGLImpl[IMPL_SOFTWARE];
+ // dynamically load our EGL implementation
+ egl_connection_t* cnx = &gEGLImpl;
if (cnx->dso == 0) {
- cnx->hooks[GLESv1_INDEX] = &gHooks[GLESv1_INDEX][IMPL_SOFTWARE];
- cnx->hooks[GLESv2_INDEX] = &gHooks[GLESv2_INDEX][IMPL_SOFTWARE];
- cnx->dso = loader.open(EGL_DEFAULT_DISPLAY, 0, cnx);
+ cnx->hooks[egl_connection_t::GLESv1_INDEX] =
+ &gHooks[egl_connection_t::GLESv1_INDEX];
+ cnx->hooks[egl_connection_t::GLESv2_INDEX] =
+ &gHooks[egl_connection_t::GLESv2_INDEX];
+ cnx->dso = loader.open(cnx);
}
- cnx = &gEGLImpl[IMPL_HARDWARE];
- if (cnx->dso == 0) {
- char value[PROPERTY_VALUE_MAX];
- property_get("debug.egl.hw", value, "1");
- if (atoi(value) != 0) {
- cnx->hooks[GLESv1_INDEX] = &gHooks[GLESv1_INDEX][IMPL_HARDWARE];
- cnx->hooks[GLESv2_INDEX] = &gHooks[GLESv2_INDEX][IMPL_HARDWARE];
- cnx->dso = loader.open(EGL_DEFAULT_DISPLAY, 1, cnx);
- } else {
- ALOGD("3D hardware acceleration is disabled");
- }
- }
-
- if (!gEGLImpl[IMPL_SOFTWARE].dso && !gEGLImpl[IMPL_HARDWARE].dso) {
- return EGL_FALSE;
- }
-
- return EGL_TRUE;
+ return cnx->dso ? EGL_TRUE : EGL_FALSE;
}
static pthread_mutex_t sInitDriverMutex = PTHREAD_MUTEX_INITIALIZER;
diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp
index 73aab26..bb2783d 100644
--- a/opengl/libs/EGL/eglApi.cpp
+++ b/opengl/libs/EGL/eglApi.cpp
@@ -44,6 +44,7 @@
#include "egl_impl.h"
#include "egl_object.h"
#include "egl_tls.h"
+#include "egldefs.h"
using namespace android;
@@ -88,24 +89,6 @@
// ----------------------------------------------------------------------------
-template<typename T>
-static __attribute__((noinline))
-int binarySearch(T const sortedArray[], int first, int last, T key) {
- while (first <= last) {
- int mid = (first + last) / 2;
- if (sortedArray[mid] < key) {
- first = mid + 1;
- } else if (key < sortedArray[mid]) {
- last = mid - 1;
- } else {
- return mid;
- }
- }
- return -1;
-}
-
-// ----------------------------------------------------------------------------
-
namespace android {
extern void setGLHooksThreadSpecific(gl_hooks_t const *value);
extern EGLBoolean egl_init_drivers();
@@ -183,21 +166,20 @@
egl_display_t const * const dp = validate_display(dpy);
if (!dp) return EGL_FALSE;
- GLint numConfigs = dp->numTotalConfigs;
- if (!configs) {
- *num_config = numConfigs;
- return EGL_TRUE;
+ if (num_config==0) {
+ return setError(EGL_BAD_PARAMETER, EGL_FALSE);
}
- GLint n = 0;
- for (intptr_t i=0 ; i<dp->numTotalConfigs && config_size ; i++) {
- *configs++ = EGLConfig(i);
- config_size--;
- n++;
+ EGLBoolean res = EGL_FALSE;
+ *num_config = 0;
+
+ egl_connection_t* const cnx = &gEGLImpl;
+ if (cnx->dso) {
+ res = cnx->egl.eglGetConfigs(
+ dp->disp.dpy, configs, config_size, num_config);
}
-
- *num_config = n;
- return EGL_TRUE;
+
+ return res;
}
EGLBoolean eglChooseConfig( EGLDisplay dpy, const EGLint *attrib_list,
@@ -213,105 +195,13 @@
return setError(EGL_BAD_PARAMETER, EGL_FALSE);
}
- EGLint n;
EGLBoolean res = EGL_FALSE;
*num_config = 0;
-
- // It is unfortunate, but we need to remap the EGL_CONFIG_IDs,
- // to do this, we have to go through the attrib_list array once
- // to figure out both its size and if it contains an EGL_CONFIG_ID
- // key. If so, the full array is copied and patched.
- // NOTE: we assume that there can be only one occurrence
- // of EGL_CONFIG_ID.
-
- EGLint patch_index = -1;
- GLint attr;
- size_t size = 0;
- if (attrib_list) {
- while ((attr=attrib_list[size]) != EGL_NONE) {
- if (attr == EGL_CONFIG_ID)
- patch_index = size;
- size += 2;
- }
- }
- if (patch_index >= 0) {
- size += 2; // we need copy the sentinel as well
- EGLint* new_list = (EGLint*)malloc(size*sizeof(EGLint));
- if (new_list == 0)
- return setError(EGL_BAD_ALLOC, EGL_FALSE);
- memcpy(new_list, attrib_list, size*sizeof(EGLint));
-
- // patch the requested EGL_CONFIG_ID
- bool found = false;
- EGLConfig ourConfig(0);
- EGLint& configId(new_list[patch_index+1]);
- for (intptr_t i=0 ; i<dp->numTotalConfigs ; i++) {
- if (dp->configs[i].configId == configId) {
- ourConfig = EGLConfig(i);
- configId = dp->configs[i].implConfigId;
- found = true;
- break;
- }
- }
-
- egl_connection_t* const cnx = &gEGLImpl[dp->configs[intptr_t(ourConfig)].impl];
- if (found && cnx->dso) {
- // and switch to the new list
- attrib_list = const_cast<const EGLint *>(new_list);
-
- // At this point, the only configuration that can match is
- // dp->configs[i][index], however, we don't know if it would be
- // rejected because of the other attributes, so we do have to call
- // cnx->egl.eglChooseConfig() -- but we don't have to loop
- // through all the EGLimpl[].
- // We also know we can only get a single config back, and we know
- // which one.
-
- res = cnx->egl.eglChooseConfig(
- dp->disp[ dp->configs[intptr_t(ourConfig)].impl ].dpy,
- attrib_list, configs, config_size, &n);
- if (res && n>0) {
- // n has to be 0 or 1, by construction, and we already know
- // which config it will return (since there can be only one).
- if (configs) {
- configs[0] = ourConfig;
- }
- *num_config = 1;
- }
- }
-
- free(const_cast<EGLint *>(attrib_list));
- return res;
- }
-
-
- for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {
- egl_connection_t* const cnx = &gEGLImpl[i];
- if (cnx->dso) {
- if (cnx->egl.eglChooseConfig(
- dp->disp[i].dpy, attrib_list, configs, config_size, &n)) {
- if (configs) {
- // now we need to convert these client EGLConfig to our
- // internal EGLConfig format.
- // This is done in O(n Log(n)) time.
- for (int j=0 ; j<n ; j++) {
- egl_config_t key(i, configs[j]);
- intptr_t index = binarySearch<egl_config_t>(
- dp->configs, 0, dp->numTotalConfigs, key);
- if (index >= 0) {
- configs[j] = EGLConfig(index);
- } else {
- return setError(EGL_BAD_CONFIG, EGL_FALSE);
- }
- }
- configs += n;
- config_size -= n;
- }
- *num_config += n;
- res = EGL_TRUE;
- }
- }
+ egl_connection_t* const cnx = &gEGLImpl;
+ if (cnx->dso) {
+ res = cnx->egl.eglChooseConfig(
+ dp->disp.dpy, attrib_list, configs, config_size, num_config);
}
return res;
}
@@ -325,13 +215,8 @@
egl_connection_t* cnx = validate_display_config(dpy, config, dp);
if (!cnx) return EGL_FALSE;
- if (attribute == EGL_CONFIG_ID) {
- *value = dp->configs[intptr_t(config)].configId;
- return EGL_TRUE;
- }
return cnx->egl.eglGetConfigAttrib(
- dp->disp[ dp->configs[intptr_t(config)].impl ].dpy,
- dp->configs[intptr_t(config)].config, attribute, value);
+ dp->disp.dpy, config, attribute, value);
}
// ----------------------------------------------------------------------------
@@ -347,8 +232,7 @@
egl_display_t const* dp = 0;
egl_connection_t* cnx = validate_display_config(dpy, config, dp);
if (cnx) {
- EGLDisplay iDpy = dp->disp[ dp->configs[intptr_t(config)].impl ].dpy;
- EGLConfig iConfig = dp->configs[intptr_t(config)].config;
+ EGLDisplay iDpy = dp->disp.dpy;
EGLint format;
if (native_window_api_connect(window, NATIVE_WINDOW_API_EGL) != OK) {
@@ -359,7 +243,7 @@
// set the native window's buffers format to match this config
if (cnx->egl.eglGetConfigAttrib(iDpy,
- iConfig, EGL_NATIVE_VISUAL_ID, &format)) {
+ config, EGL_NATIVE_VISUAL_ID, &format)) {
if (format != 0) {
int err = native_window_set_buffers_format(window, format);
if (err != 0) {
@@ -377,10 +261,9 @@
anw->setSwapInterval(anw, 1);
EGLSurface surface = cnx->egl.eglCreateWindowSurface(
- iDpy, iConfig, window, attrib_list);
+ iDpy, config, window, attrib_list);
if (surface != EGL_NO_SURFACE) {
- egl_surface_t* s = new egl_surface_t(dpy, config, window, surface,
- dp->configs[intptr_t(config)].impl, cnx);
+ egl_surface_t* s = new egl_surface_t(dpy, config, window, surface, cnx);
return s;
}
@@ -401,11 +284,9 @@
egl_connection_t* cnx = validate_display_config(dpy, config, dp);
if (cnx) {
EGLSurface surface = cnx->egl.eglCreatePixmapSurface(
- dp->disp[ dp->configs[intptr_t(config)].impl ].dpy,
- dp->configs[intptr_t(config)].config, pixmap, attrib_list);
+ dp->disp.dpy, config, pixmap, attrib_list);
if (surface != EGL_NO_SURFACE) {
- egl_surface_t* s = new egl_surface_t(dpy, config, NULL, surface,
- dp->configs[intptr_t(config)].impl, cnx);
+ egl_surface_t* s = new egl_surface_t(dpy, config, NULL, surface, cnx);
return s;
}
}
@@ -421,11 +302,9 @@
egl_connection_t* cnx = validate_display_config(dpy, config, dp);
if (cnx) {
EGLSurface surface = cnx->egl.eglCreatePbufferSurface(
- dp->disp[ dp->configs[intptr_t(config)].impl ].dpy,
- dp->configs[intptr_t(config)].config, attrib_list);
+ dp->disp.dpy, config, attrib_list);
if (surface != EGL_NO_SURFACE) {
- egl_surface_t* s = new egl_surface_t(dpy, config, NULL, surface,
- dp->configs[intptr_t(config)].impl, cnx);
+ egl_surface_t* s = new egl_surface_t(dpy, config, NULL, surface, cnx);
return s;
}
}
@@ -444,8 +323,7 @@
return setError(EGL_BAD_SURFACE, EGL_FALSE);
egl_surface_t * const s = get_surface(surface);
- EGLBoolean result = s->cnx->egl.eglDestroySurface(
- dp->disp[s->impl].dpy, s->surface);
+ EGLBoolean result = s->cnx->egl.eglDestroySurface(dp->disp.dpy, s->surface);
if (result == EGL_TRUE) {
_s.terminate();
}
@@ -465,16 +343,8 @@
return setError(EGL_BAD_SURFACE, EGL_FALSE);
egl_surface_t const * const s = get_surface(surface);
- EGLBoolean result(EGL_TRUE);
- if (attribute == EGL_CONFIG_ID) {
- // We need to remap EGL_CONFIG_IDs
- *value = dp->configs[intptr_t(s->config)].configId;
- } else {
- result = s->cnx->egl.eglQuerySurface(
- dp->disp[s->impl].dpy, s->surface, attribute, value);
- }
-
- return result;
+ return s->cnx->egl.eglQuerySurface(
+ dp->disp.dpy, s->surface, attribute, value);
}
void EGLAPI eglBeginFrame(EGLDisplay dpy, EGLSurface surface) {
@@ -514,9 +384,7 @@
share_list = c->context;
}
EGLContext context = cnx->egl.eglCreateContext(
- dp->disp[ dp->configs[intptr_t(config)].impl ].dpy,
- dp->configs[intptr_t(config)].config,
- share_list, attrib_list);
+ dp->disp.dpy, config, share_list, attrib_list);
if (context != EGL_NO_CONTEXT) {
// figure out if it's a GLESv1 or GLESv2
int version = 0;
@@ -526,15 +394,14 @@
GLint value = *attrib_list++;
if (attr == EGL_CONTEXT_CLIENT_VERSION) {
if (value == 1) {
- version = GLESv1_INDEX;
+ version = egl_connection_t::GLESv1_INDEX;
} else if (value == 2) {
- version = GLESv2_INDEX;
+ version = egl_connection_t::GLESv2_INDEX;
}
}
};
}
- egl_context_t* c = new egl_context_t(dpy, context, config,
- dp->configs[intptr_t(config)].impl, cnx, version);
+ egl_context_t* c = new egl_context_t(dpy, context, config, cnx, version);
#if EGL_TRACE
if (gEGLDebugLevel > 0)
GLTrace_eglCreateContext(version, c);
@@ -558,8 +425,7 @@
return setError(EGL_BAD_CONTEXT, EGL_FALSE);
egl_context_t * const c = get_context(ctx);
- EGLBoolean result = c->cnx->egl.eglDestroyContext(
- dp->disp[c->impl].dpy, c->context);
+ EGLBoolean result = c->cnx->egl.eglDestroyContext(dp->disp.dpy, c->context);
if (result == EGL_TRUE) {
_c.terminate();
}
@@ -625,20 +491,12 @@
// retrieve the underlying implementation's draw EGLSurface
if (draw != EGL_NO_SURFACE) {
d = get_surface(draw);
- // make sure the EGLContext and EGLSurface passed in are for
- // the same driver
- if (c && d->impl != c->impl)
- return setError(EGL_BAD_MATCH, EGL_FALSE);
impl_draw = d->surface;
}
// retrieve the underlying implementation's read EGLSurface
if (read != EGL_NO_SURFACE) {
r = get_surface(read);
- // make sure the EGLContext and EGLSurface passed in are for
- // the same driver
- if (c && r->impl != c->impl)
- return setError(EGL_BAD_MATCH, EGL_FALSE);
impl_read = r->surface;
}
@@ -682,17 +540,9 @@
if (!_c.get()) return setError(EGL_BAD_CONTEXT, EGL_FALSE);
egl_context_t * const c = get_context(ctx);
+ return c->cnx->egl.eglQueryContext(
+ dp->disp.dpy, c->context, attribute, value);
- EGLBoolean result(EGL_TRUE);
- if (attribute == EGL_CONFIG_ID) {
- *value = dp->configs[intptr_t(c->config)].configId;
- } else {
- // We need to remap EGL_CONFIG_IDs
- result = c->cnx->egl.eglQueryContext(
- dp->disp[c->impl].dpy, c->context, attribute, value);
- }
-
- return result;
}
EGLContext eglGetCurrentContext(void)
@@ -744,64 +594,37 @@
EGLBoolean eglWaitGL(void)
{
- // could be called before eglInitialize(), but we wouldn't have a context
- // then, and this function would return GL_TRUE, which isn't wrong.
-
clearError();
- EGLBoolean res = EGL_TRUE;
- EGLContext ctx = getContext();
- if (ctx) {
- egl_context_t const * const c = get_context(ctx);
- if (!c) return setError(EGL_BAD_CONTEXT, EGL_FALSE);
- if (uint32_t(c->impl)>=2)
- return setError(EGL_BAD_CONTEXT, EGL_FALSE);
- egl_connection_t* const cnx = &gEGLImpl[c->impl];
- if (!cnx->dso)
- return setError(EGL_BAD_CONTEXT, EGL_FALSE);
- res = cnx->egl.eglWaitGL();
- }
- return res;
+ egl_connection_t* const cnx = &gEGLImpl;
+ if (!cnx->dso)
+ return setError(EGL_BAD_CONTEXT, EGL_FALSE);
+
+ return cnx->egl.eglWaitGL();
}
EGLBoolean eglWaitNative(EGLint engine)
{
- // could be called before eglInitialize(), but we wouldn't have a context
- // then, and this function would return GL_TRUE, which isn't wrong.
-
clearError();
- EGLBoolean res = EGL_TRUE;
- EGLContext ctx = getContext();
- if (ctx) {
- egl_context_t const * const c = get_context(ctx);
- if (!c) return setError(EGL_BAD_CONTEXT, EGL_FALSE);
- if (uint32_t(c->impl)>=2)
- return setError(EGL_BAD_CONTEXT, EGL_FALSE);
- egl_connection_t* const cnx = &gEGLImpl[c->impl];
- if (!cnx->dso)
- return setError(EGL_BAD_CONTEXT, EGL_FALSE);
- res = cnx->egl.eglWaitNative(engine);
- }
- return res;
+ egl_connection_t* const cnx = &gEGLImpl;
+ if (!cnx->dso)
+ return setError(EGL_BAD_CONTEXT, EGL_FALSE);
+
+ return cnx->egl.eglWaitNative(engine);
}
EGLint eglGetError(void)
{
- EGLint result = EGL_SUCCESS;
- EGLint err;
- for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {
- err = EGL_SUCCESS;
- egl_connection_t* const cnx = &gEGLImpl[i];
- if (cnx->dso)
- err = cnx->egl.eglGetError();
- if (err!=EGL_SUCCESS && result==EGL_SUCCESS)
- result = err;
+ EGLint err = EGL_SUCCESS;
+ egl_connection_t* const cnx = &gEGLImpl;
+ if (cnx->dso) {
+ err = cnx->egl.eglGetError();
}
- err = egl_tls_t::getError();
- if (result == EGL_SUCCESS)
- result = err;
- return result;
+ if (err == EGL_SUCCESS) {
+ err = egl_tls_t::getError();
+ }
+ return err;
}
// Note: Similar implementations of these functions also exist in
@@ -885,20 +708,20 @@
if (!addr && (slot < MAX_NUMBER_OF_GL_EXTENSIONS)) {
bool found = false;
- for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {
- egl_connection_t* const cnx = &gEGLImpl[i];
- if (cnx->dso && cnx->egl.eglGetProcAddress) {
- found = true;
- // Extensions are independent of the bound context
- cnx->hooks[GLESv1_INDEX]->ext.extensions[slot] =
- cnx->hooks[GLESv2_INDEX]->ext.extensions[slot] =
+
+ egl_connection_t* const cnx = &gEGLImpl;
+ if (cnx->dso && cnx->egl.eglGetProcAddress) {
+ found = true;
+ // Extensions are independent of the bound context
+ cnx->hooks[egl_connection_t::GLESv1_INDEX]->ext.extensions[slot] =
+ cnx->hooks[egl_connection_t::GLESv2_INDEX]->ext.extensions[slot] =
#if EGL_TRACE
- debugHooks->ext.extensions[slot] =
- gHooksTrace.ext.extensions[slot] =
+ debugHooks->ext.extensions[slot] =
+ gHooksTrace.ext.extensions[slot] =
#endif
- cnx->egl.eglGetProcAddress(procname);
- }
+ cnx->egl.eglGetProcAddress(procname);
}
+
if (found) {
addr = gExtensionForwarders[slot];
@@ -937,7 +760,7 @@
#endif
egl_surface_t const * const s = get_surface(draw);
- return s->cnx->egl.eglSwapBuffers(dp->disp[s->impl].dpy, s->surface);
+ return s->cnx->egl.eglSwapBuffers(dp->disp.dpy, s->surface);
}
EGLBoolean eglCopyBuffers( EGLDisplay dpy, EGLSurface surface,
@@ -953,8 +776,7 @@
return setError(EGL_BAD_SURFACE, EGL_FALSE);
egl_surface_t const * const s = get_surface(surface);
- return s->cnx->egl.eglCopyBuffers(
- dp->disp[s->impl].dpy, s->surface, target);
+ return s->cnx->egl.eglCopyBuffers(dp->disp.dpy, s->surface, target);
}
const char* eglQueryString(EGLDisplay dpy, EGLint name)
@@ -973,12 +795,8 @@
return dp->getExtensionString();
case EGL_CLIENT_APIS:
return dp->getClientApiString();
- case EGL_VERSION_HW_ANDROID: {
- if (gEGLImpl[IMPL_HARDWARE].dso) {
- return dp->disp[IMPL_HARDWARE].queryString.version;
- }
- return dp->disp[IMPL_SOFTWARE].queryString.version;
- }
+ case EGL_VERSION_HW_ANDROID:
+ return dp->disp.queryString.version;
}
return setError(EGL_BAD_PARAMETER, (const char *)0);
}
@@ -1003,7 +821,7 @@
egl_surface_t const * const s = get_surface(surface);
if (s->cnx->egl.eglSurfaceAttrib) {
return s->cnx->egl.eglSurfaceAttrib(
- dp->disp[s->impl].dpy, s->surface, attribute, value);
+ dp->disp.dpy, s->surface, attribute, value);
}
return setError(EGL_BAD_SURFACE, EGL_FALSE);
}
@@ -1023,7 +841,7 @@
egl_surface_t const * const s = get_surface(surface);
if (s->cnx->egl.eglBindTexImage) {
return s->cnx->egl.eglBindTexImage(
- dp->disp[s->impl].dpy, s->surface, buffer);
+ dp->disp.dpy, s->surface, buffer);
}
return setError(EGL_BAD_SURFACE, EGL_FALSE);
}
@@ -1043,7 +861,7 @@
egl_surface_t const * const s = get_surface(surface);
if (s->cnx->egl.eglReleaseTexImage) {
return s->cnx->egl.eglReleaseTexImage(
- dp->disp[s->impl].dpy, s->surface, buffer);
+ dp->disp.dpy, s->surface, buffer);
}
return setError(EGL_BAD_SURFACE, EGL_FALSE);
}
@@ -1056,17 +874,11 @@
if (!dp) return EGL_FALSE;
EGLBoolean res = EGL_TRUE;
- for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {
- egl_connection_t* const cnx = &gEGLImpl[i];
- if (cnx->dso) {
- if (cnx->egl.eglSwapInterval) {
- if (cnx->egl.eglSwapInterval(
- dp->disp[i].dpy, interval) == EGL_FALSE) {
- res = EGL_FALSE;
- }
- }
- }
+ egl_connection_t* const cnx = &gEGLImpl;
+ if (cnx->dso && cnx->egl.eglSwapInterval) {
+ res = cnx->egl.eglSwapInterval(dp->disp.dpy, interval);
}
+
return res;
}
@@ -1079,23 +891,15 @@
{
clearError();
- // could be called before eglInitialize(), but we wouldn't have a context
- // then, and this function would return GL_TRUE, which isn't wrong.
- EGLBoolean res = EGL_TRUE;
- EGLContext ctx = getContext();
- if (ctx) {
- egl_context_t const * const c = get_context(ctx);
- if (!c) return setError(EGL_BAD_CONTEXT, EGL_FALSE);
- if (uint32_t(c->impl)>=2)
- return setError(EGL_BAD_CONTEXT, EGL_FALSE);
- egl_connection_t* const cnx = &gEGLImpl[c->impl];
- if (!cnx->dso)
- return setError(EGL_BAD_CONTEXT, EGL_FALSE);
- if (cnx->egl.eglWaitClient) {
- res = cnx->egl.eglWaitClient();
- } else {
- res = cnx->egl.eglWaitGL();
- }
+ egl_connection_t* const cnx = &gEGLImpl;
+ if (!cnx->dso)
+ return setError(EGL_BAD_CONTEXT, EGL_FALSE);
+
+ EGLBoolean res;
+ if (cnx->egl.eglWaitClient) {
+ res = cnx->egl.eglWaitClient();
+ } else {
+ res = cnx->egl.eglWaitGL();
}
return res;
}
@@ -1110,15 +914,9 @@
// bind this API on all EGLs
EGLBoolean res = EGL_TRUE;
- for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {
- egl_connection_t* const cnx = &gEGLImpl[i];
- if (cnx->dso) {
- if (cnx->egl.eglBindAPI) {
- if (cnx->egl.eglBindAPI(api) == EGL_FALSE) {
- res = EGL_FALSE;
- }
- }
- }
+ egl_connection_t* const cnx = &gEGLImpl;
+ if (cnx->dso && cnx->egl.eglBindAPI) {
+ res = cnx->egl.eglBindAPI(api);
}
return res;
}
@@ -1131,16 +929,11 @@
return setError(EGL_BAD_PARAMETER, EGL_FALSE);
}
- for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {
- egl_connection_t* const cnx = &gEGLImpl[i];
- if (cnx->dso) {
- if (cnx->egl.eglQueryAPI) {
- // the first one we find is okay, because they all
- // should be the same
- return cnx->egl.eglQueryAPI();
- }
- }
+ egl_connection_t* const cnx = &gEGLImpl;
+ if (cnx->dso && cnx->egl.eglQueryAPI) {
+ return cnx->egl.eglQueryAPI();
}
+
// or, it can only be OpenGL ES
return EGL_OPENGL_ES_API;
}
@@ -1152,14 +945,11 @@
// If there is context bound to the thread, release it
egl_display_t::loseCurrent(get_context(getContext()));
- for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {
- egl_connection_t* const cnx = &gEGLImpl[i];
- if (cnx->dso) {
- if (cnx->egl.eglReleaseThread) {
- cnx->egl.eglReleaseThread();
- }
- }
+ egl_connection_t* const cnx = &gEGLImpl;
+ if (cnx->dso && cnx->egl.eglReleaseThread) {
+ cnx->egl.eglReleaseThread();
}
+
egl_tls_t::clearTLS();
#if EGL_TRACE
if (gEGLDebugLevel > 0)
@@ -1179,9 +969,7 @@
if (!cnx) return EGL_FALSE;
if (cnx->egl.eglCreatePbufferFromClientBuffer) {
return cnx->egl.eglCreatePbufferFromClientBuffer(
- dp->disp[ dp->configs[intptr_t(config)].impl ].dpy,
- buftype, buffer,
- dp->configs[intptr_t(config)].config, attrib_list);
+ dp->disp.dpy, buftype, buffer, config, attrib_list);
}
return setError(EGL_BAD_CONFIG, EGL_NO_SURFACE);
}
@@ -1205,7 +993,7 @@
egl_surface_t const * const s = get_surface(surface);
if (s->cnx->egl.eglLockSurfaceKHR) {
return s->cnx->egl.eglLockSurfaceKHR(
- dp->disp[s->impl].dpy, s->surface, attrib_list);
+ dp->disp.dpy, s->surface, attrib_list);
}
return setError(EGL_BAD_DISPLAY, EGL_FALSE);
}
@@ -1223,8 +1011,7 @@
egl_surface_t const * const s = get_surface(surface);
if (s->cnx->egl.eglUnlockSurfaceKHR) {
- return s->cnx->egl.eglUnlockSurfaceKHR(
- dp->disp[s->impl].dpy, s->surface);
+ return s->cnx->egl.eglUnlockSurfaceKHR(dp->disp.dpy, s->surface);
}
return setError(EGL_BAD_DISPLAY, EGL_FALSE);
}
@@ -1244,12 +1031,12 @@
egl_context_t * const c = get_context(ctx);
// since we have an EGLContext, we know which implementation to use
EGLImageKHR image = c->cnx->egl.eglCreateImageKHR(
- dp->disp[c->impl].dpy, c->context, target, buffer, attrib_list);
+ dp->disp.dpy, c->context, target, buffer, attrib_list);
if (image == EGL_NO_IMAGE_KHR)
return image;
egl_image_t* result = new egl_image_t(dpy, ctx);
- result->images[c->impl] = image;
+ result->image = image;
return (EGLImageKHR)result;
} else {
// EGL_NO_CONTEXT is a valid parameter
@@ -1261,23 +1048,14 @@
EGLint currentError = eglGetError();
- EGLImageKHR implImages[IMPL_NUM_IMPLEMENTATIONS];
- bool success = false;
- for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {
- egl_connection_t* const cnx = &gEGLImpl[i];
- implImages[i] = EGL_NO_IMAGE_KHR;
- if (cnx->dso) {
- if (cnx->egl.eglCreateImageKHR) {
- implImages[i] = cnx->egl.eglCreateImageKHR(
- dp->disp[i].dpy, ctx, target, buffer, attrib_list);
- if (implImages[i] != EGL_NO_IMAGE_KHR) {
- success = true;
- }
- }
- }
+ EGLImageKHR implImage = EGL_NO_IMAGE_KHR;
+ egl_connection_t* const cnx = &gEGLImpl;
+ if (cnx->dso && cnx->egl.eglCreateImageKHR) {
+ implImage = cnx->egl.eglCreateImageKHR(
+ dp->disp.dpy, ctx, target, buffer, attrib_list);
}
- if (!success) {
+ if (implImage == EGL_NO_IMAGE_KHR) {
// failure, if there was an error when we entered this function,
// the error flag must not be updated.
// Otherwise, the error is whatever happened in the implementation
@@ -1289,13 +1067,12 @@
} else {
// In case of success, we need to clear all error flags
// (especially those caused by the implementation that didn't
- // succeed). TODO: we could avoid this if we knew this was
- // a "full" success (all implementation succeeded).
+ // succeed).
eglGetError();
}
egl_image_t* result = new egl_image_t(dpy, ctx);
- memcpy(result->images, implImages, sizeof(implImages));
+ result->image = implImage;
return (EGLImageKHR)result;
}
}
@@ -1312,19 +1089,17 @@
egl_image_t* image = get_image(img);
bool success = false;
- for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {
- egl_connection_t* const cnx = &gEGLImpl[i];
- if (image->images[i] != EGL_NO_IMAGE_KHR) {
- if (cnx->dso) {
- if (cnx->egl.eglDestroyImageKHR) {
- if (cnx->egl.eglDestroyImageKHR(
- dp->disp[i].dpy, image->images[i])) {
- success = true;
- }
- }
+
+ egl_connection_t* const cnx = &gEGLImpl;
+ if (image->image != EGL_NO_IMAGE_KHR) {
+ if (cnx->dso && cnx->egl.eglDestroyImageKHR) {
+ if (cnx->egl.eglDestroyImageKHR(
+ dp->disp.dpy, image->image)) {
+ success = true;
}
}
}
+
if (!success)
return EGL_FALSE;
@@ -1354,7 +1129,7 @@
EGLSyncKHR result = EGL_NO_SYNC_KHR;
if (c->cnx->egl.eglCreateSyncKHR) {
EGLSyncKHR sync = c->cnx->egl.eglCreateSyncKHR(
- dp->disp[c->impl].dpy, type, attrib_list);
+ dp->disp.dpy, type, attrib_list);
if (sync == EGL_NO_SYNC_KHR)
return sync;
result = (egl_sync_t*)new egl_sync_t(dpy, ctx, sync);
@@ -1382,7 +1157,7 @@
egl_context_t * const c = get_context(ctx);
if (c->cnx->egl.eglDestroySyncKHR) {
result = c->cnx->egl.eglDestroySyncKHR(
- dp->disp[c->impl].dpy, syncObject->sync);
+ dp->disp.dpy, syncObject->sync);
if (result)
_s.terminate();
}
@@ -1408,7 +1183,7 @@
egl_context_t * const c = get_context(ctx);
if (c->cnx->egl.eglClientWaitSyncKHR) {
return c->cnx->egl.eglClientWaitSyncKHR(
- dp->disp[c->impl].dpy, syncObject->sync, flags, timeout);
+ dp->disp.dpy, syncObject->sync, flags, timeout);
}
return EGL_FALSE;
@@ -1434,7 +1209,7 @@
egl_context_t * const c = get_context(ctx);
if (c->cnx->egl.eglGetSyncAttribKHR) {
return c->cnx->egl.eglGetSyncAttribKHR(
- dp->disp[c->impl].dpy, syncObject->sync, attribute, value);
+ dp->disp.dpy, syncObject->sync, attribute, value);
}
return EGL_FALSE;
@@ -1458,12 +1233,10 @@
}
EGLuint64NV ret = 0;
- egl_connection_t* const cnx = &gEGLImpl[IMPL_HARDWARE];
+ egl_connection_t* const cnx = &gEGLImpl;
- if (cnx->dso) {
- if (cnx->egl.eglGetSystemTimeFrequencyNV) {
- return cnx->egl.eglGetSystemTimeFrequencyNV();
- }
+ if (cnx->dso && cnx->egl.eglGetSystemTimeFrequencyNV) {
+ return cnx->egl.eglGetSystemTimeFrequencyNV();
}
return setErrorQuiet(EGL_BAD_DISPLAY, 0);
@@ -1478,12 +1251,10 @@
}
EGLuint64NV ret = 0;
- egl_connection_t* const cnx = &gEGLImpl[IMPL_HARDWARE];
+ egl_connection_t* const cnx = &gEGLImpl;
- if (cnx->dso) {
- if (cnx->egl.eglGetSystemTimeNV) {
- return cnx->egl.eglGetSystemTimeNV();
- }
+ if (cnx->dso && cnx->egl.eglGetSystemTimeNV) {
+ return cnx->egl.eglGetSystemTimeNV();
}
return setErrorQuiet(EGL_BAD_DISPLAY, 0);
diff --git a/opengl/libs/EGL/egl_cache.cpp b/opengl/libs/EGL/egl_cache.cpp
index 7fd6519..c79fb5f 100644
--- a/opengl/libs/EGL/egl_cache.cpp
+++ b/opengl/libs/EGL/egl_cache.cpp
@@ -83,39 +83,39 @@
void egl_cache_t::initialize(egl_display_t *display) {
Mutex::Autolock lock(mMutex);
- for (int i = 0; i < IMPL_NUM_IMPLEMENTATIONS; i++) {
- egl_connection_t* const cnx = &gEGLImpl[i];
- if (cnx->dso && cnx->major >= 0 && cnx->minor >= 0) {
- const char* exts = display->disp[i].queryString.extensions;
- size_t bcExtLen = strlen(BC_EXT_STR);
- size_t extsLen = strlen(exts);
- bool equal = !strcmp(BC_EXT_STR, exts);
- bool atStart = !strncmp(BC_EXT_STR " ", exts, bcExtLen+1);
- bool atEnd = (bcExtLen+1) < extsLen &&
- !strcmp(" " BC_EXT_STR, exts + extsLen - (bcExtLen+1));
- bool inMiddle = strstr(exts, " " BC_EXT_STR " ");
- if (equal || atStart || atEnd || inMiddle) {
- PFNEGLSETBLOBCACHEFUNCSANDROIDPROC eglSetBlobCacheFuncsANDROID;
- eglSetBlobCacheFuncsANDROID =
- reinterpret_cast<PFNEGLSETBLOBCACHEFUNCSANDROIDPROC>(
+
+ egl_connection_t* const cnx = &gEGLImpl;
+ if (cnx->dso && cnx->major >= 0 && cnx->minor >= 0) {
+ const char* exts = display->disp.queryString.extensions;
+ size_t bcExtLen = strlen(BC_EXT_STR);
+ size_t extsLen = strlen(exts);
+ bool equal = !strcmp(BC_EXT_STR, exts);
+ bool atStart = !strncmp(BC_EXT_STR " ", exts, bcExtLen+1);
+ bool atEnd = (bcExtLen+1) < extsLen &&
+ !strcmp(" " BC_EXT_STR, exts + extsLen - (bcExtLen+1));
+ bool inMiddle = strstr(exts, " " BC_EXT_STR " ");
+ if (equal || atStart || atEnd || inMiddle) {
+ PFNEGLSETBLOBCACHEFUNCSANDROIDPROC eglSetBlobCacheFuncsANDROID;
+ eglSetBlobCacheFuncsANDROID =
+ reinterpret_cast<PFNEGLSETBLOBCACHEFUNCSANDROIDPROC>(
cnx->egl.eglGetProcAddress(
"eglSetBlobCacheFuncsANDROID"));
- if (eglSetBlobCacheFuncsANDROID == NULL) {
- ALOGE("EGL_ANDROID_blob_cache advertised by display %d, "
- "but unable to get eglSetBlobCacheFuncsANDROID", i);
- continue;
- }
+ if (eglSetBlobCacheFuncsANDROID == NULL) {
+ ALOGE("EGL_ANDROID_blob_cache advertised, "
+ "but unable to get eglSetBlobCacheFuncsANDROID");
+ return;
+ }
- eglSetBlobCacheFuncsANDROID(display->disp[i].dpy,
- android::setBlob, android::getBlob);
- EGLint err = cnx->egl.eglGetError();
- if (err != EGL_SUCCESS) {
- ALOGE("eglSetBlobCacheFuncsANDROID resulted in an error: "
- "%#x", err);
- }
+ eglSetBlobCacheFuncsANDROID(display->disp.dpy,
+ android::setBlob, android::getBlob);
+ EGLint err = cnx->egl.eglGetError();
+ if (err != EGL_SUCCESS) {
+ ALOGE("eglSetBlobCacheFuncsANDROID resulted in an error: "
+ "%#x", err);
}
}
}
+
mInitialized = true;
}
diff --git a/opengl/libs/EGL/egl_display.cpp b/opengl/libs/EGL/egl_display.cpp
index 6b2ae51..c85b4ce 100644
--- a/opengl/libs/EGL/egl_display.cpp
+++ b/opengl/libs/EGL/egl_display.cpp
@@ -60,18 +60,12 @@
extern void initEglTraceLevel();
extern void setGLHooksThreadSpecific(gl_hooks_t const *value);
-static int cmp_configs(const void* a, const void *b) {
- const egl_config_t& c0 = *(egl_config_t const *)a;
- const egl_config_t& c1 = *(egl_config_t const *)b;
- return c0<c1 ? -1 : (c1<c0 ? 1 : 0);
-}
-
// ----------------------------------------------------------------------------
egl_display_t egl_display_t::sDisplay[NUM_DISPLAYS];
egl_display_t::egl_display_t() :
- magic('_dpy'), numTotalConfigs(0), configs(0), refs(0) {
+ magic('_dpy'), refs(0) {
}
egl_display_t::~egl_display_t() {
@@ -119,15 +113,13 @@
// get our driver loader
Loader& loader(Loader::getInstance());
- for (int i = 0; i < IMPL_NUM_IMPLEMENTATIONS; i++) {
- egl_connection_t* const cnx = &gEGLImpl[i];
- if (cnx->dso && disp[i].dpy == EGL_NO_DISPLAY) {
- EGLDisplay dpy = cnx->egl.eglGetDisplay(display);
- disp[i].dpy = dpy;
- if (dpy == EGL_NO_DISPLAY) {
- loader.close(cnx->dso);
- cnx->dso = NULL;
- }
+ egl_connection_t* const cnx = &gEGLImpl;
+ if (cnx->dso && disp.dpy == EGL_NO_DISPLAY) {
+ EGLDisplay dpy = cnx->egl.eglGetDisplay(display);
+ disp.dpy = dpy;
+ if (dpy == EGL_NO_DISPLAY) {
+ loader.close(cnx->dso);
+ cnx->dso = NULL;
}
}
@@ -160,12 +152,11 @@
// initialize each EGL and
// build our own extension string first, based on the extension we know
// and the extension supported by our client implementation
- for (int i = 0; i < IMPL_NUM_IMPLEMENTATIONS; i++) {
- egl_connection_t* const cnx = &gEGLImpl[i];
- cnx->major = -1;
- cnx->minor = -1;
- if (!cnx->dso)
- continue;
+
+ egl_connection_t* const cnx = &gEGLImpl;
+ cnx->major = -1;
+ cnx->minor = -1;
+ if (cnx->dso) {
#if defined(ADRENO130)
#warning "Adreno-130 eglInitialize() workaround"
@@ -177,31 +168,30 @@
* eglGetDisplay() before calling eglInitialize();
*/
if (i == IMPL_HARDWARE) {
- disp[i].dpy =
- cnx->egl.eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ disp[i].dpy = cnx->egl.eglGetDisplay(EGL_DEFAULT_DISPLAY);
}
#endif
- EGLDisplay idpy = disp[i].dpy;
+ EGLDisplay idpy = disp.dpy;
if (cnx->egl.eglInitialize(idpy, &cnx->major, &cnx->minor)) {
- //ALOGD("initialized %d dpy=%p, ver=%d.%d, cnx=%p",
- // i, idpy, cnx->major, cnx->minor, cnx);
+ //ALOGD("initialized dpy=%p, ver=%d.%d, cnx=%p",
+ // idpy, cnx->major, cnx->minor, cnx);
// display is now initialized
- disp[i].state = egl_display_t::INITIALIZED;
+ disp.state = egl_display_t::INITIALIZED;
// get the query-strings for this display for each implementation
- disp[i].queryString.vendor = cnx->egl.eglQueryString(idpy,
+ disp.queryString.vendor = cnx->egl.eglQueryString(idpy,
EGL_VENDOR);
- disp[i].queryString.version = cnx->egl.eglQueryString(idpy,
+ disp.queryString.version = cnx->egl.eglQueryString(idpy,
EGL_VERSION);
- disp[i].queryString.extensions = cnx->egl.eglQueryString(idpy,
+ disp.queryString.extensions = cnx->egl.eglQueryString(idpy,
EGL_EXTENSIONS);
- disp[i].queryString.clientApi = cnx->egl.eglQueryString(idpy,
+ disp.queryString.clientApi = cnx->egl.eglQueryString(idpy,
EGL_CLIENT_APIS);
} else {
- ALOGW("%d: eglInitialize(%p) failed (%s)", i, idpy,
+ ALOGW("eglInitialize(%p) failed (%s)", idpy,
egl_tls_t::egl_strerror(cnx->egl.eglGetError()));
}
}
@@ -211,7 +201,7 @@
mVersionString.setTo(sVersionString);
mClientApiString.setTo(sClientApiString);
- // we only add extensions that exist in at least one implementation
+ // we only add extensions that exist in the implementation
char const* start = sExtensionString;
char const* end;
do {
@@ -223,15 +213,13 @@
if (len) {
// NOTE: we could avoid the copy if we had strnstr.
const String8 ext(start, len);
- // now go through all implementations and look for this extension
- for (int i = 0; i < IMPL_NUM_IMPLEMENTATIONS; i++) {
- if (disp[i].queryString.extensions) {
- // if we find it, add this extension string to our list
- // (and don't forget the space)
- const char* match = strstr(disp[i].queryString.extensions, ext.string());
- if (match && (match[len] == ' ' || match[len] == 0)) {
- mExtensionString.append(start, len+1);
- }
+ // now look for this extension
+ if (disp.queryString.extensions) {
+ // if we find it, add this extension string to our list
+ // (and don't forget the space)
+ const char* match = strstr(disp.queryString.extensions, ext.string());
+ if (match && (match[len] == ' ' || match[len] == 0)) {
+ mExtensionString.append(start, len+1);
}
}
}
@@ -242,52 +230,12 @@
egl_cache_t::get()->initialize(this);
- EGLBoolean res = EGL_FALSE;
- for (int i = 0; i < IMPL_NUM_IMPLEMENTATIONS; i++) {
- egl_connection_t* const cnx = &gEGLImpl[i];
- if (cnx->dso && cnx->major >= 0 && cnx->minor >= 0) {
- EGLint n;
- if (cnx->egl.eglGetConfigs(disp[i].dpy, 0, 0, &n)) {
- disp[i].config = (EGLConfig*) malloc(sizeof(EGLConfig) * n);
- if (disp[i].config) {
- if (cnx->egl.eglGetConfigs(disp[i].dpy, disp[i].config, n,
- &disp[i].numConfigs)) {
- numTotalConfigs += n;
- res = EGL_TRUE;
- }
- }
- }
- }
- }
-
- if (res == EGL_TRUE) {
- configs = new egl_config_t[numTotalConfigs];
- for (int i = 0, k = 0; i < IMPL_NUM_IMPLEMENTATIONS; i++) {
- egl_connection_t* const cnx = &gEGLImpl[i];
- if (cnx->dso && cnx->major >= 0 && cnx->minor >= 0) {
- for (int j = 0; j < disp[i].numConfigs; j++) {
- configs[k].impl = i;
- configs[k].config = disp[i].config[j];
- configs[k].configId = k + 1; // CONFIG_ID start at 1
- // store the implementation's CONFIG_ID
- cnx->egl.eglGetConfigAttrib(disp[i].dpy, disp[i].config[j],
- EGL_CONFIG_ID, &configs[k].implConfigId);
- k++;
- }
- }
- }
-
- // sort our configurations so we can do binary-searches
- qsort(configs, numTotalConfigs, sizeof(egl_config_t), cmp_configs);
-
- refs++;
- if (major != NULL)
- *major = VERSION_MAJOR;
- if (minor != NULL)
- *minor = VERSION_MINOR;
- return EGL_TRUE;
- }
- return setError(EGL_NOT_INITIALIZED, EGL_FALSE);
+ refs++;
+ if (major != NULL)
+ *major = VERSION_MAJOR;
+ if (minor != NULL)
+ *minor = VERSION_MINOR;
+ return EGL_TRUE;
}
EGLBoolean egl_display_t::terminate() {
@@ -305,22 +253,15 @@
}
EGLBoolean res = EGL_FALSE;
- for (int i = 0; i < IMPL_NUM_IMPLEMENTATIONS; i++) {
- egl_connection_t* const cnx = &gEGLImpl[i];
- if (cnx->dso && disp[i].state == egl_display_t::INITIALIZED) {
- if (cnx->egl.eglTerminate(disp[i].dpy) == EGL_FALSE) {
- ALOGW("%d: eglTerminate(%p) failed (%s)", i, disp[i].dpy,
- egl_tls_t::egl_strerror(cnx->egl.eglGetError()));
- }
- // REVISIT: it's unclear what to do if eglTerminate() fails
- free(disp[i].config);
-
- disp[i].numConfigs = 0;
- disp[i].config = 0;
- disp[i].state = egl_display_t::TERMINATED;
-
- res = EGL_TRUE;
+ egl_connection_t* const cnx = &gEGLImpl;
+ if (cnx->dso && disp.state == egl_display_t::INITIALIZED) {
+ if (cnx->egl.eglTerminate(disp.dpy) == EGL_FALSE) {
+ ALOGW("eglTerminate(%p) failed (%s)", disp.dpy,
+ egl_tls_t::egl_strerror(cnx->egl.eglGetError()));
}
+ // REVISIT: it's unclear what to do if eglTerminate() fails
+ disp.state = egl_display_t::TERMINATED;
+ res = EGL_TRUE;
}
// Mark all objects remaining in the list as terminated, unless
@@ -337,8 +278,6 @@
objects.clear();
refs--;
- numTotalConfigs = 0;
- delete[] configs;
return res;
}
@@ -390,13 +329,13 @@
Mutex::Autolock _l(lock);
if (c) {
result = c->cnx->egl.eglMakeCurrent(
- disp[c->impl].dpy, impl_draw, impl_read, impl_ctx);
+ disp.dpy, impl_draw, impl_read, impl_ctx);
if (result == EGL_TRUE) {
c->onMakeCurrent(draw, read);
}
} else {
result = cur_c->cnx->egl.eglMakeCurrent(
- disp[cur_c->impl].dpy, impl_draw, impl_read, impl_ctx);
+ disp.dpy, impl_draw, impl_read, impl_ctx);
if (result == EGL_TRUE) {
cur_c->onLooseCurrent();
}
diff --git a/opengl/libs/EGL/egl_display.h b/opengl/libs/EGL/egl_display.h
index f3c4ddf..6348228 100644
--- a/opengl/libs/EGL/egl_display.h
+++ b/opengl/libs/EGL/egl_display.h
@@ -44,23 +44,6 @@
// ----------------------------------------------------------------------------
-struct egl_config_t {
- egl_config_t() {}
- egl_config_t(int impl, EGLConfig config)
- : impl(impl), config(config), configId(0), implConfigId(0) { }
- int impl; // the implementation this config is for
- EGLConfig config; // the implementation's EGLConfig
- EGLint configId; // our CONFIG_ID
- EGLint implConfigId; // the implementation's CONFIG_ID
- inline bool operator < (const egl_config_t& rhs) const {
- if (impl < rhs.impl) return true;
- if (impl > rhs.impl) return false;
- return config < rhs.config;
- }
-};
-
-// ----------------------------------------------------------------------------
-
class EGLAPI egl_display_t { // marked as EGLAPI for testing purposes
static egl_display_t sDisplay[NUM_DISPLAYS];
EGLDisplay getDisplay(EGLNativeDisplayType display);
@@ -113,12 +96,9 @@
};
struct DisplayImpl {
- DisplayImpl() : dpy(EGL_NO_DISPLAY), config(0),
- state(NOT_INITIALIZED), numConfigs(0) { }
+ DisplayImpl() : dpy(EGL_NO_DISPLAY), state(NOT_INITIALIZED) { }
EGLDisplay dpy;
- EGLConfig* config;
EGLint state;
- EGLint numConfigs;
strings_t queryString;
};
@@ -126,9 +106,7 @@
uint32_t magic;
public:
- DisplayImpl disp[IMPL_NUM_IMPLEMENTATIONS];
- EGLint numTotalConfigs;
- egl_config_t* configs;
+ DisplayImpl disp;
private:
uint32_t refs;
diff --git a/opengl/libs/EGL/egl_object.cpp b/opengl/libs/EGL/egl_object.cpp
index b660c53..d0cbb31 100644
--- a/opengl/libs/EGL/egl_object.cpp
+++ b/opengl/libs/EGL/egl_object.cpp
@@ -64,9 +64,9 @@
// ----------------------------------------------------------------------------
egl_context_t::egl_context_t(EGLDisplay dpy, EGLContext context, EGLConfig config,
- int impl, egl_connection_t const* cnx, int version) :
+ egl_connection_t const* cnx, int version) :
egl_object_t(get_display(dpy)), dpy(dpy), context(context),
- config(config), read(0), draw(0), impl(impl), cnx(cnx),
+ config(config), read(0), draw(0), cnx(cnx),
version(version)
{
}
@@ -87,7 +87,7 @@
if (gl_extensions.isEmpty()) {
// call the implementation's glGetString(GL_EXTENSIONS)
- const char* exts = (const char *)gEGLImpl[impl].hooks[version]->gl.glGetString(GL_EXTENSIONS);
+ const char* exts = (const char *)gEGLImpl.hooks[version]->gl.glGetString(GL_EXTENSIONS);
gl_extensions.setTo(exts);
if (gl_extensions.find("GL_EXT_debug_marker") < 0) {
String8 temp("GL_EXT_debug_marker ");
diff --git a/opengl/libs/EGL/egl_object.h b/opengl/libs/EGL/egl_object.h
index abd4cbb..f137bad 100644
--- a/opengl/libs/EGL/egl_object.h
+++ b/opengl/libs/EGL/egl_object.h
@@ -125,7 +125,7 @@
// ----------------------------------------------------------------------------
-class egl_surface_t: public egl_object_t {
+class egl_surface_t : public egl_object_t {
protected:
~egl_surface_t() {
ANativeWindow* const window = win.get();
@@ -140,15 +140,14 @@
typedef egl_object_t::LocalRef<egl_surface_t, EGLSurface> Ref;
egl_surface_t(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win,
- EGLSurface surface, int impl, egl_connection_t const* cnx) :
+ EGLSurface surface, egl_connection_t const* cnx) :
egl_object_t(get_display(dpy)), dpy(dpy), surface(surface),
- config(config), win(win), impl(impl), cnx(cnx) {
+ config(config), win(win), cnx(cnx) {
}
EGLDisplay dpy;
EGLSurface surface;
EGLConfig config;
sp<ANativeWindow> win;
- int impl;
egl_connection_t const* cnx;
};
@@ -159,7 +158,7 @@
typedef egl_object_t::LocalRef<egl_context_t, EGLContext> Ref;
egl_context_t(EGLDisplay dpy, EGLContext context, EGLConfig config,
- int impl, egl_connection_t const* cnx, int version);
+ egl_connection_t const* cnx, int version);
void onLooseCurrent();
void onMakeCurrent(EGLSurface draw, EGLSurface read);
@@ -169,7 +168,6 @@
EGLConfig config;
EGLSurface read;
EGLSurface draw;
- int impl;
egl_connection_t const* cnx;
int version;
String8 gl_extensions;
@@ -182,12 +180,11 @@
typedef egl_object_t::LocalRef<egl_image_t, EGLImageKHR> Ref;
egl_image_t(EGLDisplay dpy, EGLContext context) :
- egl_object_t(get_display(dpy)), dpy(dpy), context(context) {
- memset(images, 0, sizeof(images));
- }
+ egl_object_t(get_display(dpy)),
+ dpy(dpy), context(context), image(EGL_NO_IMAGE_KHR) { }
EGLDisplay dpy;
EGLContext context;
- EGLImageKHR images[IMPL_NUM_IMPLEMENTATIONS];
+ EGLImageKHR image;
};
class egl_sync_t: public egl_object_t {
diff --git a/opengl/libs/EGL/egldefs.h b/opengl/libs/EGL/egldefs.h
index ff20957..c900c1c 100644
--- a/opengl/libs/EGL/egldefs.h
+++ b/opengl/libs/EGL/egldefs.h
@@ -19,31 +19,24 @@
#include "hooks.h"
+#define VERSION_MAJOR 1
+#define VERSION_MINOR 4
+
// ----------------------------------------------------------------------------
namespace android {
// ----------------------------------------------------------------------------
-#define VERSION_MAJOR 1
-#define VERSION_MINOR 4
-
// EGLDisplay are global, not attached to a given thread
const unsigned int NUM_DISPLAYS = 1;
-enum {
- IMPL_HARDWARE = 0,
- IMPL_SOFTWARE,
- IMPL_NUM_IMPLEMENTATIONS
-};
-
-enum {
- GLESv1_INDEX = 0,
- GLESv2_INDEX = 1,
-};
-
// ----------------------------------------------------------------------------
-struct egl_connection_t
-{
+struct egl_connection_t {
+ enum {
+ GLESv1_INDEX = 0,
+ GLESv2_INDEX = 1
+ };
+
inline egl_connection_t() : dso(0) { }
void * dso;
gl_hooks_t * hooks[2];
@@ -54,7 +47,7 @@
// ----------------------------------------------------------------------------
-extern gl_hooks_t gHooks[2][IMPL_NUM_IMPLEMENTATIONS];
+extern gl_hooks_t gHooks[2];
extern gl_hooks_t gHooksNoContext;
extern pthread_key_t gGLWrapperKey;
extern "C" void gl_unimplemented();
@@ -63,7 +56,7 @@
extern char const * const gl_names[];
extern char const * const egl_names[];
-extern egl_connection_t gEGLImpl[IMPL_NUM_IMPLEMENTATIONS];
+extern egl_connection_t gEGLImpl;
// ----------------------------------------------------------------------------
}; // namespace android
diff --git a/opengl/libs/GLES_trace/src/gltrace_fixup.cpp b/opengl/libs/GLES_trace/src/gltrace_fixup.cpp
index 871b5dc..3e185bc 100644
--- a/opengl/libs/GLES_trace/src/gltrace_fixup.cpp
+++ b/opengl/libs/GLES_trace/src/gltrace_fixup.cpp
@@ -15,9 +15,13 @@
*/
#include <cutils/log.h>
+#include <GLES/gl.h>
+#include <GLES/glext.h>
#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
#include "gltrace.pb.h"
+#include "gltrace_api.h"
#include "gltrace_context.h"
#include "gltrace_fixup.h"
@@ -198,6 +202,20 @@
arg_strpp->add_charvalue(src);
}
+void fixup_glUniformGenericInteger(int argIndex, int nIntegers, GLMessage *glmsg) {
+ /* void glUniform?iv(GLint location, GLsizei count, const GLint *value); */
+ GLMessage_DataType *arg_values = glmsg->mutable_args(argIndex);
+ GLint *src = (GLint*)arg_values->intvalue(0);
+
+ arg_values->set_type(GLMessage::DataType::INT);
+ arg_values->set_isarray(true);
+ arg_values->clear_intvalue();
+
+ for (int i = 0; i < nIntegers; i++) {
+ arg_values->add_intvalue(*src++);
+ }
+}
+
void fixup_glUniformGeneric(int argIndex, int nFloats, GLMessage *glmsg) {
GLMessage_DataType *arg_values = glmsg->mutable_args(argIndex);
GLfloat *src = (GLfloat*)arg_values->intvalue(0);
@@ -223,6 +241,10 @@
GLMessage_DataType *arg_intarray = glmsg->mutable_args(argIndex);
GLint *intp = (GLint *)arg_intarray->intvalue(0);
+ if (intp == NULL) {
+ return;
+ }
+
arg_intarray->set_type(GLMessage::DataType::INT);
arg_intarray->set_isarray(true);
arg_intarray->clear_intvalue();
@@ -232,6 +254,15 @@
}
}
+void fixup_GenericEnumArray(int argIndex, int nEnums, GLMessage *glmsg) {
+ // fixup as if they were ints
+ fixup_GenericIntArray(argIndex, nEnums, glmsg);
+
+ // and then set the data type to be enum
+ GLMessage_DataType *arg_enumarray = glmsg->mutable_args(argIndex);
+ arg_enumarray->set_type(GLMessage::DataType::ENUM);
+}
+
void fixup_glGenGeneric(GLMessage *glmsg) {
/* void glGen*(GLsizei n, GLuint * buffers); */
GLMessage_DataType arg_n = glmsg->args(0);
@@ -270,6 +301,84 @@
arg_params->add_floatvalue(*src);
}
+void fixup_glLinkProgram(GLMessage *glmsg) {
+ /* void glLinkProgram(GLuint program); */
+ GLuint program = glmsg->args(0).intvalue(0);
+
+ /* We don't have to fixup this call, but as soon as a program is linked,
+ we obtain information about all active attributes and uniforms to
+ pass on to the debugger. Note that in order to pass this info to
+ the debugger, all we need to do is call the trace versions of the
+ necessary calls. */
+
+ GLint n, maxNameLength;
+ GLchar *name;
+ GLint size;
+ GLenum type;
+
+ // obtain info regarding active attributes
+ GLTrace_glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &n);
+ GLTrace_glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxNameLength);
+
+ name = (GLchar *) malloc(maxNameLength);
+ for (int i = 0; i < n; i++) {
+ GLTrace_glGetActiveAttrib(program, i, maxNameLength, NULL, &size, &type, name);
+ }
+ free(name);
+
+ // obtain info regarding active uniforms
+ GLTrace_glGetProgramiv(program, GL_ACTIVE_UNIFORMS, &n);
+ GLTrace_glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxNameLength);
+
+ name = (GLchar *) malloc(maxNameLength);
+ for (int i = 0; i < n; i++) {
+ GLTrace_glGetActiveUniform(program, i, maxNameLength, NULL, &size, &type, name);
+ }
+ free(name);
+}
+
+/** Given a glGetActive[Uniform|Attrib] call, obtain the location
+ * of the variable in the call.
+ */
+int getShaderVariableLocation(GLTraceContext *context, GLMessage *glmsg) {
+ GLMessage_Function func = glmsg->function();
+ if (func != GLMessage::glGetActiveAttrib && func != GLMessage::glGetActiveUniform) {
+ return -1;
+ }
+
+ int program = glmsg->args(0).intvalue(0);
+ GLchar *name = (GLchar*) glmsg->args(6).intvalue(0);
+
+ if (func == GLMessage::glGetActiveAttrib) {
+ return context->hooks->gl.glGetAttribLocation(program, name);
+ } else {
+ return context->hooks->gl.glGetUniformLocation(program, name);
+ }
+}
+
+void fixup_glGetActiveAttribOrUniform(GLMessage *glmsg, int location) {
+ /* void glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize,
+ GLsizei* length, GLint* size, GLenum* type, GLchar* name); */
+ /* void glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize,
+ GLsizei* length, GLint* size, GLenum* type, GLchar* name) */
+
+ fixup_GenericIntArray(3, 1, glmsg); // length
+ fixup_GenericIntArray(4, 1, glmsg); // size
+ fixup_GenericEnumArray(5, 1, glmsg); // type
+ fixup_CStringPtr(6, glmsg); // name
+
+ // The index argument in the glGetActive[Attrib|Uniform] functions
+ // does not correspond to the actual location index as used in
+ // glUniform*() or glVertexAttrib*() to actually upload the data.
+ // In order to make things simpler for the debugger, we also pass
+ // a hidden location argument that stores the actual location.
+ // append the location value to the end of the argument list
+ GLMessage_DataType *arg_location = glmsg->add_args();
+ arg_location->set_isarray(false);
+ arg_location->set_type(GLMessage::DataType::INT);
+ arg_location->add_intvalue(location);
+}
+
void fixupGLMessage(GLTraceContext *context, nsecs_t start, nsecs_t end, GLMessage *glmsg) {
// for all messages, set the current context id
glmsg->set_context_id(context->getId());
@@ -292,6 +401,19 @@
case GLMessage::glGenTextures: /* void glGenTextures(GLsizei n, GLuint *textures); */
fixup_glGenGeneric(glmsg);
break;
+ case GLMessage::glLinkProgram: /* void glLinkProgram(GLuint program); */
+ fixup_glLinkProgram(glmsg);
+ break;
+ case GLMessage::glGetActiveAttrib:
+ fixup_glGetActiveAttribOrUniform(glmsg, getShaderVariableLocation(context, glmsg));
+ break;
+ case GLMessage::glGetActiveUniform:
+ fixup_glGetActiveAttribOrUniform(glmsg, getShaderVariableLocation(context, glmsg));
+ break;
+ case GLMessage::glBindAttribLocation:
+ /* void glBindAttribLocation(GLuint program, GLuint index, const GLchar* name); */
+ fixup_CStringPtr(2, glmsg);
+ break;
case GLMessage::glGetAttribLocation:
case GLMessage::glGetUniformLocation:
/* int glGetAttribLocation(GLuint program, const GLchar* name) */
@@ -331,6 +453,38 @@
case GLMessage::glShaderSource:
fixup_glShaderSource(glmsg);
break;
+ case GLMessage::glUniform1iv:
+ /* void glUniform1iv(GLint location, GLsizei count, const GLint *value); */
+ fixup_glUniformGenericInteger(2, 1, glmsg);
+ break;
+ case GLMessage::glUniform2iv:
+ /* void glUniform2iv(GLint location, GLsizei count, const GLint *value); */
+ fixup_glUniformGenericInteger(2, 2, glmsg);
+ break;
+ case GLMessage::glUniform3iv:
+ /* void glUniform3iv(GLint location, GLsizei count, const GLint *value); */
+ fixup_glUniformGenericInteger(2, 3, glmsg);
+ break;
+ case GLMessage::glUniform4iv:
+ /* void glUniform4iv(GLint location, GLsizei count, const GLint *value); */
+ fixup_glUniformGenericInteger(2, 4, glmsg);
+ break;
+ case GLMessage::glUniform1fv:
+ /* void glUniform1fv(GLint location, GLsizei count, const GLfloat *value); */
+ fixup_glUniformGeneric(2, 1, glmsg);
+ break;
+ case GLMessage::glUniform2fv:
+ /* void glUniform2fv(GLint location, GLsizei count, const GLfloat *value); */
+ fixup_glUniformGeneric(2, 2, glmsg);
+ break;
+ case GLMessage::glUniform3fv:
+ /* void glUniform3fv(GLint location, GLsizei count, const GLfloat *value); */
+ fixup_glUniformGeneric(2, 3, glmsg);
+ break;
+ case GLMessage::glUniform4fv:
+ /* void glUniform4fv(GLint location, GLsizei count, const GLfloat *value); */
+ fixup_glUniformGeneric(2, 4, glmsg);
+ break;
case GLMessage::glUniformMatrix2fv:
/* void glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose,
const GLfloat* value) */
diff --git a/packages/SystemUI/res/layout-land/status_bar_recent_item.xml b/packages/SystemUI/res/layout-land/status_bar_recent_item.xml
index 2d76455..aa27861 100644
--- a/packages/SystemUI/res/layout-land/status_bar_recent_item.xml
+++ b/packages/SystemUI/res/layout-land/status_bar_recent_item.xml
@@ -58,6 +58,7 @@
android:maxHeight="@dimen/status_bar_recents_app_icon_max_height"
android:scaleType="centerInside"
android:adjustViewBounds="true"
+ android:visibility="invisible"
/>
<TextView android:id="@+id/app_label"
diff --git a/packages/SystemUI/res/layout-port/status_bar_recent_item.xml b/packages/SystemUI/res/layout-port/status_bar_recent_item.xml
index b653fcd..bc389f9 100644
--- a/packages/SystemUI/res/layout-port/status_bar_recent_item.xml
+++ b/packages/SystemUI/res/layout-port/status_bar_recent_item.xml
@@ -81,6 +81,7 @@
android:maxHeight="@dimen/status_bar_recents_app_icon_max_height"
android:scaleType="centerInside"
android:adjustViewBounds="true"
+ android:visibility="invisible"
/>
<TextView android:id="@+id/app_description"
diff --git a/packages/SystemUI/res/layout-sw600dp/status_bar_recent_item.xml b/packages/SystemUI/res/layout-sw600dp/status_bar_recent_item.xml
index cb26db00..333fcda 100644
--- a/packages/SystemUI/res/layout-sw600dp/status_bar_recent_item.xml
+++ b/packages/SystemUI/res/layout-sw600dp/status_bar_recent_item.xml
@@ -65,6 +65,7 @@
android:maxHeight="@dimen/status_bar_recents_app_icon_max_height"
android:scaleType="centerInside"
android:adjustViewBounds="true"
+ android:visibility="invisible"
/>
diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
index 14ce266..cd8bd4e 100644
--- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
@@ -236,6 +236,10 @@
public void onAnimationEnd(Animator animation) {
mCallback.onChildDismissed(view);
animView.setLayerType(View.LAYER_TYPE_NONE, null);
+ // Restore the alpha/translation parameters to what they were before swiping
+ // (for when these items are recycled)
+ animView.setAlpha(1f);
+ setTranslation(animView, 0f);
}
});
anim.addUpdateListener(new AnimatorUpdateListener() {
diff --git a/packages/SystemUI/src/com/android/systemui/recent/Choreographer.java b/packages/SystemUI/src/com/android/systemui/recent/Choreographer.java
index ad38a11..f8a4592 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/Choreographer.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/Choreographer.java
@@ -134,6 +134,7 @@
void jumpTo(boolean appearing) {
mContentView.setTranslationY(appearing ? 0 : mPanelHeight);
+ mScrimView.getBackground().setAlpha(appearing ? 255 : 0);
}
public void setPanelHeight(int h) {
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentTasksLoader.java b/packages/SystemUI/src/com/android/systemui/recent/RecentTasksLoader.java
index 4145fc4..92f4ca9 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentTasksLoader.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentTasksLoader.java
@@ -16,12 +16,6 @@
package com.android.systemui.recent;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
@@ -36,15 +30,17 @@
import android.os.AsyncTask;
import android.os.Handler;
import android.os.Process;
-import android.os.SystemClock;
-import android.util.DisplayMetrics;
import android.util.Log;
-import android.util.LruCache;
import com.android.systemui.R;
import com.android.systemui.statusbar.phone.PhoneStatusBar;
import com.android.systemui.statusbar.tablet.TabletStatusBar;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+
public class RecentTasksLoader {
static final String TAG = "RecentTasksLoader";
static final boolean DEBUG = TabletStatusBar.DEBUG || PhoneStatusBar.DEBUG || false;
@@ -55,11 +51,14 @@
private Context mContext;
private RecentsPanelView mRecentsPanel;
- private AsyncTask<Void, Integer, Void> mThumbnailLoader;
+ private AsyncTask<Void, ArrayList<TaskDescription>, Void> mTaskLoader;
+ private AsyncTask<Void, TaskDescription, Void> mThumbnailLoader;
private final Handler mHandler;
private int mIconDpi;
private Bitmap mDefaultThumbnailBackground;
+ private Bitmap mDefaultIconBackground;
+ private int mNumTasksInFirstScreenful;
public RecentTasksLoader(Context context) {
mContext = context;
@@ -76,12 +75,20 @@
mIconDpi = res.getDisplayMetrics().densityDpi;
}
+ // Render default icon (just a blank image)
+ int defaultIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.app_icon_size);
+ int iconSize = (int) (defaultIconSize * mIconDpi / res.getDisplayMetrics().densityDpi);
+ mDefaultIconBackground = Bitmap.createBitmap(iconSize, iconSize, Bitmap.Config.ARGB_8888);
+
// Render the default thumbnail background
- int width = (int) res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_width);
- int height = (int) res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_height);
+ int thumbnailWidth =
+ (int) res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_width);
+ int thumbnailHeight =
+ (int) res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_height);
int color = res.getColor(R.drawable.status_bar_recents_app_thumbnail_background);
- mDefaultThumbnailBackground = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+ mDefaultThumbnailBackground =
+ Bitmap.createBitmap(thumbnailWidth, thumbnailHeight, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(mDefaultThumbnailBackground);
c.drawColor(color);
@@ -95,12 +102,17 @@
public void setRecentsPanel(RecentsPanelView recentsPanel) {
mRecentsPanel = recentsPanel;
+ mNumTasksInFirstScreenful = mRecentsPanel.numItemsInOneScreenful();
}
public Bitmap getDefaultThumbnail() {
return mDefaultThumbnailBackground;
}
+ public Bitmap getDefaultIcon() {
+ return mDefaultIconBackground;
+ }
+
// Create an TaskDescription, returning null if the title or icon is null, or if it's the
// home activity
TaskDescription createTaskDescription(int taskId, int persistentTaskId, Intent baseIntent,
@@ -114,6 +126,12 @@
homeInfo = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME)
.resolveActivityInfo(pm, 0);
}
+ // Don't load the current home activity.
+ if (homeInfo != null
+ && homeInfo.packageName.equals(intent.getComponent().getPackageName())
+ && homeInfo.name.equals(intent.getComponent().getClassName())) {
+ return null;
+ }
intent.setFlags((intent.getFlags()&~Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED)
| Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -121,9 +139,8 @@
if (resolveInfo != null) {
final ActivityInfo info = resolveInfo.activityInfo;
final String title = info.loadLabel(pm).toString();
- Drawable icon = getFullResIcon(resolveInfo, pm);
- if (title != null && title.length() > 0 && icon != null) {
+ if (title != null && title.length() > 0) {
if (DEBUG) Log.v(TAG, "creating activity desc for id="
+ persistentTaskId + ", label=" + title);
@@ -131,14 +148,6 @@
persistentTaskId, resolveInfo, baseIntent, info.packageName,
description);
item.setLabel(title);
- item.setIcon(icon);
-
- // Don't load the current home activity.
- if (homeInfo != null
- && homeInfo.packageName.equals(intent.getComponent().getPackageName())
- && homeInfo.name.equals(intent.getComponent().getClassName())) {
- return null;
- }
return item;
} else {
@@ -148,10 +157,12 @@
return null;
}
- void loadThumbnail(TaskDescription td) {
+ void loadThumbnailAndIcon(TaskDescription td) {
final ActivityManager am = (ActivityManager)
mContext.getSystemService(Context.ACTIVITY_SERVICE);
+ final PackageManager pm = mContext.getPackageManager();
ActivityManager.TaskThumbnails thumbs = am.getTaskThumbnails(td.persistentTaskId);
+ Drawable icon = getFullResIcon(td.resolveInfo, pm);
if (DEBUG) Log.v(TAG, "Loaded bitmap for task "
+ td + ": " + thumbs.mainThumbnail);
@@ -161,6 +172,10 @@
} else {
td.setThumbnail(mDefaultThumbnailBackground);
}
+ if (icon != null) {
+ td.setIcon(icon);
+ }
+ td.setLoaded(true);
}
}
@@ -194,111 +209,149 @@
return getFullResDefaultActivityIcon();
}
- public void cancelLoadingThumbnails() {
+ public void cancelLoadingThumbnailsAndIcons() {
+ if (mTaskLoader != null) {
+ mTaskLoader.cancel(false);
+ mTaskLoader = null;
+ }
if (mThumbnailLoader != null) {
mThumbnailLoader.cancel(false);
mThumbnailLoader = null;
}
}
- // return a snapshot of the current list of recent apps
- ArrayList<TaskDescription> getRecentTasks() {
- cancelLoadingThumbnails();
-
- ArrayList<TaskDescription> tasks = new ArrayList<TaskDescription>();
- final PackageManager pm = mContext.getPackageManager();
- final ActivityManager am = (ActivityManager)
+ public void loadTasksInBackground() {
+ // cancel all previous loading of tasks and thumbnails
+ cancelLoadingThumbnailsAndIcons();
+ final LinkedBlockingQueue<TaskDescription> tasksWaitingForThumbnails =
+ new LinkedBlockingQueue<TaskDescription>();
+ final ArrayList<TaskDescription> taskDescriptionsWaitingToLoad =
+ new ArrayList<TaskDescription>();
+ mTaskLoader = new AsyncTask<Void, ArrayList<TaskDescription>, Void>() {
+ @Override
+ protected void onProgressUpdate(ArrayList<TaskDescription>... values) {
+ if (!isCancelled()) {
+ ArrayList<TaskDescription> newTasks = values[0];
+ // do a callback to RecentsPanelView to let it know we have more values
+ // how do we let it know we're all done? just always call back twice
+ mRecentsPanel.onTasksLoaded(newTasks);
+ }
+ }
+ @Override
+ protected Void doInBackground(Void... params) {
+ // We load in two stages: first, we update progress with just the first screenful
+ // of items. Then, we update with the rest of the items
+ final int origPri = Process.getThreadPriority(Process.myTid());
+ Process.setThreadPriority(Process.THREAD_GROUP_BG_NONINTERACTIVE);
+ final PackageManager pm = mContext.getPackageManager();
+ final ActivityManager am = (ActivityManager)
mContext.getSystemService(Context.ACTIVITY_SERVICE);
- final List<ActivityManager.RecentTaskInfo> recentTasks =
- am.getRecentTasks(MAX_TASKS, ActivityManager.RECENT_IGNORE_UNAVAILABLE);
+ final List<ActivityManager.RecentTaskInfo> recentTasks =
+ am.getRecentTasks(MAX_TASKS, ActivityManager.RECENT_IGNORE_UNAVAILABLE);
+ int numTasks = recentTasks.size();
+ ActivityInfo homeInfo = new Intent(Intent.ACTION_MAIN)
+ .addCategory(Intent.CATEGORY_HOME).resolveActivityInfo(pm, 0);
- ActivityInfo homeInfo = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME)
- .resolveActivityInfo(pm, 0);
+ boolean firstScreenful = true;
+ ArrayList<TaskDescription> tasks = new ArrayList<TaskDescription>();
- HashSet<Integer> recentTasksToKeepInCache = new HashSet<Integer>();
- int numTasks = recentTasks.size();
-
- // skip the first task - assume it's either the home screen or the current activity.
- final int first = 1;
- recentTasksToKeepInCache.add(recentTasks.get(0).persistentId);
- for (int i = first, index = 0; i < numTasks && (index < MAX_TASKS); ++i) {
- final ActivityManager.RecentTaskInfo recentInfo = recentTasks.get(i);
-
- TaskDescription item = createTaskDescription(recentInfo.id,
- recentInfo.persistentId, recentInfo.baseIntent,
- recentInfo.origActivity, recentInfo.description, homeInfo);
-
- if (item != null) {
- tasks.add(item);
- ++index;
- }
- }
-
- // when we're not using the TaskDescription cache, we load the thumbnails in the
- // background
- loadThumbnailsInBackground(new ArrayList<TaskDescription>(tasks));
- return tasks;
- }
-
- private void loadThumbnailsInBackground(final ArrayList<TaskDescription> descriptions) {
- if (descriptions.size() > 0) {
- if (DEBUG) Log.v(TAG, "Showing " + descriptions.size() + " tasks");
- loadThumbnail(descriptions.get(0));
- if (descriptions.size() > 1) {
- mThumbnailLoader = new AsyncTask<Void, Integer, Void>() {
- @Override
- protected void onProgressUpdate(Integer... values) {
- final TaskDescription td = descriptions.get(values[0]);
- if (!isCancelled()) {
- mRecentsPanel.onTaskThumbnailLoaded(td);
- }
- // This is to prevent the loader thread from getting ahead
- // of our UI updates.
- mHandler.post(new Runnable() {
- @Override public void run() {
- synchronized (td) {
- td.notifyAll();
- }
- }
- });
+ // skip the first task - assume it's either the home screen or the current activity.
+ final int first = 1;
+ for (int i = first, index = 0; i < numTasks && (index < MAX_TASKS); ++i) {
+ if (isCancelled()) {
+ break;
}
+ final ActivityManager.RecentTaskInfo recentInfo = recentTasks.get(i);
+ TaskDescription item = createTaskDescription(recentInfo.id,
+ recentInfo.persistentId, recentInfo.baseIntent,
+ recentInfo.origActivity, recentInfo.description, homeInfo);
- @Override
- protected Void doInBackground(Void... params) {
- final int origPri = Process.getThreadPriority(Process.myTid());
- Process.setThreadPriority(Process.THREAD_GROUP_BG_NONINTERACTIVE);
- long nextTime = SystemClock.uptimeMillis();
- for (int i=1; i<descriptions.size(); i++) {
- TaskDescription td = descriptions.get(i);
- loadThumbnail(td);
- long now = SystemClock.uptimeMillis();
- nextTime += 0;
- if (nextTime > now) {
- try {
- Thread.sleep(nextTime-now);
- } catch (InterruptedException e) {
- }
- }
-
- if (isCancelled()) {
+ if (item != null) {
+ while (true) {
+ try {
+ tasksWaitingForThumbnails.put(item);
break;
- }
- synchronized (td) {
- publishProgress(i);
- try {
- td.wait(500);
- } catch (InterruptedException e) {
- }
+ } catch (InterruptedException e) {
}
}
- Process.setThreadPriority(origPri);
- return null;
+ tasks.add(item);
+ if (firstScreenful && tasks.size() == mNumTasksInFirstScreenful) {
+ publishProgress(tasks);
+ tasks = new ArrayList<TaskDescription>();
+ firstScreenful = false;
+ //break;
+ }
+ ++index;
}
- };
- mThumbnailLoader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ }
+
+ if (!isCancelled()) {
+ publishProgress(tasks);
+ if (firstScreenful) {
+ // always should publish two updates
+ publishProgress(new ArrayList<TaskDescription>());
+ }
+ }
+
+ while (true) {
+ try {
+ tasksWaitingForThumbnails.put(new TaskDescription());
+ break;
+ } catch (InterruptedException e) {
+ }
+ }
+
+ Process.setThreadPriority(origPri);
+ return null;
}
- }
+ };
+ mTaskLoader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ loadThumbnailsAndIconsInBackground(tasksWaitingForThumbnails);
}
+ private void loadThumbnailsAndIconsInBackground(
+ final BlockingQueue<TaskDescription> tasksWaitingForThumbnails) {
+ // continually read items from tasksWaitingForThumbnails and load
+ // thumbnails and icons for them. finish thread when cancelled or there
+ // is a null item in tasksWaitingForThumbnails
+ mThumbnailLoader = new AsyncTask<Void, TaskDescription, Void>() {
+ @Override
+ protected void onProgressUpdate(TaskDescription... values) {
+ if (!isCancelled()) {
+ TaskDescription td = values[0];
+ mRecentsPanel.onTaskThumbnailLoaded(td);
+ }
+ }
+ @Override
+ protected Void doInBackground(Void... params) {
+ final int origPri = Process.getThreadPriority(Process.myTid());
+ Process.setThreadPriority(Process.THREAD_GROUP_BG_NONINTERACTIVE);
+
+ while (true) {
+ if (isCancelled()) {
+ break;
+ }
+ TaskDescription td = null;
+ while (td == null) {
+ try {
+ td = tasksWaitingForThumbnails.take();
+ } catch (InterruptedException e) {
+ }
+ }
+ if (td.isNull()) {
+ break;
+ }
+ loadThumbnailAndIcon(td);
+ synchronized(td) {
+ publishProgress(td);
+ }
+ }
+
+ Process.setThreadPriority(origPri);
+ return null;
+ }
+ };
+ mThumbnailLoader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java
index f971d2d..4718a17 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java
@@ -22,11 +22,18 @@
import android.database.DataSetObserver;
import android.graphics.Canvas;
import android.util.AttributeSet;
+import android.util.DisplayMetrics;
+import android.util.FloatMath;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
-import android.view.ViewConfiguration;
+import android.view.View.MeasureSpec;
+import android.view.View.OnClickListener;
+import android.view.View.OnLongClickListener;
import android.view.View.OnTouchListener;
+import android.view.ViewConfiguration;
+import android.view.ViewTreeObserver;
+import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
@@ -34,6 +41,8 @@
import com.android.systemui.SwipeHelper;
import com.android.systemui.recent.RecentsPanelView.TaskDescriptionAdapter;
+import java.util.ArrayList;
+
public class RecentsHorizontalScrollView extends HorizontalScrollView
implements SwipeHelper.Callback {
private static final String TAG = RecentsPanelView.TAG;
@@ -44,6 +53,8 @@
protected int mLastScrollPosition;
private SwipeHelper mSwipeHelper;
private RecentsScrollViewPerformanceHelper mPerformanceHelper;
+ private ArrayList<View> mRecycledViews;
+ private int mNumItemsInOneScreenful;
public RecentsHorizontalScrollView(Context context, AttributeSet attrs) {
super(context, attrs, 0);
@@ -51,6 +62,7 @@
float pagingTouchSlop = ViewConfiguration.get(mContext).getScaledPagingTouchSlop();
mSwipeHelper = new SwipeHelper(SwipeHelper.Y, this, densityScale, pagingTouchSlop);
mPerformanceHelper = RecentsScrollViewPerformanceHelper.create(context, attrs, this, false);
+ mRecycledViews = new ArrayList<View>();
}
private int scrollPositionOfMostRecent() {
@@ -58,9 +70,23 @@
}
private void update() {
+ for (int i = 0; i < mLinearLayout.getChildCount(); i++) {
+ View v = mLinearLayout.getChildAt(i);
+ mRecycledViews.add(v);
+ mAdapter.recycleView(v);
+ }
+ LayoutTransition transitioner = getLayoutTransition();
+ setLayoutTransition(null);
+
mLinearLayout.removeAllViews();
for (int i = 0; i < mAdapter.getCount(); i++) {
- final View view = mAdapter.getView(i, null, mLinearLayout);
+ View old = null;
+ if (mRecycledViews.size() != 0) {
+ old = mRecycledViews.remove(mRecycledViews.size() - 1);
+ old.setVisibility(VISIBLE);
+ }
+
+ final View view = mAdapter.getView(i, old, mLinearLayout);
if (mPerformanceHelper != null) {
mPerformanceHelper.addViewCallback(view);
@@ -87,7 +113,8 @@
}
};
- final View thumbnailView = view.findViewById(R.id.app_thumbnail);
+ RecentsPanelView.ViewHolder holder = (RecentsPanelView.ViewHolder) view.getTag();
+ final View thumbnailView = holder.thumbnailView;
OnLongClickListener longClickListener = new OnLongClickListener() {
public boolean onLongClick(View v) {
final View anchorView = view.findViewById(R.id.app_description);
@@ -107,13 +134,21 @@
appTitle.setOnTouchListener(noOpListener);
mLinearLayout.addView(view);
}
+ setLayoutTransition(transitioner);
+
// Scroll to end after layout.
- post(new Runnable() {
- public void run() {
- mLastScrollPosition = scrollPositionOfMostRecent();
- scrollTo(mLastScrollPosition, 0);
- }
- });
+ final ViewTreeObserver observer = getViewTreeObserver();
+
+ final OnGlobalLayoutListener updateScroll = new OnGlobalLayoutListener() {
+ public void onGlobalLayout() {
+ mLastScrollPosition = scrollPositionOfMostRecent();
+ scrollTo(mLastScrollPosition, 0);
+ if (observer.isAlive()) {
+ observer.removeOnGlobalLayoutListener(this);
+ }
+ }
+ };
+ observer.addOnGlobalLayoutListener(updateScroll);
}
@Override
@@ -142,8 +177,10 @@
}
public void onChildDismissed(View v) {
+ mRecycledViews.add(v);
mLinearLayout.removeView(v);
mCallback.handleSwipe(v);
+ v.setActivated(false);
}
public void onBeginDrag(View v) {
@@ -315,6 +352,24 @@
update();
}
});
+ DisplayMetrics dm = getResources().getDisplayMetrics();
+ int childWidthMeasureSpec =
+ MeasureSpec.makeMeasureSpec(dm.widthPixels, MeasureSpec.AT_MOST);
+ int childheightMeasureSpec =
+ MeasureSpec.makeMeasureSpec(dm.heightPixels, MeasureSpec.AT_MOST);
+ View child = mAdapter.createView(mLinearLayout);
+ child.measure(childWidthMeasureSpec, childheightMeasureSpec);
+ mNumItemsInOneScreenful =
+ (int) FloatMath.ceil(dm.widthPixels / (float) child.getMeasuredWidth());
+ mRecycledViews.add(child);
+
+ for (int i = 0; i < mNumItemsInOneScreenful - 1; i++) {
+ mRecycledViews.add(mAdapter.createView(mLinearLayout));
+ }
+ }
+
+ public int numItemsInOneScreenful() {
+ return mNumItemsInOneScreenful;
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
index a10e363..8706f10 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
@@ -27,6 +27,7 @@
import android.graphics.Matrix;
import android.graphics.Shader.TileMode;
import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.provider.Settings;
import android.util.AttributeSet;
@@ -36,18 +37,18 @@
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
-import android.view.ViewConfiguration;
import android.view.ViewGroup;
+import android.view.ViewRootImpl;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
+import android.widget.FrameLayout;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.PopupMenu;
-import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
@@ -59,7 +60,7 @@
import java.util.ArrayList;
-public class RecentsPanelView extends RelativeLayout implements OnItemClickListener, RecentsCallback,
+public class RecentsPanelView extends FrameLayout implements OnItemClickListener, RecentsCallback,
StatusBarPanel, Animator.AnimatorListener, View.OnTouchListener {
static final String TAG = "RecentsPanelView";
static final boolean DEBUG = TabletStatusBar.DEBUG || PhoneStatusBar.DEBUG || false;
@@ -71,6 +72,10 @@
private StatusBarTouchProxy mStatusBarTouchProxy;
private boolean mShowing;
+ private boolean mWaitingToShow;
+ private boolean mWaitingToShowAnimated;
+ private boolean mReadyToShow;
+ private int mNumItemsWaitingForThumbnailsAndIcons;
private Choreographer mChoreo;
OnRecentsPanelVisibilityChangedListener mVisibilityChangedListener;
@@ -104,6 +109,7 @@
TextView labelView;
TextView descriptionView;
TaskDescription taskDescription;
+ boolean loadedThumbnailAndIcon;
}
/* package */ final class TaskDescriptionAdapter extends BaseAdapter {
@@ -125,42 +131,82 @@
return position; // we just need something unique for this position
}
- public View getView(int position, View convertView, ViewGroup parent) {
- ViewHolder holder;
- if (convertView == null) {
- convertView = mInflater.inflate(R.layout.status_bar_recent_item, parent, false);
- holder = new ViewHolder();
- holder.thumbnailView = convertView.findViewById(R.id.app_thumbnail);
- holder.thumbnailViewImage = (ImageView) convertView.findViewById(
- R.id.app_thumbnail_image);
- // If we set the default thumbnail now, we avoid an onLayout when we update
- // the thumbnail later (if they both have the same dimensions)
+ public View createView(ViewGroup parent) {
+ View convertView = mInflater.inflate(R.layout.status_bar_recent_item, parent, false);
+ ViewHolder holder = new ViewHolder();
+ holder.thumbnailView = convertView.findViewById(R.id.app_thumbnail);
+ holder.thumbnailViewImage =
+ (ImageView) convertView.findViewById(R.id.app_thumbnail_image);
+ // If we set the default thumbnail now, we avoid an onLayout when we update
+ // the thumbnail later (if they both have the same dimensions)
+ if (mRecentTasksLoader != null) {
updateThumbnail(holder, mRecentTasksLoader.getDefaultThumbnail(), false, false);
-
- holder.iconView = (ImageView) convertView.findViewById(R.id.app_icon);
- holder.labelView = (TextView) convertView.findViewById(R.id.app_label);
- holder.descriptionView = (TextView) convertView.findViewById(R.id.app_description);
-
- convertView.setTag(holder);
- } else {
- holder = (ViewHolder) convertView.getTag();
}
+ holder.iconView = (ImageView) convertView.findViewById(R.id.app_icon);
+ if (mRecentTasksLoader != null) {
+ holder.iconView.setImageBitmap(mRecentTasksLoader.getDefaultIcon());
+ }
+ holder.labelView = (TextView) convertView.findViewById(R.id.app_label);
+ holder.descriptionView = (TextView) convertView.findViewById(R.id.app_description);
+
+ convertView.setTag(holder);
+ return convertView;
+ }
+
+ public View getView(int position, View convertView, ViewGroup parent) {
+ if (convertView == null) {
+ convertView = createView(parent);
+ }
+ ViewHolder holder = (ViewHolder) convertView.getTag();
// index is reverse since most recent appears at the bottom...
final int index = mRecentTaskDescriptions.size() - position - 1;
final TaskDescription td = mRecentTaskDescriptions.get(index);
- holder.iconView.setImageDrawable(td.getIcon());
+
holder.labelView.setText(td.getLabel());
holder.thumbnailView.setContentDescription(td.getLabel());
- updateThumbnail(holder, td.getThumbnail(), true, false);
+ holder.loadedThumbnailAndIcon = td.isLoaded();
+ if (td.isLoaded()) {
+ updateThumbnail(holder, td.getThumbnail(), true, false);
+ updateIcon(holder, td.getIcon(), true, false);
+ mNumItemsWaitingForThumbnailsAndIcons--;
+ }
holder.thumbnailView.setTag(td);
holder.thumbnailView.setOnLongClickListener(new OnLongClickDelegate(convertView));
holder.taskDescription = td;
-
return convertView;
}
+
+ public void recycleView(View v) {
+ ViewHolder holder = (ViewHolder) v.getTag();
+ updateThumbnail(holder, mRecentTasksLoader.getDefaultThumbnail(), false, false);
+ holder.iconView.setImageBitmap(mRecentTasksLoader.getDefaultIcon());
+ holder.iconView.setVisibility(INVISIBLE);
+ holder.labelView.setText(null);
+ holder.thumbnailView.setContentDescription(null);
+ holder.thumbnailView.setTag(null);
+ holder.thumbnailView.setOnLongClickListener(null);
+ holder.thumbnailView.setVisibility(INVISIBLE);
+ holder.taskDescription = null;
+ holder.loadedThumbnailAndIcon = false;
+ }
+ }
+
+ public int numItemsInOneScreenful() {
+ if (mRecentsContainer instanceof RecentsHorizontalScrollView){
+ RecentsHorizontalScrollView scrollView
+ = (RecentsHorizontalScrollView) mRecentsContainer;
+ return scrollView.numItemsInOneScreenful();
+ } else if (mRecentsContainer instanceof RecentsVerticalScrollView){
+ RecentsVerticalScrollView scrollView
+ = (RecentsVerticalScrollView) mRecentsContainer;
+ return scrollView.numItemsInOneScreenful();
+ }
+ else {
+ throw new IllegalArgumentException("missing Recents[Horizontal]ScrollView");
+ }
}
@Override
@@ -192,15 +238,31 @@
}
public void show(boolean show, boolean animate) {
- show(show, animate, null);
+ if (show) {
+ mWaitingToShow = true;
+ mWaitingToShowAnimated = animate;
+ showIfReady();
+ } else {
+ show(show, animate, null, false);
+ }
+ }
+
+ private void showIfReady() {
+ // mWaitingToShow = there was a touch up on the recents button
+ // mReadyToShow = we've created views for the first screenful of items
+ if (mWaitingToShow && mReadyToShow) { // && mNumItemsWaitingForThumbnailsAndIcons <= 0
+ show(true, mWaitingToShowAnimated, null, false);
+ }
}
public void show(boolean show, boolean animate,
- ArrayList<TaskDescription> recentTaskDescriptions) {
+ ArrayList<TaskDescription> recentTaskDescriptions, boolean firstScreenful) {
+ // For now, disable animations. We may want to re-enable in the future
+ animate = false;
if (show) {
// Need to update list of recent apps before we set visibility so this view's
// content description is updated before it gets focus for TalkBack mode
- refreshRecentTasksList(recentTaskDescriptions);
+ refreshRecentTasksList(recentTaskDescriptions, firstScreenful);
// if there are no apps, either bring up a "No recent apps" message, or just
// quit early
@@ -209,19 +271,24 @@
mRecentsNoApps.setVisibility(noApps ? View.VISIBLE : View.INVISIBLE);
} else {
if (noApps) {
- if (DEBUG) Log.v(TAG, "Nothing to show");
+ if (DEBUG) Log.v(TAG, "Nothing to show");
// Need to set recent tasks to dirty so that next time we load, we
// refresh the list of tasks
- mRecentTasksLoader.cancelLoadingThumbnails();
+ mRecentTasksLoader.cancelLoadingThumbnailsAndIcons();
mRecentTasksDirty = true;
+
+ mWaitingToShow = false;
+ mReadyToShow = false;
return;
}
}
} else {
// Need to set recent tasks to dirty so that next time we load, we
// refresh the list of tasks
- mRecentTasksLoader.cancelLoadingThumbnails();
+ mRecentTasksLoader.cancelLoadingThumbnailsAndIcons();
mRecentTasksDirty = true;
+ mWaitingToShow = false;
+ mReadyToShow = false;
}
if (animate) {
if (mShowing != show) {
@@ -385,7 +452,6 @@
throw new IllegalArgumentException("missing Recents[Horizontal]ScrollView");
}
-
mRecentsScrim = findViewById(R.id.recents_bg_protect);
mRecentsNoApps = findViewById(R.id.recents_no_apps);
mChoreo = new Choreographer(this, mRecentsScrim, mRecentsContainer, mRecentsNoApps, this);
@@ -425,6 +491,20 @@
}
}
+
+ private void updateIcon(ViewHolder h, Drawable icon, boolean show, boolean anim) {
+ if (icon != null) {
+ h.iconView.setImageDrawable(icon);
+ if (show && h.iconView.getVisibility() != View.VISIBLE) {
+ if (anim) {
+ h.iconView.setAnimation(
+ AnimationUtils.loadAnimation(mContext, R.anim.recent_appear));
+ }
+ h.iconView.setVisibility(View.VISIBLE);
+ }
+ }
+ }
+
private void updateThumbnail(ViewHolder h, Bitmap thumbnail, boolean show, boolean anim) {
if (thumbnail != null) {
// Should remove the default image in the frame
@@ -458,31 +538,36 @@
}
}
- void onTaskThumbnailLoaded(TaskDescription ad) {
- synchronized (ad) {
+ void onTaskThumbnailLoaded(TaskDescription td) {
+ synchronized (td) {
if (mRecentsContainer != null) {
ViewGroup container = mRecentsContainer;
if (container instanceof HorizontalScrollView
|| container instanceof ScrollView) {
- container = (ViewGroup)container.findViewById(
+ container = (ViewGroup) container.findViewById(
R.id.recents_linear_layout);
}
// Look for a view showing this thumbnail, to update.
- for (int i=0; i<container.getChildCount(); i++) {
+ for (int i=0; i < container.getChildCount(); i++) {
View v = container.getChildAt(i);
if (v.getTag() instanceof ViewHolder) {
ViewHolder h = (ViewHolder)v.getTag();
- if (h.taskDescription == ad) {
+ if (!h.loadedThumbnailAndIcon && h.taskDescription == td) {
// only fade in the thumbnail if recents is already visible-- we
// show it immediately otherwise
- boolean animateShow = mShowing &&
- mRecentsContainer.getAlpha() > ViewConfiguration.ALPHA_THRESHOLD;
- updateThumbnail(h, ad.getThumbnail(), true, animateShow);
+ //boolean animateShow = mShowing &&
+ // mRecentsContainer.getAlpha() > ViewConfiguration.ALPHA_THRESHOLD;
+ boolean animateShow = false;
+ updateIcon(h, td.getIcon(), true, animateShow);
+ updateThumbnail(h, td.getThumbnail(), true, animateShow);
+ h.loadedThumbnailAndIcon = true;
+ mNumItemsWaitingForThumbnailsAndIcons--;
}
}
}
}
- }
+ }
+ showIfReady();
}
// additional optimization when we have sofware system buttons - start loading the recent
@@ -516,7 +601,7 @@
public void clearRecentTasksList() {
// Clear memory used by screenshots
if (mRecentTaskDescriptions != null) {
- mRecentTasksLoader.cancelLoadingThumbnails();
+ mRecentTasksLoader.cancelLoadingThumbnailsAndIcons();
mRecentTaskDescriptions.clear();
mListAdapter.notifyDataSetInvalidated();
mRecentTasksDirty = true;
@@ -524,26 +609,50 @@
}
public void refreshRecentTasksList() {
- refreshRecentTasksList(null);
+ refreshRecentTasksList(null, false);
}
- private void refreshRecentTasksList(ArrayList<TaskDescription> recentTasksList) {
+ private void refreshRecentTasksList(
+ ArrayList<TaskDescription> recentTasksList, boolean firstScreenful) {
if (mRecentTasksDirty) {
if (recentTasksList != null) {
- mRecentTaskDescriptions = recentTasksList;
+ mFirstScreenful = true;
+ onTasksLoaded(recentTasksList);
} else {
- mRecentTaskDescriptions = mRecentTasksLoader.getRecentTasks();
+ mFirstScreenful = true;
+ mRecentTasksLoader.loadTasksInBackground();
}
- mListAdapter.notifyDataSetInvalidated();
- updateUiElements(getResources().getConfiguration());
mRecentTasksDirty = false;
}
}
+ boolean mFirstScreenful;
+ public void onTasksLoaded(ArrayList<TaskDescription> tasks) {
+ if (!mFirstScreenful && tasks.size() == 0) {
+ return;
+ }
+ mNumItemsWaitingForThumbnailsAndIcons =
+ mFirstScreenful ? tasks.size() : mRecentTaskDescriptions.size();
+ if (mRecentTaskDescriptions == null) {
+ mRecentTaskDescriptions = new ArrayList(tasks);
+ } else {
+ mRecentTaskDescriptions.addAll(tasks);
+ }
+ mListAdapter.notifyDataSetInvalidated();
+ updateUiElements(getResources().getConfiguration());
+ mReadyToShow = true;
+ mFirstScreenful = false;
+ showIfReady();
+ }
+
public ArrayList<TaskDescription> getRecentTasksList() {
return mRecentTaskDescriptions;
}
+ public boolean getFirstScreenful() {
+ return mFirstScreenful;
+ }
+
private void updateUiElements(Configuration config) {
final int items = mRecentTaskDescriptions.size();
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java
index dc13092..0605c4c 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java
@@ -22,10 +22,18 @@
import android.database.DataSetObserver;
import android.graphics.Canvas;
import android.util.AttributeSet;
+import android.util.DisplayMetrics;
+import android.util.FloatMath;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
+import android.view.View.MeasureSpec;
+import android.view.View.OnClickListener;
+import android.view.View.OnLongClickListener;
+import android.view.View.OnTouchListener;
import android.view.ViewConfiguration;
+import android.view.ViewTreeObserver;
+import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.widget.LinearLayout;
import android.widget.ScrollView;
@@ -33,6 +41,8 @@
import com.android.systemui.SwipeHelper;
import com.android.systemui.recent.RecentsPanelView.TaskDescriptionAdapter;
+import java.util.ArrayList;
+
public class RecentsVerticalScrollView extends ScrollView implements SwipeHelper.Callback {
private static final String TAG = RecentsPanelView.TAG;
private static final boolean DEBUG = RecentsPanelView.DEBUG;
@@ -42,6 +52,8 @@
protected int mLastScrollPosition;
private SwipeHelper mSwipeHelper;
private RecentsScrollViewPerformanceHelper mPerformanceHelper;
+ private ArrayList<View> mRecycledViews;
+ private int mNumItemsInOneScreenful;
public RecentsVerticalScrollView(Context context, AttributeSet attrs) {
super(context, attrs, 0);
@@ -50,6 +62,7 @@
mSwipeHelper = new SwipeHelper(SwipeHelper.X, this, densityScale, pagingTouchSlop);
mPerformanceHelper = RecentsScrollViewPerformanceHelper.create(context, attrs, this, true);
+ mRecycledViews = new ArrayList<View>();
}
private int scrollPositionOfMostRecent() {
@@ -57,77 +70,91 @@
}
private void update() {
+ for (int i = 0; i < mLinearLayout.getChildCount(); i++) {
+ View v = mLinearLayout.getChildAt(i);
+ mRecycledViews.add(v);
+ mAdapter.recycleView(v);
+ }
+ LayoutTransition transitioner = getLayoutTransition();
+ setLayoutTransition(null);
+
mLinearLayout.removeAllViews();
// Once we can clear the data associated with individual item views,
// we can get rid of the removeAllViews() and the code below will
// recycle them.
for (int i = 0; i < mAdapter.getCount(); i++) {
View old = null;
- if (i < mLinearLayout.getChildCount()) {
- old = mLinearLayout.getChildAt(i);
- old.setVisibility(View.VISIBLE);
+ if (mRecycledViews.size() != 0) {
+ old = mRecycledViews.remove(mRecycledViews.size() - 1);
+ old.setVisibility(VISIBLE);
}
+
final View view = mAdapter.getView(i, old, mLinearLayout);
if (mPerformanceHelper != null) {
mPerformanceHelper.addViewCallback(view);
}
- if (old == null) {
- OnTouchListener noOpListener = new OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- return true;
- }
- };
+ OnTouchListener noOpListener = new OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ return true;
+ }
+ };
- view.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- mCallback.dismiss();
- }
- });
- // We don't want a click sound when we dimiss recents
- view.setSoundEffectsEnabled(false);
+ view.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ mCallback.dismiss();
+ }
+ });
+ // We don't want a click sound when we dimiss recents
+ view.setSoundEffectsEnabled(false);
- OnClickListener launchAppListener = new OnClickListener() {
- public void onClick(View v) {
- mCallback.handleOnClick(view);
- }
- };
+ OnClickListener launchAppListener = new OnClickListener() {
+ public void onClick(View v) {
+ mCallback.handleOnClick(view);
+ }
+ };
- final View thumbnailView = view.findViewById(R.id.app_thumbnail);
- OnLongClickListener longClickListener = new OnLongClickListener() {
- public boolean onLongClick(View v) {
- final View anchorView = view.findViewById(R.id.app_description);
- mCallback.handleLongPress(view, anchorView, thumbnailView);
- return true;
- }
- };
- thumbnailView.setClickable(true);
- thumbnailView.setOnClickListener(launchAppListener);
- thumbnailView.setOnLongClickListener(longClickListener);
+ RecentsPanelView.ViewHolder holder = (RecentsPanelView.ViewHolder) view.getTag();
+ final View thumbnailView = holder.thumbnailView;
+ OnLongClickListener longClickListener = new OnLongClickListener() {
+ public boolean onLongClick(View v) {
+ final View anchorView = view.findViewById(R.id.app_description);
+ mCallback.handleLongPress(view, anchorView, thumbnailView);
+ return true;
+ }
+ };
+ thumbnailView.setClickable(true);
+ thumbnailView.setOnClickListener(launchAppListener);
+ thumbnailView.setOnLongClickListener(longClickListener);
- // We don't want to dismiss recents if a user clicks on the app title
- // (we also don't want to launch the app either, though, because the
- // app title is a small target and doesn't have great click feedback)
- final View appTitle = view.findViewById(R.id.app_label);
- appTitle.setContentDescription(" ");
- appTitle.setOnTouchListener(noOpListener);
- final View calloutLine = view.findViewById(R.id.recents_callout_line);
- calloutLine.setOnTouchListener(noOpListener);
- mLinearLayout.addView(view);
- }
+ // We don't want to dismiss recents if a user clicks on the app title
+ // (we also don't want to launch the app either, though, because the
+ // app title is a small target and doesn't have great click feedback)
+ final View appTitle = view.findViewById(R.id.app_label);
+ appTitle.setContentDescription(" ");
+ appTitle.setOnTouchListener(noOpListener);
+ final View calloutLine = view.findViewById(R.id.recents_callout_line);
+ calloutLine.setOnTouchListener(noOpListener);
+
+ mLinearLayout.addView(view);
}
- for (int i = mAdapter.getCount(); i < mLinearLayout.getChildCount(); i++) {
- mLinearLayout.getChildAt(i).setVisibility(View.GONE);
- }
+ setLayoutTransition(transitioner);
+
// Scroll to end after layout.
- post(new Runnable() {
- public void run() {
- mLastScrollPosition = scrollPositionOfMostRecent();
- scrollTo(0, mLastScrollPosition);
- }
- });
+ final ViewTreeObserver observer = getViewTreeObserver();
+
+ final OnGlobalLayoutListener updateScroll = new OnGlobalLayoutListener() {
+ public void onGlobalLayout() {
+ mLastScrollPosition = scrollPositionOfMostRecent();
+ scrollTo(0, mLastScrollPosition);
+ if (observer.isAlive()) {
+ observer.removeOnGlobalLayoutListener(this);
+ }
+ }
+ };
+ observer.addOnGlobalLayoutListener(updateScroll);
}
@Override
@@ -156,8 +183,10 @@
}
public void onChildDismissed(View v) {
+ mRecycledViews.add(v);
mLinearLayout.removeView(v);
mCallback.handleSwipe(v);
+ v.setActivated(false);
}
public void onBeginDrag(View v) {
@@ -330,6 +359,25 @@
update();
}
});
+
+ DisplayMetrics dm = getResources().getDisplayMetrics();
+ int childWidthMeasureSpec =
+ MeasureSpec.makeMeasureSpec(dm.widthPixels, MeasureSpec.AT_MOST);
+ int childheightMeasureSpec =
+ MeasureSpec.makeMeasureSpec(dm.heightPixels, MeasureSpec.AT_MOST);
+ View child = mAdapter.createView(mLinearLayout);
+ child.measure(childWidthMeasureSpec, childheightMeasureSpec);
+ mNumItemsInOneScreenful =
+ (int) FloatMath.ceil(dm.heightPixels / (float) child.getMeasuredHeight());
+ mRecycledViews.add(child);
+
+ for (int i = 0; i < mNumItemsInOneScreenful - 1; i++) {
+ mRecycledViews.add(mAdapter.createView(mLinearLayout));
+ }
+ }
+
+ public int numItemsInOneScreenful() {
+ return mNumItemsInOneScreenful;
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/recent/TaskDescription.java b/packages/SystemUI/src/com/android/systemui/recent/TaskDescription.java
index dcfd6d8..7e979b7 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/TaskDescription.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/TaskDescription.java
@@ -32,6 +32,7 @@
private Bitmap mThumbnail; // generated by Activity.onCreateThumbnail()
private Drawable mIcon; // application package icon
private CharSequence mLabel; // application package label
+ private boolean mLoaded;
public TaskDescription(int _taskId, int _persistentTaskId,
ResolveInfo _resolveInfo, Intent _intent,
@@ -45,6 +46,28 @@
packageName = _packageName;
}
+ public TaskDescription() {
+ resolveInfo = null;
+ intent = null;
+ taskId = -1;
+ persistentTaskId = -1;
+
+ description = null;
+ packageName = null;
+ }
+
+ public void setLoaded(boolean loaded) {
+ mLoaded = loaded;
+ }
+
+ public boolean isLoaded() {
+ return mLoaded;
+ }
+
+ public boolean isNull() {
+ return resolveInfo == null;
+ }
+
// mark all these as locked?
public CharSequence getLabel() {
return mLabel;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 5a1e3f4..b3cef90 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -393,7 +393,7 @@
}
lp.gravity = Gravity.BOTTOM | Gravity.LEFT;
lp.setTitle("RecentsPanel");
- lp.windowAnimations = R.style.Animation_RecentPanel;
+ lp.windowAnimations = com.android.internal.R.style.Animation_RecentApplications;
lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED
| WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
return lp;
@@ -403,11 +403,13 @@
// Recents Panel
boolean visible = false;
ArrayList<TaskDescription> recentTasksList = null;
+ boolean firstScreenful = false;
if (mRecentsPanel != null) {
visible = mRecentsPanel.isShowing();
WindowManagerImpl.getDefault().removeView(mRecentsPanel);
if (visible) {
recentTasksList = mRecentsPanel.getRecentTasksList();
+ firstScreenful = mRecentsPanel.getFirstScreenful();
}
}
@@ -425,7 +427,7 @@
WindowManagerImpl.getDefault().addView(mRecentsPanel, lp);
mRecentsPanel.setBar(this);
if (visible) {
- mRecentsPanel.show(true, false, recentTasksList);
+ mRecentsPanel.show(true, false, recentTasksList, firstScreenful);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
index d787e10..c59290c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
@@ -88,6 +88,7 @@
int mLastSignalLevel;
boolean mShowPhoneRSSIForData = false;
boolean mShowAtLeastThreeGees = false;
+ boolean mAlwaysShowCdmaRssi = false;
String mContentDescriptionPhoneSignal;
String mContentDescriptionWifi;
@@ -156,7 +157,7 @@
IBatteryStats mBatteryStats;
public interface SignalCluster {
- void setWifiIndicators(boolean visible, int strengthIcon, int activityIcon,
+ void setWifiIndicators(boolean visible, int strengthIcon, int activityIcon,
String contentDescription);
void setMobileDataIndicators(boolean visible, int strengthIcon, int activityIcon,
int typeIcon, String contentDescription, String typeContentDescription);
@@ -176,6 +177,8 @@
mShowPhoneRSSIForData = res.getBoolean(R.bool.config_showPhoneRSSIForData);
mShowAtLeastThreeGees = res.getBoolean(R.bool.config_showMin3G);
+ mAlwaysShowCdmaRssi = res.getBoolean(
+ com.android.internal.R.bool.config_alwaysUseCdmaRssi);
// set up the default wifi icon, used when no radios have ever appeared
updateWifiIcons();
@@ -287,7 +290,7 @@
// wimax is special
cluster.setMobileDataIndicators(
true,
- mWimaxIconId,
+ mAlwaysShowCdmaRssi ? mPhoneSignalIconId : mWimaxIconId,
mMobileActivityIconId,
mDataTypeIconId,
mContentDescriptionWimax,
@@ -351,7 +354,7 @@
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
if (DEBUG) {
- Slog.d(TAG, "onSignalStrengthsChanged signalStrength=" + signalStrength +
+ Slog.d(TAG, "onSignalStrengthsChanged signalStrength=" + signalStrength +
((signalStrength == null) ? "" : (" level=" + signalStrength.getLevel())));
}
mSignalStrength = signalStrength;
@@ -469,7 +472,15 @@
} else {
int iconLevel;
int[] iconList;
- mLastSignalLevel = iconLevel = mSignalStrength.getLevel();
+ if (isCdma() && mAlwaysShowCdmaRssi) {
+ mLastSignalLevel = iconLevel = mSignalStrength.getCdmaLevel();
+ if(DEBUG) Slog.d(TAG, "mAlwaysShowCdmaRssi=" + mAlwaysShowCdmaRssi
+ + " set to cdmaLevel=" + mSignalStrength.getCdmaLevel()
+ + " instead of level=" + mSignalStrength.getLevel());
+ } else {
+ mLastSignalLevel = iconLevel = mSignalStrength.getLevel();
+ }
+
if (isCdma()) {
if (isCdmaEri()) {
iconList = TelephonyIcons.TELEPHONY_SIGNAL_STRENGTH_ROAMING[mInetCondition];
@@ -487,7 +498,6 @@
mPhoneSignalIconId = iconList[iconLevel];
mContentDescriptionPhoneSignal = mContext.getString(
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[iconLevel]);
-
mDataSignalIconId = TelephonyIcons.DATA_SIGNAL_STRENGTH[mInetCondition][iconLevel];
}
}
@@ -914,7 +924,7 @@
mobileLabel = "";
}
} else {
- mobileLabel
+ mobileLabel
= context.getString(R.string.status_bar_settings_signal_meter_disconnected);
}
@@ -1190,7 +1200,7 @@
v.setText(wifiLabel);
}
}
-
+
// mobile label
N = mMobileLabelViews.size();
for (int i=0; i<N; i++) {
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java
index 34a8a02..b3eceb1 100755
--- a/services/java/com/android/server/NotificationManagerService.java
+++ b/services/java/com/android/server/NotificationManagerService.java
@@ -768,7 +768,9 @@
long identity = Binder.clearCallingIdentity();
try {
r.statusBarKey = mStatusBar.addNotification(n);
- mAttentionLight.pulse();
+ if ((n.notification.flags & Notification.FLAG_SHOW_LIGHTS) != 0) {
+ mAttentionLight.pulse();
+ }
}
finally {
Binder.restoreCallingIdentity(identity);
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index ac311b8..9d5caae 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -6995,7 +6995,7 @@
/* TODO: Send this to all users */
broadcastIntentLocked(null, null, intent, null, finisher,
0, null, null, null, true, false, MY_PID, Process.SYSTEM_UID,
- Process.SYSTEM_UID);
+ 0 /* UserId zero */);
if (finisher != null) {
mWaitingUpdate = true;
}
diff --git a/tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java b/tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java
index 5f53a9b..1a2dcb9 100644
--- a/tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java
+++ b/tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java
@@ -19,12 +19,21 @@
import com.android.internal.os.RuntimeInit;
import android.app.ActivityManager;
+import android.app.ActivityManager.ProcessErrorStateInfo;
import android.content.Context;
+import android.content.ComponentName;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.test.AndroidTestCase;
import android.util.Log;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
/**
* This smoke test is designed to quickly sniff for any error conditions
@@ -32,53 +41,125 @@
*/
public class ProcessErrorsTest extends AndroidTestCase {
- private final String TAG = "ProcessErrorsTest";
+ private static final String TAG = "ProcessErrorsTest";
protected ActivityManager mActivityManager;
+ protected PackageManager mPackageManager;
@Override
public void setUp() throws Exception {
super.setUp();
- mActivityManager = (ActivityManager)
+ mActivityManager = (ActivityManager)
getContext().getSystemService(Context.ACTIVITY_SERVICE);
+ mPackageManager = getContext().getPackageManager();
}
public void testSetUpConditions() throws Exception {
assertNotNull(mActivityManager);
+ assertNotNull(mPackageManager);
}
public void testNoProcessErrors() throws Exception {
- List<ActivityManager.ProcessErrorStateInfo> errList;
+ final String reportMsg = checkForProcessErrors();
+ if (reportMsg != null) {
+ Log.w(TAG, reportMsg);
+ }
+
+ // report a non-empty list back to the test framework
+ assertNull(reportMsg, reportMsg);
+ }
+
+ private String checkForProcessErrors() throws Exception {
+ List<ProcessErrorStateInfo> errList;
errList = mActivityManager.getProcessesInErrorState();
// note: this contains information about each process that is currently in an error
// condition. if the list is empty (null) then "we're good".
// if the list is non-empty, then it's useful to report the contents of the list
- // we'll put a copy in the log, and we'll report it back to the framework via the assert.
final String reportMsg = reportListContents(errList);
- if (reportMsg != null) {
- Log.w(TAG, reportMsg);
- }
-
- // report a non-empty list back to the test framework
- assertNull(reportMsg, errList);
+ return reportMsg;
}
-
+
+ /**
+ * A test that runs all Launcher-launchable activities and verifies that no ANRs or crashes
+ * happened while doing so.
+ * <p />
+ * FIXME: Doesn't detect multiple crashing apps properly, since the crash dialog for the
+ * FIXME: first app doesn't go away.
+ */
+ public void testRunAllActivities() throws Exception {
+ final Intent home = new Intent(Intent.ACTION_MAIN);
+ home.addCategory(Intent.CATEGORY_HOME);
+ home.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
+ final Intent launchable = new Intent(Intent.ACTION_MAIN);
+ launchable.addCategory(Intent.CATEGORY_LAUNCHER);
+ final List<ResolveInfo> activities = mPackageManager.queryIntentActivities(launchable, 0);
+ final Set<ProcessError> errSet = new HashSet<ProcessError>();
+
+ for (ResolveInfo info : activities) {
+ Log.i(TAG, String.format("Got %s/%s", info.activityInfo.packageName,
+ info.activityInfo.name));
+
+ // build an Intent to launch the app
+ final ComponentName component = new ComponentName(info.activityInfo.packageName,
+ info.activityInfo.name);
+ final Intent intent = new Intent(Intent.ACTION_MAIN);
+ intent.setComponent(component);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
+ // launch app, and wait 7 seconds for it to start/settle
+ getContext().startActivity(intent);
+ try {
+ Thread.sleep(7000);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+
+ // See if there are any errors
+ Collection<ProcessErrorStateInfo> procs = mActivityManager.getProcessesInErrorState();
+ if (procs != null) {
+ errSet.addAll(ProcessError.fromCollection(procs));
+ }
+
+ // Send the "home" intent and wait 2 seconds for us to get there
+ getContext().startActivity(home);
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ }
+
+ if (!errSet.isEmpty()) {
+ fail(String.format("Got %d errors: %s", errSet.size(),
+ reportWrappedListContents(errSet)));
+ }
+ }
+
+ private String reportWrappedListContents(Collection<ProcessError> errList) {
+ List<ProcessErrorStateInfo> newList = new ArrayList<ProcessErrorStateInfo>(errList.size());
+ for (ProcessError err : errList) {
+ newList.add(err.info);
+ }
+ return reportListContents(newList);
+ }
+
/**
* This helper function will dump the actual error reports.
*
* @param errList The error report containing one or more error records.
* @return Returns a string containing all of the errors.
*/
- private String reportListContents(List<ActivityManager.ProcessErrorStateInfo> errList) {
+ private String reportListContents(Collection<ProcessErrorStateInfo> errList) {
if (errList == null) return null;
StringBuilder builder = new StringBuilder();
- Iterator<ActivityManager.ProcessErrorStateInfo> iter = errList.iterator();
+ Iterator<ProcessErrorStateInfo> iter = errList.iterator();
while (iter.hasNext()) {
- ActivityManager.ProcessErrorStateInfo entry = iter.next();
+ ProcessErrorStateInfo entry = iter.next();
String condition;
switch (entry.condition) {
@@ -96,8 +177,77 @@
builder.append("Process error ").append(condition).append(" ");
builder.append(" ").append(entry.shortMsg);
builder.append(" detected in ").append(entry.processName).append(" ").append(entry.tag);
+ builder.append("\n");
}
return builder.toString();
}
-
+
+ /**
+ * A {@link ProcessErrorStateInfo} wrapper class that hashes how we want (so that equivalent
+ * crashes are considered equal).
+ */
+ private static class ProcessError {
+ public final ProcessErrorStateInfo info;
+
+ public ProcessError(ProcessErrorStateInfo newInfo) {
+ info = newInfo;
+ }
+
+ public static Collection<ProcessError> fromCollection(Collection<ProcessErrorStateInfo> in)
+ {
+ List<ProcessError> out = new ArrayList<ProcessError>(in.size());
+ for (ProcessErrorStateInfo info : in) {
+ out.add(new ProcessError(info));
+ }
+ return out;
+ }
+
+ private boolean strEquals(String a, String b) {
+ if ((a == null) && (b == null)) {
+ return true;
+ } else if ((a == null) || (b == null)) {
+ return false;
+ } else {
+ return a.equals(b);
+ }
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == null) return false;
+ if (!(other instanceof ProcessError)) return false;
+ ProcessError peOther = (ProcessError) other;
+
+ return (info.condition == peOther.info.condition)
+ && strEquals(info.longMsg, peOther.info.longMsg)
+ && (info.pid == peOther.info.pid)
+ && strEquals(info.processName, peOther.info.processName)
+ && strEquals(info.shortMsg, peOther.info.shortMsg)
+ && strEquals(info.stackTrace, peOther.info.stackTrace)
+ && strEquals(info.tag, peOther.info.tag)
+ && (info.uid == peOther.info.uid);
+ }
+
+ private int hash(Object obj) {
+ if (obj == null) {
+ return 13;
+ } else {
+ return obj.hashCode();
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ int code = 17;
+ code += info.condition;
+ code *= hash(info.longMsg);
+ code += info.pid;
+ code *= hash(info.processName);
+ code *= hash(info.shortMsg);
+ code *= hash(info.stackTrace);
+ code *= hash(info.tag);
+ code += info.uid;
+ return code;
+ }
+ }
}
diff --git a/tests/SmokeTestApps/Android.mk b/tests/SmokeTestApps/Android.mk
new file mode 100644
index 0000000..3f5f011
--- /dev/null
+++ b/tests/SmokeTestApps/Android.mk
@@ -0,0 +1,12 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := SmokeTestTriggerApps
+
+include $(BUILD_PACKAGE)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/SmokeTestApps/AndroidManifest.xml b/tests/SmokeTestApps/AndroidManifest.xml
new file mode 100644
index 0000000..0f20107
--- /dev/null
+++ b/tests/SmokeTestApps/AndroidManifest.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.smoketest.triggers">
+
+ <application android:label="something">
+ <activity android:name=".CrashyApp"
+ android:label="Test Crashy App">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ <activity android:name=".CrashyApp2"
+ android:label="Test Crashy App2">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ <activity android:name=".UnresponsiveApp"
+ android:label="Test Unresponsive App">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
diff --git a/tests/SmokeTestApps/README b/tests/SmokeTestApps/README
new file mode 100644
index 0000000..04aa366
--- /dev/null
+++ b/tests/SmokeTestApps/README
@@ -0,0 +1,3 @@
+The apps in this folder are intentionally bad-behaving apps that are intended
+to trigger the smoke tests to fail. They are otherwise not useful.
+
diff --git a/tests/SmokeTestApps/src/com/android/smoketest/triggers/CrashyApp.java b/tests/SmokeTestApps/src/com/android/smoketest/triggers/CrashyApp.java
new file mode 100644
index 0000000..c11b0f3
--- /dev/null
+++ b/tests/SmokeTestApps/src/com/android/smoketest/triggers/CrashyApp.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.smoketest.triggers;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.widget.TextView;
+
+public class CrashyApp extends Activity {
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ TextView tv = new TextView(this);
+ tv.setText("Hello, Crashy Android");
+ setContentView(tv);
+ }
+
+ @Override
+ public void onResume() {
+ ((String) null).length();
+ }
+}
diff --git a/tests/SmokeTestApps/src/com/android/smoketest/triggers/CrashyApp2.java b/tests/SmokeTestApps/src/com/android/smoketest/triggers/CrashyApp2.java
new file mode 100644
index 0000000..3ef5b2b
--- /dev/null
+++ b/tests/SmokeTestApps/src/com/android/smoketest/triggers/CrashyApp2.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.smoketest.triggers;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.widget.TextView;
+
+public class CrashyApp2 extends Activity {
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ TextView tv = new TextView(this);
+ tv.setText("Hello, Other Crashy Android");
+ setContentView(tv);
+ }
+
+
+ @Override
+ public void onResume() {
+ throw new RuntimeException("Two drums and a cymbal fall off a cliff...");
+ }
+}
diff --git a/tests/SmokeTestApps/src/com/android/smoketest/triggers/UnresponsiveApp.java b/tests/SmokeTestApps/src/com/android/smoketest/triggers/UnresponsiveApp.java
new file mode 100644
index 0000000..1291897
--- /dev/null
+++ b/tests/SmokeTestApps/src/com/android/smoketest/triggers/UnresponsiveApp.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.smoketest.triggers;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.widget.TextView;
+
+public class UnresponsiveApp extends Activity {
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ TextView tv = new TextView(this);
+ tv.setText("Hello, Unresponsive Android");
+ setContentView(tv);
+ }
+
+ @Override
+ public void onResume() {
+ // Attempt to provoke the ire of the ActivityManager
+ while (true) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ }
+ }
+}
diff --git a/wifi/java/android/net/wifi/WifiMonitor.java b/wifi/java/android/net/wifi/WifiMonitor.java
index bbb74d1..d05e0b8 100644
--- a/wifi/java/android/net/wifi/WifiMonitor.java
+++ b/wifi/java/android/net/wifi/WifiMonitor.java
@@ -366,17 +366,6 @@
handleDriverEvent(eventData);
} else if (event == TERMINATING) {
/**
- * If monitor socket is closed, we have already
- * stopped the supplicant, simply exit the monitor thread
- */
- if (eventData.startsWith(MONITOR_SOCKET_CLOSED_STR)) {
- if (false) {
- Log.d(TAG, "Monitor socket is closed, exiting thread");
- }
- break;
- }
-
- /**
* Close the supplicant connection if we see
* too many recv errors
*/
diff --git a/wifi/java/android/net/wifi/WifiNative.java b/wifi/java/android/net/wifi/WifiNative.java
index 48a785c..e3dd3a6 100644
--- a/wifi/java/android/net/wifi/WifiNative.java
+++ b/wifi/java/android/net/wifi/WifiNative.java
@@ -39,6 +39,8 @@
*/
public class WifiNative {
+ private static final boolean DBG = false;
+ private final String mTAG;
private static final int DEFAULT_GROUP_OWNER_INTENT = 7;
static final int BLUETOOTH_COEXISTENCE_MODE_ENABLED = 0;
@@ -53,9 +55,7 @@
public native static boolean unloadDriver();
- public native static boolean startSupplicant();
-
- public native static boolean startP2pSupplicant();
+ public native static boolean startSupplicant(boolean p2pSupported);
/* Sends a kill signal to supplicant. To be used when we have lost connection
or when the supplicant is hung */
@@ -79,6 +79,7 @@
public WifiNative(String iface) {
mInterface = iface;
+ mTAG = "WifiNative-" + iface;
}
public boolean connectToSupplicant() {
@@ -94,14 +95,17 @@
}
private boolean doBooleanCommand(String command) {
+ if (DBG) Log.d(mTAG, "doBoolean: " + command);
return doBooleanCommand(mInterface, command);
}
private int doIntCommand(String command) {
+ if (DBG) Log.d(mTAG, "doInt: " + command);
return doIntCommand(mInterface, command);
}
private String doStringCommand(String command) {
+ if (DBG) Log.d(mTAG, "doString: " + command);
return doStringCommand(mInterface, command);
}
@@ -437,6 +441,10 @@
return doBooleanCommand("P2P_FIND " + timeout);
}
+ public boolean p2pStopFind() {
+ return doBooleanCommand("P2P_STOP_FIND");
+ }
+
public boolean p2pListen() {
return doBooleanCommand("P2P_LISTEN");
}
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index fb9286e..0134456 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -45,6 +45,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.DhcpInfo;
import android.net.DhcpInfoInternal;
@@ -118,6 +119,8 @@
private INetworkManagementService mNwService;
private ConnectivityManager mCm;
+ private final boolean mP2pSupported;
+
/* Scan results handling */
private List<ScanResult> mScanResults;
private static final Pattern scanResultPattern = Pattern.compile("\t+");
@@ -361,9 +364,9 @@
/* Reset the WPS state machine */
static final int CMD_RESET_WPS_STATE = BASE + 122;
- /* Interaction with WifiP2pService */
- public static final int WIFI_ENABLE_PENDING = BASE + 131;
- public static final int P2P_ENABLE_PROCEED = BASE + 132;
+ /* P2p commands */
+ public static final int CMD_ENABLE_P2P = BASE + 131;
+ public static final int CMD_DISABLE_P2P = BASE + 132;
private static final int CONNECT_MODE = 1;
private static final int SCAN_ONLY_MODE = 2;
@@ -482,9 +485,6 @@
/* Waiting for untether confirmation to stop soft Ap */
private State mSoftApStoppingState = new SoftApStoppingState();
- /* Wait till p2p is disabled */
- private State mWaitForP2pDisableState = new WaitForP2pDisableState();
-
private class TetherStateChange {
ArrayList<String> available;
ArrayList<String> active;
@@ -556,6 +556,9 @@
IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE);
mNwService = INetworkManagementService.Stub.asInterface(b);
+ mP2pSupported = mContext.getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_WIFI_DIRECT);
+
mWifiNative = new WifiNative(mInterfaceName);
mWifiConfigStore = new WifiConfigStore(context, mWifiNative);
mWifiMonitor = new WifiMonitor(this, mWifiNative);
@@ -639,7 +642,6 @@
addState(mTetheringState, mSoftApStartedState);
addState(mTetheredState, mSoftApStartedState);
addState(mSoftApStoppingState, mDefaultState);
- addState(mWaitForP2pDisableState, mDefaultState);
setInitialState(mInitialState);
@@ -1896,11 +1898,6 @@
mReplyChannel.replyToMessage(message, WifiManager.CMD_WPS_COMPLETED,
new WpsResult(Status.FAILURE));
break;
- case WifiP2pService.P2P_ENABLE_PENDING:
- // turn off wifi and defer to be handled in DriverUnloadedState
- setWifiEnabled(false);
- deferMessage(message);
- break;
default:
loge("Error! unhandled message" + message);
break;
@@ -2060,7 +2057,7 @@
loge("Unable to change interface settings: " + ie);
}
- if(mWifiNative.startSupplicant()) {
+ if(mWifiNative.startSupplicant(mP2pSupported)) {
if (DBG) log("Supplicant start successful");
mWifiMonitor.startMonitoring();
transitionTo(mSupplicantStartingState);
@@ -2172,11 +2169,7 @@
if (DBG) log(getName() + message.toString() + "\n");
switch (message.what) {
case CMD_LOAD_DRIVER:
- mWifiP2pChannel.sendMessage(WIFI_ENABLE_PENDING);
- transitionTo(mWaitForP2pDisableState);
- break;
- case WifiP2pService.P2P_ENABLE_PENDING:
- mReplyChannel.replyToMessage(message, P2P_ENABLE_PROCEED);
+ transitionTo(mDriverLoadingState);
break;
default:
return NOT_HANDLED;
@@ -2556,13 +2549,15 @@
mWifiNative.status();
transitionTo(mDisconnectedState);
}
+
+ if (mP2pSupported) mWifiP2pChannel.sendMessage(WifiStateMachine.CMD_ENABLE_P2P);
}
@Override
public boolean processMessage(Message message) {
if (DBG) log(getName() + message.toString() + "\n");
boolean eventLoggingEnabled = true;
switch(message.what) {
- case CMD_SET_SCAN_TYPE:
+ case CMD_SET_SCAN_TYPE:
mSetScanActive = (message.arg1 == SCAN_ACTIVE);
mWifiNative.setScanMode(mSetScanActive);
break;
@@ -2675,6 +2670,8 @@
mIsRunning = false;
updateBatteryWorkSource(null);
mScanResults = null;
+
+ if (mP2pSupported) mWifiP2pChannel.sendMessage(WifiStateMachine.CMD_DISABLE_P2P);
}
}
@@ -3348,7 +3345,6 @@
case CMD_START_PACKET_FILTERING:
case CMD_STOP_PACKET_FILTERING:
case CMD_TETHER_STATE_CHANGE:
- case WifiP2pService.P2P_ENABLE_PENDING:
deferMessage(message);
break;
case WifiStateMachine.CMD_RESPONSE_AP_CONFIG:
@@ -3412,55 +3408,6 @@
transitionTo(mTetheringState);
}
break;
- case WifiP2pService.P2P_ENABLE_PENDING:
- // turn of soft Ap and defer to be handled in DriverUnloadedState
- setWifiApEnabled(null, false);
- deferMessage(message);
- break;
- default:
- return NOT_HANDLED;
- }
- EventLog.writeEvent(EVENTLOG_WIFI_EVENT_HANDLED, message.what);
- return HANDLED;
- }
- }
-
- class WaitForP2pDisableState extends State {
- private int mSavedArg;
- @Override
- public void enter() {
- if (DBG) log(getName() + "\n");
- EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName());
-
- //Preserve the argument arg1 that has information used in DriverLoadingState
- mSavedArg = getCurrentMessage().arg1;
- }
- @Override
- public boolean processMessage(Message message) {
- if (DBG) log(getName() + message.toString() + "\n");
- switch(message.what) {
- case WifiP2pService.WIFI_ENABLE_PROCEED:
- //restore argument from original message (CMD_LOAD_DRIVER)
- message.arg1 = mSavedArg;
- transitionTo(mDriverLoadingState);
- break;
- case CMD_LOAD_DRIVER:
- case CMD_UNLOAD_DRIVER:
- case CMD_START_SUPPLICANT:
- case CMD_STOP_SUPPLICANT:
- case CMD_START_AP:
- case CMD_STOP_AP:
- case CMD_START_DRIVER:
- case CMD_STOP_DRIVER:
- case CMD_SET_SCAN_MODE:
- case CMD_SET_SCAN_TYPE:
- case CMD_SET_HIGH_PERF_MODE:
- case CMD_SET_COUNTRY_CODE:
- case CMD_SET_FREQUENCY_BAND:
- case CMD_START_PACKET_FILTERING:
- case CMD_STOP_PACKET_FILTERING:
- deferMessage(message);
- break;
default:
return NOT_HANDLED;
}
@@ -3510,7 +3457,6 @@
case CMD_SET_FREQUENCY_BAND:
case CMD_START_PACKET_FILTERING:
case CMD_STOP_PACKET_FILTERING:
- case WifiP2pService.P2P_ENABLE_PENDING:
deferMessage(message);
break;
default:
@@ -3606,7 +3552,6 @@
case CMD_SET_FREQUENCY_BAND:
case CMD_START_PACKET_FILTERING:
case CMD_STOP_PACKET_FILTERING:
- case WifiP2pService.P2P_ENABLE_PENDING:
deferMessage(message);
break;
default:
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pDevice.java b/wifi/java/android/net/wifi/p2p/WifiP2pDevice.java
index 7471a2d..b0cde64 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pDevice.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pDevice.java
@@ -301,7 +301,8 @@
private String trimQuotes(String str) {
str = str.trim();
if (str.startsWith("'") && str.endsWith("'")) {
- return str.substring(1, str.length()-1);
+ if (str.length() <= 2) return "";
+ else return str.substring(1, str.length()-1);
}
return str;
}
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
index 9205300..4fd0a57 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
@@ -199,68 +199,61 @@
private static final int BASE = Protocol.BASE_WIFI_P2P_MANAGER;
/** @hide */
- public static final int ENABLE_P2P = BASE + 1;
+ public static final int DISCOVER_PEERS = BASE + 1;
/** @hide */
- public static final int ENABLE_P2P_FAILED = BASE + 2;
+ public static final int DISCOVER_PEERS_FAILED = BASE + 2;
/** @hide */
- public static final int ENABLE_P2P_SUCCEEDED = BASE + 3;
+ public static final int DISCOVER_PEERS_SUCCEEDED = BASE + 3;
/** @hide */
- public static final int DISABLE_P2P = BASE + 4;
+ public static final int STOP_DISCOVERY = BASE + 4;
/** @hide */
- public static final int DISABLE_P2P_FAILED = BASE + 5;
+ public static final int STOP_DISCOVERY_FAILED = BASE + 5;
/** @hide */
- public static final int DISABLE_P2P_SUCCEEDED = BASE + 6;
+ public static final int STOP_DISCOVERY_SUCCEEDED = BASE + 6;
/** @hide */
- public static final int DISCOVER_PEERS = BASE + 7;
+ public static final int CONNECT = BASE + 7;
/** @hide */
- public static final int DISCOVER_PEERS_FAILED = BASE + 8;
+ public static final int CONNECT_FAILED = BASE + 8;
/** @hide */
- public static final int DISCOVER_PEERS_SUCCEEDED = BASE + 9;
+ public static final int CONNECT_SUCCEEDED = BASE + 9;
/** @hide */
- public static final int CONNECT = BASE + 10;
+ public static final int CANCEL_CONNECT = BASE + 10;
/** @hide */
- public static final int CONNECT_FAILED = BASE + 11;
+ public static final int CANCEL_CONNECT_FAILED = BASE + 11;
/** @hide */
- public static final int CONNECT_SUCCEEDED = BASE + 12;
+ public static final int CANCEL_CONNECT_SUCCEEDED = BASE + 12;
/** @hide */
- public static final int CANCEL_CONNECT = BASE + 13;
+ public static final int CREATE_GROUP = BASE + 13;
/** @hide */
- public static final int CANCEL_CONNECT_FAILED = BASE + 14;
+ public static final int CREATE_GROUP_FAILED = BASE + 14;
/** @hide */
- public static final int CANCEL_CONNECT_SUCCEEDED = BASE + 15;
+ public static final int CREATE_GROUP_SUCCEEDED = BASE + 15;
/** @hide */
- public static final int CREATE_GROUP = BASE + 16;
+ public static final int REMOVE_GROUP = BASE + 16;
/** @hide */
- public static final int CREATE_GROUP_FAILED = BASE + 17;
+ public static final int REMOVE_GROUP_FAILED = BASE + 17;
/** @hide */
- public static final int CREATE_GROUP_SUCCEEDED = BASE + 18;
+ public static final int REMOVE_GROUP_SUCCEEDED = BASE + 18;
/** @hide */
- public static final int REMOVE_GROUP = BASE + 19;
+ public static final int REQUEST_PEERS = BASE + 19;
/** @hide */
- public static final int REMOVE_GROUP_FAILED = BASE + 20;
- /** @hide */
- public static final int REMOVE_GROUP_SUCCEEDED = BASE + 21;
+ public static final int RESPONSE_PEERS = BASE + 20;
/** @hide */
- public static final int REQUEST_PEERS = BASE + 22;
+ public static final int REQUEST_CONNECTION_INFO = BASE + 21;
/** @hide */
- public static final int RESPONSE_PEERS = BASE + 23;
+ public static final int RESPONSE_CONNECTION_INFO = BASE + 22;
/** @hide */
- public static final int REQUEST_CONNECTION_INFO = BASE + 24;
+ public static final int REQUEST_GROUP_INFO = BASE + 23;
/** @hide */
- public static final int RESPONSE_CONNECTION_INFO = BASE + 25;
-
- /** @hide */
- public static final int REQUEST_GROUP_INFO = BASE + 26;
- /** @hide */
- public static final int RESPONSE_GROUP_INFO = BASE + 27;
+ public static final int RESPONSE_GROUP_INFO = BASE + 24;
/**
* Create a new WifiP2pManager instance. Applications use
@@ -376,6 +369,7 @@
break;
/* ActionListeners grouped together */
case WifiP2pManager.DISCOVER_PEERS_FAILED:
+ case WifiP2pManager.STOP_DISCOVERY_FAILED:
case WifiP2pManager.CONNECT_FAILED:
case WifiP2pManager.CANCEL_CONNECT_FAILED:
case WifiP2pManager.CREATE_GROUP_FAILED:
@@ -386,6 +380,7 @@
break;
/* ActionListeners grouped together */
case WifiP2pManager.DISCOVER_PEERS_SUCCEEDED:
+ case WifiP2pManager.STOP_DISCOVERY_SUCCEEDED:
case WifiP2pManager.CONNECT_SUCCEEDED:
case WifiP2pManager.CANCEL_CONNECT_SUCCEEDED:
case WifiP2pManager.CREATE_GROUP_SUCCEEDED:
@@ -459,26 +454,6 @@
}
/**
- * Sends in a request to the system to enable p2p. This will pop up a dialog
- * to the user and upon authorization will enable p2p.
- * @hide
- */
- public void enableP2p(Channel c) {
- if (c == null) return;
- c.mAsyncChannel.sendMessage(ENABLE_P2P);
- }
-
- /**
- * Sends in a request to the system to disable p2p. This will pop up a dialog
- * to the user and upon authorization will enable p2p.
- * @hide
- */
- public void disableP2p(Channel c) {
- if (c == null) return;
- c.mAsyncChannel.sendMessage(DISABLE_P2P);
- }
-
- /**
* Initiate peer discovery. A discovery process involves scanning for available Wi-Fi peers
* for the purpose of establishing a connection.
*
@@ -503,6 +478,16 @@
}
/**
+ * TODO: Add more documentation before opening up
+ * Cancel peer discovery
+ * @hide
+ */
+ public void stopPeerDiscovery(Channel c, ActionListener listener) {
+ if (c == null) return;
+ c.mAsyncChannel.sendMessage(STOP_DISCOVERY, 0, c.putListener(listener));
+ }
+
+ /**
* Start a p2p connection to a device with the specified configuration.
*
* <p> The function call immediately returns after sending a connection request
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pService.java b/wifi/java/android/net/wifi/p2p/WifiP2pService.java
index 69cbb5c..5b0e424 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pService.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pService.java
@@ -49,6 +49,7 @@
import android.os.HandlerThread;
import android.os.Message;
import android.os.Messenger;
+import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.provider.Settings;
@@ -84,7 +85,7 @@
*/
public class WifiP2pService extends IWifiP2pManager.Stub {
private static final String TAG = "WifiP2pService";
- private static final boolean DBG = true;
+ private static final boolean DBG = false;
private static final String NETWORKTYPE = "WIFI_P2P";
private Context mContext;
@@ -94,11 +95,6 @@
INetworkManagementService mNwService;
private DhcpStateMachine mDhcpStateMachine;
- //Tracked to notify the user about wifi client/hotspot being shut down
- //during p2p bring up
- private int mWifiState = WifiManager.WIFI_STATE_DISABLED;
- private int mWifiApState = WifiManager.WIFI_AP_STATE_DISABLED;
-
private P2pStateMachine mP2pStateMachine;
private AsyncChannel mReplyChannel = new AsyncChannel();
private AsyncChannel mWifiChannel;
@@ -110,6 +106,9 @@
private static final int GROUP_CREATING_WAIT_TIME_MS = 120 * 1000;
private static int mGroupCreatingTimeoutIndex = 0;
+ /* Set a two minute discover timeout to avoid STA scans from being blocked */
+ private static final int DISCOVER_TIMEOUT_S = 120;
+
/**
* Delay between restarts upon failure to setup connection with supplicant
*/
@@ -124,28 +123,13 @@
private static final int BASE = Protocol.BASE_WIFI_P2P_SERVICE;
- /* Message sent to WifiStateMachine to indicate p2p enable is pending */
- public static final int P2P_ENABLE_PENDING = BASE + 1;
- /* Message sent to WifiStateMachine to indicate Wi-Fi client/hotspot operation can proceed */
- public static final int WIFI_ENABLE_PROCEED = BASE + 2;
-
/* Delayed message to timeout group creation */
- public static final int GROUP_CREATING_TIMED_OUT = BASE + 3;
-
- /* User accepted to disable Wi-Fi in order to enable p2p */
- private static final int WIFI_DISABLE_USER_ACCEPT = BASE + 4;
- /* User rejected to disable Wi-Fi in order to enable p2p */
- private static final int WIFI_DISABLE_USER_REJECT = BASE + 5;
+ public static final int GROUP_CREATING_TIMED_OUT = BASE + 1;
/* User accepted a peer request */
- private static final int PEER_CONNECTION_USER_ACCEPT = BASE + 6;
+ private static final int PEER_CONNECTION_USER_ACCEPT = BASE + 2;
/* User rejected a peer request */
- private static final int PEER_CONNECTION_USER_REJECT = BASE + 7;
-
- /* Airplane mode changed */
- private static final int AIRPLANE_MODE_CHANGED = BASE + 8;
- /* Emergency callback mode */
- private static final int EMERGENCY_CALLBACK_MODE = BASE + 9;
+ private static final int PEER_CONNECTION_USER_REJECT = BASE + 3;
private final boolean mP2pSupported;
@@ -166,7 +150,7 @@
public WifiP2pService(Context context) {
mContext = context;
- //STOPSHIP: fix this
+ //STOPSHIP: get this from native side
mInterface = "p2p0";
mNetworkInfo = new NetworkInfo(ConnectivityManager.TYPE_WIFI_P2P, 0, NETWORKTYPE, "");
@@ -179,15 +163,6 @@
mP2pStateMachine = new P2pStateMachine(TAG, mP2pSupported);
mP2pStateMachine.start();
-
- // broadcasts
- IntentFilter filter = new IntentFilter();
- filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
- filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
- filter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
- filter.addAction(WifiManager.WIFI_AP_STATE_CHANGED_ACTION);
- mContext.registerReceiver(new WifiStateReceiver(), filter);
-
}
public void connectivityServiceReady() {
@@ -195,26 +170,6 @@
mNwService = INetworkManagementService.Stub.asInterface(b);
}
- private class WifiStateReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (action.equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) {
- mWifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
- WifiManager.WIFI_STATE_DISABLED);
- } else if (action.equals(WifiManager.WIFI_AP_STATE_CHANGED_ACTION)) {
- mWifiApState = intent.getIntExtra(WifiManager.EXTRA_WIFI_AP_STATE,
- WifiManager.WIFI_AP_STATE_DISABLED);
- } else if (action.equals(Intent.ACTION_AIRPLANE_MODE_CHANGED)) {
- mP2pStateMachine.sendMessage(AIRPLANE_MODE_CHANGED);
- } else if (action.equals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED)) {
- if (intent.getBooleanExtra("phoneinECMState", false) == true) {
- mP2pStateMachine.sendMessage(EMERGENCY_CALLBACK_MODE);
- }
- }
- }
- }
-
private void enforceAccessPermission() {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.ACCESS_WIFI_STATE,
"WifiP2pService");
@@ -264,8 +219,6 @@
private P2pNotSupportedState mP2pNotSupportedState = new P2pNotSupportedState();
private P2pDisablingState mP2pDisablingState = new P2pDisablingState();
private P2pDisabledState mP2pDisabledState = new P2pDisabledState();
- private WaitForUserActionState mWaitForUserActionState = new WaitForUserActionState();
- private WaitForWifiDisableState mWaitForWifiDisableState = new WaitForWifiDisableState();
private P2pEnablingState mP2pEnablingState = new P2pEnablingState();
private P2pEnabledState mP2pEnabledState = new P2pEnabledState();
// Inactive is when p2p is enabled with no connectivity
@@ -299,8 +252,6 @@
addState(mP2pNotSupportedState, mDefaultState);
addState(mP2pDisablingState, mDefaultState);
addState(mP2pDisabledState, mDefaultState);
- addState(mWaitForUserActionState, mP2pDisabledState);
- addState(mWaitForWifiDisableState, mP2pDisabledState);
addState(mP2pEnablingState, mDefaultState);
addState(mP2pEnabledState, mDefaultState);
addState(mInactiveState, mP2pEnabledState);
@@ -346,23 +297,14 @@
AsyncChannel ac = new AsyncChannel();
ac.connect(mContext, getHandler(), message.replyTo);
break;
- case WifiStateMachine.WIFI_ENABLE_PENDING:
- // Disable p2p operation before we can respond
- sendMessage(WifiP2pManager.DISABLE_P2P);
- deferMessage(message);
- break;
- case WifiP2pManager.ENABLE_P2P:
- replyToMessage(message, WifiP2pManager.ENABLE_P2P_FAILED,
- WifiP2pManager.BUSY);
- break;
- case WifiP2pManager.DISABLE_P2P:
- replyToMessage(message, WifiP2pManager.DISABLE_P2P_FAILED,
- WifiP2pManager.BUSY);
- break;
case WifiP2pManager.DISCOVER_PEERS:
replyToMessage(message, WifiP2pManager.DISCOVER_PEERS_FAILED,
WifiP2pManager.BUSY);
break;
+ case WifiP2pManager.STOP_DISCOVERY:
+ replyToMessage(message, WifiP2pManager.STOP_DISCOVERY_FAILED,
+ WifiP2pManager.BUSY);
+ break;
case WifiP2pManager.CONNECT:
replyToMessage(message, WifiP2pManager.CONNECT_FAILED,
WifiP2pManager.BUSY);
@@ -388,16 +330,14 @@
case WifiP2pManager.REQUEST_GROUP_INFO:
replyToMessage(message, WifiP2pManager.RESPONSE_GROUP_INFO, mGroup);
break;
- case AIRPLANE_MODE_CHANGED:
- if (isAirplaneModeOn()) sendMessage(WifiP2pManager.DISABLE_P2P);
- break;
- case EMERGENCY_CALLBACK_MODE:
- sendMessage(WifiP2pManager.DISABLE_P2P);
- break;
// Ignore
case WifiMonitor.P2P_INVITATION_RESULT_EVENT:
- case WIFI_DISABLE_USER_ACCEPT:
- case WIFI_DISABLE_USER_REJECT:
+ case WifiMonitor.SCAN_RESULTS_EVENT:
+ case WifiMonitor.SUP_CONNECTION_EVENT:
+ case WifiMonitor.SUP_DISCONNECTION_EVENT:
+ case WifiMonitor.NETWORK_CONNECTION_EVENT:
+ case WifiMonitor.NETWORK_DISCONNECTION_EVENT:
+ case WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT:
case PEER_CONNECTION_USER_ACCEPT:
case PEER_CONNECTION_USER_REJECT:
case GROUP_CREATING_TIMED_OUT:
@@ -414,22 +354,14 @@
@Override
public boolean processMessage(Message message) {
switch (message.what) {
- // Allow Wi-Fi to proceed
- case WifiStateMachine.WIFI_ENABLE_PENDING:
- replyToMessage(message, WIFI_ENABLE_PROCEED);
- break;
- case WifiP2pManager.ENABLE_P2P:
- replyToMessage(message, WifiP2pManager.ENABLE_P2P_FAILED,
- WifiP2pManager.P2P_UNSUPPORTED);
- break;
- case WifiP2pManager.DISABLE_P2P:
- replyToMessage(message, WifiP2pManager.DISABLE_P2P_FAILED,
- WifiP2pManager.P2P_UNSUPPORTED);
- break;
- case WifiP2pManager.DISCOVER_PEERS:
+ case WifiP2pManager.DISCOVER_PEERS:
replyToMessage(message, WifiP2pManager.DISCOVER_PEERS_FAILED,
WifiP2pManager.P2P_UNSUPPORTED);
break;
+ case WifiP2pManager.STOP_DISCOVERY:
+ replyToMessage(message, WifiP2pManager.STOP_DISCOVERY_FAILED,
+ WifiP2pManager.P2P_UNSUPPORTED);
+ break;
case WifiP2pManager.CONNECT:
replyToMessage(message, WifiP2pManager.CONNECT_FAILED,
WifiP2pManager.P2P_UNSUPPORTED);
@@ -438,7 +370,7 @@
replyToMessage(message, WifiP2pManager.CANCEL_CONNECT_FAILED,
WifiP2pManager.P2P_UNSUPPORTED);
break;
- case WifiP2pManager.CREATE_GROUP:
+ case WifiP2pManager.CREATE_GROUP:
replyToMessage(message, WifiP2pManager.CREATE_GROUP_FAILED,
WifiP2pManager.P2P_UNSUPPORTED);
break;
@@ -455,26 +387,15 @@
class P2pDisablingState extends State {
@Override
- public void enter() {
- if (DBG) logd(getName());
- logd("stopping supplicant");
- if (!mWifiNative.stopSupplicant()) {
- loge("Failed to stop supplicant, issue kill");
- mWifiNative.killSupplicant();
- }
- }
-
- @Override
public boolean processMessage(Message message) {
if (DBG) logd(getName() + message.toString());
switch (message.what) {
case WifiMonitor.SUP_DISCONNECTION_EVENT:
- logd("Supplicant connection lost");
- mWifiNative.closeSupplicantConnection();
+ if (DBG) logd("p2p socket connection lost");
transitionTo(mP2pDisabledState);
break;
- case WifiP2pManager.ENABLE_P2P:
- case WifiP2pManager.DISABLE_P2P:
+ case WifiStateMachine.CMD_ENABLE_P2P:
+ case WifiStateMachine.CMD_DISABLE_P2P:
deferMessage(message);
break;
default:
@@ -484,7 +405,6 @@
}
}
-
class P2pDisabledState extends State {
@Override
public void enter() {
@@ -495,118 +415,19 @@
public boolean processMessage(Message message) {
if (DBG) logd(getName() + message.toString());
switch (message.what) {
- case WifiP2pManager.ENABLE_P2P:
- OnClickListener listener = new OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- if (which == DialogInterface.BUTTON_POSITIVE) {
- sendMessage(WIFI_DISABLE_USER_ACCEPT);
- } else {
- sendMessage(WIFI_DISABLE_USER_REJECT);
- }
- }
- };
-
- // Show a user request dialog if we know Wi-Fi client/hotspot is in operation
- if (mWifiState != WifiManager.WIFI_STATE_DISABLED ||
- mWifiApState != WifiManager.WIFI_AP_STATE_DISABLED) {
- Resources r = Resources.getSystem();
- AlertDialog dialog = new AlertDialog.Builder(mContext)
- .setTitle(r.getString(R.string.wifi_p2p_dialog_title))
- .setMessage(r.getString(R.string.wifi_p2p_turnon_message))
- .setPositiveButton(r.getString(R.string.ok), listener)
- .setNegativeButton(r.getString(R.string.cancel), listener)
- .create();
- dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
- dialog.show();
- transitionTo(mWaitForUserActionState);
- } else {
- mWifiChannel.sendMessage(P2P_ENABLE_PENDING);
- transitionTo(mWaitForWifiDisableState);
- }
- replyToMessage(message, WifiP2pManager.ENABLE_P2P_SUCCEEDED);
- break;
- case WifiP2pManager.DISABLE_P2P:
- replyToMessage(message, WifiP2pManager.DISABLE_P2P_SUCCEEDED);
- break;
- case WifiStateMachine.WIFI_ENABLE_PENDING:
- replyToMessage(message, WIFI_ENABLE_PROCEED);
- break;
- default:
- return NOT_HANDLED;
- }
- return HANDLED;
- }
- }
-
- class WaitForUserActionState extends State {
- @Override
- public void enter() {
- if (DBG) logd(getName());
- }
-
- @Override
- public boolean processMessage(Message message) {
- if (DBG) logd(getName() + message.toString());
- switch (message.what) {
- case WIFI_DISABLE_USER_ACCEPT:
- mWifiChannel.sendMessage(P2P_ENABLE_PENDING);
- transitionTo(mWaitForWifiDisableState);
- break;
- case WIFI_DISABLE_USER_REJECT:
- logd("User rejected enabling p2p");
- sendP2pStateChangedBroadcast(false);
- transitionTo(mP2pDisabledState);
- break;
- case WifiP2pManager.ENABLE_P2P:
- case WifiP2pManager.DISABLE_P2P:
- deferMessage(message);
- break;
- default:
- return NOT_HANDLED;
- }
- return HANDLED;
- }
- }
-
- class WaitForWifiDisableState extends State {
- @Override
- public void enter() {
- if (DBG) logd(getName());
- }
-
- @Override
- public boolean processMessage(Message message) {
- if (DBG) logd(getName() + message.toString());
- switch (message.what) {
- case WifiStateMachine.P2P_ENABLE_PROCEED:
+ case WifiStateMachine.CMD_ENABLE_P2P:
try {
- mNwService.wifiFirmwareReload(mInterface, "P2P");
- } catch (Exception e) {
- loge("Failed to reload p2p firmware " + e);
- // continue
+ mNwService.setInterfaceUp(mInterface);
+ } catch (RemoteException re) {
+ loge("Unable to change interface settings: " + re);
+ } catch (IllegalStateException ie) {
+ loge("Unable to change interface settings: " + ie);
}
-
- //A runtime crash can leave the interface up and
- //this affects p2p when supplicant starts up.
- //Ensure interface is down before a supplicant start.
- try {
- mNwService.setInterfaceDown(mInterface);
- } catch (Exception e) {
- if (DBG) Slog.w(TAG, "Unable to bring down wlan interface: " + e);
- }
-
- if (mWifiNative.startP2pSupplicant()) {
- mWifiMonitor.startMonitoring();
- transitionTo(mP2pEnablingState);
- } else {
- notifyP2pEnableFailure();
- transitionTo(mP2pDisabledState);
- }
+ mWifiMonitor.startMonitoring();
+ transitionTo(mP2pEnablingState);
break;
- case WifiP2pManager.ENABLE_P2P:
- case WifiP2pManager.DISABLE_P2P:
- deferMessage(message);
+ case WifiStateMachine.CMD_DISABLE_P2P:
+ //Nothing to do
break;
default:
return NOT_HANDLED;
@@ -626,22 +447,15 @@
if (DBG) logd(getName() + message.toString());
switch (message.what) {
case WifiMonitor.SUP_CONNECTION_EVENT:
- logd("P2p start successful");
+ if (DBG) logd("P2p socket connection successful");
transitionTo(mInactiveState);
break;
case WifiMonitor.SUP_DISCONNECTION_EVENT:
- if (++mP2pRestartCount <= P2P_RESTART_TRIES) {
- loge("Failed to start p2p, retry");
- mWifiNative.killSupplicant();
- sendMessageDelayed(WifiP2pManager.ENABLE_P2P, P2P_RESTART_INTERVAL_MSECS);
- } else {
- loge("Failed " + mP2pRestartCount + " times to start p2p, quit ");
- mP2pRestartCount = 0;
- }
+ loge("P2p socket connection failed");
transitionTo(mP2pDisabledState);
break;
- case WifiP2pManager.ENABLE_P2P:
- case WifiP2pManager.DISABLE_P2P:
+ case WifiStateMachine.CMD_ENABLE_P2P:
+ case WifiStateMachine.CMD_DISABLE_P2P:
deferMessage(message);
break;
default:
@@ -658,30 +472,36 @@
sendP2pStateChangedBroadcast(true);
mNetworkInfo.setIsAvailable(true);
initializeP2pSettings();
- showNotification();
}
@Override
public boolean processMessage(Message message) {
if (DBG) logd(getName() + message.toString());
switch (message.what) {
- case WifiP2pManager.ENABLE_P2P:
- replyToMessage(message, WifiP2pManager.ENABLE_P2P_SUCCEEDED);
+ case WifiStateMachine.CMD_ENABLE_P2P:
+ //Nothing to do
break;
- case WifiP2pManager.DISABLE_P2P:
+ case WifiStateMachine.CMD_DISABLE_P2P:
if (mPeers.clear()) sendP2pPeersChangedBroadcast();
- replyToMessage(message, WifiP2pManager.DISABLE_P2P_SUCCEEDED);
+ mWifiNative.closeSupplicantConnection();
transitionTo(mP2pDisablingState);
break;
case WifiP2pManager.DISCOVER_PEERS:
- int timeout = message.arg1;
- if (mWifiNative.p2pFind(timeout)) {
+ if (mWifiNative.p2pFind(DISCOVER_TIMEOUT_S)) {
replyToMessage(message, WifiP2pManager.DISCOVER_PEERS_SUCCEEDED);
} else {
replyToMessage(message, WifiP2pManager.DISCOVER_PEERS_FAILED,
WifiP2pManager.ERROR);
}
break;
+ case WifiP2pManager.STOP_DISCOVERY:
+ if (mWifiNative.p2pStopFind()) {
+ replyToMessage(message, WifiP2pManager.STOP_DISCOVERY_SUCCEEDED);
+ } else {
+ replyToMessage(message, WifiP2pManager.STOP_DISCOVERY_FAILED,
+ WifiP2pManager.ERROR);
+ }
+ break;
case WifiMonitor.P2P_DEVICE_FOUND_EVENT:
WifiP2pDevice device = (WifiP2pDevice) message.obj;
if (mThisDevice.deviceAddress.equals(device.deviceAddress)) break;
@@ -692,15 +512,7 @@
device = (WifiP2pDevice) message.obj;
if (mPeers.remove(device)) sendP2pPeersChangedBroadcast();
break;
- case WifiMonitor.SUP_DISCONNECTION_EVENT: /* Supplicant died */
- loge("Connection lost, restart p2p");
- mWifiNative.killSupplicant();
- mWifiNative.closeSupplicantConnection();
- if (mPeers.clear()) sendP2pPeersChangedBroadcast();
- transitionTo(mP2pDisabledState);
- sendMessageDelayed(WifiP2pManager.ENABLE_P2P, P2P_RESTART_INTERVAL_MSECS);
- break;
- default:
+ default:
return NOT_HANDLED;
}
return HANDLED;
@@ -710,7 +522,6 @@
public void exit() {
sendP2pStateChangedBroadcast(false);
mNetworkInfo.setIsAvailable(false);
- clearNotification();
}
}
@@ -719,7 +530,8 @@
public void enter() {
if (DBG) logd(getName());
//Start listening every time we get inactive
- mWifiNative.p2pListen();
+ //TODO: Fix listen after driver behavior is fixed
+ //mWifiNative.p2pListen();
}
@Override
@@ -737,6 +549,8 @@
//TODO: if failure, remove config and do a regular p2pConnect()
mWifiNative.p2pReinvoke(netId, mSavedPeerConfig.deviceAddress);
} else {
+ //Stop discovery before issuing connect
+ mWifiNative.p2pStopFind();
//If peer is a GO, we do not need to send provisional discovery,
//the supplicant takes care of it.
if (isGroupOwner(mSavedPeerConfig.deviceAddress)) {
@@ -1114,7 +928,7 @@
}
// Do the regular device lost handling
return NOT_HANDLED;
- case WifiP2pManager.DISABLE_P2P:
+ case WifiStateMachine.CMD_DISABLE_P2P:
sendMessage(WifiP2pManager.REMOVE_GROUP);
deferMessage(message);
break;
@@ -1494,54 +1308,5 @@
Slog.e(TAG, s);
}
- private void showNotification() {
- NotificationManager notificationManager =
- (NotificationManager)mContext.getSystemService(Context.NOTIFICATION_SERVICE);
- if (notificationManager == null || mNotification != null) {
- return;
- }
-
- Intent intent = new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS);
- intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
-
- PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0);
-
- Resources r = Resources.getSystem();
- CharSequence title = r.getText(R.string.wifi_p2p_enabled_notification_title);
- CharSequence message = r.getText(R.string.wifi_p2p_enabled_notification_message);
-
- mNotification = new Notification();
- mNotification.when = 0;
- //TODO: might change to be a seperate icon
- mNotification.icon = R.drawable.stat_sys_tether_wifi;
- mNotification.defaults &= ~Notification.DEFAULT_SOUND;
- mNotification.flags = Notification.FLAG_ONGOING_EVENT;
- mNotification.tickerText = title;
- mNotification.setLatestEventInfo(mContext, title, message, pi);
-
- notificationManager.notify(mNotification.icon, mNotification);
- }
-
- private void clearNotification() {
- NotificationManager notificationManager =
- (NotificationManager)mContext.getSystemService(Context.NOTIFICATION_SERVICE);
- if (notificationManager != null && mNotification != null) {
- notificationManager.cancel(mNotification.icon);
- mNotification = null;
- }
- }
-
- private boolean isAirplaneSensitive() {
- String airplaneModeRadios = Settings.System.getString(mContext.getContentResolver(),
- Settings.System.AIRPLANE_MODE_RADIOS);
- return airplaneModeRadios == null
- || airplaneModeRadios.contains(Settings.System.RADIO_WIFI);
- }
-
- private boolean isAirplaneModeOn() {
- return isAirplaneSensitive() && Settings.System.getInt(mContext.getContentResolver(),
- Settings.System.AIRPLANE_MODE_ON, 0) == 1;
- }
-
}
}