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.ResourceBasedOverride.Overrides.getObject; 19 20 import android.content.ComponentName; 21 import android.os.UserHandle; 22 23 import com.android.launcher3.R; 24 import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; 25 import com.android.launcher3.util.MainThreadInitializedObject; 26 import com.android.launcher3.util.ResourceBasedOverride; 27 28 import androidx.annotation.Nullable; 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 new MainThreadInitializedObject<>(c -> 47 getObject(AppLaunchTracker.class, c, R.string.app_launch_tracker_class)); 48 onStartShortcut(String packageName, String shortcutId, UserHandle user, @Nullable String container)49 public void onStartShortcut(String packageName, String shortcutId, UserHandle user, 50 @Nullable String container) { } 51 onStartApp(ComponentName componentName, UserHandle user, @Nullable String container)52 public void onStartApp(ComponentName componentName, UserHandle user, 53 @Nullable String container) { } 54 onReturnedToHome()55 public void onReturnedToHome() { } 56 } 57