summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiranda Kephart <mkephart@google.com>2020-11-16 11:22:13 -0500
committerAnis Assi <anisassi@google.com>2021-02-26 12:32:53 -0800
commit8abed643c72f7120ab1dfea00bec72d07e230ff3 (patch)
tree38ad1762a4b20299712b5d2940ac6e0f4453fe62
parent7d142d2a2244aa86e796523dd36456c8b77336df (diff)
downloadbase-android-security-8.1.0_r87.tar.gz
[DO NOT MERGE] Close screenshot process on user switchedandroid-security-8.1.0_r87
Currently, we keep the process up even if the user switches, meaning that in some cases (if the user is switched while the screenshot UI is up) we will save images to the wrong profile. This change makes ScreenshotHelper listen for user switches and close the screenshot service, so that a new screenshot is guaranteed to be constructed with the correct user's context. Bug: 170474245 Fix: 170474245 Test: manual -- verified bad state occurs if user switches within the timeout period, ensured that screenshots work immediately after switching with this change. Change-Id: I9d32d0928e6c2bda161d04555438d0dd7afef0ba (cherry picked from commit 7ef1a5dd1506075507412626f2533283d9520144) (cherry picked from commit 8a2656d4b69efcec5140f3de5a9a721ffb21112e)
-rw-r--r--services/core/java/com/android/server/policy/PhoneWindowManager.java25
1 files changed, 19 insertions, 6 deletions
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index cd82d086d6ef..ada1ce3fa5dc 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -5837,8 +5837,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
@Override public void run() {
synchronized (mScreenshotLock) {
if (mScreenshotConnection != null) {
- mContext.unbindService(mScreenshotConnection);
- mScreenshotConnection = null;
+ resetScreenshotConnection();
notifyScreenshotError();
}
}
@@ -5870,8 +5869,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
public void handleMessage(Message msg) {
synchronized (mScreenshotLock) {
if (mScreenshotConnection == myConn) {
- mContext.unbindService(mScreenshotConnection);
- mScreenshotConnection = null;
+ resetScreenshotConnection();
mHandler.removeCallbacks(mScreenshotTimeout);
}
}
@@ -5894,8 +5892,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
public void onServiceDisconnected(ComponentName name) {
synchronized (mScreenshotLock) {
if (mScreenshotConnection != null) {
- mContext.unbindService(mScreenshotConnection);
- mScreenshotConnection = null;
+ resetScreenshotConnection();
mHandler.removeCallbacks(mScreenshotTimeout);
notifyScreenshotError();
}
@@ -5925,6 +5922,16 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mContext.sendBroadcastAsUser(errorIntent, UserHandle.CURRENT);
}
+ /**
+ * Reset the screenshot connection.
+ */
+ private void resetScreenshotConnection() {
+ if (mScreenshotConnection != null) {
+ mContext.unbindService(mScreenshotConnection);
+ mScreenshotConnection = null;
+ }
+ }
+
/** {@inheritDoc} */
@Override
public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) {
@@ -6605,6 +6612,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mLastSystemUiFlags = 0;
updateSystemUiVisibilityLw();
}
+
+ // close the screenshot connection on user switch so that screenshots
+ // are always started with the correct user's context
+ synchronized(mScreenshotLock) {
+ resetScreenshotConnection();
+ }
}
}
};