blob: 3edb33da9cd0f7bc14975ce6712d1fea75554aea [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;
Satakshid2010f22019-10-29 10:57:43 -070023import android.util.Log;
24
25import java.util.Collections;
26import java.util.List;
27import java.util.concurrent.CompletableFuture;
Satakshid2010f22019-10-29 10:57:43 -070028
29/**
30 * This class can be overridden by a vendor-specific sys UI implementation,
31 * in order to provide smart actions in the screenshot notification.
32 */
33public class ScreenshotNotificationSmartActionsProvider {
Satakshiaaf69532019-11-07 17:54:24 -080034 /* Key provided in the notification action to get the type of smart action. */
35 public static final String ACTION_TYPE = "action_type";
36 public static final String DEFAULT_ACTION_TYPE = "Smart Action";
37
38 /* Define phases of screenshot execution. */
39 protected enum ScreenshotOp {
40 OP_UNKNOWN,
41 RETRIEVE_SMART_ACTIONS,
42 REQUEST_SMART_ACTIONS,
43 WAIT_FOR_SMART_ACTIONS
44 }
45
46 /* Enum to report success or failure for screenshot execution phases. */
47 protected enum ScreenshotOpStatus {
48 OP_STATUS_UNKNOWN,
49 SUCCESS,
50 ERROR,
51 TIMEOUT
52 }
53
Satakshid2010f22019-10-29 10:57:43 -070054 private static final String TAG = "ScreenshotActions";
55
56 /**
57 * Default implementation that returns an empty list.
58 * This method is overridden in vendor-specific Sys UI implementation.
59 *
Katsiaryna Naliuka858daa42020-03-20 14:58:35 +010060 * @param screenshotId A generated random unique id for the screenshot.
61 * @param screenshotFileName name of the file where the screenshot will be written.
62 * @param bitmap The bitmap of the screenshot. The bitmap config must be {@link
63 * HARDWARE}.
64 * @param componentName Contains package and activity class names where the screenshot was
65 * taken. This is used as an additional signal to generate and rank
66 * more relevant actions.
67 * @param isManagedProfile The screenshot was taken for a work profile app.
Satakshid2010f22019-10-29 10:57:43 -070068 */
Satakshiaaf69532019-11-07 17:54:24 -080069 public CompletableFuture<List<Notification.Action>> getActions(
70 String screenshotId,
Katsiaryna Naliuka2f8ae172020-04-22 14:14:27 +020071 Uri screenshotUri,
Satakshiaaf69532019-11-07 17:54:24 -080072 Bitmap bitmap,
73 ComponentName componentName,
Satakshid2010f22019-10-29 10:57:43 -070074 boolean isManagedProfile) {
75 Log.d(TAG, "Returning empty smart action list.");
76 return CompletableFuture.completedFuture(Collections.emptyList());
77 }
Satakshiaaf69532019-11-07 17:54:24 -080078
79 /**
80 * Notify exceptions and latency encountered during generating smart actions.
81 * This method is overridden in vendor-specific Sys UI implementation.
82 *
Katsiaryna Naliuka858daa42020-03-20 14:58:35 +010083 * @param screenshotId unique id of the screenshot.
Satakshiaaf69532019-11-07 17:54:24 -080084 * @param op screenshot execution phase defined in {@link ScreenshotOp}
85 * @param status {@link ScreenshotOpStatus} to report success or failure.
86 * @param durationMs latency experienced in different phases of screenshots.
87 */
88 public void notifyOp(String screenshotId, ScreenshotOp op, ScreenshotOpStatus status,
89 long durationMs) {
90 Log.d(TAG, "Return without notify.");
91 }
92
93 /**
94 * Notify screenshot notification action invoked.
95 * This method is overridden in vendor-specific Sys UI implementation.
96 *
97 * @param screenshotId Unique id of the screenshot.
98 * @param action type of notification action invoked.
99 * @param isSmartAction whether action invoked was a smart action.
100 */
101 public void notifyAction(String screenshotId, String action, boolean isSmartAction) {
102 Log.d(TAG, "Return without notify.");
103 }
Satakshid2010f22019-10-29 10:57:43 -0700104}