1 /*
2  * Copyright (C) 2016 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 android.content.pm;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.annotation.UserIdInt;
22 import android.appwidget.AppWidgetProviderInfo;
23 import android.content.ComponentName;
24 import android.content.Intent;
25 import android.content.IntentSender;
26 import android.content.pm.LauncherApps.ShortcutQuery;
27 import android.os.Bundle;
28 import android.os.ParcelFileDescriptor;
29 
30 import java.util.List;
31 
32 /**
33  * Entry points used by {@link LauncherApps}.
34  *
35  * <p>No permission / argument checks will be performed inside.
36  * Callers must check the calling app permission and the calling package name.
37  * @hide
38  */
39 public abstract class ShortcutServiceInternal {
40     public interface ShortcutChangeListener {
onShortcutChanged(@onNull String packageName, @UserIdInt int userId)41         void onShortcutChanged(@NonNull String packageName, @UserIdInt int userId);
42     }
43 
44     public abstract List<ShortcutInfo>
getShortcuts(int launcherUserId, @NonNull String callingPackage, long changedSince, @Nullable String packageName, @Nullable List<String> shortcutIds, @Nullable ComponentName componentName, @ShortcutQuery.QueryFlags int flags, int userId)45             getShortcuts(int launcherUserId,
46             @NonNull String callingPackage, long changedSince,
47             @Nullable String packageName, @Nullable List<String> shortcutIds,
48             @Nullable ComponentName componentName, @ShortcutQuery.QueryFlags int flags,
49             int userId);
50 
51     public abstract boolean
isPinnedByCaller(int launcherUserId, @NonNull String callingPackage, @NonNull String packageName, @NonNull String id, int userId)52             isPinnedByCaller(int launcherUserId, @NonNull String callingPackage,
53             @NonNull String packageName, @NonNull String id, int userId);
54 
pinShortcuts(int launcherUserId, @NonNull String callingPackage, @NonNull String packageName, @NonNull List<String> shortcutIds, int userId)55     public abstract void pinShortcuts(int launcherUserId,
56             @NonNull String callingPackage, @NonNull String packageName,
57             @NonNull List<String> shortcutIds, int userId);
58 
createShortcutIntents( int launcherUserId, @NonNull String callingPackage, @NonNull String packageName, @NonNull String shortcutId, int userId)59     public abstract Intent[] createShortcutIntents(
60             int launcherUserId, @NonNull String callingPackage,
61             @NonNull String packageName, @NonNull String shortcutId, int userId);
62 
addListener(@onNull ShortcutChangeListener listener)63     public abstract void addListener(@NonNull ShortcutChangeListener listener);
64 
getShortcutIconResId(int launcherUserId, @NonNull String callingPackage, @NonNull String packageName, @NonNull String shortcutId, int userId)65     public abstract int getShortcutIconResId(int launcherUserId, @NonNull String callingPackage,
66             @NonNull String packageName, @NonNull String shortcutId, int userId);
67 
getShortcutIconFd(int launcherUserId, @NonNull String callingPackage, @NonNull String packageName, @NonNull String shortcutId, int userId)68     public abstract ParcelFileDescriptor getShortcutIconFd(int launcherUserId,
69             @NonNull String callingPackage,
70             @NonNull String packageName, @NonNull String shortcutId, int userId);
71 
hasShortcutHostPermission(int launcherUserId, @NonNull String callingPackage)72     public abstract boolean hasShortcutHostPermission(int launcherUserId,
73             @NonNull String callingPackage);
74 
requestPinAppWidget(@onNull String callingPackage, @NonNull AppWidgetProviderInfo appWidget, @Nullable Bundle extras, @Nullable IntentSender resultIntent, int userId)75     public abstract boolean requestPinAppWidget(@NonNull String callingPackage,
76             @NonNull AppWidgetProviderInfo appWidget, @Nullable Bundle extras,
77             @Nullable IntentSender resultIntent, int userId);
78 
isRequestPinItemSupported(int callingUserId, int requestType)79     public abstract boolean isRequestPinItemSupported(int callingUserId, int requestType);
80 }
81