Merge "[DO NOT MERGE] Close screenshot process on user switched" into oc-mr1-dev

This commit is contained in:
Miranda Kephart
2021-02-03 14:23:55 +00:00
committed by Android (Google) Code Review

View File

@@ -5837,8 +5837,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
@Override public void run() { @Override public void run() {
synchronized (mScreenshotLock) { synchronized (mScreenshotLock) {
if (mScreenshotConnection != null) { if (mScreenshotConnection != null) {
mContext.unbindService(mScreenshotConnection); resetScreenshotConnection();
mScreenshotConnection = null;
notifyScreenshotError(); notifyScreenshotError();
} }
} }
@@ -5870,8 +5869,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
synchronized (mScreenshotLock) { synchronized (mScreenshotLock) {
if (mScreenshotConnection == myConn) { if (mScreenshotConnection == myConn) {
mContext.unbindService(mScreenshotConnection); resetScreenshotConnection();
mScreenshotConnection = null;
mHandler.removeCallbacks(mScreenshotTimeout); mHandler.removeCallbacks(mScreenshotTimeout);
} }
} }
@@ -5894,8 +5892,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
public void onServiceDisconnected(ComponentName name) { public void onServiceDisconnected(ComponentName name) {
synchronized (mScreenshotLock) { synchronized (mScreenshotLock) {
if (mScreenshotConnection != null) { if (mScreenshotConnection != null) {
mContext.unbindService(mScreenshotConnection); resetScreenshotConnection();
mScreenshotConnection = null;
mHandler.removeCallbacks(mScreenshotTimeout); mHandler.removeCallbacks(mScreenshotTimeout);
notifyScreenshotError(); notifyScreenshotError();
} }
@@ -5925,6 +5922,16 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mContext.sendBroadcastAsUser(errorIntent, UserHandle.CURRENT); mContext.sendBroadcastAsUser(errorIntent, UserHandle.CURRENT);
} }
/**
* Reset the screenshot connection.
*/
private void resetScreenshotConnection() {
if (mScreenshotConnection != null) {
mContext.unbindService(mScreenshotConnection);
mScreenshotConnection = null;
}
}
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) { public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) {
@@ -6605,6 +6612,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mLastSystemUiFlags = 0; mLastSystemUiFlags = 0;
updateSystemUiVisibilityLw(); updateSystemUiVisibilityLw();
} }
// close the screenshot connection on user switch so that screenshots
// are always started with the correct user's context
synchronized(mScreenshotLock) {
resetScreenshotConnection();
}
} }
} }
}; };