1 /*
2  * Copyright (C) 2020 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 
17 package com.android.systemui.screenshot;
18 
19 import static android.view.WindowManager.ScreenshotSource.SCREENSHOT_ACCESSIBILITY_ACTIONS;
20 import static android.view.WindowManager.ScreenshotSource.SCREENSHOT_GLOBAL_ACTIONS;
21 import static android.view.WindowManager.ScreenshotSource.SCREENSHOT_KEY_CHORD;
22 import static android.view.WindowManager.ScreenshotSource.SCREENSHOT_KEY_OTHER;
23 import static android.view.WindowManager.ScreenshotSource.SCREENSHOT_OTHER;
24 import static android.view.WindowManager.ScreenshotSource.SCREENSHOT_OVERVIEW;
25 
26 import com.android.internal.logging.UiEvent;
27 import com.android.internal.logging.UiEventLogger;
28 
29 public enum ScreenshotEvent implements UiEventLogger.UiEventEnum {
30     @UiEvent(doc = "screenshot requested from global actions")
31     SCREENSHOT_REQUESTED_GLOBAL_ACTIONS(302),
32     @UiEvent(doc = "screenshot requested from key chord")
33     SCREENSHOT_REQUESTED_KEY_CHORD(303),
34     @UiEvent(doc = "screenshot requested from other key press (e.g. ctrl-s)")
35     SCREENSHOT_REQUESTED_KEY_OTHER(384),
36     @UiEvent(doc = "screenshot requested from overview")
37     SCREENSHOT_REQUESTED_OVERVIEW(304),
38     @UiEvent(doc = "screenshot requested from accessibility actions")
39     SCREENSHOT_REQUESTED_ACCESSIBILITY_ACTIONS(382),
40     @UiEvent(doc = "screenshot requested (other)")
41     SCREENSHOT_REQUESTED_OTHER(305),
42     @UiEvent(doc = "screenshot was saved")
43     SCREENSHOT_SAVED(306),
44     @UiEvent(doc = "screenshot failed to save")
45     SCREENSHOT_NOT_SAVED(336),
46     @UiEvent(doc = "screenshot preview tapped")
47     SCREENSHOT_PREVIEW_TAPPED(307),
48     @UiEvent(doc = "screenshot edit button tapped")
49     SCREENSHOT_EDIT_TAPPED(308),
50     @UiEvent(doc = "screenshot share button tapped")
51     SCREENSHOT_SHARE_TAPPED(309),
52     @UiEvent(doc = "screenshot smart action chip tapped")
53     SCREENSHOT_SMART_ACTION_TAPPED(374),
54     @UiEvent(doc = "screenshot scroll tapped")
55     SCREENSHOT_SCROLL_TAPPED(373),
56     @UiEvent(doc = "screenshot interaction timed out")
57     SCREENSHOT_INTERACTION_TIMEOUT(310),
58     @UiEvent(doc = "screenshot explicitly dismissed")
59     SCREENSHOT_EXPLICIT_DISMISSAL(311);
60 
61     private final int mId;
62 
ScreenshotEvent(int id)63     ScreenshotEvent(int id) {
64         mId = id;
65     }
66 
67     @Override
getId()68     public int getId() {
69         return mId;
70     }
71 
getScreenshotSource(int source)72     static ScreenshotEvent getScreenshotSource(int source) {
73         switch (source) {
74             case SCREENSHOT_GLOBAL_ACTIONS:
75                 return ScreenshotEvent.SCREENSHOT_REQUESTED_GLOBAL_ACTIONS;
76             case SCREENSHOT_KEY_CHORD:
77                 return ScreenshotEvent.SCREENSHOT_REQUESTED_KEY_CHORD;
78             case SCREENSHOT_KEY_OTHER:
79                 return ScreenshotEvent.SCREENSHOT_REQUESTED_KEY_OTHER;
80             case SCREENSHOT_OVERVIEW:
81                 return ScreenshotEvent.SCREENSHOT_REQUESTED_OVERVIEW;
82             case SCREENSHOT_ACCESSIBILITY_ACTIONS:
83                 return ScreenshotEvent.SCREENSHOT_REQUESTED_ACCESSIBILITY_ACTIONS;
84             case SCREENSHOT_OTHER:
85             default:
86                 return ScreenshotEvent.SCREENSHOT_REQUESTED_OTHER;
87         }
88     }
89 }
90