Merge "Enable global (cross-application) drag/drop"
diff --git a/api/current.xml b/api/current.xml
index d3fef4c..e8a6790 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -1896,6 +1896,28 @@
visibility="public"
>
</field>
+<field name="actionMenuTextAppearance"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843616"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="actionMenuTextColor"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843617"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
<field name="actionModeBackground"
type="int"
transient="false"
@@ -95677,6 +95699,17 @@
visibility="public"
>
</constructor>
+<method name="getBackDisposition"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
<method name="getCandidatesHiddenVisibility"
return="int"
abstract="false"
@@ -96402,6 +96435,19 @@
<parameter name="charCode" type="char">
</parameter>
</method>
+<method name="setBackDisposition"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="disposition" type="int">
+</parameter>
+</method>
<method name="setCandidatesView"
return="void"
abstract="false"
@@ -96528,6 +96574,39 @@
visibility="public"
>
</method>
+<field name="BACK_DISPOSITION_DEFAULT"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="0"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="BACK_DISPOSITION_WILL_DISMISS"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="2"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="BACK_DISPOSITION_WILL_NOT_DISMISS"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
</class>
<class name="InputMethodService.InputMethodImpl"
extends="android.inputmethodservice.AbstractInputMethodService.AbstractInputMethodImpl"
diff --git a/core/java/android/animation/LayoutTransition.java b/core/java/android/animation/LayoutTransition.java
index f13d940..d3e10f3 100644
--- a/core/java/android/animation/LayoutTransition.java
+++ b/core/java/android/animation/LayoutTransition.java
@@ -166,6 +166,7 @@
* we cache all of the current animations in this map for possible cancellation on
* another layout event.
*/
+ private final HashMap<View, Animator> pendingAnimations = new HashMap<View, Animator>();
private final HashMap<View, Animator> currentChangingAnimations = new HashMap<View, Animator>();
private final HashMap<View, Animator> currentVisibilityAnimations =
new HashMap<View, Animator>();
@@ -542,6 +543,8 @@
// reset the inter-animation delay, in case we use it later
staggerDelay = 0;
+ final long duration = (changeReason == APPEARING) ?
+ mChangingAppearingDuration : mChangingDisappearingDuration;
final ViewTreeObserver observer = parent.getViewTreeObserver(); // used for later cleanup
if (!observer.isAlive()) {
@@ -556,12 +559,6 @@
// only animate the views not being added or removed
if (child != newView) {
- // If there's an animation running on this view already, cancel it
- Animator currentAnimation = currentChangingAnimations.get(child);
- if (currentAnimation != null) {
- currentAnimation.cancel();
- currentChangingAnimations.remove(child);
- }
// Make a copy of the appropriate animation
final Animator anim = baseAnimator.clone();
@@ -573,6 +570,30 @@
// its target object
anim.setupStartValues();
+ // If there's an animation running on this view already, cancel it
+ Animator currentAnimation = pendingAnimations.get(child);
+ if (currentAnimation != null) {
+ currentAnimation.cancel();
+ pendingAnimations.remove(child);
+ }
+ // Cache the animation in case we need to cancel it later
+ pendingAnimations.put(child, anim);
+
+ // For the animations which don't get started, we have to have a means of
+ // removing them from the cache, lest we leak them and their target objects.
+ // We run an animator for the default duration+100 (an arbitrary time, but one
+ // which should far surpass the delay between setting them up here and
+ // handling layout events which start them.
+ ValueAnimator pendingAnimRemover = ValueAnimator.ofFloat(0f, 1f).
+ setDuration(duration+100);
+ pendingAnimRemover.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ pendingAnimations.remove(child);
+ }
+ });
+ pendingAnimRemover.start();
+
// Add a listener to track layout changes on this view. If we don't get a callback,
// then there's nothing to animate.
final View.OnLayoutChangeListener listener = new View.OnLayoutChangeListener() {
@@ -583,19 +604,25 @@
anim.setupEndValues();
long startDelay;
- long duration;
if (changeReason == APPEARING) {
startDelay = mChangingAppearingDelay + staggerDelay;
staggerDelay += mChangingAppearingStagger;
- duration = mChangingAppearingDuration;
} else {
startDelay = mChangingDisappearingDelay + staggerDelay;
staggerDelay += mChangingDisappearingStagger;
- duration = mChangingDisappearingDuration;
}
anim.setStartDelay(startDelay);
anim.setDuration(duration);
+ Animator prevAnimation = currentChangingAnimations.get(child);
+ if (prevAnimation != null) {
+ prevAnimation.cancel();
+ currentChangingAnimations.remove(child);
+ }
+ Animator pendingAnimation = pendingAnimations.get(child);
+ if (pendingAnimation != null) {
+ pendingAnimations.remove(child);
+ }
// Cache the animation in case we need to cancel it later
currentChangingAnimations.put(child, anim);
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 79890ef..04d839d 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -4318,7 +4318,7 @@
mWindow = PolicyManager.makeNewWindow(this);
mWindow.setCallback(this);
- mWindow.getLayoutInflater().setFactory2(this);
+ mWindow.getLayoutInflater().setPrivateFactory(this);
if (info.softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) {
mWindow.setSoftInputMode(info.softInputMode);
}
diff --git a/core/java/android/app/StatusBarManager.java b/core/java/android/app/StatusBarManager.java
index 97e6931..1af0983 100644
--- a/core/java/android/app/StatusBarManager.java
+++ b/core/java/android/app/StatusBarManager.java
@@ -22,6 +22,7 @@
import android.os.RemoteException;
import android.os.IBinder;
import android.os.ServiceManager;
+import android.view.View;
import com.android.internal.statusbar.IStatusBarService;
@@ -31,52 +32,24 @@
* @hide
*/
public class StatusBarManager {
- /**
- * Flag for {@link #disable} to make the status bar not expandable. Unless you also
- * set {@link #DISABLE_NOTIFICATION_ICONS}, new notifications will continue to show.
- */
- public static final int DISABLE_EXPAND = 0x00000001;
- /**
- * Flag for {@link #disable} to hide notification icons and scrolling ticker text.
- */
- public static final int DISABLE_NOTIFICATION_ICONS = 0x00000002;
+ public static final int DISABLE_EXPAND = View.STATUS_BAR_DISABLE_EXPAND;
+ public static final int DISABLE_NOTIFICATION_ICONS = View.STATUS_BAR_DISABLE_NOTIFICATION_ICONS;
+ public static final int DISABLE_NOTIFICATION_ALERTS
+ = View.STATUS_BAR_DISABLE_NOTIFICATION_ALERTS;
+ public static final int DISABLE_NOTIFICATION_TICKER
+ = View.STATUS_BAR_DISABLE_NOTIFICATION_TICKER;
+ public static final int DISABLE_SYSTEM_INFO = View.STATUS_BAR_DISABLE_SYSTEM_INFO;
+ public static final int DISABLE_NAVIGATION = View.STATUS_BAR_DISABLE_NAVIGATION;
+ public static final int DISABLE_BACK = View.STATUS_BAR_DISABLE_BACK;
+ public static final int DISABLE_CLOCK = View.STATUS_BAR_DISABLE_CLOCK;
- /**
- * Flag for {@link #disable} to disable incoming notification alerts. This will not block
- * icons, but it will block sound, vibrating and other visual or aural notifications.
- */
- public static final int DISABLE_NOTIFICATION_ALERTS = 0x00000004;
-
- /**
- * Flag for {@link #disable} to hide only the scrolling ticker. Note that
- * {@link #DISABLE_NOTIFICATION_ICONS} implies {@link #DISABLE_NOTIFICATION_TICKER}.
- */
- public static final int DISABLE_NOTIFICATION_TICKER = 0x00000008;
-
- /**
- * Flag for {@link #disable} to hide the center system info area.
- */
- public static final int DISABLE_SYSTEM_INFO = 0x00000010;
-
- /**
- * Flag for {@link #disable} to hide only the navigation buttons. Don't use this
- * unless you're a special part of the system UI (i.e., setup wizard, keyguard).
- */
- public static final int DISABLE_NAVIGATION = 0x00000020;
-
- /**
- * Flag for {@link #disable} to hide only the clock. You might use this if your activity has
- * its own clock making the status bar's clock redundant.
- */
- public static final int DISABLE_CLOCK = 0x00000040;
-
-
- /**
- * Re-enable all of the status bar features that you've disabled.
- */
public static final int DISABLE_NONE = 0x00000000;
+ public static final int DISABLE_MASK = DISABLE_EXPAND | DISABLE_NOTIFICATION_ICONS
+ | DISABLE_NOTIFICATION_ALERTS | DISABLE_NOTIFICATION_TICKER
+ | DISABLE_SYSTEM_INFO| DISABLE_NAVIGATION | DISABLE_BACK | DISABLE_CLOCK;
+
private Context mContext;
private IStatusBarService mService;
private IBinder mToken = new Binder();
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 6e3663e..e7b96e7 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -2794,7 +2794,7 @@
* @param action The Intent action, such as ACTION_VIEW.
*/
public Intent(String action) {
- mAction = action;
+ setAction(action);
}
/**
@@ -2814,7 +2814,7 @@
* @param uri The Intent data URI.
*/
public Intent(String action, Uri uri) {
- mAction = action;
+ setAction(action);
mData = uri;
}
@@ -2863,7 +2863,7 @@
*/
public Intent(String action, Uri uri,
Context packageContext, Class<?> cls) {
- mAction = action;
+ setAction(action);
mData = uri;
mComponent = new ComponentName(packageContext, cls);
}
@@ -2985,7 +2985,7 @@
// action
if (uri.startsWith("action=", i)) {
- intent.mAction = value;
+ intent.setAction(value);
}
// categories
@@ -4061,7 +4061,7 @@
* @see #getAction
*/
public Intent setAction(String action) {
- mAction = action;
+ mAction = action != null ? action.intern() : null;
return this;
}
@@ -4165,7 +4165,7 @@
if (mCategories == null) {
mCategories = new HashSet<String>();
}
- mCategories.add(category);
+ mCategories.add(category.intern());
return this;
}
@@ -5678,7 +5678,7 @@
}
public void readFromParcel(Parcel in) {
- mAction = in.readString();
+ setAction(in.readString());
mData = Uri.CREATOR.createFromParcel(in);
mType = in.readString();
mFlags = in.readInt();
@@ -5694,7 +5694,7 @@
mCategories = new HashSet<String>();
int i;
for (i=0; i<N; i++) {
- mCategories.add(in.readString());
+ mCategories.add(in.readString().intern());
}
} else {
mCategories = null;
diff --git a/core/java/android/content/IntentFilter.java b/core/java/android/content/IntentFilter.java
index 452fd8a..61d7424 100644
--- a/core/java/android/content/IntentFilter.java
+++ b/core/java/android/content/IntentFilter.java
@@ -461,7 +461,7 @@
* @return True if the action is explicitly mentioned in the filter.
*/
public final boolean hasAction(String action) {
- return mActions.contains(action);
+ return action != null && mActions.contains(action);
}
/**
@@ -470,14 +470,10 @@
*
* @param action The desired action to look for.
*
- * @return True if the action is listed in the filter or the filter does
- * not specify any actions.
+ * @return True if the action is listed in the filter.
*/
public final boolean matchAction(String action) {
- if (action == null || mActions == null || mActions.size() == 0) {
- return false;
- }
- return mActions.contains(action);
+ return hasAction(action);
}
/**
@@ -818,9 +814,9 @@
if (mDataPaths == null) {
return false;
}
- Iterator<PatternMatcher> i = mDataPaths.iterator();
- while (i.hasNext()) {
- final PatternMatcher pe = i.next();
+ final int numDataPaths = mDataPaths.size();
+ for (int i = 0; i < numDataPaths; i++) {
+ final PatternMatcher pe = mDataPaths.get(i);
if (pe.match(data)) {
return true;
}
@@ -849,9 +845,9 @@
if (mDataAuthorities == null) {
return NO_MATCH_DATA;
}
- Iterator<AuthorityEntry> i = mDataAuthorities.iterator();
- while (i.hasNext()) {
- final AuthorityEntry ae = i.next();
+ final int numDataAuthorities = mDataAuthorities.size();
+ for (int i = 0; i < numDataAuthorities; i++) {
+ final AuthorityEntry ae = mDataAuthorities.get(i);
int match = ae.match(data);
if (match >= 0) {
return match;
@@ -1098,7 +1094,7 @@
*/
public final int match(String action, String type, String scheme,
Uri data, Set<String> categories, String logTag) {
- if (action != null && !matchAction(action)) {
+ if (!matchAction(action)) {
if (Config.LOGV) Log.v(
logTag, "No matching action " + action + " for " + this);
return NO_MATCH_ACTION;
@@ -1119,11 +1115,11 @@
return dataMatch;
}
- String categoryMatch = matchCategories(categories);
- if (categoryMatch != null) {
- if (Config.LOGV) Log.v(
- logTag, "No matching category "
- + categoryMatch + " for " + this);
+ String categoryMismatch = matchCategories(categories);
+ if (categoryMismatch != null) {
+ if (Config.LOGV) {
+ Log.v(logTag, "No matching category " + categoryMismatch + " for " + this);
+ }
return NO_MATCH_CATEGORY;
}
@@ -1469,9 +1465,9 @@
if (typeLength == slashpos+2 && type.charAt(slashpos+1) == '*') {
// Need to look through all types for one that matches
// our base...
- final Iterator<String> it = t.iterator();
- while (it.hasNext()) {
- String v = it.next();
+ final int numTypes = t.size();
+ for (int i = 0; i < numTypes; i++) {
+ final String v = t.get(i);
if (type.regionMatches(0, v, 0, slashpos+1)) {
return true;
}
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index 255eb6c..a99256f 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -219,7 +219,34 @@
public class InputMethodService extends AbstractInputMethodService {
static final String TAG = "InputMethodService";
static final boolean DEBUG = false;
-
+
+ /**
+ * The back button will close the input window.
+ */
+ public static final int BACK_DISPOSITION_DEFAULT = 0; // based on window
+
+ /**
+ * This input method will not consume the back key.
+ */
+ public static final int BACK_DISPOSITION_WILL_NOT_DISMISS = 1; // back
+
+ /**
+ * This input method will consume the back key.
+ */
+ public static final int BACK_DISPOSITION_WILL_DISMISS = 2; // down
+
+ /**
+ * @hide
+ * The IME is active. It may or may not be visible.
+ */
+ public static final int IME_ACTIVE = 0x1;
+
+ /**
+ * @hide
+ * The IME is visible.
+ */
+ public static final int IME_VISIBLE = 0x2;
+
InputMethodManager mImm;
int mTheme = 0;
@@ -271,6 +298,7 @@
boolean mIsInputViewShown;
int mStatusIcon;
+ int mBackDisposition;
final Insets mTmpInsets = new Insets();
final int[] mTmpLocation = new int[2];
@@ -394,9 +422,9 @@
showWindow(true);
}
// If user uses hard keyboard, IME button should always be shown.
- if (!onEvaluateInputViewShown()) {
- mImm.setIMEButtonVisible(mToken, true);
- }
+ boolean showing = onEvaluateInputViewShown();
+ mImm.setImeWindowStatus(mToken, IME_ACTIVE | (showing ? IME_VISIBLE : 0),
+ mBackDisposition);
if (resultReceiver != null) {
resultReceiver.send(wasVis != isInputViewShown()
? InputMethodManager.RESULT_SHOWN
@@ -704,9 +732,9 @@
hideWindow();
}
// If user uses hard keyboard, IME button should always be shown.
- if (!onEvaluateInputViewShown()) {
- mImm.setIMEButtonVisible(mToken, true);
- }
+ boolean showing = onEvaluateInputViewShown();
+ mImm.setImeWindowStatus(mToken, IME_ACTIVE | (showing ? IME_VISIBLE : 0),
+ mBackDisposition);
}
}
@@ -736,6 +764,14 @@
return mWindow;
}
+ public void setBackDisposition(int disposition) {
+ mBackDisposition = disposition;
+ }
+
+ public int getBackDisposition() {
+ return mBackDisposition;
+ }
+
/**
* Return the maximum width, in pixels, available the input method.
* Input methods are positioned at the bottom of the screen and, unless
@@ -1378,7 +1414,7 @@
if (!wasVisible) {
if (DEBUG) Log.v(TAG, "showWindow: showing!");
- mImm.setIMEButtonVisible(mToken, true);
+ mImm.setImeWindowStatus(mToken, IME_ACTIVE, mBackDisposition);
onWindowShown();
mWindow.show();
}
@@ -1394,7 +1430,7 @@
}
mInputViewStarted = false;
mCandidatesViewStarted = false;
- mImm.setIMEButtonVisible(mToken, false);
+ mImm.setImeWindowStatus(mToken, 0, mBackDisposition);
if (mWindowVisible) {
mWindow.hide();
mWindowVisible = false;
diff --git a/core/java/android/text/TextUtils.java b/core/java/android/text/TextUtils.java
index 7748265..d5010c6 100644
--- a/core/java/android/text/TextUtils.java
+++ b/core/java/android/text/TextUtils.java
@@ -1142,7 +1142,7 @@
// XXX this is probably ok, but need to look at it more
tempMt.setPara(format, 0, format.length(), request);
- float moreWid = mt.addStyleRun(p, mt.mLen, null);
+ float moreWid = tempMt.addStyleRun(p, tempMt.mLen, null);
if (w + moreWid <= avail) {
ok = i + 1;
diff --git a/core/java/android/util/FastImmutableArraySet.java b/core/java/android/util/FastImmutableArraySet.java
new file mode 100644
index 0000000..4175c605
--- /dev/null
+++ b/core/java/android/util/FastImmutableArraySet.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.util;
+
+import java.util.AbstractSet;
+import java.util.Iterator;
+
+/**
+ * A fast immutable set wrapper for an array that is optimized for non-concurrent iteration.
+ * The same iterator instance is reused each time to avoid creating lots of garbage.
+ * Iterating over an array in this fashion is 2.5x faster than iterating over a {@link HashSet}
+ * so it is worth copying the contents of the set to an array when iterating over it
+ * hundreds of times.
+ * @hide
+ */
+public final class FastImmutableArraySet<T> extends AbstractSet<T> {
+ FastIterator<T> mIterator;
+ T[] mContents;
+
+ public FastImmutableArraySet(T[] contents) {
+ mContents = contents;
+ }
+
+ @Override
+ public Iterator<T> iterator() {
+ FastIterator<T> it = mIterator;
+ if (it == null) {
+ it = new FastIterator<T>(mContents);
+ mIterator = it;
+ } else {
+ it.mIndex = 0;
+ }
+ return it;
+ }
+
+ @Override
+ public int size() {
+ return mContents.length;
+ }
+
+ private static final class FastIterator<T> implements Iterator<T> {
+ private final T[] mContents;
+ int mIndex;
+
+ public FastIterator(T[] contents) {
+ mContents = contents;
+ }
+
+ @Override
+ public boolean hasNext() {
+ return mIndex != mContents.length;
+ }
+
+ @Override
+ public T next() {
+ return mContents[mIndex++];
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
diff --git a/core/java/android/view/LayoutInflater.java b/core/java/android/view/LayoutInflater.java
index 6b44f9e..81346b4 100644
--- a/core/java/android/view/LayoutInflater.java
+++ b/core/java/android/view/LayoutInflater.java
@@ -68,6 +68,7 @@
private boolean mFactorySet;
private Factory mFactory;
private Factory2 mFactory2;
+ private Factory2 mPrivateFactory;
private Filter mFilter;
private final Object[] mConstructorArgs = new Object[2];
@@ -193,6 +194,7 @@
mContext = newContext;
mFactory = original.mFactory;
mFactory2 = original.mFactory2;
+ mPrivateFactory = original.mPrivateFactory;
mFilter = original.mFilter;
}
@@ -300,6 +302,13 @@
}
/**
+ * @hide for use by framework
+ */
+ public void setPrivateFactory(Factory2 factory) {
+ mPrivateFactory = factory;
+ }
+
+ /**
* @return The {@link Filter} currently used by this LayoutInflater to restrict the set of Views
* that are allowed to be inflated.
*/
@@ -651,6 +660,10 @@
else if (mFactory != null) view = mFactory.onCreateView(name, mContext, attrs);
else view = null;
+ if (view == null && mPrivateFactory != null) {
+ view = mPrivateFactory.onCreateView(parent, name, mContext, attrs);
+ }
+
if (view == null) {
if (-1 == name.indexOf('.')) {
view = onCreateView(parent, name, attrs);
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java
index 0326a8f..83f9119 100644
--- a/core/java/android/view/Surface.java
+++ b/core/java/android/view/Surface.java
@@ -99,6 +99,17 @@
*/
public static final int OPAQUE = 0x00000400;
+ /**
+ * Application requires a hardware-protected path to an
+ * external display sink. If a hardware-protected path is not available,
+ * then this surface will not be displayed on the external sink.
+ *
+ * @hide
+ */
+ public static final int PROTECTED_APP = 0x00000800;
+
+ // 0x1000 is reserved for an independent DRM protected flag in framework
+
/** Creates a normal surface. This is the default. */
public static final int FX_SURFACE_NORMAL = 0x00000000;
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index 966bd8d..87b3d79 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -174,6 +174,7 @@
return true;
}
};
+ private boolean mGlobalListenersAdded;
public SurfaceView(Context context) {
super(context);
@@ -212,9 +213,13 @@
mLayout.token = getWindowToken();
mLayout.setTitle("SurfaceView");
mViewVisibility = getVisibility() == VISIBLE;
- ViewTreeObserver observer = getViewTreeObserver();
- observer.addOnScrollChangedListener(mScrollChangedListener);
- observer.addOnPreDrawListener(mDrawListener);
+
+ if (!mGlobalListenersAdded) {
+ ViewTreeObserver observer = getViewTreeObserver();
+ observer.addOnScrollChangedListener(mScrollChangedListener);
+ observer.addOnPreDrawListener(mDrawListener);
+ mGlobalListenersAdded = true;
+ }
}
@Override
@@ -275,9 +280,13 @@
@Override
protected void onDetachedFromWindow() {
- ViewTreeObserver observer = getViewTreeObserver();
- observer.removeOnScrollChangedListener(mScrollChangedListener);
- observer.removeOnPreDrawListener(mDrawListener);
+ if (mGlobalListenersAdded) {
+ ViewTreeObserver observer = getViewTreeObserver();
+ observer.removeOnScrollChangedListener(mScrollChangedListener);
+ observer.removeOnPreDrawListener(mDrawListener);
+ mGlobalListenersAdded = false;
+ }
+
mRequestedVisible = false;
updateWindow(false, false);
mHaveFrame = false;
@@ -285,6 +294,7 @@
try {
mSession.remove(mWindow);
} catch (RemoteException ex) {
+ // Not much we can do here...
}
mWindow = null;
}
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 7e968d7..5aa2f1a 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -1732,6 +1732,102 @@
public static final int STATUS_BAR_HIDDEN = 0x00000001;
/**
+ * @hide
+ *
+ * NOTE: This flag may only be used in subtreeSystemUiVisibility. It is masked
+ * out of the public fields to keep the undefined bits out of the developer's way.
+ *
+ * Flag to make the status bar not expandable. Unless you also
+ * set {@link #STATUS_BAR_DISABLE_NOTIFICATION_ICONS}, new notifications will continue to show.
+ */
+ public static final int STATUS_BAR_DISABLE_EXPAND = 0x00010000;
+
+ /**
+ * @hide
+ *
+ * NOTE: This flag may only be used in subtreeSystemUiVisibility. It is masked
+ * out of the public fields to keep the undefined bits out of the developer's way.
+ *
+ * Flag to hide notification icons and scrolling ticker text.
+ */
+ public static final int STATUS_BAR_DISABLE_NOTIFICATION_ICONS = 0x00020000;
+
+ /**
+ * @hide
+ *
+ * NOTE: This flag may only be used in subtreeSystemUiVisibility. It is masked
+ * out of the public fields to keep the undefined bits out of the developer's way.
+ *
+ * Flag to disable incoming notification alerts. This will not block
+ * icons, but it will block sound, vibrating and other visual or aural notifications.
+ */
+ public static final int STATUS_BAR_DISABLE_NOTIFICATION_ALERTS = 0x00040000;
+
+ /**
+ * @hide
+ *
+ * NOTE: This flag may only be used in subtreeSystemUiVisibility. It is masked
+ * out of the public fields to keep the undefined bits out of the developer's way.
+ *
+ * Flag to hide only the scrolling ticker. Note that
+ * {@link #STATUS_BAR_DISABLE_NOTIFICATION_ICONS} implies
+ * {@link #STATUS_BAR_DISABLE_NOTIFICATION_TICKER}.
+ */
+ public static final int STATUS_BAR_DISABLE_NOTIFICATION_TICKER = 0x00080000;
+
+ /**
+ * @hide
+ *
+ * NOTE: This flag may only be used in subtreeSystemUiVisibility. It is masked
+ * out of the public fields to keep the undefined bits out of the developer's way.
+ *
+ * Flag to hide the center system info area.
+ */
+ public static final int STATUS_BAR_DISABLE_SYSTEM_INFO = 0x00100000;
+
+ /**
+ * @hide
+ *
+ * NOTE: This flag may only be used in subtreeSystemUiVisibility. It is masked
+ * out of the public fields to keep the undefined bits out of the developer's way.
+ *
+ * Flag to hide only the navigation buttons. Don't use this
+ * unless you're a special part of the system UI (i.e., setup wizard, keyguard).
+ *
+ * THIS DOES NOT DISABLE THE BACK BUTTON
+ */
+ public static final int STATUS_BAR_DISABLE_NAVIGATION = 0x00200000;
+
+ /**
+ * @hide
+ *
+ * NOTE: This flag may only be used in subtreeSystemUiVisibility. It is masked
+ * out of the public fields to keep the undefined bits out of the developer's way.
+ *
+ * Flag to hide only the back button. Don't use this
+ * unless you're a special part of the system UI (i.e., setup wizard, keyguard).
+ */
+ public static final int STATUS_BAR_DISABLE_BACK = 0x00400000;
+
+ /**
+ * @hide
+ *
+ * NOTE: This flag may only be used in subtreeSystemUiVisibility. It is masked
+ * out of the public fields to keep the undefined bits out of the developer's way.
+ *
+ * Flag to hide only the clock. You might use this if your activity has
+ * its own clock making the status bar's clock redundant.
+ */
+ public static final int STATUS_BAR_DISABLE_CLOCK = 0x00800000;
+
+
+ /**
+ * @hide
+ */
+ public static final int PUBLIC_STATUS_BAR_VISIBILITY_MASK = STATUS_BAR_HIDDEN;
+
+
+ /**
* Controls the over-scroll mode for this view.
* See {@link #overScrollBy(int, int, int, int, int, int, int, int, boolean)},
* {@link #OVER_SCROLL_ALWAYS}, {@link #OVER_SCROLL_IF_CONTENT_SCROLLS},
@@ -7844,7 +7940,6 @@
}
void dispatchDetachedFromWindow() {
- //System.out.println("Detached! " + this);
AttachInfo info = mAttachInfo;
if (info != null) {
int vis = info.mWindowVisibility;
@@ -7854,10 +7949,12 @@
}
onDetachedFromWindow();
- if ((mPrivateFlags&SCROLL_CONTAINER_ADDED) != 0) {
+
+ if ((mPrivateFlags & SCROLL_CONTAINER_ADDED) != 0) {
mAttachInfo.mScrollContainers.remove(this);
mPrivateFlags &= ~SCROLL_CONTAINER_ADDED;
}
+
mAttachInfo = null;
}
@@ -10880,9 +10977,9 @@
/**
*/
public void dispatchSystemUiVisibilityChanged(int visibility) {
- mSystemUiVisibility = visibility;
if (mOnSystemUiVisibilityChangeListener != null) {
- mOnSystemUiVisibilityChangeListener.onSystemUiVisibilityChange(visibility);
+ mOnSystemUiVisibilityChangeListener.onSystemUiVisibilityChange(
+ visibility & ~PUBLIC_STATUS_BAR_VISIBILITY_MASK);
}
}
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index 02e5b63..ca932e9 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -537,7 +537,7 @@
public static final int FLAG_DITHER = 0x00001000;
/** Window flag: don't allow screen shots while this window is
- * displayed. */
+ * displayed. Maps to Surface.SECURE. */
public static final int FLAG_SECURE = 0x00002000;
/** Window flag: a special mode where the layout parameters are used
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index 7edfd7b..cb67b78 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -531,9 +531,9 @@
}
/** @hide */
- public void setIMEButtonVisible(IBinder imeToken, boolean visible) {
+ public void setImeWindowStatus(IBinder imeToken, int vis, int backDisposition) {
try {
- mService.setIMEButtonVisible(imeToken, visible);
+ mService.setImeWindowStatus(imeToken, vis, backDisposition);
} catch (RemoteException e) {
throw new RuntimeException(e);
}
diff --git a/core/java/android/widget/TabWidget.java b/core/java/android/widget/TabWidget.java
index 51ece33..1a4ff29 100644
--- a/core/java/android/widget/TabWidget.java
+++ b/core/java/android/widget/TabWidget.java
@@ -132,7 +132,17 @@
mRightStrip = resources.getDrawable(
com.android.internal.R.drawable.tab_bottom_right_v4);
}
- }
+ } else {
+ // Use modern color scheme for Eclair and beyond
+ if (mLeftStrip == null) {
+ mLeftStrip = resources.getDrawable(
+ com.android.internal.R.drawable.tab_bottom_left);
+ }
+ if (mRightStrip == null) {
+ mRightStrip = resources.getDrawable(
+ com.android.internal.R.drawable.tab_bottom_right);
+ }
+ }
// Deal with focus, as we don't want the focus to go by default
// to a tab other than the current tab
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index b217052..10ec6ca 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -4608,9 +4608,7 @@
mInput.onKeyDown(this, (Editable)mText, keyCode, down);
mInput.onKeyUp(this, (Editable)mText, keyCode, up);
}
- if (mError != null && !mErrorWasChanged) {
- setError(null, null);
- }
+ hideErrorIfUnchanged();
} else if (which == 2) {
mMovement.onKeyUp(this, (Spannable)mText, keyCode, up);
@@ -4731,13 +4729,7 @@
}
if (mInput != null) {
- /*
- * Keep track of what the error was before doing the input
- * so that if an input filter changed the error, we leave
- * that error showing. Otherwise, we take down whatever
- * error was showing when the user types something.
- */
- mErrorWasChanged = false;
+ resetErrorChangedFlag();
boolean doDown = true;
if (otherEvent != null) {
@@ -4745,9 +4737,7 @@
beginBatchEdit();
boolean handled = mInput.onKeyOther(this, (Editable) mText,
otherEvent);
- if (mError != null && !mErrorWasChanged) {
- setError(null, null);
- }
+ hideErrorIfUnchanged();
doDown = false;
if (handled) {
return -1;
@@ -4764,9 +4754,7 @@
beginBatchEdit();
if (mInput.onKeyDown(this, (Editable) mText, keyCode, event)) {
endBatchEdit();
- if (mError != null && !mErrorWasChanged) {
- setError(null, null);
- }
+ hideErrorIfUnchanged();
return 1;
}
endBatchEdit();
@@ -4800,6 +4788,30 @@
return 0;
}
+ /**
+ * Resets the mErrorWasChanged flag, so that future calls to {@link #setError(CharSequence)}
+ * can be recorded.
+ * @hide
+ */
+ public void resetErrorChangedFlag() {
+ /*
+ * Keep track of what the error was before doing the input
+ * so that if an input filter changed the error, we leave
+ * that error showing. Otherwise, we take down whatever
+ * error was showing when the user types something.
+ */
+ mErrorWasChanged = false;
+ }
+
+ /**
+ * @hide
+ */
+ public void hideErrorIfUnchanged() {
+ if (mError != null && !mErrorWasChanged) {
+ setError(null, null);
+ }
+ }
+
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (!isEnabled()) {
diff --git a/core/java/com/android/internal/statusbar/IStatusBar.aidl b/core/java/com/android/internal/statusbar/IStatusBar.aidl
index 1cc068f..5fcd0c2 100644
--- a/core/java/com/android/internal/statusbar/IStatusBar.aidl
+++ b/core/java/com/android/internal/statusbar/IStatusBar.aidl
@@ -32,6 +32,6 @@
void animateCollapse();
void setLightsOn(boolean on);
void setMenuKeyVisible(boolean visible);
- void setIMEButtonVisible(in IBinder token, boolean visible);
+ void setImeWindowStatus(in IBinder token, int vis, int backDisposition);
}
diff --git a/core/java/com/android/internal/statusbar/IStatusBarService.aidl b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
index d1ea52e..c62aeb0 100644
--- a/core/java/com/android/internal/statusbar/IStatusBarService.aidl
+++ b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
@@ -31,7 +31,7 @@
void setIconVisibility(String slot, boolean visible);
void removeIcon(String slot);
void setMenuKeyVisible(boolean visible);
- void setIMEButtonVisible(in IBinder token, boolean visible);
+ void setImeWindowStatus(in IBinder token, int vis, int backDisposition);
// ---- Methods below are for use by the status bar policy services ----
// You need the STATUS_BAR_SERVICE permission
diff --git a/core/java/com/android/internal/view/IInputMethodManager.aidl b/core/java/com/android/internal/view/IInputMethodManager.aidl
index b2fbd3a7..611d987 100644
--- a/core/java/com/android/internal/view/IInputMethodManager.aidl
+++ b/core/java/com/android/internal/view/IInputMethodManager.aidl
@@ -59,7 +59,7 @@
void hideMySoftInput(in IBinder token, int flags);
void showMySoftInput(in IBinder token, int flags);
void updateStatusIcon(in IBinder token, String packageName, int iconId);
- void setIMEButtonVisible(in IBinder token, boolean visible);
+ void setImeWindowStatus(in IBinder token, int vis, int backDisposition);
InputMethodSubtype getCurrentInputMethodSubtype();
boolean setCurrentInputMethodSubtype(in InputMethodSubtype subtype);
boolean switchToLastInputMethod(in IBinder token);
diff --git a/core/java/com/android/internal/widget/EditableInputConnection.java b/core/java/com/android/internal/widget/EditableInputConnection.java
index e992e7c..9f9f020 100644
--- a/core/java/com/android/internal/widget/EditableInputConnection.java
+++ b/core/java/com/android/internal/widget/EditableInputConnection.java
@@ -138,9 +138,9 @@
return super.commitText(text, newCursorPosition);
}
- CharSequence errorBefore = mTextView.getError();
+ mTextView.resetErrorChangedFlag();
boolean success = super.commitText(text, newCursorPosition);
- CharSequence errorAfter = mTextView.getError();
+ mTextView.hideErrorIfUnchanged();
return success;
}
diff --git a/core/res/res/layout-xlarge/status_bar_latest_event_content.xml b/core/res/res/layout-xlarge/status_bar_latest_event_content.xml
index 1a3ee82..676c38b 100644
--- a/core/res/res/layout-xlarge/status_bar_latest_event_content.xml
+++ b/core/res/res/layout-xlarge/status_bar_latest_event_content.xml
@@ -23,14 +23,14 @@
android:singleLine="true"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
- android:layout_marginBottom="-4dp"
+ android:layout_marginBottom="-3dp"
/>
<TextView android:id="@+id/text"
android:textAppearance="@style/TextAppearance.StatusBar.EventContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:layout_marginTop="-4dp"
+ android:layout_marginTop="-2dp"
android:singleLine="true"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
diff --git a/core/res/res/layout-xlarge/status_bar_latest_event_content_large_icon.xml b/core/res/res/layout-xlarge/status_bar_latest_event_content_large_icon.xml
index fcbdf6d..ebdaaa3 100644
--- a/core/res/res/layout-xlarge/status_bar_latest_event_content_large_icon.xml
+++ b/core/res/res/layout-xlarge/status_bar_latest_event_content_large_icon.xml
@@ -17,14 +17,14 @@
android:singleLine="true"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
- android:layout_marginBottom="-4dp"
+ android:layout_marginBottom="-3dp"
/>
<TextView android:id="@+id/text"
android:textAppearance="@style/TextAppearance.StatusBar.EventContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:layout_marginTop="-4dp"
+ android:layout_marginTop="-2dp"
android:singleLine="true"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
diff --git a/core/res/res/layout/action_menu_item_layout.xml b/core/res/res/layout/action_menu_item_layout.xml
index 4477df7..15dfea3 100644
--- a/core/res/res/layout/action_menu_item_layout.xml
+++ b/core/res/res/layout/action_menu_item_layout.xml
@@ -40,9 +40,9 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone"
- android:textAppearance="?attr/textAppearanceMedium"
+ android:textAppearance="?attr/actionMenuTextAppearance"
style="?attr/buttonStyleSmall"
- android:textColor="?attr/textColorPrimary"
+ android:textColor="?attr/actionMenuTextColor"
android:background="@null"
android:paddingLeft="4dip"
android:paddingRight="4dip" />
diff --git a/core/res/res/values-xlarge/styles.xml b/core/res/res/values-xlarge/styles.xml
index ed05cb1..dd78920 100644
--- a/core/res/res/values-xlarge/styles.xml
+++ b/core/res/res/values-xlarge/styles.xml
@@ -30,6 +30,7 @@
</style>
<style name="TextAppearance.StatusBar.EventContent">
<item name="android:textColor">#ff999999</item>
+ <item name="android:textSize">14sp</item>
</style>
<style name="TextAppearance.StatusBar.EventContent.Title">
<item name="android:textColor">?android:attr/textColorPrimary</item>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index a152d4c..1c9b587 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -587,7 +587,11 @@
<attr name="actionBarSize" format="dimension" >
<enum name="wrap_content" value="0" />
</attr>
-
+ <!-- TextAppearance style that will be applied to text that
+ appears within action menu items. -->
+ <attr name="actionMenuTextAppearance" format="reference" />
+ <!-- Color for text that appears within action menu items. -->
+ <attr name="actionMenuTextColor" format="color|reference" />
<!-- =================== -->
<!-- Action mode styles -->
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 957707d..02b42d0 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1430,6 +1430,8 @@
<public type="attr" name="calendarViewStyle" />
<public type="attr" name="textEditSidePasteWindowLayout" />
<public type="attr" name="textEditSideNoPasteWindowLayout" />
+ <public type="attr" name="actionMenuTextAppearance" />
+ <public type="attr" name="actionMenuTextColor" />
<!-- A simple fade-in animation. -->
<public type="animator" name="fade_in" id="0x010b0000" />
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index b828318..f54f8cc 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -224,7 +224,7 @@
<item name="android:textStyle">bold</item>
</style>
<style name="TextAppearance.StatusBar.EventContent">
- <item name="android:textSize">10sp</item>
+ <item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
<item name="android:textColor">?android:attr/textColorPrimaryInverse</item>
</style>
<style name="TextAppearance.StatusBar.EventContent.Title">
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index c5ae77f..38b068e 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -270,6 +270,8 @@
<item name="actionBarStyle">@android:style/Widget.ActionBar</item>
<item name="actionBarSize">56dip</item>
<item name="actionModePopupWindowStyle">?android:attr/popupWindowStyle</item>
+ <item name="actionMenuTextAppearance">?android:attr/textAppearanceMedium</item>
+ <item name="actionMenuTextColor">?android:attr/textColorPrimary</item>
<item name="dividerVertical">@drawable/divider_vertical_dark</item>
<item name="dividerHorizontal">@drawable/divider_vertical_dark</item>
diff --git a/include/surfaceflinger/ISurfaceComposer.h b/include/surfaceflinger/ISurfaceComposer.h
index 56ed3a4..361e7dc 100644
--- a/include/surfaceflinger/ISurfaceComposer.h
+++ b/include/surfaceflinger/ISurfaceComposer.h
@@ -44,6 +44,8 @@
eSecure = 0x00000080,
eNonPremultiplied = 0x00000100,
eOpaque = 0x00000400,
+ eProtectedByApp = 0x00000800,
+ eProtectedByDRM = 0x00001000,
eFXSurfaceNormal = 0x00000000,
eFXSurfaceBlur = 0x00010000,
diff --git a/include/ui/GraphicBuffer.h b/include/ui/GraphicBuffer.h
index 8b256f4..02d6f8f 100644
--- a/include/ui/GraphicBuffer.h
+++ b/include/ui/GraphicBuffer.h
@@ -54,9 +54,11 @@
USAGE_SW_WRITE_RARELY = GRALLOC_USAGE_SW_WRITE_RARELY,
USAGE_SW_WRITE_OFTEN = GRALLOC_USAGE_SW_WRITE_OFTEN,
USAGE_SW_WRITE_MASK = GRALLOC_USAGE_SW_WRITE_MASK,
-
+
USAGE_SOFTWARE_MASK = USAGE_SW_READ_MASK|USAGE_SW_WRITE_MASK,
-
+
+ USAGE_PROTECTED = GRALLOC_USAGE_PROTECTED,
+
USAGE_HW_TEXTURE = GRALLOC_USAGE_HW_TEXTURE,
USAGE_HW_RENDER = GRALLOC_USAGE_HW_RENDER,
USAGE_HW_2D = GRALLOC_USAGE_HW_2D,
diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp
index 0ed8be5..c0e4e0f 100644
--- a/libs/gui/SurfaceTextureClient.cpp
+++ b/libs/gui/SurfaceTextureClient.cpp
@@ -88,7 +88,7 @@
int buf = -1;
status_t err = mSurfaceTexture->dequeueBuffer(&buf);
if (err < 0) {
- LOGE("dequeueBuffer: ISurfaceTexture::dequeueBuffer failed: %d", err);
+ LOGV("dequeueBuffer: ISurfaceTexture::dequeueBuffer failed: %d", err);
return err;
}
sp<GraphicBuffer>& gbuf(mSlots[buf]);
diff --git a/packages/SystemUI/res/layout-xlarge/status_bar.xml b/packages/SystemUI/res/layout-xlarge/status_bar.xml
index f355e17..6c173c9 100644
--- a/packages/SystemUI/res/layout-xlarge/status_bar.xml
+++ b/packages/SystemUI/res/layout-xlarge/status_bar.xml
@@ -44,20 +44,20 @@
/>
<!-- navigation controls -->
+ <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/back"
+ android:layout_width="80dip"
+ android:layout_height="match_parent"
+ android:src="@drawable/ic_sysbar_back"
+ android:layout_alignParentLeft="true"
+ systemui:keyCode="4"
+ />
<LinearLayout
android:id="@+id/navigationArea"
android:layout_width="wrap_content"
android:layout_height="match_parent"
- android:layout_alignParentLeft="true"
+ android:layout_toRightOf="@+id/back"
android:orientation="horizontal"
>
-
- <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/back"
- android:layout_width="80dip"
- android:layout_height="match_parent"
- android:src="@drawable/ic_sysbar_back"
- systemui:keyCode="4"
- />
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/home"
android:layout_width="80dip"
android:layout_height="match_parent"
diff --git a/packages/SystemUI/res/values-xlarge/styles.xml b/packages/SystemUI/res/values-xlarge/styles.xml
index fb10a24..c1cd533 100644
--- a/packages/SystemUI/res/values-xlarge/styles.xml
+++ b/packages/SystemUI/res/values-xlarge/styles.xml
@@ -39,6 +39,7 @@
<item name="android:layout_weight">1</item>
<item name="android:layout_gravity">left|center_vertical</item>
<item name="android:textColor">?android:attr/textColorPrimary</item>
+ <item name="android:textSize">18sp</item>
</style>
<style name="StatusBarPanelSettingsPanelSeparator">
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
index 37939df..76aa793 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
@@ -82,7 +82,7 @@
public void animateCollapse();
public void setLightsOn(boolean on);
public void setMenuKeyVisible(boolean visible);
- public void setIMEButtonVisible(IBinder token, boolean visible);
+ public void setImeWindowStatus(IBinder token, int vis, int backDisposition);
}
public CommandQueue(Callbacks callbacks, StatusBarIconList list) {
@@ -165,10 +165,11 @@
}
}
- public void setIMEButtonVisible(IBinder token, boolean visible) {
+ public void setImeWindowStatus(IBinder token, int vis, int backDisposition) {
synchronized (mList) {
mHandler.removeMessages(MSG_SHOW_IME_BUTTON);
- mHandler.obtainMessage(MSG_SHOW_IME_BUTTON, visible ? 1 : 0, 0, token).sendToTarget();
+ mHandler.obtainMessage(MSG_SHOW_IME_BUTTON, vis, backDisposition, token)
+ .sendToTarget();
}
}
@@ -233,7 +234,7 @@
mCallbacks.setMenuKeyVisible(msg.arg1 != 0);
break;
case MSG_SHOW_IME_BUTTON:
- mCallbacks.setIMEButtonVisible((IBinder)msg.obj, msg.arg1 != 0);
+ mCallbacks.setImeWindowStatus((IBinder)msg.obj, msg.arg1, msg.arg2);
break;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java
index 8fca759..da8e831 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java
@@ -67,7 +67,7 @@
mCommandQueue = new CommandQueue(this, iconList);
mBarService = IStatusBarService.Stub.asInterface(
ServiceManager.getService(Context.STATUS_BAR_SERVICE));
- int[] switches = new int[4];
+ int[] switches = new int[5];
ArrayList<IBinder> binders = new ArrayList<IBinder>();
try {
mBarService.registerStatusBar(mCommandQueue, iconList, notificationKeys, notifications,
@@ -80,7 +80,7 @@
setLightsOn(switches[1] != 0);
setMenuKeyVisible(switches[2] != 0);
// StatusBarManagerService has a back up of IME token and it's restored here.
- setIMEButtonVisible(binders.get(0), switches[3] != 0);
+ setImeWindowStatus(binders.get(0), switches[3], switches[4]);
// Set up the initial icon state
int N = iconList.size();
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 132433b..9505391 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -1020,7 +1020,7 @@
// Not supported
public void setMenuKeyVisible(boolean visible) { }
- public void setIMEButtonVisible(IBinder token, boolean visible) { }
+ public void setImeWindowStatus(IBinder token, int vis, int backDisposition) { }
private class Launcher implements View.OnClickListener {
private PendingIntent mIntent;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodButton.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodButton.java
index 28f485c..f131111 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodButton.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodButton.java
@@ -53,7 +53,7 @@
private final int mId;
private ImageView mIcon;
private IBinder mToken;
- private boolean mKeyboardVisible = false;
+ private boolean mShowButton = false;
private boolean mScreenLocked = false;
private InputMethodInfo mShortcutInfo;
private InputMethodSubtype mShortcutSubtype;
@@ -144,7 +144,7 @@
// * There are no explicitly enabled (by the user) subtypes of the IME, or the IME doesn't have
// its subtypes at all
private boolean needsToShowIMEButton() {
- if (!mKeyboardVisible || mScreenLocked) return false;
+ if (!mShowButton || mScreenLocked) return false;
List<InputMethodInfo> imis = mImm.getEnabledInputMethodList();
final int size = imis.size();
final int visibility = loadInputMethodSelectorVisibility();
@@ -194,9 +194,9 @@
}
}
- public void setIMEButtonVisible(IBinder token, boolean keyboardVisible) {
+ public void setImeWindowStatus(IBinder token, boolean showButton) {
mToken = token;
- mKeyboardVisible = keyboardVisible;
+ mShowButton = showButton;
refreshStatusIcon();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
index eaa5cc9..6c8a20d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
@@ -33,6 +33,7 @@
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.inputmethodservice.InputMethodService;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
@@ -367,8 +368,8 @@
(ImageView)sb.findViewById(R.id.network_type));
// The navigation buttons
+ mBackButton = (ImageView)sb.findViewById(R.id.back);
mNavigationArea = sb.findViewById(R.id.navigationArea);
- mBackButton = (ImageView)mNavigationArea.findViewById(R.id.back);
mHomeButton = mNavigationArea.findViewById(R.id.home);
mMenuButton = mNavigationArea.findViewById(R.id.menu);
mRecentButton = mNavigationArea.findViewById(R.id.recent_apps);
@@ -792,6 +793,18 @@
mInputMethodSwitchButton.setScreenLocked(false);
}
}
+ if ((diff & StatusBarManager.DISABLE_BACK) != 0) {
+ if ((state & StatusBarManager.DISABLE_BACK) != 0) {
+ Slog.i(TAG, "DISABLE_BACK: yes");
+ mBackButton.setVisibility(View.INVISIBLE);
+ mInputMethodSwitchButton.setScreenLocked(true);
+ } else {
+ Slog.i(TAG, "DISABLE_BACK: no");
+ mBackButton.setVisibility(View.VISIBLE);
+ mInputMethodSwitchButton.setScreenLocked(false);
+ }
+ }
+
}
private boolean hasTicker(Notification n) {
@@ -863,17 +876,32 @@
if (visible) setLightsOn(true);
}
- public void setIMEButtonVisible(IBinder token, boolean visible) {
- if (DEBUG) {
- Slog.d(TAG, (visible?"showing":"hiding") + " the IME button");
- }
- mInputMethodSwitchButton.setIMEButtonVisible(token, visible);
+ public void setImeWindowStatus(IBinder token, int vis, int backDisposition) {
+ mInputMethodSwitchButton.setImeWindowStatus(token,
+ (vis & InputMethodService.IME_ACTIVE) != 0);
updateNotificationIcons();
mInputMethodsPanel.setImeToken(token);
- mBackButton.setImageResource(
- visible ? R.drawable.ic_sysbar_back_ime : R.drawable.ic_sysbar_back);
+ int res;
+ switch (backDisposition) {
+ case InputMethodService.BACK_DISPOSITION_WILL_NOT_DISMISS:
+ res = R.drawable.ic_sysbar_back;
+ break;
+ case InputMethodService.BACK_DISPOSITION_WILL_DISMISS:
+ res = R.drawable.ic_sysbar_back_ime;
+ break;
+ case InputMethodService.BACK_DISPOSITION_DEFAULT:
+ default:
+ if ((vis & InputMethodService.IME_VISIBLE) != 0) {
+ res = R.drawable.ic_sysbar_back_ime;
+ } else {
+ res = R.drawable.ic_sysbar_back;
+ }
+ break;
+ }
+ mBackButton.setImageResource(res);
if (FAKE_SPACE_BAR) {
- mFakeSpaceBar.setVisibility(visible ? View.VISIBLE : View.GONE);
+ mFakeSpaceBar.setVisibility(((vis & InputMethodService.IME_VISIBLE) != 0)
+ ? View.VISIBLE : View.GONE);
}
}
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewBase.java b/policy/src/com/android/internal/policy/impl/KeyguardViewBase.java
index 6b52454..36afd75 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardViewBase.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardViewBase.java
@@ -50,6 +50,8 @@
public KeyguardViewBase(Context context) {
super(context);
+ setSystemUiVisibility(STATUS_BAR_DISABLE_BACK);
+
// This is a faster way to draw the background on devices without hardware acceleration
setBackgroundDrawable(new Drawable() {
@Override
@@ -235,4 +237,9 @@
return false;
}
+ @Override
+ public void dispatchSystemUiVisibilityChanged(int visibility) {
+ super.dispatchSystemUiVisibilityChanged(visibility);
+ setSystemUiVisibility(STATUS_BAR_DISABLE_BACK);
+ }
}
diff --git a/policy/src/com/android/internal/policy/impl/StatusView.java b/policy/src/com/android/internal/policy/impl/StatusView.java
index 1732adb..da7bbb8 100644
--- a/policy/src/com/android/internal/policy/impl/StatusView.java
+++ b/policy/src/com/android/internal/policy/impl/StatusView.java
@@ -19,10 +19,10 @@
import android.widget.TextView;
class StatusView {
- public static final int LOCK_ICON = R.drawable.ic_lock_idle_lock;
- public static final int ALARM_ICON = R.drawable.ic_lock_idle_alarm;
- public static final int CHARGING_ICON = R.drawable.ic_lock_idle_charging;
- public static final int BATTERY_LOW_ICON = R.drawable.ic_lock_idle_low_battery;
+ public static final int LOCK_ICON = 0; // R.drawable.ic_lock_idle_lock;
+ public static final int ALARM_ICON = 0; // R.drawable.ic_lock_idle_alarm;
+ public static final int CHARGING_ICON = 0; //R.drawable.ic_lock_idle_charging;
+ public static final int BATTERY_LOW_ICON = 0; //R.drawable.ic_lock_idle_low_battery;
private String mDateFormatString;
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java
index 0147b1a..8d6d3a1 100644
--- a/services/java/com/android/server/InputMethodManagerService.java
+++ b/services/java/com/android/server/InputMethodManagerService.java
@@ -49,6 +49,7 @@
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.database.ContentObserver;
+import android.inputmethodservice.InputMethodService;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
@@ -311,6 +312,9 @@
*/
boolean mScreenOn = true;
+ int mBackDisposition = InputMethodService.BACK_DISPOSITION_DEFAULT;
+ int mImeWindowVis;
+
AlertDialog.Builder mDialogBuilder;
AlertDialog mSwitchingDialog;
InputMethodInfo[] mIms;
@@ -430,7 +434,9 @@
// Uh oh, current input method is no longer around!
// Pick another one...
Slog.i(TAG, "Current input method removed: " + curInputMethodId);
- mStatusBar.setIMEButtonVisible(mCurToken, false);
+ mImeWindowVis = 0;
+ mStatusBar.setImeWindowStatus(mCurToken, mImeWindowVis,
+ mBackDisposition);
if (!chooseNewDefaultIMELocked()) {
changed = true;
curIm = null;
@@ -982,17 +988,19 @@
}
}
- public void setIMEButtonVisible(IBinder token, boolean visible) {
+ public void setImeWindowStatus(IBinder token, int vis, int backDisposition) {
int uid = Binder.getCallingUid();
long ident = Binder.clearCallingIdentity();
try {
if (token == null || mCurToken != token) {
- Slog.w(TAG, "Ignoring setIMEButtonVisible of uid " + uid + " token: " + token);
+ Slog.w(TAG, "Ignoring setImeWindowStatus of uid " + uid + " token: " + token);
return;
}
synchronized (mMethodMap) {
- mStatusBar.setIMEButtonVisible(token, visible);
+ mImeWindowVis = vis;
+ mBackDisposition = backDisposition;
+ mStatusBar.setImeWindowStatus(token, vis, backDisposition);
}
} finally {
Binder.restoreCallingIdentity(ident);
@@ -1045,12 +1053,9 @@
}
if (mCurMethod != null) {
try {
- if (mInputShown) {
- // If mInputShown is false, there is no IME button on the
- // system bar.
- // Thus there is no need to make it invisible explicitly.
- mStatusBar.setIMEButtonVisible(mCurToken, true);
- }
+ mImeWindowVis = 0;
+ mStatusBar.setImeWindowStatus(mCurToken, mImeWindowVis,
+ mBackDisposition);
// If subtype is null, try to find the most applicable one from
// getCurrentInputMethodSubtype.
if (subtype == null) {
@@ -1168,11 +1173,14 @@
if (!mIWindowManager.inputMethodClientHasFocus(client)) {
if (DEBUG) Slog.w(TAG, "Ignoring hideSoftInput of uid "
+ uid + ": " + client);
- mStatusBar.setIMEButtonVisible(mCurToken, false);
+ mImeWindowVis = 0;
+ mStatusBar.setImeWindowStatus(mCurToken, mImeWindowVis,
+ mBackDisposition);
return false;
}
} catch (RemoteException e) {
- mStatusBar.setIMEButtonVisible(mCurToken, false);
+ mImeWindowVis = 0;
+ mStatusBar.setImeWindowStatus(mCurToken, mImeWindowVis, mBackDisposition);
return false;
}
}
diff --git a/services/java/com/android/server/IntentResolver.java b/services/java/com/android/server/IntentResolver.java
index a8b2840..e9ee12c 100644
--- a/services/java/com/android/server/IntentResolver.java
+++ b/services/java/com/android/server/IntentResolver.java
@@ -27,6 +27,8 @@
import java.util.Map;
import java.util.Set;
+import android.net.Uri;
+import android.util.FastImmutableArraySet;
import android.util.Log;
import android.util.PrintWriterPrinter;
import android.util.Slog;
@@ -207,10 +209,11 @@
final boolean debug = localLOGV ||
((intent.getFlags() & Intent.FLAG_DEBUG_LOG_RESOLUTION) != 0);
+ FastImmutableArraySet<String> categories = getFastIntentCategories(intent);
final String scheme = intent.getScheme();
int N = listCut.size();
for (int i = 0; i < N; ++i) {
- buildResolveList(intent, debug, defaultOnly,
+ buildResolveList(intent, categories, debug, defaultOnly,
resolvedType, scheme, listCut.get(i), resultList);
}
sortResults(resultList);
@@ -286,20 +289,21 @@
if (debug) Slog.v(TAG, "Action list: " + firstTypeCut);
}
+ FastImmutableArraySet<String> categories = getFastIntentCategories(intent);
if (firstTypeCut != null) {
- buildResolveList(intent, debug, defaultOnly,
+ buildResolveList(intent, categories, debug, defaultOnly,
resolvedType, scheme, firstTypeCut, finalList);
}
if (secondTypeCut != null) {
- buildResolveList(intent, debug, defaultOnly,
+ buildResolveList(intent, categories, debug, defaultOnly,
resolvedType, scheme, secondTypeCut, finalList);
}
if (thirdTypeCut != null) {
- buildResolveList(intent, debug, defaultOnly,
+ buildResolveList(intent, categories, debug, defaultOnly,
resolvedType, scheme, thirdTypeCut, finalList);
}
if (schemeCut != null) {
- buildResolveList(intent, debug, defaultOnly,
+ buildResolveList(intent, categories, debug, defaultOnly,
resolvedType, scheme, schemeCut, finalList);
}
sortResults(finalList);
@@ -478,9 +482,19 @@
return false;
}
- private void buildResolveList(Intent intent, boolean debug, boolean defaultOnly,
+ private static FastImmutableArraySet<String> getFastIntentCategories(Intent intent) {
+ final Set<String> categories = intent.getCategories();
+ if (categories == null) {
+ return null;
+ }
+ return new FastImmutableArraySet<String>(categories.toArray(new String[categories.size()]));
+ }
+
+ private void buildResolveList(Intent intent, FastImmutableArraySet<String> categories,
+ boolean debug, boolean defaultOnly,
String resolvedType, String scheme, List<F> src, List<R> dest) {
- Set<String> categories = intent.getCategories();
+ final String action = intent.getAction();
+ final Uri data = intent.getData();
final int N = src != null ? src.size() : 0;
boolean hasNonDefaults = false;
@@ -498,8 +512,7 @@
continue;
}
- match = filter.match(
- intent.getAction(), resolvedType, scheme, intent.getData(), categories, TAG);
+ match = filter.match(action, resolvedType, scheme, data, categories, TAG);
if (match >= 0) {
if (debug) Slog.v(TAG, " Filter matched! match=0x" +
Integer.toHexString(match));
diff --git a/services/java/com/android/server/StatusBarManagerService.java b/services/java/com/android/server/StatusBarManagerService.java
index bdaa3b0..1a2f867 100644
--- a/services/java/com/android/server/StatusBarManagerService.java
+++ b/services/java/com/android/server/StatusBarManagerService.java
@@ -67,14 +67,16 @@
// for disabling the status bar
ArrayList<DisableRecord> mDisableRecords = new ArrayList<DisableRecord>();
+ IBinder mSysUiVisToken = new Binder();
int mDisabled = 0;
Object mLock = new Object();
// We usually call it lights out mode, but double negatives are annoying
boolean mLightsOn = true;
boolean mMenuVisible = false;
- boolean mIMEButtonVisible = false;
- IBinder mIMEToken = null;
+ int mImeWindowVis = 0;
+ int mImeBackDisposition;
+ IBinder mImeToken = null;
private class DisableRecord implements IBinder.DeathRecipient {
String pkg;
@@ -140,25 +142,29 @@
public void disable(int what, IBinder token, String pkg) {
enforceStatusBar();
+ synchronized (mLock) {
+ disableLocked(what, token, pkg);
+ }
+ }
+
+ private void disableLocked(int what, IBinder token, String pkg) {
// It's important that the the callback and the call to mBar get done
// in the same order when multiple threads are calling this function
// so they are paired correctly. The messages on the handler will be
// handled in the order they were enqueued, but will be outside the lock.
- synchronized (mDisableRecords) {
- manageDisableListLocked(what, token, pkg);
- final int net = gatherDisableActionsLocked();
- if (net != mDisabled) {
- mDisabled = net;
- mHandler.post(new Runnable() {
- public void run() {
- mNotificationCallbacks.onSetDisabled(net);
- }
- });
- if (mBar != null) {
- try {
- mBar.disable(net);
- } catch (RemoteException ex) {
+ manageDisableListLocked(what, token, pkg);
+ final int net = gatherDisableActionsLocked();
+ if (net != mDisabled) {
+ mDisabled = net;
+ mHandler.post(new Runnable() {
+ public void run() {
+ mNotificationCallbacks.onSetDisabled(net);
}
+ });
+ if (mBar != null) {
+ try {
+ mBar.disable(net);
+ } catch (RemoteException ex) {
}
}
}
@@ -259,22 +265,25 @@
}
}
- public void setIMEButtonVisible(final IBinder token, final boolean visible) {
+ public void setImeWindowStatus(final IBinder token, final int vis, final int backDisposition) {
enforceStatusBar();
- if (SPEW) Slog.d(TAG, (visible?"showing":"hiding") + " IME Button");
+ if (SPEW) {
+ Slog.d(TAG, "swetImeWindowStatus vis=" + vis + " backDisposition=" + backDisposition);
+ }
synchronized(mLock) {
- // In case of IME change, we need to call up setIMEButtonVisible() regardless of
- // mIMEButtonVisible because mIMEButtonVisible may not have been set to false when the
+ // In case of IME change, we need to call up setImeWindowStatus() regardless of
+ // mImeWindowVis because mImeWindowVis may not have been set to false when the
// previous IME was destroyed.
- mIMEButtonVisible = visible;
- mIMEToken = token;
+ mImeWindowVis = vis;
+ mImeBackDisposition = backDisposition;
+ mImeToken = token;
mHandler.post(new Runnable() {
public void run() {
if (mBar != null) {
try {
- mBar.setIMEButtonVisible(token, visible);
+ mBar.setImeWindowStatus(token, vis, backDisposition);
} catch (RemoteException ex) {
}
}
@@ -290,6 +299,8 @@
synchronized (mLock) {
final boolean lightsOn = (vis & View.STATUS_BAR_HIDDEN) == 0;
updateLightsOnLocked(lightsOn);
+ disableLocked(vis & StatusBarManager.DISABLE_MASK, mSysUiVisToken,
+ "WindowManager.LayoutParams");
}
}
@@ -348,8 +359,9 @@
switches[0] = gatherDisableActionsLocked();
switches[1] = mLightsOn ? 1 : 0;
switches[2] = mMenuVisible ? 1 : 0;
- switches[3] = mIMEButtonVisible ? 1 : 0;
- binders.add(mIMEToken);
+ switches[3] = mImeWindowVis;
+ switches[4] = mImeBackDisposition;
+ binders.add(mImeToken);
}
}
@@ -447,37 +459,35 @@
Slog.d(TAG, "manageDisableList what=0x" + Integer.toHexString(what) + " pkg=" + pkg);
}
// update the list
- synchronized (mDisableRecords) {
- final int N = mDisableRecords.size();
- DisableRecord tok = null;
- int i;
- for (i=0; i<N; i++) {
- DisableRecord t = mDisableRecords.get(i);
- if (t.token == token) {
- tok = t;
- break;
- }
+ final int N = mDisableRecords.size();
+ DisableRecord tok = null;
+ int i;
+ for (i=0; i<N; i++) {
+ DisableRecord t = mDisableRecords.get(i);
+ if (t.token == token) {
+ tok = t;
+ break;
}
- if (what == 0 || !token.isBinderAlive()) {
- if (tok != null) {
- mDisableRecords.remove(i);
- tok.token.unlinkToDeath(tok, 0);
- }
- } else {
- if (tok == null) {
- tok = new DisableRecord();
- try {
- token.linkToDeath(tok, 0);
- }
- catch (RemoteException ex) {
- return; // give up
- }
- mDisableRecords.add(tok);
- }
- tok.what = what;
- tok.token = token;
- tok.pkg = pkg;
+ }
+ if (what == 0 || !token.isBinderAlive()) {
+ if (tok != null) {
+ mDisableRecords.remove(i);
+ tok.token.unlinkToDeath(tok, 0);
}
+ } else {
+ if (tok == null) {
+ tok = new DisableRecord();
+ try {
+ token.linkToDeath(tok, 0);
+ }
+ catch (RemoteException ex) {
+ return; // give up
+ }
+ mDisableRecords.add(tok);
+ }
+ tok.what = what;
+ tok.token = token;
+ tok.pkg = pkg;
}
}
@@ -518,7 +528,7 @@
}
}
- synchronized (mDisableRecords) {
+ synchronized (mLock) {
final int N = mDisableRecords.size();
pw.println(" mDisableRecords.size=" + N
+ " mDisabled=0x" + Integer.toHexString(mDisabled));
diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java
index 04f4e4e7..5e78353 100644
--- a/services/java/com/android/server/WifiService.java
+++ b/services/java/com/android/server/WifiService.java
@@ -890,10 +890,10 @@
* @see #shouldDeviceStayAwake(int, int)
*/
private boolean shouldWifiStayAwake(int stayAwakeConditions, int pluggedType) {
- //Never sleep when plugged in as long as the user has not changed the settings
+ //Never sleep as long as the user has not changed the settings
int wifiSleepPolicy = Settings.System.getInt(mContext.getContentResolver(),
Settings.System.WIFI_SLEEP_POLICY,
- Settings.System.WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED);
+ Settings.System.WIFI_SLEEP_POLICY_NEVER);
if (wifiSleepPolicy == Settings.System.WIFI_SLEEP_POLICY_NEVER) {
// Never sleep
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 6b1dd34..8f2a84e 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -11314,13 +11314,13 @@
mInputMonitor.thawInputDispatchingLw();
+ boolean configChanged;
+
// While the display is frozen we don't re-compute the orientation
// to avoid inconsistent states. However, something interesting
// could have actually changed during that time so re-evaluate it
// now to catch that.
- if (updateOrientationFromAppTokensLocked(false)) {
- mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
- }
+ configChanged = updateOrientationFromAppTokensLocked(false);
// A little kludge: a lot could have happened while the
// display was frozen, so now that we are coming back we
@@ -11335,11 +11335,12 @@
if (updateRotation) {
if (DEBUG_ORIENTATION) Slog.d(TAG, "Performing post-rotate rotation");
- boolean changed = setRotationUncheckedLocked(
+ configChanged |= setRotationUncheckedLocked(
WindowManagerPolicy.USE_LAST_ROTATION, 0, false);
- if (changed) {
- sendNewConfiguration();
- }
+ }
+
+ if (configChanged) {
+ mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
}
}
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 3730739..188686d 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -56,6 +56,8 @@
mNeedsBlending(true),
mNeedsDithering(false),
mSecure(false),
+ mProtectedByApp(false),
+ mProtectedByDRM(false),
mTextureManager(),
mBufferManager(mTextureManager),
mWidth(0), mHeight(0), mNeedsScaling(false), mFixedSize(false)
@@ -191,6 +193,8 @@
mReqHeight = h;
mSecure = (flags & ISurfaceComposer::eSecure) ? true : false;
+ mProtectedByApp = (flags & ISurfaceComposer::eProtectedByApp) ? true : false;
+ mProtectedByDRM = (flags & ISurfaceComposer::eProtectedByDRM) ? true : false;
mNeedsBlending = (info.h_alpha - info.l_alpha) > 0 &&
(flags & ISurfaceComposer::eOpaque) == 0;
@@ -476,6 +480,10 @@
// request EGLImage for all buffers
usage |= GraphicBuffer::USAGE_HW_TEXTURE;
}
+ if (mProtectedByApp || mProtectedByDRM) {
+ // need a hardware-protected path to external video sink
+ usage |= GraphicBuffer::USAGE_PROTECTED;
+ }
return usage;
}
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 2908119..d9a8be3 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -79,6 +79,8 @@
virtual bool needsDithering() const { return mNeedsDithering; }
virtual bool needsFiltering() const;
virtual bool isSecure() const { return mSecure; }
+ virtual bool isProtectedByApp() const { return mProtectedByApp; }
+ virtual bool isProtectedByDRM() const { return mProtectedByDRM; }
virtual sp<Surface> createSurface() const;
virtual status_t ditch();
virtual void onRemoved();
@@ -218,7 +220,9 @@
bool mNeedsDithering;
// page-flip thread (currently main thread)
- bool mSecure;
+ bool mSecure; // no screenshots
+ bool mProtectedByApp; // application requires protected path to external sink
+ bool mProtectedByDRM; // DRM agent requires protected path to external sink
Region mPostedDirtyRegion;
// page-flip thread and transaction thread (currently main thread)
diff --git a/services/surfaceflinger/LayerBase.h b/services/surfaceflinger/LayerBase.h
index 8ed4749..184edd7 100644
--- a/services/surfaceflinger/LayerBase.h
+++ b/services/surfaceflinger/LayerBase.h
@@ -196,6 +196,18 @@
*/
virtual bool isSecure() const { return false; }
+ /**
+ * isProtectedByApp - true if application says this surface is protected, that
+ * is if it requires a hardware-protected data path to an external sink.
+ */
+ virtual bool isProtectedByApp() const { return false; }
+
+ /**
+ * isProtectedByDRM - true if DRM agent says this surface is protected, that
+ * is if it requires a hardware-protected data path to an external sink.
+ */
+ virtual bool isProtectedByDRM() const { return false; }
+
/** Called from the main thread, when the surface is removed from the
* draw list */
virtual status_t ditch() { return NO_ERROR; }
diff --git a/services/surfaceflinger/LayerDim.h b/services/surfaceflinger/LayerDim.h
index f032314..a04a0c0 100644
--- a/services/surfaceflinger/LayerDim.h
+++ b/services/surfaceflinger/LayerDim.h
@@ -42,8 +42,10 @@
virtual ~LayerDim();
virtual void onDraw(const Region& clip) const;
- virtual bool needsBlending() const { return true; }
- virtual bool isSecure() const { return false; }
+ virtual bool needsBlending() const { return true; }
+ virtual bool isSecure() const { return false; }
+ virtual bool isProtectedByApp() const { return false; }
+ virtual bool isProtectedByDRM() const { return false; }
virtual const char* getTypeId() const { return "LayerDim"; }
static void initDimmer(SurfaceFlinger* flinger, uint32_t w, uint32_t h);
diff --git a/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java b/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java
index 5fd946e..13665e1 100644
--- a/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java
+++ b/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java
@@ -70,6 +70,12 @@
}
private Test[] mTests = new Test[] {
+ new Test("DISABLE_NAVIGATION") {
+ public void run() {
+ View v = findViewById(android.R.id.list);
+ v.setSystemUiVisibility(View.STATUS_BAR_DISABLE_NAVIGATION);
+ }
+ },
new Test("STATUS_BAR_HIDDEN") {
public void run() {
View v = findViewById(android.R.id.list);
@@ -77,7 +83,7 @@
v.setOnSystemUiVisibilityChangeListener(mOnSystemUiVisibilityChangeListener);
}
},
- new Test("not STATUS_BAR_HIDDEN") {
+ new Test("no setSystemUiVisibility") {
public void run() {
View v = findViewById(android.R.id.list);
v.setSystemUiVisibility(View.STATUS_BAR_VISIBLE);
diff --git a/tools/layoutlib/bridge/.classpath b/tools/layoutlib/bridge/.classpath
index 64c1fb5..2eaf8e3 100644
--- a/tools/layoutlib/bridge/.classpath
+++ b/tools/layoutlib/bridge/.classpath
@@ -8,6 +8,6 @@
<classpathentry kind="var" path="ANDROID_PLAT_SRC/prebuilt/common/kxml2/kxml2-2.3.0.jar" sourcepath="/ANDROID_PLAT_SRC/dalvik/libcore/xml/src/main/java"/>
<classpathentry kind="var" path="ANDROID_PLAT_SRC/out/host/common/obj/JAVA_LIBRARIES/temp_layoutlib_intermediates/javalib.jar" sourcepath="/ANDROID_PLAT_SRC/frameworks/base"/>
<classpathentry kind="var" path="ANDROID_PLAT_SRC/prebuilt/common/ninepatch/ninepatch-prebuilt.jar"/>
- <classpathentry kind="var" path="ANDROID_PLAT_SRC/prebuilt/common/resources/resources-prebuilt.jar"/>
+ <classpathentry kind="var" path="ANDROID_PLAT_SRC/prebuilt/common/common/common-prebuilt.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/tools/layoutlib/bridge/Android.mk b/tools/layoutlib/bridge/Android.mk
index 57dd7ae..3d4c76a 100644
--- a/tools/layoutlib/bridge/Android.mk
+++ b/tools/layoutlib/bridge/Android.mk
@@ -21,7 +21,7 @@
LOCAL_JAVA_LIBRARIES := \
kxml2-2.3.0 \
layoutlib_api-prebuilt \
- resources-prebuilt
+ common-prebuilt
LOCAL_STATIC_JAVA_LIBRARIES := \
temp_layoutlib \
diff --git a/tools/layoutlib/bridge/src/android/graphics/Gradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Gradient_Delegate.java
index 7a0c2f7..38c092d 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Gradient_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Gradient_Delegate.java
@@ -95,7 +95,7 @@
* Pre-computes the colors for the gradient. This must be called once before any call
* to {@link #getGradientColor(float)}
*/
- protected synchronized void precomputeGradientColors() {
+ protected void precomputeGradientColors() {
if (mGradient == null) {
// actually create an array with an extra size, so that we can really go
// from 0 to SIZE (100%), or currentPos in the loop below will never equal 1.0
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
index bd52dc2..93c81d1 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
@@ -28,8 +28,10 @@
import com.android.layoutlib.bridge.impl.FontLoader;
import com.android.layoutlib.bridge.impl.RenderSessionImpl;
import com.android.ninepatch.NinePatchChunk;
+import com.android.resources.ResourceType;
import com.android.tools.layoutlib.create.MethodAdapter;
import com.android.tools.layoutlib.create.OverrideMethod;
+import com.android.util.Pair;
import android.graphics.Bitmap;
import android.graphics.Typeface;
@@ -41,6 +43,7 @@
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Arrays;
+import java.util.EnumMap;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
@@ -68,9 +71,11 @@
private final static ReentrantLock sLock = new ReentrantLock();
/**
- * Maps from id to resource name/type. This is for android.R only.
+ * Maps from id to resource type/name. This is for android.R only.
*/
- private final static Map<Integer, String[]> sRMap = new HashMap<Integer, String[]>();
+ private final static Map<Integer, Pair<ResourceType, String>> sRMap =
+ new HashMap<Integer, Pair<ResourceType, String>>();
+
/**
* Same as sRMap except for int[] instead of int resources. This is for android.R only.
*/
@@ -79,8 +84,8 @@
* Reverse map compared to sRMap, resource type -> (resource name -> id).
* This is for android.R only.
*/
- private final static Map<String, Map<String, Integer>> sRFullMap =
- new HashMap<String, Map<String,Integer>>();
+ private final static Map<ResourceType, Map<String, Integer>> sRFullMap =
+ new EnumMap<ResourceType, Map<String,Integer>>(ResourceType.class);
private final static Map<Object, Map<String, SoftReference<Bitmap>>> sProjectBitmapCache =
new HashMap<Object, Map<String, SoftReference<Bitmap>>>();
@@ -130,7 +135,7 @@
}
}
- /** Instance of IntArrayWrapper to be reused in {@link #resolveResourceValue(int[])}. */
+ /** Instance of IntArrayWrapper to be reused in {@link #resolveResourceId(int[])}. */
private final static IntArray sIntArrayWrapper = new IntArray();
/**
@@ -236,28 +241,30 @@
Class<?> r = com.android.internal.R.class;
for (Class<?> inner : r.getDeclaredClasses()) {
- String resType = inner.getSimpleName();
+ String resTypeName = inner.getSimpleName();
+ ResourceType resType = ResourceType.getEnum(resTypeName);
+ if (resType != null) {
+ Map<String, Integer> fullMap = new HashMap<String, Integer>();
+ sRFullMap.put(resType, fullMap);
- Map<String, Integer> fullMap = new HashMap<String, Integer>();
- sRFullMap.put(resType, fullMap);
-
- for (Field f : inner.getDeclaredFields()) {
- // only process static final fields. Since the final attribute may have
- // been altered by layoutlib_create, we only check static
- int modifiers = f.getModifiers();
- if (Modifier.isStatic(modifiers)) {
- Class<?> type = f.getType();
- if (type.isArray() && type.getComponentType() == int.class) {
- // if the object is an int[] we put it in sRArrayMap using an IntArray
- // wrapper that properly implements equals and hashcode for the array
- // objects, as required by the map contract.
- sRArrayMap.put(new IntArray((int[]) f.get(null)), f.getName());
- } else if (type == int.class) {
- Integer value = (Integer) f.get(null);
- sRMap.put(value, new String[] { f.getName(), resType });
- fullMap.put(f.getName(), value);
- } else {
- assert false;
+ for (Field f : inner.getDeclaredFields()) {
+ // only process static final fields. Since the final attribute may have
+ // been altered by layoutlib_create, we only check static
+ int modifiers = f.getModifiers();
+ if (Modifier.isStatic(modifiers)) {
+ Class<?> type = f.getType();
+ if (type.isArray() && type.getComponentType() == int.class) {
+ // if the object is an int[] we put it in sRArrayMap using an IntArray
+ // wrapper that properly implements equals and hashcode for the array
+ // objects, as required by the map contract.
+ sRArrayMap.put(new IntArray((int[]) f.get(null)), f.getName());
+ } else if (type == int.class) {
+ Integer value = (Integer) f.get(null);
+ sRMap.put(value, Pair.of(resType, f.getName()));
+ fullMap.put(f.getName(), value);
+ } else {
+ assert false;
+ }
}
}
}
@@ -388,10 +395,10 @@
/**
* Returns details of a framework resource from its integer value.
* @param value the integer value
- * @return an array of 2 strings containing the resource name and type, or null if the id
- * does not match any resource.
+ * @return a Pair containing the resource type and name, or null if the id
+ * does not match any resource.
*/
- public static String[] resolveResourceValue(int value) {
+ public static Pair<ResourceType, String> resolveResourceId(int value) {
return sRMap.get(value);
}
@@ -399,7 +406,7 @@
* Returns the name of a framework resource whose value is an int array.
* @param array
*/
- public static String resolveResourceValue(int[] array) {
+ public static String resolveResourceId(int[] array) {
sIntArrayWrapper.set(array);
return sRArrayMap.get(sIntArrayWrapper);
}
@@ -410,7 +417,7 @@
* @param name the name of the resource.
* @return an {@link Integer} containing the resource id, or null if no resource were found.
*/
- public static Integer getResourceValue(String type, String name) {
+ public static Integer getResourceId(ResourceType type, String name) {
Map<String, Integer> map = sRFullMap.get(type);
if (map != null) {
return map.get(name);
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
index 79264d0..037ad23 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
@@ -24,6 +24,8 @@
import com.android.layoutlib.bridge.Bridge;
import com.android.layoutlib.bridge.BridgeConstants;
import com.android.layoutlib.bridge.impl.Stack;
+import com.android.resources.ResourceType;
+import com.android.util.Pair;
import android.app.Activity;
import android.app.Fragment;
@@ -517,14 +519,14 @@
*/
private TreeMap<Integer,String> searchAttrs(int[] attrs, boolean[] outFrameworkFlag) {
// get the name of the array from the framework resources
- String arrayName = Bridge.resolveResourceValue(attrs);
+ String arrayName = Bridge.resolveResourceId(attrs);
if (arrayName != null) {
// if we found it, get the name of each of the int in the array.
TreeMap<Integer,String> attributes = new TreeMap<Integer, String>();
for (int i = 0 ; i < attrs.length ; i++) {
- String[] info = Bridge.resolveResourceValue(attrs[i]);
+ Pair<ResourceType, String> info = Bridge.resolveResourceId(attrs[i]);
if (info != null) {
- attributes.put(i, info[0]);
+ attributes.put(i, info.getSecond());
} else {
// FIXME Not sure what we should be doing here...
attributes.put(i, null);
@@ -540,13 +542,13 @@
// if the name was not found in the framework resources, look in the project
// resources
- arrayName = mProjectCallback.resolveResourceValue(attrs);
+ arrayName = mProjectCallback.resolveResourceId(attrs);
if (arrayName != null) {
TreeMap<Integer,String> attributes = new TreeMap<Integer, String>();
for (int i = 0 ; i < attrs.length ; i++) {
- String[] info = mProjectCallback.resolveResourceValue(attrs[i]);
+ Pair<ResourceType, String> info = mProjectCallback.resolveResourceId(attrs[i]);
if (info != null) {
- attributes.put(i, info[0]);
+ attributes.put(i, info.getSecond());
} else {
// FIXME Not sure what we should be doing here...
attributes.put(i, null);
@@ -571,14 +573,14 @@
* if nothing is found.
*/
public String searchAttr(int attr) {
- String[] info = Bridge.resolveResourceValue(attr);
+ Pair<ResourceType, String> info = Bridge.resolveResourceId(attr);
if (info != null) {
- return info[0];
+ return info.getSecond();
}
- info = mProjectCallback.resolveResourceValue(attr);
+ info = mProjectCallback.resolveResourceId(attr);
if (info != null) {
- return info[0];
+ return info.getSecond();
}
return null;
@@ -614,8 +616,8 @@
return null;
}
- int getFrameworkResourceValue(String resType, String resName, int defValue) {
- Integer value = Bridge.getResourceValue(resType, resName);
+ int getFrameworkResourceValue(ResourceType resType, String resName, int defValue) {
+ Integer value = Bridge.getResourceId(resType, resName);
if (value != null) {
return value.intValue();
}
@@ -623,9 +625,9 @@
return defValue;
}
- int getProjectResourceValue(String resType, String resName, int defValue) {
+ int getProjectResourceValue(ResourceType resType, String resName, int defValue) {
if (mProjectCallback != null) {
- Integer value = mProjectCallback.getResourceValue(resType, resName);
+ Integer value = mProjectCallback.getResourceId(resType, resName);
if (value != null) {
return value.intValue();
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java
index 465bf1d..5740e8b 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java
@@ -19,9 +19,10 @@
import com.android.ide.common.rendering.api.IProjectCallback;
import com.android.ide.common.rendering.api.LayoutLog;
import com.android.ide.common.rendering.api.MergeCookie;
-import com.android.ide.common.rendering.api.RenderResources;
import com.android.ide.common.rendering.api.ResourceValue;
import com.android.layoutlib.bridge.Bridge;
+import com.android.resources.ResourceType;
+import com.android.util.Pair;
import org.kxml2.io.KXmlParser;
import org.xmlpull.v1.XmlPullParser;
@@ -155,16 +156,16 @@
ResourceValue value = null;
- String[] layoutInfo = Bridge.resolveResourceValue(resource);
+ Pair<ResourceType, String> layoutInfo = Bridge.resolveResourceId(resource);
if (layoutInfo != null) {
value = bridgeContext.getRenderResources().getFrameworkResource(
- RenderResources.RES_LAYOUT, layoutInfo[0]);
+ ResourceType.LAYOUT, layoutInfo.getSecond());
} else {
- layoutInfo = mProjectCallback.resolveResourceValue(resource);
+ layoutInfo = mProjectCallback.resolveResourceId(resource);
if (layoutInfo != null) {
value = bridgeContext.getRenderResources().getProjectResource(
- RenderResources.RES_LAYOUT, layoutInfo[0]);
+ ResourceType.LAYOUT, layoutInfo.getSecond());
}
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java
index 7b66809..5ea0a8d 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java
@@ -22,6 +22,8 @@
import com.android.layoutlib.bridge.Bridge;
import com.android.layoutlib.bridge.BridgeConstants;
import com.android.layoutlib.bridge.impl.ResourceHelper;
+import com.android.resources.ResourceType;
+import com.android.util.Pair;
import org.kxml2.io.KXmlParser;
import org.xmlpull.v1.XmlPullParser;
@@ -100,22 +102,22 @@
private ResourceValue getResourceValue(int id, boolean[] platformResFlag_out) {
// first get the String related to this id in the framework
- String[] resourceInfo = Bridge.resolveResourceValue(id);
+ Pair<ResourceType, String> resourceInfo = Bridge.resolveResourceId(id);
if (resourceInfo != null) {
platformResFlag_out[0] = true;
return mContext.getRenderResources().getFrameworkResource(
- resourceInfo[1], resourceInfo[0]);
+ resourceInfo.getFirst(), resourceInfo.getSecond());
}
// didn't find a match in the framework? look in the project.
if (mProjectCallback != null) {
- resourceInfo = mProjectCallback.resolveResourceValue(id);
+ resourceInfo = mProjectCallback.resolveResourceId(id);
if (resourceInfo != null) {
platformResFlag_out[0] = false;
return mContext.getRenderResources().getProjectResource(
- resourceInfo[1], resourceInfo[0]);
+ resourceInfo.getFirst(), resourceInfo.getSecond());
}
}
@@ -614,18 +616,18 @@
*/
private void throwException(int id) throws NotFoundException {
// first get the String related to this id in the framework
- String[] resourceInfo = Bridge.resolveResourceValue(id);
+ Pair<ResourceType, String> resourceInfo = Bridge.resolveResourceId(id);
// if the name is unknown in the framework, get it from the custom view loader.
if (resourceInfo == null && mProjectCallback != null) {
- resourceInfo = mProjectCallback.resolveResourceValue(id);
+ resourceInfo = mProjectCallback.resolveResourceId(id);
}
String message = null;
if (resourceInfo != null) {
message = String.format(
"Could not find %1$s resource matching value 0x%2$X (resolved name: %3$s) in current configuration.",
- resourceInfo[1], id, resourceInfo[0]);
+ resourceInfo.getFirst(), id, resourceInfo.getSecond());
} else {
message = String.format(
"Could not resolve resource value: 0x%1$X.", id);
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java
index 8d3c929..cf2c0ff 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java
@@ -24,6 +24,7 @@
import com.android.layoutlib.bridge.Bridge;
import com.android.layoutlib.bridge.BridgeConstants;
import com.android.layoutlib.bridge.impl.ResourceHelper;
+import com.android.resources.ResourceType;
import org.kxml2.io.KXmlParser;
import org.xmlpull.v1.XmlPullParser;
@@ -39,6 +40,7 @@
import java.io.File;
import java.io.FileReader;
+import java.util.Arrays;
import java.util.Map;
/**
@@ -587,17 +589,17 @@
// then the xml attribute value was "resolved" which leads us to a ResourceValue with a
// valid getType() and getName() returning a resource name.
// (and getValue() returning null!). We need to handle this!
- if (resValue.getType() != null && resValue.getType().startsWith("@+") == false) {
+ if (resValue.getResourceType() != null) {
// if this is a framework id
if (mPlatformFile || resValue.isFramework()) {
// look for idName in the android R classes
return mContext.getFrameworkResourceValue(
- resValue.getType(), resValue.getName(), defValue);
+ resValue.getResourceType(), resValue.getName(), defValue);
}
// look for idName in the project R class.
return mContext.getProjectResourceValue(
- resValue.getType(), resValue.getName(), defValue);
+ resValue.getResourceType(), resValue.getName(), defValue);
}
// else, try to get the value, and resolve it somehow.
@@ -634,21 +636,22 @@
// if this is a framework id
if (mPlatformFile || value.startsWith("@android") || value.startsWith("@+android")) {
// look for idName in the android R classes
- return mContext.getFrameworkResourceValue(RenderResources.RES_ID, idName, defValue);
+ return mContext.getFrameworkResourceValue(ResourceType.ID, idName, defValue);
}
// look for idName in the project R class.
- return mContext.getProjectResourceValue(RenderResources.RES_ID, idName, defValue);
+ return mContext.getProjectResourceValue(ResourceType.ID, idName, defValue);
}
// not a direct id valid reference? resolve it
Integer idValue = null;
if (resValue.isFramework()) {
- idValue = Bridge.getResourceValue(resValue.getType(), resValue.getName());
+ idValue = Bridge.getResourceId(resValue.getResourceType(),
+ resValue.getName());
} else {
- idValue = mContext.getProjectCallback().getResourceValue(
- resValue.getType(), resValue.getName());
+ idValue = mContext.getProjectCallback().getResourceId(
+ resValue.getResourceType(), resValue.getName());
}
if (idValue != null) {
@@ -796,6 +799,6 @@
@Override
public String toString() {
- return mResourceData.toString();
+ return Arrays.toString(mResourceData);
}
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlPullAttributes.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlPullAttributes.java
index 4a6880b..ba856e0 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlPullAttributes.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlPullAttributes.java
@@ -20,6 +20,7 @@
import com.android.ide.common.rendering.api.ResourceValue;
import com.android.layoutlib.bridge.Bridge;
import com.android.layoutlib.bridge.BridgeConstants;
+import com.android.resources.ResourceType;
import org.xmlpull.v1.XmlPullParser;
@@ -58,7 +59,7 @@
String ns = mParser.getAttributeNamespace(index);
if (BridgeConstants.NS_RESOURCES.equals(ns)) {
- Integer v = Bridge.getResourceValue(RenderResources.RES_ATTR, name);
+ Integer v = Bridge.getResourceId(ResourceType.ATTR, name);
if (v != null) {
return v.intValue();
}
@@ -69,8 +70,7 @@
// this is not an attribute in the android namespace, we query the customviewloader, if
// the namespaces match.
if (mContext.getProjectCallback().getNamespace().equals(ns)) {
- Integer v = mContext.getProjectCallback().getResourceValue(RenderResources.RES_ATTR,
- name);
+ Integer v = mContext.getProjectCallback().getResourceId(ResourceType.ATTR, name);
if (v != null) {
return v.intValue();
}
@@ -110,10 +110,10 @@
if (resource != null) {
Integer id = null;
if (mPlatformFile || resource.isFramework()) {
- id = Bridge.getResourceValue(resource.getType(), resource.getName());
+ id = Bridge.getResourceId(resource.getResourceType(), resource.getName());
} else {
- id = mContext.getProjectCallback().getResourceValue(
- resource.getType(), resource.getName());
+ id = mContext.getProjectCallback().getResourceId(
+ resource.getResourceType(), resource.getName());
}
if (id != null) {
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/FontLoader.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/FontLoader.java
index 5d56370..f62fad2 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/FontLoader.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/FontLoader.java
@@ -163,7 +163,7 @@
mTtfToFontMap.put(ttf, styleMap);
}
- Font f = styleMap.get(style);
+ Font f = styleMap.get(style[0]);
if (f != null) {
return f;
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
index 978832f..d816d18 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
@@ -48,7 +48,9 @@
import com.android.layoutlib.bridge.android.BridgeWindowSession;
import com.android.layoutlib.bridge.android.BridgeXmlBlockParser;
import com.android.resources.Density;
+import com.android.resources.ResourceType;
import com.android.resources.ScreenSize;
+import com.android.util.Pair;
import android.animation.Animator;
import android.animation.AnimatorInflater;
@@ -566,17 +568,16 @@
int animationId = 0;
if (isFrameworkAnimation) {
animationResource = mContext.getRenderResources().getFrameworkResource(
- RenderResources.RES_ANIMATOR, animationName);
+ ResourceType.ANIMATOR, animationName);
if (animationResource != null) {
- animationId = Bridge.getResourceValue(RenderResources.RES_ANIMATOR,
- animationName);
+ animationId = Bridge.getResourceId(ResourceType.ANIMATOR, animationName);
}
} else {
animationResource = mContext.getRenderResources().getProjectResource(
- RenderResources.RES_ANIMATOR, animationName);
+ ResourceType.ANIMATOR, animationName);
if (animationResource != null) {
- animationId = mContext.getProjectCallback().getResourceValue(
- RenderResources.RES_ANIMATOR, animationName);
+ animationId = mContext.getProjectCallback().getResourceId(
+ ResourceType.ANIMATOR, animationName);
}
}
@@ -1022,7 +1023,7 @@
mStatusBarSize = DEFAULT_STATUS_BAR_HEIGHT;
// get the real value
- ResourceValue value = resources.getFrameworkResource(RenderResources.RES_DIMEN,
+ ResourceValue value = resources.getFrameworkResource(ResourceType.DIMEN,
"status_bar_height");
if (value != null) {
@@ -1110,7 +1111,7 @@
mSystemBarSize = 56; // ??
// get the real value
- ResourceValue value = resources.getFrameworkResource(RenderResources.RES_DIMEN,
+ ResourceValue value = resources.getFrameworkResource(ResourceType.DIMEN,
"status_bar_height");
if (value != null) {
@@ -1227,10 +1228,10 @@
View child = content.getChildAt(i);
String tabSpec = String.format("tab_spec%d", i+1);
int id = child.getId();
- String[] resource = projectCallback.resolveResourceValue(id);
+ Pair<ResourceType, String> resource = projectCallback.resolveResourceId(id);
String name;
if (resource != null) {
- name = resource[0]; // 0 is resource name, 1 is resource type.
+ name = resource.getSecond();
} else {
name = String.format("Tab %d", i+1); // default name if id is unresolved.
}
@@ -1309,7 +1310,7 @@
// --- FrameworkResourceIdProvider methods
@Override
- public Integer getId(String resType, String resName) {
- return Bridge.getResourceValue(resType, resName);
+ public Integer getId(ResourceType resType, String resName) {
+ return Bridge.getResourceId(resType, resName);
}
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
index 119dfb1..25bb81c 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
@@ -197,7 +197,8 @@
} catch (Exception e) {
// this is an error and not warning since the file existence is checked before
// attempting to parse it.
- Bridge.getLog().error(null, "Failed to parse file " + value, e, null /*data*/);
+ Bridge.getLog().error(null, "Failed to parse file " + stringValue,
+ e, null /*data*/);
}
} else {
Bridge.getLog().error(LayoutLog.TAG_BROKEN,
@@ -298,7 +299,7 @@
*/
public static boolean stringToFloat(String s, TypedValue outValue) {
// remove the space before and after
- s.trim();
+ s = s.trim();
int len = s.length();
if (len <= 0) {