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
17package android.content.pm;
18
19import android.annotation.NonNull;
20import android.annotation.Nullable;
21import android.annotation.UserIdInt;
22import android.appwidget.AppWidgetProviderInfo;
23import android.content.ComponentName;
24import android.content.Intent;
25import android.content.IntentSender;
26import android.content.pm.LauncherApps.ShortcutQuery;
27import android.os.Bundle;
28import android.os.ParcelFileDescriptor;
29
30import 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 */
39public abstract class ShortcutServiceInternal {
40    public interface ShortcutChangeListener {
41        void onShortcutChanged(@NonNull String packageName, @UserIdInt int userId);
42    }
43
44    public abstract List<ShortcutInfo>
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
52            isPinnedByCaller(int launcherUserId, @NonNull String callingPackage,
53            @NonNull String packageName, @NonNull String id, int userId);
54
55    public abstract void pinShortcuts(int launcherUserId,
56            @NonNull String callingPackage, @NonNull String packageName,
57            @NonNull List<String> shortcutIds, int userId);
58
59    public abstract Intent[] createShortcutIntents(
60            int launcherUserId, @NonNull String callingPackage,
61            @NonNull String packageName, @NonNull String shortcutId, int userId);
62
63    public abstract void addListener(@NonNull ShortcutChangeListener listener);
64
65    public abstract int getShortcutIconResId(int launcherUserId, @NonNull String callingPackage,
66            @NonNull String packageName, @NonNull String shortcutId, int userId);
67
68    public abstract ParcelFileDescriptor getShortcutIconFd(int launcherUserId,
69            @NonNull String callingPackage,
70            @NonNull String packageName, @NonNull String shortcutId, int userId);
71
72    public abstract boolean hasShortcutHostPermission(int launcherUserId,
73            @NonNull String callingPackage);
74
75    public abstract boolean requestPinAppWidget(@NonNull String callingPackage,
76            @NonNull AppWidgetProviderInfo appWidget, @Nullable Bundle extras,
77            @Nullable IntentSender resultIntent, int userId);
78
79    public abstract boolean isRequestPinItemSupported(int callingUserId, int requestType);
80}
81