From a22423972392682bd38009ade798336c28e10dc8 Mon Sep 17 00:00:00 2001 From: Garfield Tan Date: Mon, 4 Nov 2019 17:40:26 -0800 Subject: [PATCH] Make StatusBar optional in GlobalScreenshot. Bug: 143911461 Test: Builds on targets that don't provide StatusBar, e.g. ARC++. Change-Id: I9b2e80e6bf83c1cd0ac8ccfadd8b3c847664a66f --- .../systemui/screenshot/GlobalScreenshot.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java index 6d7acd9727cd9..251ba9e68cc9a 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java @@ -93,6 +93,7 @@ import java.io.OutputStream; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -100,6 +101,7 @@ import java.util.concurrent.TimeoutException; import javax.inject.Inject; import javax.inject.Singleton; +import dagger.Lazy; /** * POD used in the AsyncTask which saves an image in the background. @@ -921,8 +923,9 @@ public class GlobalScreenshot { private final StatusBar mStatusBar; @Inject - public ActionProxyReceiver(StatusBar statusBar) { - mStatusBar = statusBar; + public ActionProxyReceiver(Optional> statusBarLazy) { + Lazy statusBar = statusBarLazy.orElse(null); + mStatusBar = statusBar != null ? statusBar.get() : null; } @Override @@ -947,8 +950,13 @@ public class GlobalScreenshot { context.startActivityAsUser(actionIntent, opts.toBundle(), UserHandle.CURRENT); }; - mStatusBar.executeRunnableDismissingKeyguard(startActivityRunnable, null, - true /* dismissShade */, true /* afterKeyguardGone */, true /* deferred */); + if (mStatusBar != null) { + mStatusBar.executeRunnableDismissingKeyguard(startActivityRunnable, null, + true /* dismissShade */, true /* afterKeyguardGone */, + true /* deferred */); + } else { + startActivityRunnable.run(); + } } }