• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.IntentFilter;
26 import android.content.IntentSender;
27 import android.content.LocusId;
28 import android.content.pm.LauncherApps.ShortcutQuery;
29 import android.os.Bundle;
30 import android.os.ParcelFileDescriptor;
31 
32 import java.util.List;
33 
34 /**
35  * Entry points used by {@link LauncherApps}.
36  *
37  * <p>No permission / argument checks will be performed inside.
38  * Callers must check the calling app permission and the calling package name.
39  * @hide
40  */
41 public abstract class ShortcutServiceInternal {
42     public interface ShortcutChangeListener {
onShortcutChanged(@onNull String packageName, @UserIdInt int userId)43         void onShortcutChanged(@NonNull String packageName, @UserIdInt int userId);
44     }
45 
46     public abstract List<ShortcutInfo>
getShortcuts(int launcherUserId, @NonNull String callingPackage, long changedSince, @Nullable String packageName, @Nullable List<String> shortcutIds, @Nullable List<LocusId> locusIds, @Nullable ComponentName componentName, @ShortcutQuery.QueryFlags int flags, int userId, int callingPid, int callingUid)47             getShortcuts(int launcherUserId,
48             @NonNull String callingPackage, long changedSince,
49             @Nullable String packageName, @Nullable List<String> shortcutIds,
50             @Nullable List<LocusId> locusIds, @Nullable ComponentName componentName,
51             @ShortcutQuery.QueryFlags int flags, int userId, int callingPid, int callingUid);
52 
53     public abstract boolean
isPinnedByCaller(int launcherUserId, @NonNull String callingPackage, @NonNull String packageName, @NonNull String id, int userId)54             isPinnedByCaller(int launcherUserId, @NonNull String callingPackage,
55             @NonNull String packageName, @NonNull String id, int userId);
56 
pinShortcuts(int launcherUserId, @NonNull String callingPackage, @NonNull String packageName, @NonNull List<String> shortcutIds, int userId)57     public abstract void pinShortcuts(int launcherUserId,
58             @NonNull String callingPackage, @NonNull String packageName,
59             @NonNull List<String> shortcutIds, int userId);
60 
createShortcutIntents( int launcherUserId, @NonNull String callingPackage, @NonNull String packageName, @NonNull String shortcutId, int userId, int callingPid, int callingUid)61     public abstract Intent[] createShortcutIntents(
62             int launcherUserId, @NonNull String callingPackage,
63             @NonNull String packageName, @NonNull String shortcutId, int userId,
64             int callingPid, int callingUid);
65 
addListener(@onNull ShortcutChangeListener listener)66     public abstract void addListener(@NonNull ShortcutChangeListener listener);
67 
addShortcutChangeCallback( @onNull LauncherApps.ShortcutChangeCallback callback)68     public abstract void addShortcutChangeCallback(
69             @NonNull LauncherApps.ShortcutChangeCallback callback);
70 
getShortcutIconResId(int launcherUserId, @NonNull String callingPackage, @NonNull String packageName, @NonNull String shortcutId, int userId)71     public abstract int getShortcutIconResId(int launcherUserId, @NonNull String callingPackage,
72             @NonNull String packageName, @NonNull String shortcutId, int userId);
73 
74     /**
75      * Get the theme res ID of the starting window, it can be 0 if not specified.
76      */
getShortcutStartingThemeResName(int launcherUserId, @NonNull String callingPackage, @NonNull String packageName, @NonNull String shortcutId, int userId)77     public abstract @Nullable String getShortcutStartingThemeResName(int launcherUserId,
78             @NonNull String callingPackage, @NonNull String packageName, @NonNull String shortcutId,
79             int userId);
80 
getShortcutIconFd(int launcherUserId, @NonNull String callingPackage, @NonNull String packageName, @NonNull String shortcutId, int userId)81     public abstract ParcelFileDescriptor getShortcutIconFd(int launcherUserId,
82             @NonNull String callingPackage,
83             @NonNull String packageName, @NonNull String shortcutId, int userId);
84 
hasShortcutHostPermission(int launcherUserId, @NonNull String callingPackage, int callingPid, int callingUid)85     public abstract boolean hasShortcutHostPermission(int launcherUserId,
86             @NonNull String callingPackage, int callingPid, int callingUid);
87 
setShortcutHostPackage(@onNull String type, @Nullable String packageName, int userId)88     public abstract void setShortcutHostPackage(@NonNull String type, @Nullable String packageName,
89             int userId);
90 
requestPinAppWidget(@onNull String callingPackage, @NonNull AppWidgetProviderInfo appWidget, @Nullable Bundle extras, @Nullable IntentSender resultIntent, int userId)91     public abstract boolean requestPinAppWidget(@NonNull String callingPackage,
92             @NonNull AppWidgetProviderInfo appWidget, @Nullable Bundle extras,
93             @Nullable IntentSender resultIntent, int userId);
94 
isRequestPinItemSupported(int callingUserId, int requestType)95     public abstract boolean isRequestPinItemSupported(int callingUserId, int requestType);
96 
isForegroundDefaultLauncher(@onNull String callingPackage, int callingUid)97     public abstract boolean isForegroundDefaultLauncher(@NonNull String callingPackage,
98             int callingUid);
99 
cacheShortcuts(int launcherUserId, @NonNull String callingPackage, @NonNull String packageName, @NonNull List<String> shortcutIds, int userId, int cacheFlags)100     public abstract void cacheShortcuts(int launcherUserId,
101             @NonNull String callingPackage, @NonNull String packageName,
102             @NonNull List<String> shortcutIds, int userId, int cacheFlags);
uncacheShortcuts(int launcherUserId, @NonNull String callingPackage, @NonNull String packageName, @NonNull List<String> shortcutIds, int userId, int cacheFlags)103     public abstract void uncacheShortcuts(int launcherUserId,
104             @NonNull String callingPackage, @NonNull String packageName,
105             @NonNull List<String> shortcutIds, int userId, int cacheFlags);
106 
107     /**
108      * Retrieves all of the direct share targets that match the given IntentFilter for the specified
109      * user.
110      */
getShareTargets( @onNull String callingPackage, @NonNull IntentFilter intentFilter, int userId)111     public abstract List<ShortcutManager.ShareShortcutInfo> getShareTargets(
112             @NonNull String callingPackage, @NonNull IntentFilter intentFilter, int userId);
113 
114     /**
115      * Returns the icon Uri of the shortcut, and grants Uri read permission to the caller.
116      */
getShortcutIconUri(int launcherUserId, @NonNull String launcherPackage, @NonNull String packageName, @NonNull String shortcutId, int userId)117     public abstract String getShortcutIconUri(int launcherUserId, @NonNull String launcherPackage,
118             @NonNull String packageName, @NonNull String shortcutId, int userId);
119 
isSharingShortcut(int callingUserId, @NonNull String callingPackage, @NonNull String packageName, @NonNull String shortcutId, int userId, @NonNull IntentFilter filter)120     public abstract boolean isSharingShortcut(int callingUserId, @NonNull String callingPackage,
121             @NonNull String packageName, @NonNull String shortcutId, int userId,
122             @NonNull IntentFilter filter);
123 }
124