Debian Codegraph @

core/java/com/android/internal/app/ChooserActivityLoggerImpl.java

raw symbols SCIP
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.internal.app;
18
19 import com.android.internal.logging.InstanceId;
20 import com.android.internal.logging.InstanceIdSequence;
21 import com.android.internal.logging.UiEventLogger;
22 import com.android.internal.logging.UiEventLoggerImpl;
23 import com.android.internal.util.FrameworkStatsLog;
24
25 /**
26 * Standard implementation of ChooserActivityLogger interface.
27 * @hide
28 */
29 public class ChooserActivityLoggerImpl implements ChooserActivityLogger {
30 private static final int SHARESHEET_INSTANCE_ID_MAX = (1 << 13);
31
32 private UiEventLogger mUiEventLogger = new UiEventLoggerImpl();
33 // A small per-notification ID, used for statsd logging.
34 private InstanceId mInstanceId;
35 private static InstanceIdSequence sInstanceIdSequence;
36
37 @Override
38 public void logShareStarted(int eventId, String packageName, String mimeType,
39 int appProvidedDirect, int appProvidedApp, boolean isWorkprofile, int previewType,
40 String intent) {
41 FrameworkStatsLog.write(FrameworkStatsLog.SHARESHEET_STARTED,
42 /* event_id = 1 */ SharesheetStartedEvent.SHARE_STARTED.getId(),
43 /* package_name = 2 */ packageName,
44 /* instance_id = 3 */ getInstanceId().getId(),
45 /* mime_type = 4 */ mimeType,
46 /* num_app_provided_direct_targets = 5 */ appProvidedDirect,
47 /* num_app_provided_app_targets = 6 */ appProvidedApp,
48 /* is_workprofile = 7 */ isWorkprofile,
49 /* previewType = 8 */ typeFromPreviewInt(previewType),
50 /* intentType = 9 */ typeFromIntentString(intent));
51 }
52
53 @Override
54 public void logShareTargetSelected(int targetType, String packageName, int positionPicked,
55 boolean isPinned) {
56 FrameworkStatsLog.write(FrameworkStatsLog.RANKING_SELECTED,
57 /* event_id = 1 */ SharesheetTargetSelectedEvent.fromTargetType(targetType).getId(),
58 /* package_name = 2 */ packageName,
59 /* instance_id = 3 */ getInstanceId().getId(),
60 /* position_picked = 4 */ positionPicked,
61 /* is_pinned = 5 */ isPinned);
62 }
63
64 @Override
65 public void log(UiEventLogger.UiEventEnum event, InstanceId instanceId) {
66 mUiEventLogger.logWithInstanceId(
67 event,
68 0,
69 null,
70 instanceId);
71 }
72
73 @Override
74 public InstanceId getInstanceId() {
75 if (mInstanceId == null) {
76 if (sInstanceIdSequence == null) {
77 sInstanceIdSequence = new InstanceIdSequence(SHARESHEET_INSTANCE_ID_MAX);
78 }
79 mInstanceId = sInstanceIdSequence.newInstanceId();
80 }
81 return mInstanceId;
82 }
83
84 }