1 /* 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 package com.android.launcher3.model; 17 18 import static com.android.launcher3.util.MainThreadInitializedObject.forOverride; 19 20 import android.content.ComponentName; 21 import android.os.UserHandle; 22 23 import androidx.annotation.Nullable; 24 25 import com.android.launcher3.R; 26 import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; 27 import com.android.launcher3.util.MainThreadInitializedObject; 28 import com.android.launcher3.util.ResourceBasedOverride; 29 30 /** 31 * Callback for receiving various app launch events 32 */ 33 public class AppLaunchTracker implements ResourceBasedOverride { 34 35 /** 36 * Derived from LauncherEvent proto. 37 * TODO: Use proper descriptive constants 38 */ 39 public static final String CONTAINER_DEFAULT = Integer.toString(ContainerType.WORKSPACE); 40 public static final String CONTAINER_ALL_APPS = Integer.toString(ContainerType.ALLAPPS); 41 public static final String CONTAINER_PREDICTIONS = Integer.toString(ContainerType.PREDICTION); 42 public static final String CONTAINER_SEARCH = Integer.toString(ContainerType.SEARCHRESULT); 43 44 45 public static final MainThreadInitializedObject<AppLaunchTracker> INSTANCE = 46 forOverride(AppLaunchTracker.class, R.string.app_launch_tracker_class); 47 onStartShortcut(String packageName, String shortcutId, UserHandle user, @Nullable String container)48 public void onStartShortcut(String packageName, String shortcutId, UserHandle user, 49 @Nullable String container) { } 50 onStartApp(ComponentName componentName, UserHandle user, @Nullable String container)51 public void onStartApp(ComponentName componentName, UserHandle user, 52 @Nullable String container) { } 53 onDismissApp(ComponentName componentName, UserHandle user, @Nullable String container)54 public void onDismissApp(ComponentName componentName, UserHandle user, 55 @Nullable String container){} 56 onReturnedToHome()57 public void onReturnedToHome() { } 58 } 59