Merge "GlobalScreenshot - Fix race condition" into qt-dev

This commit is contained in:
Matt Pietal
2019-06-12 00:04:23 +00:00
committed by Android (Google) Code Review
2 changed files with 20 additions and 4 deletions

View File

@@ -64,6 +64,7 @@ import com.android.systemui.shared.recents.model.ThumbnailData;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.Future;
import java.util.function.Consumer; import java.util.function.Consumer;
public class ActivityManagerWrapper { public class ActivityManagerWrapper {
@@ -380,8 +381,8 @@ public class ActivityManagerWrapper {
/** /**
* Requests that the system close any open system windows (including other SystemUI). * Requests that the system close any open system windows (including other SystemUI).
*/ */
public void closeSystemWindows(final String reason) { public Future<?> closeSystemWindows(final String reason) {
mBackgroundExecutor.submit(new Runnable() { return mBackgroundExecutor.submit(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {

View File

@@ -92,6 +92,11 @@ import java.io.OutputStream;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
/** /**
* POD used in the AsyncTask which saves an image in the background. * POD used in the AsyncTask which saves an image in the background.
@@ -446,6 +451,8 @@ class GlobalScreenshot {
static final String EXTRA_CANCEL_NOTIFICATION = "android:screenshot_cancel_notification"; static final String EXTRA_CANCEL_NOTIFICATION = "android:screenshot_cancel_notification";
static final String EXTRA_DISALLOW_ENTER_PIP = "android:screenshot_disallow_enter_pip"; static final String EXTRA_DISALLOW_ENTER_PIP = "android:screenshot_disallow_enter_pip";
private static final String TAG = "GlobalScreenshot";
private static final int SCREENSHOT_FLASH_TO_PEAK_DURATION = 130; private static final int SCREENSHOT_FLASH_TO_PEAK_DURATION = 130;
private static final int SCREENSHOT_DROP_IN_DURATION = 430; private static final int SCREENSHOT_DROP_IN_DURATION = 430;
private static final int SCREENSHOT_DROP_OUT_DELAY = 500; private static final int SCREENSHOT_DROP_OUT_DELAY = 500;
@@ -902,11 +909,19 @@ class GlobalScreenshot {
* appropriate signals to the system (ie. to dismiss the keyguard if necessary). * appropriate signals to the system (ie. to dismiss the keyguard if necessary).
*/ */
public static class ActionProxyReceiver extends BroadcastReceiver { public static class ActionProxyReceiver extends BroadcastReceiver {
static final int CLOSE_WINDOWS_TIMEOUT_MILLIS = 3000;
@Override @Override
public void onReceive(Context context, final Intent intent) { public void onReceive(Context context, final Intent intent) {
Runnable startActivityRunnable = () -> { Runnable startActivityRunnable = () -> {
ActivityManagerWrapper.getInstance().closeSystemWindows( try {
SYSTEM_DIALOG_REASON_SCREENSHOT); ActivityManagerWrapper.getInstance().closeSystemWindows(
SYSTEM_DIALOG_REASON_SCREENSHOT).get(
CLOSE_WINDOWS_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
} catch (TimeoutException | InterruptedException | ExecutionException e) {
Slog.e(TAG, "Unable to share screenshot", e);
return;
}
Intent actionIntent = intent.getParcelableExtra(EXTRA_ACTION_INTENT); Intent actionIntent = intent.getParcelableExtra(EXTRA_ACTION_INTENT);
if (intent.getBooleanExtra(EXTRA_CANCEL_NOTIFICATION, false)) { if (intent.getBooleanExtra(EXTRA_CANCEL_NOTIFICATION, false)) {