blob: 63f323ed2768c3681a80d088dea390e85b9f67a3 [file] [log] [blame]
Satakshid2010f22019-10-29 10:57:43 -07001/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.systemui.screenshot;
18
19import android.app.Notification;
20import android.content.ComponentName;
Satakshid2010f22019-10-29 10:57:43 -070021import android.graphics.Bitmap;
Katsiaryna Naliuka2f8ae172020-04-22 14:14:27 +020022import android.net.Uri;
Katsiaryna Naliuka104380d2020-05-14 14:01:29 +020023import android.os.UserHandle;
Satakshid2010f22019-10-29 10:57:43 -070024import android.util.Log;
25
26import java.util.Collections;
27import java.util.List;
28import java.util.concurrent.CompletableFuture;
Satakshid2010f22019-10-29 10:57:43 -070029
30/**
31 * This class can be overridden by a vendor-specific sys UI implementation,
32 * in order to provide smart actions in the screenshot notification.
33 */
34public class ScreenshotNotificationSmartActionsProvider {
Satakshiaaf69532019-11-07 17:54:24 -080035 /* Key provided in the notification action to get the type of smart action. */
36 public static final String ACTION_TYPE = "action_type";
37 public static final String DEFAULT_ACTION_TYPE = "Smart Action";
38
39 /* Define phases of screenshot execution. */
40 protected enum ScreenshotOp {
41 OP_UNKNOWN,
42 RETRIEVE_SMART_ACTIONS,
43 REQUEST_SMART_ACTIONS,
44 WAIT_FOR_SMART_ACTIONS
45 }
46
47 /* Enum to report success or failure for screenshot execution phases. */
48 protected enum ScreenshotOpStatus {
49 OP_STATUS_UNKNOWN,
50 SUCCESS,
51 ERROR,
52 TIMEOUT
53 }
54
Satakshid2010f22019-10-29 10:57:43 -070055 private static final String TAG = "ScreenshotActions";
56
57 /**
58 * Default implementation that returns an empty list.
59 * This method is overridden in vendor-specific Sys UI implementation.
60 *
Katsiaryna Naliuka858daa42020-03-20 14:58:35 +010061 * @param screenshotId A generated random unique id for the screenshot.
62 * @param screenshotFileName name of the file where the screenshot will be written.
63 * @param bitmap The bitmap of the screenshot. The bitmap config must be {@link
64 * HARDWARE}.
65 * @param componentName Contains package and activity class names where the screenshot was
66 * taken. This is used as an additional signal to generate and rank
67 * more relevant actions.
Katsiaryna Naliuka104380d2020-05-14 14:01:29 +020068 * @param userHandle The user handle of the app where the screenshot was taken.
Satakshid2010f22019-10-29 10:57:43 -070069 */
Satakshiaaf69532019-11-07 17:54:24 -080070 public CompletableFuture<List<Notification.Action>> getActions(
71 String screenshotId,
Katsiaryna Naliuka2f8ae172020-04-22 14:14:27 +020072 Uri screenshotUri,
Satakshiaaf69532019-11-07 17:54:24 -080073 Bitmap bitmap,
74 ComponentName componentName,
Katsiaryna Naliuka104380d2020-05-14 14:01:29 +020075 UserHandle userHandle) {
Satakshid2010f22019-10-29 10:57:43 -070076 Log.d(TAG, "Returning empty smart action list.");
77 return CompletableFuture.completedFuture(Collections.emptyList());
78 }
Satakshiaaf69532019-11-07 17:54:24 -080079
80 /**
81 * Notify exceptions and latency encountered during generating smart actions.
82 * This method is overridden in vendor-specific Sys UI implementation.
83 *
Katsiaryna Naliuka858daa42020-03-20 14:58:35 +010084 * @param screenshotId unique id of the screenshot.
Satakshiaaf69532019-11-07 17:54:24 -080085 * @param op screenshot execution phase defined in {@link ScreenshotOp}
86 * @param status {@link ScreenshotOpStatus} to report success or failure.
87 * @param durationMs latency experienced in different phases of screenshots.
88 */
89 public void notifyOp(String screenshotId, ScreenshotOp op, ScreenshotOpStatus status,
90 long durationMs) {
91 Log.d(TAG, "Return without notify.");
92 }
93
94 /**
95 * Notify screenshot notification action invoked.
96 * This method is overridden in vendor-specific Sys UI implementation.
97 *
98 * @param screenshotId Unique id of the screenshot.
99 * @param action type of notification action invoked.
100 * @param isSmartAction whether action invoked was a smart action.
101 */
102 public void notifyAction(String screenshotId, String action, boolean isSmartAction) {
103 Log.d(TAG, "Return without notify.");
104 }
Satakshid2010f22019-10-29 10:57:43 -0700105}