summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorJames O'Leary <jamesoleary@google.com>2019-11-15 14:05:59 -0800
committerandroid-build-merger <android-build-merger@google.com>2019-11-15 14:05:59 -0800
commitfe08abee19829c68d4917a421dab4a4750c4085f (patch)
tree7404c11491f94b911663e521cfe95cdc47131d9a /core/java
parente633cc0936be47e2823b256378a47faee5f318b4 (diff)
parent712eb51dc9af1d4cdb987918607a5e4cebfe9f6b (diff)
[DO NOT MERGE] Convert TakeScreenshot finishers Runnables to Consumer<Uri>
am: 712eb51dc9 Change-Id: I1a5cc3ceef3f95e02abcbe86fcafd56e19aedc65
Diffstat (limited to 'core/java')
-rw-r--r--core/java/com/android/internal/util/ScreenshotHelper.java16
1 files changed, 9 insertions, 7 deletions
diff --git a/core/java/com/android/internal/util/ScreenshotHelper.java b/core/java/com/android/internal/util/ScreenshotHelper.java
index cac691cf7d45..d24d78c6f3da 100644
--- a/core/java/com/android/internal/util/ScreenshotHelper.java
+++ b/core/java/com/android/internal/util/ScreenshotHelper.java
@@ -6,6 +6,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
+import android.net.Uri;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
@@ -58,7 +59,7 @@ public class ScreenshotHelper {
*/
public void takeScreenshot(final int screenshotType, final boolean hasStatus,
final boolean hasNav, @NonNull Handler handler,
- @Nullable Consumer<Boolean> completionConsumer) {
+ @Nullable Consumer<Uri> completionConsumer) {
takeScreenshot(screenshotType, hasStatus, hasNav, SCREENSHOT_TIMEOUT_MS, handler,
completionConsumer);
}
@@ -83,12 +84,12 @@ public class ScreenshotHelper {
* the screenshot attempt will be cancelled and `completionConsumer`
* will be run.
* @param handler A handler used in case the screenshot times out
- * @param completionConsumer Consumes `false` if a screenshot was not taken, and `true` if the
- * screenshot was taken.
+ * @param completionConsumer Consumes `null` if a screenshot was not taken, and the URI of the
+ * screenshot if the screenshot was taken.
*/
public void takeScreenshot(final int screenshotType, final boolean hasStatus,
final boolean hasNav, long timeoutMs, @NonNull Handler handler,
- @Nullable Consumer<Boolean> completionConsumer) {
+ @Nullable Consumer<Uri> completionConsumer) {
synchronized (mScreenshotLock) {
if (mScreenshotConnection != null) {
return;
@@ -108,7 +109,7 @@ public class ScreenshotHelper {
}
}
if (completionConsumer != null) {
- completionConsumer.accept(false);
+ completionConsumer.accept(null);
}
}
};
@@ -134,8 +135,9 @@ public class ScreenshotHelper {
handler.removeCallbacks(mScreenshotTimeout);
}
}
+
if (completionConsumer != null) {
- completionConsumer.accept(true);
+ completionConsumer.accept((Uri) msg.obj);
}
}
};
@@ -148,7 +150,7 @@ public class ScreenshotHelper {
} catch (RemoteException e) {
Log.e(TAG, "Couldn't take screenshot: " + e);
if (completionConsumer != null) {
- completionConsumer.accept(false);
+ completionConsumer.accept(null);
}
}
}