From 205964034c283dd18dfcaa31f9ca52e5fd75bab8 Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Mon, 27 Aug 2012 12:04:40 -0700 Subject: [PATCH 01/12] Fix adb install Was not properly handling creating DefContainerService when the installation was for USER_ALL. Not a problem for Market installs. Bug: 7061571 Change-Id: I4528b4c56e38effa137da56460e78c55b242ba45 --- services/java/com/android/server/am/ActiveServices.java | 2 +- .../java/com/android/server/pm/PackageManagerService.java | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/services/java/com/android/server/am/ActiveServices.java b/services/java/com/android/server/am/ActiveServices.java index e6bcaa1d92dfb..ca7faa2de622c 100644 --- a/services/java/com/android/server/am/ActiveServices.java +++ b/services/java/com/android/server/am/ActiveServices.java @@ -729,7 +729,7 @@ public class ActiveServices { ServiceInfo sInfo = rInfo != null ? rInfo.serviceInfo : null; if (sInfo == null) { - Slog.w(TAG, "Unable to start service " + service + + Slog.w(TAG, "Unable to start service " + service + " U=" + userId + ": not found"); return null; } diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java index 0345df100b37e..ba8533fed3a62 100644 --- a/services/java/com/android/server/pm/PackageManagerService.java +++ b/services/java/com/android/server/pm/PackageManagerService.java @@ -473,6 +473,9 @@ public class PackageManagerService extends IPackageManager.Stub { mContainerServiceUserId = 0; if (mPendingInstalls.size() > 0) { mContainerServiceUserId = mPendingInstalls.get(0).getUser().getIdentifier(); + if (mContainerServiceUserId == UserHandle.USER_ALL) { + mContainerServiceUserId = 0; + } } if (mContext.bindService(service, mDefContainerConn, Context.BIND_AUTO_CREATE, mContainerServiceUserId)) { @@ -554,7 +557,10 @@ public class PackageManagerService extends IPackageManager.Stub { if (params != null) { // Check if we're connected to the correct service, if it's an install // request. - if (params.getUser().getIdentifier() != mContainerServiceUserId) { + final int installFor = params.getUser().getIdentifier(); + if (installFor != mContainerServiceUserId + && (installFor == UserHandle.USER_ALL + && mContainerServiceUserId != 0)) { mHandler.sendEmptyMessage(MCS_RECONNECT); return; } From 64cca45c97dc772b977574f2e5047f76e773c5e8 Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Tue, 28 Aug 2012 14:34:53 -0700 Subject: [PATCH 02/12] Fix PendingIntent caching for multiuser Store the userId in the PendingIntentRecord.Key, so that it doesn't match an identical pending intent from another user. Change-Id: Icfc39e0f717c902dc3a60bdf5283a3402bbd2eaa --- .../android/server/am/ActivityManagerService.java | 3 ++- .../com/android/server/am/PendingIntentRecord.java | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index 6e4759d31ab74..368db2661f568 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -4430,7 +4430,8 @@ public final class ActivityManagerService extends ActivityManagerNative PendingIntentRecord.Key key = new PendingIntentRecord.Key( type, packageName, activity, resultWho, - requestCode, intents, resolvedTypes, flags, options); + requestCode, intents, resolvedTypes, flags, options, + UserHandle.getUserId(callingUid)); WeakReference ref; ref = mIntentSenderRecords.get(key); PendingIntentRecord rec = ref != null ? ref.get() : null; diff --git a/services/java/com/android/server/am/PendingIntentRecord.java b/services/java/com/android/server/am/PendingIntentRecord.java index d3b851026aac0..8e70376fc26b8 100644 --- a/services/java/com/android/server/am/PendingIntentRecord.java +++ b/services/java/com/android/server/am/PendingIntentRecord.java @@ -54,11 +54,12 @@ class PendingIntentRecord extends IIntentSender.Stub { String[] allResolvedTypes; final int flags; final int hashCode; + final int userId; private static final int ODD_PRIME_NUMBER = 37; Key(int _t, String _p, ActivityRecord _a, String _w, - int _r, Intent[] _i, String[] _it, int _f, Bundle _o) { + int _r, Intent[] _i, String[] _it, int _f, Bundle _o, int _userId) { type = _t; packageName = _p; activity = _a; @@ -70,10 +71,12 @@ class PendingIntentRecord extends IIntentSender.Stub { allResolvedTypes = _it; flags = _f; options = _o; - + userId = _userId; + int hash = 23; hash = (ODD_PRIME_NUMBER*hash) + _f; hash = (ODD_PRIME_NUMBER*hash) + _r; + hash = (ODD_PRIME_NUMBER*hash) + _userId; if (_w != null) { hash = (ODD_PRIME_NUMBER*hash) + _w.hashCode(); } @@ -102,6 +105,9 @@ class PendingIntentRecord extends IIntentSender.Stub { if (type != other.type) { return false; } + if (userId != other.userId){ + return false; + } if (!packageName.equals(other.packageName)) { return false; } @@ -156,7 +162,7 @@ class PendingIntentRecord extends IIntentSender.Stub { + " intent=" + (requestIntent != null ? requestIntent.toShortString(false, true, false, false) : "") - + " flags=0x" + Integer.toHexString(flags) + "}"; + + " flags=0x" + Integer.toHexString(flags) + " u=" + userId + "}"; } String typeName() { From 093405813c366ce9c0fa4f1de0fb691f3accbcc0 Mon Sep 17 00:00:00 2001 From: Craig Mautner Date: Tue, 28 Aug 2012 17:12:52 -0700 Subject: [PATCH 03/12] Check proximity detector before powering off. Do not automatically power off if the proximity detector wakelock is active. Fixes bug 7047455. Change-Id: I44e30bf388292e5c476dfb5d0de9226d21853e4d --- .../java/com/android/server/power/PowerManagerService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/java/com/android/server/power/PowerManagerService.java b/services/java/com/android/server/power/PowerManagerService.java index 6d681046a2c60..59d09546ce96b 100644 --- a/services/java/com/android/server/power/PowerManagerService.java +++ b/services/java/com/android/server/power/PowerManagerService.java @@ -1136,7 +1136,8 @@ public final class PowerManagerService extends IPowerManager.Stub private boolean isItBedTimeYetLocked() { return mBootCompleted && !mStayOn && (mWakeLockSummary - & (WAKE_LOCK_SCREEN_BRIGHT | WAKE_LOCK_SCREEN_DIM)) == 0 + & (WAKE_LOCK_SCREEN_BRIGHT | WAKE_LOCK_SCREEN_DIM + | WAKE_LOCK_PROXIMITY_SCREEN_OFF)) == 0 && (mUserActivitySummary & (USER_ACTIVITY_SCREEN_BRIGHT | USER_ACTIVITY_SCREEN_DIM)) == 0; } From 79df5454d8c6de4653b37ed0d7d0d3e02d605380 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Thu, 30 Aug 2012 10:24:40 -0700 Subject: [PATCH 04/12] Fix keyguard layout on tablet Bug:7084961 Change-Id: I6415aa736bf9e2b71a288716e3125429be2b663c --- core/res/res/layout-sw600dp-land/keyguard_host_view.xml | 4 ++-- core/res/res/layout-sw600dp-port/keyguard_host_view.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/res/res/layout-sw600dp-land/keyguard_host_view.xml b/core/res/res/layout-sw600dp-land/keyguard_host_view.xml index c552885a41711..e77f5843ac560 100644 --- a/core/res/res/layout-sw600dp-land/keyguard_host_view.xml +++ b/core/res/res/layout-sw600dp-land/keyguard_host_view.xml @@ -26,7 +26,7 @@ android:layout_height="match_parent" android:orientation="horizontal"> - - + - - + Date: Wed, 29 Aug 2012 13:54:44 -0700 Subject: [PATCH 05/12] Use focal point for scrolling in GestureDetector Remove workaround for obsolete touchscreen hardware. Provide a better focal point for scroll events. Change-Id: I879acb4cfd23bd3762d0332e4df2203d913ae869 --- core/java/android/view/GestureDetector.java | 118 +++++++++++--------- 1 file changed, 64 insertions(+), 54 deletions(-) diff --git a/core/java/android/view/GestureDetector.java b/core/java/android/view/GestureDetector.java index 0114a419f23c9..23337f03792c2 100644 --- a/core/java/android/view/GestureDetector.java +++ b/core/java/android/view/GestureDetector.java @@ -226,17 +226,12 @@ public class GestureDetector { */ private boolean mIsDoubleTapping; - private float mLastMotionY; - private float mLastMotionX; + private float mLastFocusX; + private float mLastFocusY; + private float mDownFocusX; + private float mDownFocusY; private boolean mIsLongpressEnabled; - - /** - * True if we are at a target API level of >= Froyo or the developer can - * explicitly set it. If true, input events with > 1 pointer will be ignored - * so we can work side by side with multitouch gesture detectors. - */ - private boolean mIgnoreMultitouch; /** * Determines speed during touch scrolling @@ -349,8 +344,16 @@ public class GestureDetector { * @throws NullPointerException if {@code listener} is null. */ public GestureDetector(Context context, OnGestureListener listener, Handler handler) { - this(context, listener, handler, context != null && - context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.FROYO); + if (handler != null) { + mHandler = new GestureHandler(handler); + } else { + mHandler = new GestureHandler(); + } + mListener = listener; + if (listener instanceof OnDoubleTapListener) { + setOnDoubleTapListener((OnDoubleTapListener) listener); + } + init(context); } /** @@ -362,31 +365,19 @@ public class GestureDetector { * @param listener the listener invoked for all the callbacks, this must * not be null. * @param handler the handler to use - * @param ignoreMultitouch whether events involving more than one pointer should - * be ignored. * * @throws NullPointerException if {@code listener} is null. */ public GestureDetector(Context context, OnGestureListener listener, Handler handler, - boolean ignoreMultitouch) { - if (handler != null) { - mHandler = new GestureHandler(handler); - } else { - mHandler = new GestureHandler(); - } - mListener = listener; - if (listener instanceof OnDoubleTapListener) { - setOnDoubleTapListener((OnDoubleTapListener) listener); - } - init(context, ignoreMultitouch); + boolean unused) { + this(context, listener, handler); } - private void init(Context context, boolean ignoreMultitouch) { + private void init(Context context) { if (mListener == null) { throw new NullPointerException("OnGestureListener must not be null"); } mIsLongpressEnabled = true; - mIgnoreMultitouch = ignoreMultitouch; // Fallback to support pre-donuts releases int touchSlop, doubleTapSlop, doubleTapTouchSlop; @@ -456,34 +447,40 @@ public class GestureDetector { } final int action = ev.getAction(); - final float y = ev.getY(); - final float x = ev.getX(); if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); } mVelocityTracker.addMovement(ev); + final boolean pointerUp = action == MotionEvent.ACTION_POINTER_UP; + final int skipIndex = pointerUp ? ev.getActionIndex() : -1; + + // Determine focal point + float sumX = 0, sumY = 0; + final int count = ev.getPointerCount(); + for (int i = 0; i < count; i++) { + if (skipIndex == i) continue; + sumX += ev.getX(i); + sumY += ev.getY(i); + } + final int div = pointerUp ? count - 1 : count; + final float focusX = sumX / div; + final float focusY = sumY / div; + boolean handled = false; switch (action & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_POINTER_DOWN: - if (mIgnoreMultitouch) { - // Multitouch event - abort. - cancel(); - } + mDownFocusX = mLastFocusX = focusX; + mDownFocusY = mLastFocusY = focusY; + // Cancel long press and taps + cancelTaps(); break; case MotionEvent.ACTION_POINTER_UP: - // Ending a multitouch gesture and going back to 1 finger - if (mIgnoreMultitouch && ev.getPointerCount() == 2) { - int index = (((action & MotionEvent.ACTION_POINTER_INDEX_MASK) - >> MotionEvent.ACTION_POINTER_INDEX_SHIFT) == 0) ? 1 : 0; - mLastMotionX = ev.getX(index); - mLastMotionY = ev.getY(index); - mVelocityTracker.recycle(); - mVelocityTracker = VelocityTracker.obtain(); - } + mDownFocusX = mLastFocusX = focusX; + mDownFocusY = mLastFocusY = focusY; break; case MotionEvent.ACTION_DOWN: @@ -504,8 +501,8 @@ public class GestureDetector { } } - mLastMotionX = x; - mLastMotionY = y; + mDownFocusX = mLastFocusX = focusX; + mDownFocusY = mLastFocusY = focusY; if (mCurrentDownEvent != null) { mCurrentDownEvent.recycle(); } @@ -525,22 +522,22 @@ public class GestureDetector { break; case MotionEvent.ACTION_MOVE: - if (mInLongPress || (mIgnoreMultitouch && ev.getPointerCount() > 1)) { + if (mInLongPress) { break; } - final float scrollX = mLastMotionX - x; - final float scrollY = mLastMotionY - y; + final float scrollX = mLastFocusX - focusX; + final float scrollY = mLastFocusY - focusY; if (mIsDoubleTapping) { // Give the move events of the double-tap handled |= mDoubleTapListener.onDoubleTapEvent(ev); } else if (mAlwaysInTapRegion) { - final int deltaX = (int) (x - mCurrentDownEvent.getX()); - final int deltaY = (int) (y - mCurrentDownEvent.getY()); + final int deltaX = (int) (focusX - mDownFocusX); + final int deltaY = (int) (focusY - mDownFocusY); int distance = (deltaX * deltaX) + (deltaY * deltaY); if (distance > mTouchSlopSquare) { handled = mListener.onScroll(mCurrentDownEvent, ev, scrollX, scrollY); - mLastMotionX = x; - mLastMotionY = y; + mLastFocusX = focusX; + mLastFocusY = focusY; mAlwaysInTapRegion = false; mHandler.removeMessages(TAP); mHandler.removeMessages(SHOW_PRESS); @@ -551,8 +548,8 @@ public class GestureDetector { } } else if ((Math.abs(scrollX) >= 1) || (Math.abs(scrollY) >= 1)) { handled = mListener.onScroll(mCurrentDownEvent, ev, scrollX, scrollY); - mLastMotionX = x; - mLastMotionY = y; + mLastFocusX = focusX; + mLastFocusY = focusY; } break; @@ -571,9 +568,10 @@ public class GestureDetector { // A fling must travel the minimum tap distance final VelocityTracker velocityTracker = mVelocityTracker; + final int pointerId = ev.getPointerId(0); velocityTracker.computeCurrentVelocity(1000, mMaximumFlingVelocity); - final float velocityY = velocityTracker.getYVelocity(); - final float velocityX = velocityTracker.getXVelocity(); + final float velocityY = velocityTracker.getYVelocity(pointerId); + final float velocityX = velocityTracker.getXVelocity(pointerId); if ((Math.abs(velocityY) > mMinimumFlingVelocity) || (Math.abs(velocityX) > mMinimumFlingVelocity)){ @@ -622,6 +620,18 @@ public class GestureDetector { } } + private void cancelTaps() { + mHandler.removeMessages(SHOW_PRESS); + mHandler.removeMessages(LONG_PRESS); + mHandler.removeMessages(TAP); + mIsDoubleTapping = false; + mAlwaysInTapRegion = false; + mAlwaysInBiggerTapRegion = false; + if (mInLongPress) { + mInLongPress = false; + } + } + private boolean isConsideredDoubleTap(MotionEvent firstDown, MotionEvent firstUp, MotionEvent secondDown) { if (!mAlwaysInBiggerTapRegion) { From 101136931dcb8b7af043beafbf124456aae7e247 Mon Sep 17 00:00:00 2001 From: Maxim Siniavine Date: Thu, 30 Aug 2012 14:05:38 -0700 Subject: [PATCH 06/12] Fixed MemoryUsage issue with reporting results. When the memory of the application did not stabilize within the time limit, the test would report that using the application name, instead of the result key. Fixed the test to always use the result key. Change-Id: Ie16969e831bd3d89ee0496b992568f52bf1989cb --- .../tests/memoryusage/MemoryUsageTest.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java b/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java index f26edc649204d..e39d53c75d692 100644 --- a/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java +++ b/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java @@ -54,9 +54,9 @@ public class MemoryUsageTest extends InstrumentationTestCase { private static final String TAG = "MemoryUsageInstrumentation"; private static final String KEY_APPS = "apps"; - private Map nameToIntent; - private Map nameToProcess; - private Map nameToResultKey; + private Map mNameToIntent; + private Map mNameToProcess; + private Map mNameToResultKey; public void testMemory() { MemoryUsageInstrumentation instrumentation = @@ -67,7 +67,7 @@ public class MemoryUsageTest extends InstrumentationTestCase { parseArgs(args); Bundle results = new Bundle(); - for (String app : nameToResultKey.keySet()) { + for (String app : mNameToResultKey.keySet()) { String processName; try { processName = startApp(app); @@ -81,7 +81,7 @@ public class MemoryUsageTest extends InstrumentationTestCase { } private void parseArgs(Bundle args) { - nameToResultKey = new HashMap(); + mNameToResultKey = new HashMap(); String appList = args.getString(KEY_APPS); if (appList == null) @@ -95,13 +95,13 @@ public class MemoryUsageTest extends InstrumentationTestCase { fail(); } - nameToResultKey.put(parts[0], parts[1]); + mNameToResultKey.put(parts[0], parts[1]); } } private void createMappings() { - nameToIntent = new HashMap(); - nameToProcess = new HashMap(); + mNameToIntent = new HashMap(); + mNameToProcess = new HashMap(); PackageManager pm = getInstrumentation().getContext() .getPackageManager(); @@ -120,8 +120,8 @@ public class MemoryUsageTest extends InstrumentationTestCase { | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); startIntent.setClassName(ri.activityInfo.packageName, ri.activityInfo.name); - nameToIntent.put(ri.loadLabel(pm).toString(), startIntent); - nameToProcess.put(ri.loadLabel(pm).toString(), + mNameToIntent.put(ri.loadLabel(pm).toString(), startIntent); + mNameToProcess.put(ri.loadLabel(pm).toString(), ri.activityInfo.processName); } } @@ -130,11 +130,11 @@ public class MemoryUsageTest extends InstrumentationTestCase { private String startApp(String appName) throws NameNotFoundException { Log.i(TAG, "Starting " + appName); - if (!nameToProcess.containsKey(appName)) + if (!mNameToProcess.containsKey(appName)) throw new NameNotFoundException("Could not find: " + appName); - String process = nameToProcess.get(appName); - Intent startIntent = nameToIntent.get(appName); + String process = mNameToProcess.get(appName); + Intent startIntent = mNameToIntent.get(appName); getInstrumentation().getContext().startActivity(startIntent); return process; } @@ -154,14 +154,14 @@ public class MemoryUsageTest extends InstrumentationTestCase { } pssData.add(pss); if (iteration >= MIN_ITERATIONS && stabilized(pssData)) { - results.putInt(nameToResultKey.get(appName), pss); + results.putInt(mNameToResultKey.get(appName), pss); return; } iteration++; } Log.w(TAG, appName + " memory usage did not stabilize"); - results.putInt(appName, average(pssData)); + results.putInt(mNameToResultKey.get(appName), average(pssData)); } private int average(List pssData) { @@ -202,12 +202,12 @@ public class MemoryUsageTest extends InstrumentationTestCase { continue; Log.w(TAG, appName + " crashed: " + crash.shortMsg); - results.putString(nameToResultKey.get(appName), crash.shortMsg); + results.putString(mNameToResultKey.get(appName), crash.shortMsg); return; } } - results.putString(nameToResultKey.get(appName), + results.putString(mNameToResultKey.get(appName), "Crashed for unknown reason"); Log.w(TAG, appName + " not found in process list, most likely it is crashed"); From f331e6f29f154a1cd12ea6e00abb973976925bf4 Mon Sep 17 00:00:00 2001 From: Daniel Sandler Date: Thu, 30 Aug 2012 17:10:50 -0400 Subject: [PATCH 07/12] Turn off deadzone flash, replacing it with logcat. Change-Id: I30db97e5c3a6ef3a06e6065ccf087a7f6d1f9286 --- packages/SystemUI/res/values/config.xml | 2 ++ .../systemui/statusbar/policy/DeadZone.java | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml index 333757333d9af..13622e6145fd0 100644 --- a/packages/SystemUI/res/values/config.xml +++ b/packages/SystemUI/res/values/config.xml @@ -76,5 +76,7 @@ 333 333 + + false diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeadZone.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeadZone.java index 6ffca2a9f0ad3..e5ef5fe83f8ee 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeadZone.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeadZone.java @@ -35,6 +35,8 @@ public class DeadZone extends View { public static final int HORIZONTAL = 0; public static final int VERTICAL = 1; + private static final boolean CHATTY = true; // print to logcat when we eat a click + private boolean mShouldFlash; private float mFlashFrac = 0f; @@ -76,7 +78,7 @@ public class DeadZone extends View { Slog.v(TAG, this + " size=[" + mSizeMin + "-" + mSizeMax + "] hold=" + mHold + (mVertical ? " vertical" : " horizontal")); - setFlashOnTouchCapture(true); + setFlashOnTouchCapture(context.getResources().getBoolean(R.bool.config_dead_zone_flash)); } static float lerp(float a, float b, float f) { @@ -100,27 +102,30 @@ public class DeadZone extends View { postInvalidate(); } - // I made you a touch event + // I made you a touch event... @Override public boolean onTouchEvent(MotionEvent event) { - if (DEBUG) + if (DEBUG) { Slog.v(TAG, this + " onTouch: " + MotionEvent.actionToString(event.getAction())); + } final int action = event.getAction(); if (action == MotionEvent.ACTION_OUTSIDE) { poke(event); } else if (action == MotionEvent.ACTION_DOWN) { - if (DEBUG) + if (DEBUG) { Slog.v(TAG, this + " ACTION_DOWN: " + event.getX() + "," + event.getY()); + } int size = (int) getSize(event.getEventTime()); if ((mVertical && event.getX() < size) || event.getY() < size) { - if (DEBUG) - Slog.v(TAG, "eating click!"); + if (CHATTY) { + Slog.v(TAG, "consuming errant click: (" + event.getX() + "," + event.getY() + ")"); + } if (mShouldFlash) { post(mDebugFlash); postInvalidate(); } - return true; // but I eated it + return true; // ...but I eated it } } return false; From 753f590eb72c91627015d1f71244396e914b849b Mon Sep 17 00:00:00 2001 From: Adam Powell Date: Fri, 31 Aug 2012 11:11:39 -0700 Subject: [PATCH 08/12] GestureDetector - Mask action when checking POINTER_UP Bug 7088494 Change-Id: I723e9b77f0d0473f9d769e53aaa568c4aaac90aa --- core/java/android/view/GestureDetector.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/java/android/view/GestureDetector.java b/core/java/android/view/GestureDetector.java index 23337f03792c2..4bbdd4e3b534a 100644 --- a/core/java/android/view/GestureDetector.java +++ b/core/java/android/view/GestureDetector.java @@ -453,7 +453,8 @@ public class GestureDetector { } mVelocityTracker.addMovement(ev); - final boolean pointerUp = action == MotionEvent.ACTION_POINTER_UP; + final boolean pointerUp = + (action & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_UP; final int skipIndex = pointerUp ? ev.getActionIndex() : -1; // Determine focal point From 1d963f3676fbe1a4c3fa99d857faa9927f9fc995 Mon Sep 17 00:00:00 2001 From: Daniel Sandler Date: Fri, 31 Aug 2012 14:57:09 -0400 Subject: [PATCH 09/12] Work around instability of Display.getRotation(). Ensures that the navigation buttons are properly oriented each time the screen comes on. Bug: 7086018 Change-Id: Iac6243792a8c64001ff7409108fb892bd470e4c4 --- .../systemui/statusbar/phone/PhoneStatusBar.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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 9b4ee38f9e381..31bc8a0e68093 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -451,6 +451,7 @@ public class PhoneStatusBar extends BaseStatusBar { filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); filter.addAction(Intent.ACTION_SCREEN_OFF); + filter.addAction(Intent.ACTION_SCREEN_ON); context.registerReceiver(mBroadcastReceiver, filter); return mStatusBarView; @@ -788,11 +789,6 @@ public class PhoneStatusBar extends BaseStatusBar { setAreThereNotifications(); } - @Override - protected void onConfigurationChanged(Configuration newConfig) { - updateShowSearchHoldoff(); - } - private void updateShowSearchHoldoff() { mShowSearchHoldoff = mContext.getResources().getInteger( R.integer.config_show_search_delay); @@ -1804,9 +1800,17 @@ public class PhoneStatusBar extends BaseStatusBar { makeExpandedInvisible(); } else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) { + if (DEBUG) { + Slog.v(TAG, "configuration changed: " + mContext.getResources().getConfiguration()); + } updateResources(); repositionNavigationBar(); updateExpandedViewPos(EXPANDED_LEAVE_ALONE); + updateShowSearchHoldoff(); + } + else if (Intent.ACTION_SCREEN_ON.equals(action)) { + // work around problem where mDisplay.getRotation() is not stable while screen is off (bug 7086018) + repositionNavigationBar(); } } }; From d2ed9d01c89d773a0a5088fe785fdcc793f915f5 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Tue, 4 Sep 2012 10:55:44 -0700 Subject: [PATCH 10/12] Fix issue #7097984 java.lang.SecurityException: Permission Denial: broadcast asks to run as user -1 but is calling from user 0; this requires Also improve part of issue #7087789: Local denial of service via low-permissioned apps No longer allow closeSystemDialogs() from background processes. Change-Id: I752d5a1d51be0b69fde6999d6659835e5bde3efe --- .../server/am/ActivityManagerService.java | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index 590e9d9addc56..01ac8c0ab9863 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -153,7 +153,6 @@ import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; @@ -3570,15 +3569,32 @@ public final class ActivityManagerService extends ActivityManagerNative public void closeSystemDialogs(String reason) { enforceNotIsolatedCaller("closeSystemDialogs"); + final int pid = Binder.getCallingPid(); final int uid = Binder.getCallingUid(); final long origId = Binder.clearCallingIdentity(); - synchronized (this) { - closeSystemDialogsLocked(uid, reason); + try { + synchronized (this) { + // Only allow this from foreground processes, so that background + // applications can't abuse it to prevent system UI from being shown. + if (uid >= Process.FIRST_APPLICATION_UID) { + ProcessRecord proc; + synchronized (mPidsSelfLocked) { + proc = mPidsSelfLocked.get(pid); + } + if (proc.curRawAdj > ProcessList.PERCEPTIBLE_APP_ADJ) { + Slog.w(TAG, "Ignoring closeSystemDialogs " + reason + + " from background process " + proc); + return; + } + } + closeSystemDialogsLocked(reason); + } + } finally { + Binder.restoreCallingIdentity(origId); } - Binder.restoreCallingIdentity(origId); } - void closeSystemDialogsLocked(int callingUid, String reason) { + void closeSystemDialogsLocked(String reason) { Intent intent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); if (reason != null) { @@ -3594,14 +3610,9 @@ public final class ActivityManagerService extends ActivityManagerNative } } - final long origId = Binder.clearCallingIdentity(); - try { - broadcastIntentLocked(null, null, intent, null, - null, 0, null, null, null, false, false, -1, - callingUid, UserHandle.USER_ALL); - } finally { - Binder.restoreCallingIdentity(origId); - } + broadcastIntentLocked(null, null, intent, null, + null, 0, null, null, null, false, false, -1, + Process.SYSTEM_UID, UserHandle.USER_ALL); } public Debug.MemoryInfo[] getProcessMemoryInfo(int[] pids) From 3e4599a8d0c0e55e6ee33542eec37676461c6902 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Wed, 5 Sep 2012 12:17:55 -0700 Subject: [PATCH 11/12] Don't depend on LockPatternUtils to get DevicePolicyManager This fixes a crash where LockPatternUtils hasn't been set yet and keyguard attempts to get the device policy for widgets. This change breaks the dependency by getting a handle to DPM directly. Bug:7109723 Change-Id: Iecae91474358821ebd30456648377253864c35cf --- .../internal/policy/impl/keyguard/KeyguardHostView.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java index e0ba211c2e252..da2f268e3e2ac 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java @@ -582,7 +582,9 @@ public class KeyguardHostView extends KeyguardViewBase { } private void maybePopulateWidgets() { - if (mLockPatternUtils.getDevicePolicyManager().getKeyguardWidgetsDisabled(null) + DevicePolicyManager dpm = + (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE); + if (dpm != null && dpm.getKeyguardWidgetsDisabled(null) != DevicePolicyManager.KEYGUARD_DISABLE_WIDGETS_NONE) { Log.v(TAG, "Keyguard widgets disabled because of device policy admin"); return; From f645da5b67960b12911620f7483a973a3d2d097b Mon Sep 17 00:00:00 2001 From: Craig Mautner Date: Thu, 6 Sep 2012 15:04:22 -0700 Subject: [PATCH 12/12] Convert resized() method to new parameters. When the BaseIWindow.resized method got switched from taking (int x, int y, ...) to taking (Rect, ...) the SurfaceView.MyWindow override never got updated. Fixes bug 6992324. Change-Id: Id0b9625559ae0100336f4573f09d313138c8a6e7 --- core/java/android/view/SurfaceView.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java index fdf1c226b510d..973c7f6328591 100644 --- a/core/java/android/view/SurfaceView.java +++ b/core/java/android/view/SurfaceView.java @@ -615,21 +615,22 @@ public class SurfaceView extends View { mSurfaceView = new WeakReference(surfaceView); } - public void resized(int w, int h, Rect contentInsets, + @Override + public void resized(Rect frame, Rect contentInsets, Rect visibleInsets, boolean reportDraw, Configuration newConfig) { SurfaceView surfaceView = mSurfaceView.get(); if (surfaceView != null) { if (DEBUG) Log.v( - "SurfaceView", surfaceView + " got resized: w=" + - w + " h=" + h + ", cur w=" + mCurWidth + " h=" + mCurHeight); + "SurfaceView", surfaceView + " got resized: w=" + frame.width() + + " h=" + frame.height() + ", cur w=" + mCurWidth + " h=" + mCurHeight); surfaceView.mSurfaceLock.lock(); try { if (reportDraw) { surfaceView.mUpdateWindowNeeded = true; surfaceView.mReportDrawNeeded = true; surfaceView.mHandler.sendEmptyMessage(UPDATE_WINDOW_MSG); - } else if (surfaceView.mWinFrame.width() != w - || surfaceView.mWinFrame.height() != h) { + } else if (surfaceView.mWinFrame.width() != frame.width() + || surfaceView.mWinFrame.height() != frame.height()) { surfaceView.mUpdateWindowNeeded = true; surfaceView.mHandler.sendEmptyMessage(UPDATE_WINDOW_MSG); }