2 * Copyright (C) 2014 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package android.content.pm;
19 import android.annotation.IntDef;
20 import android.annotation.NonNull;
21 import android.annotation.Nullable;
22 import android.annotation.TestApi;
23 import android.content.ComponentName;
24 import android.content.Context;
25 import android.content.Intent;
26 import android.content.pm.PackageManager.ApplicationInfoFlags;
27 import android.graphics.Rect;
28 import android.os.Bundle;
29 import android.os.Handler;
30 import android.os.Looper;
31 import android.os.Message;
32 import android.os.ParcelFileDescriptor;
33 import android.os.RemoteException;
34 import android.os.ServiceManager;
35 import android.os.UserHandle;
36 import android.os.UserManager;
37 import android.util.Log;
39 import java.lang.annotation.Retention;
40 import java.lang.annotation.RetentionPolicy;
41 import java.util.ArrayList;
42 import java.util.Arrays;
43 import java.util.Collections;
44 import java.util.List;
47 * Class for retrieving a list of launchable activities for the current user and any associated
48 * managed profiles. This is mainly for use by launchers. Apps can be queried for each user profile.
49 * Since the PackageManager will not deliver package broadcasts for other profiles, you can register
50 * for package changes here.
52 * To watch for managed profiles being added or removed, register for the following broadcasts:
53 * {@link Intent#ACTION_MANAGED_PROFILE_ADDED} and {@link Intent#ACTION_MANAGED_PROFILE_REMOVED}.
55 * You can retrieve the list of profiles associated with this user with
56 * {@link UserManager#getUserProfiles()}.
58 public class LauncherApps {
60 static final String TAG = "LauncherApps";
61 static final boolean DEBUG = false;
63 private Context mContext;
64 private ILauncherApps mService;
65 private PackageManager mPm;
67 private List<CallbackMessageHandler> mCallbacks
68 = new ArrayList<CallbackMessageHandler>();
71 * Callbacks for package changes to this and related managed profiles.
73 public static abstract class Callback {
75 * Indicates that a package was removed from the specified profile.
77 * If a package is removed while being updated onPackageChanged will be
80 * @param packageName The name of the package that was removed.
81 * @param user The UserHandle of the profile that generated the change.
83 abstract public void onPackageRemoved(String packageName, UserHandle user);
86 * Indicates that a package was added to the specified profile.
88 * If a package is added while being updated then onPackageChanged will be
91 * @param packageName The name of the package that was added.
92 * @param user The UserHandle of the profile that generated the change.
94 abstract public void onPackageAdded(String packageName, UserHandle user);
97 * Indicates that a package was modified in the specified profile.
98 * This can happen, for example, when the package is updated or when
99 * one or more components are enabled or disabled.
101 * @param packageName The name of the package that has changed.
102 * @param user The UserHandle of the profile that generated the change.
104 abstract public void onPackageChanged(String packageName, UserHandle user);
107 * Indicates that one or more packages have become available. For
108 * example, this can happen when a removable storage card has
111 * @param packageNames The names of the packages that have become
113 * @param user The UserHandle of the profile that generated the change.
114 * @param replacing Indicates whether these packages are replacing
117 abstract public void onPackagesAvailable(String[] packageNames, UserHandle user,
121 * Indicates that one or more packages have become unavailable. For
122 * example, this can happen when a removable storage card has been
125 * @param packageNames The names of the packages that have become
127 * @param user The UserHandle of the profile that generated the change.
128 * @param replacing Indicates whether the packages are about to be
129 * replaced with new versions.
131 abstract public void onPackagesUnavailable(String[] packageNames, UserHandle user,
135 * Indicates that one or more packages have been suspended. For
136 * example, this can happen when a Device Administrator suspends
139 * @param packageNames The names of the packages that have just been
141 * @param user The UserHandle of the profile that generated the change.
143 public void onPackagesSuspended(String[] packageNames, UserHandle user) {
147 * Indicates that one or more packages have been unsuspended. For
148 * example, this can happen when a Device Administrator unsuspends
151 * @param packageNames The names of the packages that have just been
153 * @param user The UserHandle of the profile that generated the change.
155 public void onPackagesUnsuspended(String[] packageNames, UserHandle user) {
159 * Indicates that one or more shortcuts (which may be dynamic and/or pinned)
160 * have been added, updated or removed.
162 * <p>Only the applications that are allowed to access the shortcut information,
163 * as defined in {@link #hasShortcutHostPermission()}, will receive it.
165 * @param packageName The name of the package that has the shortcuts.
166 * @param shortcuts all shortcuts from the package (dynamic and/or pinned). Only "key"
167 * information will be provided, as defined in {@link ShortcutInfo#hasKeyFieldsOnly()}.
168 * @param user The UserHandle of the profile that generated the change.
172 public void onShortcutsChanged(@NonNull String packageName,
173 @NonNull List<ShortcutInfo> shortcuts, @NonNull UserHandle user) {
178 * Represents a query passed to {@link #getShortcuts(ShortcutQuery, UserHandle)}.
182 public static class ShortcutQuery {
184 * Include dynamic shortcuts in the result.
186 public static final int FLAG_GET_DYNAMIC = 1 << 0;
189 * Include pinned shortcuts in the result.
191 public static final int FLAG_GET_PINNED = 1 << 1;
194 * Requests "key" fields only. See {@link ShortcutInfo#hasKeyFieldsOnly()} for which
195 * fields are available.
197 public static final int FLAG_GET_KEY_FIELDS_ONLY = 1 << 2;
204 FLAG_GET_KEY_FIELDS_ONLY,
206 @Retention(RetentionPolicy.SOURCE)
207 public @interface QueryFlags {}
215 List<String> mShortcutIds;
218 ComponentName mActivity;
223 public ShortcutQuery() {
227 * If non-zero, returns only shortcuts that have been added or updated since the timestamp,
228 * which is a milliseconds since the Epoch.
230 public void setChangedSince(long changedSince) {
231 mChangedSince = changedSince;
235 * If non-null, returns only shortcuts from the package.
237 public void setPackage(@Nullable String packageName) {
238 mPackage = packageName;
242 * If non-null, return only the specified shortcuts by ID. When setting this field,
243 * a packange name must also be set with {@link #setPackage}.
245 public void setShortcutIds(@Nullable List<String> shortcutIds) {
246 mShortcutIds = shortcutIds;
250 * If non-null, returns only shortcuts associated with the activity.
252 public void setActivity(@Nullable ComponentName activity) {
253 mActivity = activity;
259 public void setQueryFlags(@QueryFlags int queryFlags) {
260 mQueryFlags = queryFlags;
265 public LauncherApps(Context context, ILauncherApps service) {
268 mPm = context.getPackageManager();
273 public LauncherApps(Context context) {
274 this(context, ILauncherApps.Stub.asInterface(
275 ServiceManager.getService(Context.LAUNCHER_APPS_SERVICE)));
279 * Retrieves a list of launchable activities that match {@link Intent#ACTION_MAIN} and
280 * {@link Intent#CATEGORY_LAUNCHER}, for a specified user.
282 * @param packageName The specific package to query. If null, it checks all installed packages
284 * @param user The UserHandle of the profile.
285 * @return List of launchable activities. Can be an empty list but will not be null.
287 public List<LauncherActivityInfo> getActivityList(String packageName, UserHandle user) {
288 ParceledListSlice<ResolveInfo> activities = null;
290 activities = mService.getLauncherActivities(packageName, user);
291 } catch (RemoteException re) {
292 throw re.rethrowFromSystemServer();
294 if (activities == null) {
295 return Collections.EMPTY_LIST;
297 ArrayList<LauncherActivityInfo> lais = new ArrayList<LauncherActivityInfo>();
298 for (ResolveInfo ri : activities.getList()) {
299 LauncherActivityInfo lai = new LauncherActivityInfo(mContext, ri.activityInfo, user);
301 Log.v(TAG, "Returning activity for profile " + user + " : "
302 + lai.getComponentName());
310 * Returns the activity info for a given intent and user handle, if it resolves. Otherwise it
313 * @param intent The intent to find a match for.
314 * @param user The profile to look in for a match.
315 * @return An activity info object if there is a match.
317 public LauncherActivityInfo resolveActivity(Intent intent, UserHandle user) {
319 ActivityInfo ai = mService.resolveActivity(intent.getComponent(), user);
321 LauncherActivityInfo info = new LauncherActivityInfo(mContext, ai, user);
324 } catch (RemoteException re) {
325 throw re.rethrowFromSystemServer();
331 * Starts a Main activity in the specified profile.
333 * @param component The ComponentName of the activity to launch
334 * @param user The UserHandle of the profile
335 * @param sourceBounds The Rect containing the source bounds of the clicked icon
336 * @param opts Options to pass to startActivity
338 public void startMainActivity(ComponentName component, UserHandle user, Rect sourceBounds,
341 Log.i(TAG, "StartMainActivity " + component + " " + user.getIdentifier());
344 mService.startActivityAsUser(component, sourceBounds, opts, user);
345 } catch (RemoteException re) {
346 throw re.rethrowFromSystemServer();
351 * Starts the settings activity to show the application details for a
352 * package in the specified profile.
354 * @param component The ComponentName of the package to launch settings for.
355 * @param user The UserHandle of the profile
356 * @param sourceBounds The Rect containing the source bounds of the clicked icon
357 * @param opts Options to pass to startActivity
359 public void startAppDetailsActivity(ComponentName component, UserHandle user,
360 Rect sourceBounds, Bundle opts) {
362 mService.showAppDetailsAsUser(component, sourceBounds, opts, user);
363 } catch (RemoteException re) {
364 throw re.rethrowFromSystemServer();
369 * Checks if the package is installed and enabled for a profile.
371 * @param packageName The package to check.
372 * @param user The UserHandle of the profile.
374 * @return true if the package exists and is enabled.
376 public boolean isPackageEnabled(String packageName, UserHandle user) {
378 return mService.isPackageEnabled(packageName, user);
379 } catch (RemoteException re) {
380 throw re.rethrowFromSystemServer();
385 * Retrieve all of the information we know about a particular package / application.
387 * @param packageName The package of the application
388 * @param flags Additional option flags {@link PackageManager#getApplicationInfo}
389 * @param user The UserHandle of the profile.
391 * @return An {@link ApplicationInfo} containing information about the package or
392 * null of the package isn't found.
395 public ApplicationInfo getApplicationInfo(String packageName, @ApplicationInfoFlags int flags,
398 return mService.getApplicationInfo(packageName, flags, user);
399 } catch (RemoteException re) {
400 throw re.rethrowFromSystemServer();
405 * Checks if the activity exists and it enabled for a profile.
407 * @param component The activity to check.
408 * @param user The UserHandle of the profile.
410 * @return true if the activity exists and is enabled.
412 public boolean isActivityEnabled(ComponentName component, UserHandle user) {
414 return mService.isActivityEnabled(component, user);
415 } catch (RemoteException re) {
416 throw re.rethrowFromSystemServer();
421 * Returns whether the caller can access the shortcut information.
423 * <p>Only the default launcher can access the shortcut information.
425 * <p>Note when this method returns {@code false}, that may be a temporary situation because
426 * the user is trying a new launcher application. The user may decide to change the default
427 * launcher to the calling application again, so even if a launcher application loses
428 * this permission, it does <b>not</b> have to purge pinned shortcut information.
432 public boolean hasShortcutHostPermission() {
434 return mService.hasShortcutHostPermission(mContext.getPackageName());
435 } catch (RemoteException re) {
436 throw re.rethrowFromSystemServer();
441 * Returns the IDs of {@link ShortcutInfo}s that match {@code query}.
443 * <p>Callers must be allowed to access the shortcut information, as defined in {@link
444 * #hasShortcutHostPermission()}.
446 * @param query result includes shortcuts matching this query.
447 * @param user The UserHandle of the profile.
449 * @return the IDs of {@link ShortcutInfo}s that match the query.
454 public List<ShortcutInfo> getShortcuts(@NonNull ShortcutQuery query,
455 @NonNull UserHandle user) {
457 return mService.getShortcuts(mContext.getPackageName(),
458 query.mChangedSince, query.mPackage, query.mShortcutIds, query.mActivity,
459 query.mQueryFlags, user)
461 } catch (RemoteException e) {
462 throw e.rethrowFromSystemServer();
467 * @hide // No longer used. Use getShortcuts() instead. Kept for unit tests.
470 public List<ShortcutInfo> getShortcutInfo(@NonNull String packageName,
471 @NonNull List<String> ids, @NonNull UserHandle user) {
472 final ShortcutQuery q = new ShortcutQuery();
473 q.setPackage(packageName);
474 q.setShortcutIds(ids);
475 q.setQueryFlags(ShortcutQuery.FLAG_GET_DYNAMIC | ShortcutQuery.FLAG_GET_PINNED);
476 return getShortcuts(q, user);
480 * Pin shortcuts on a package.
482 * <p>This API is <b>NOT</b> cumulative; this will replace all pinned shortcuts for the package.
483 * However, different launchers may have different set of pinned shortcuts.
485 * <p>Callers must be allowed to access the shortcut information, as defined in {@link
486 * #hasShortcutHostPermission()}.
488 * @param packageName The target package name.
489 * @param shortcutIds The IDs of the shortcut to be pinned.
490 * @param user The UserHandle of the profile.
494 public void pinShortcuts(@NonNull String packageName, @NonNull List<String> shortcutIds,
495 @NonNull UserHandle user) {
497 mService.pinShortcuts(mContext.getPackageName(), packageName, shortcutIds, user);
498 } catch (RemoteException e) {
499 throw e.rethrowFromSystemServer();
504 * @hide kept for testing.
506 public int getShortcutIconResId(@NonNull ShortcutInfo shortcut) {
507 return shortcut.getIconResourceId();
511 * @hide kept for testing.
513 public int getShortcutIconResId(@NonNull String packageName, @NonNull String shortcutId,
514 @NonNull UserHandle user) {
515 final ShortcutQuery q = new ShortcutQuery();
516 q.setPackage(packageName);
517 q.setShortcutIds(Arrays.asList(shortcutId));
518 q.setQueryFlags(ShortcutQuery.FLAG_GET_DYNAMIC | ShortcutQuery.FLAG_GET_PINNED);
519 final List<ShortcutInfo> shortcuts = getShortcuts(q, user);
521 return shortcuts.size() > 0 ? shortcuts.get(0).getIconResourceId() : 0;
525 * Return the icon as {@link ParcelFileDescriptor}, when it's stored as a file
526 * (i.e. when {@link ShortcutInfo#hasIconFile()} returns {@code true}).
528 * <p>Callers must be allowed to access the shortcut information, as defined in {@link
529 * #hasShortcutHostPermission()}.
531 * @param shortcut The target shortcut.
535 public ParcelFileDescriptor getShortcutIconFd(
536 @NonNull ShortcutInfo shortcut) {
537 return getShortcutIconFd(shortcut.getPackageName(), shortcut.getId(),
538 shortcut.getUserId());
542 * Return the icon as {@link ParcelFileDescriptor}, when it's stored as a file
543 * (i.e. when {@link ShortcutInfo#hasIconFile()} returns {@code true}).
545 * <p>Callers must be allowed to access the shortcut information, as defined in {@link
546 * #hasShortcutHostPermission()}.
548 * @param packageName The target package name.
549 * @param shortcutId The ID of the shortcut to lad rom.
550 * @param user The UserHandle of the profile.
554 public ParcelFileDescriptor getShortcutIconFd(
555 @NonNull String packageName, @NonNull String shortcutId, @NonNull UserHandle user) {
556 return getShortcutIconFd(packageName, shortcutId, user.getIdentifier());
559 private ParcelFileDescriptor getShortcutIconFd(
560 @NonNull String packageName, @NonNull String shortcutId, int userId) {
562 return mService.getShortcutIconFd(mContext.getPackageName(),
563 packageName, shortcutId, userId);
564 } catch (RemoteException e) {
565 throw e.rethrowFromSystemServer();
570 * Launches a shortcut.
572 * <p>Callers must be allowed to access the shortcut information, as defined in {@link
573 * #hasShortcutHostPermission()}.
575 * @param packageName The target shortcut package name.
576 * @param shortcutId The target shortcut ID.
577 * @param sourceBounds The Rect containing the source bounds of the clicked icon.
578 * @param startActivityOptions Options to pass to startActivity.
579 * @param user The UserHandle of the profile.
580 * @return {@code false} when the shortcut is no longer valid (e.g. the creator application
581 * has been uninstalled). {@code true} when the shortcut is still valid.
585 public boolean startShortcut(@NonNull String packageName, @NonNull String shortcutId,
586 @Nullable Rect sourceBounds, @Nullable Bundle startActivityOptions,
587 @NonNull UserHandle user) {
588 return startShortcut(packageName, shortcutId, sourceBounds, startActivityOptions,
589 user.getIdentifier());
593 * Launches a shortcut.
595 * <p>Callers must be allowed to access the shortcut information, as defined in {@link
596 * #hasShortcutHostPermission()}.
598 * @param shortcut The target shortcut.
599 * @param sourceBounds The Rect containing the source bounds of the clicked icon.
600 * @param startActivityOptions Options to pass to startActivity.
601 * @return {@code false} when the shortcut is no longer valid (e.g. the creator application
602 * has been uninstalled). {@code true} when the shortcut is still valid.
606 public boolean startShortcut(@NonNull ShortcutInfo shortcut,
607 @Nullable Rect sourceBounds, @Nullable Bundle startActivityOptions) {
608 return startShortcut(shortcut.getPackageName(), shortcut.getId(),
609 sourceBounds, startActivityOptions,
610 shortcut.getUserId());
613 private boolean startShortcut(@NonNull String packageName, @NonNull String shortcutId,
614 @Nullable Rect sourceBounds, @Nullable Bundle startActivityOptions,
617 return mService.startShortcut(mContext.getPackageName(), packageName, shortcutId,
618 sourceBounds, startActivityOptions, userId);
619 } catch (RemoteException e) {
620 throw e.rethrowFromSystemServer();
625 * Registers a callback for changes to packages in current and managed profiles.
627 * @param callback The callback to register.
629 public void registerCallback(Callback callback) {
630 registerCallback(callback, null);
634 * Registers a callback for changes to packages in current and managed profiles.
636 * @param callback The callback to register.
637 * @param handler that should be used to post callbacks on, may be null.
639 public void registerCallback(Callback callback, Handler handler) {
640 synchronized (this) {
641 if (callback != null && findCallbackLocked(callback) < 0) {
642 boolean addedFirstCallback = mCallbacks.size() == 0;
643 addCallbackLocked(callback, handler);
644 if (addedFirstCallback) {
646 mService.addOnAppsChangedListener(mContext.getPackageName(),
647 mAppsChangedListener);
648 } catch (RemoteException re) {
649 throw re.rethrowFromSystemServer();
657 * Unregisters a callback that was previously registered.
659 * @param callback The callback to unregister.
660 * @see #registerCallback(Callback)
662 public void unregisterCallback(Callback callback) {
663 synchronized (this) {
664 removeCallbackLocked(callback);
665 if (mCallbacks.size() == 0) {
667 mService.removeOnAppsChangedListener(mAppsChangedListener);
668 } catch (RemoteException re) {
669 throw re.rethrowFromSystemServer();
675 /** @return position in mCallbacks for callback or -1 if not present. */
676 private int findCallbackLocked(Callback callback) {
677 if (callback == null) {
678 throw new IllegalArgumentException("Callback cannot be null");
680 final int size = mCallbacks.size();
681 for (int i = 0; i < size; ++i) {
682 if (mCallbacks.get(i).mCallback == callback) {
689 private void removeCallbackLocked(Callback callback) {
690 int pos = findCallbackLocked(callback);
692 mCallbacks.remove(pos);
696 private void addCallbackLocked(Callback callback, Handler handler) {
697 // Remove if already present.
698 removeCallbackLocked(callback);
699 if (handler == null) {
700 handler = new Handler();
702 CallbackMessageHandler toAdd = new CallbackMessageHandler(handler.getLooper(), callback);
703 mCallbacks.add(toAdd);
706 private IOnAppsChangedListener.Stub mAppsChangedListener = new IOnAppsChangedListener.Stub() {
709 public void onPackageRemoved(UserHandle user, String packageName)
710 throws RemoteException {
712 Log.d(TAG, "onPackageRemoved " + user.getIdentifier() + "," + packageName);
714 synchronized (LauncherApps.this) {
715 for (CallbackMessageHandler callback : mCallbacks) {
716 callback.postOnPackageRemoved(packageName, user);
722 public void onPackageChanged(UserHandle user, String packageName) throws RemoteException {
724 Log.d(TAG, "onPackageChanged " + user.getIdentifier() + "," + packageName);
726 synchronized (LauncherApps.this) {
727 for (CallbackMessageHandler callback : mCallbacks) {
728 callback.postOnPackageChanged(packageName, user);
734 public void onPackageAdded(UserHandle user, String packageName) throws RemoteException {
736 Log.d(TAG, "onPackageAdded " + user.getIdentifier() + "," + packageName);
738 synchronized (LauncherApps.this) {
739 for (CallbackMessageHandler callback : mCallbacks) {
740 callback.postOnPackageAdded(packageName, user);
746 public void onPackagesAvailable(UserHandle user, String[] packageNames, boolean replacing)
747 throws RemoteException {
749 Log.d(TAG, "onPackagesAvailable " + user.getIdentifier() + "," + packageNames);
751 synchronized (LauncherApps.this) {
752 for (CallbackMessageHandler callback : mCallbacks) {
753 callback.postOnPackagesAvailable(packageNames, user, replacing);
759 public void onPackagesUnavailable(UserHandle user, String[] packageNames, boolean replacing)
760 throws RemoteException {
762 Log.d(TAG, "onPackagesUnavailable " + user.getIdentifier() + "," + packageNames);
764 synchronized (LauncherApps.this) {
765 for (CallbackMessageHandler callback : mCallbacks) {
766 callback.postOnPackagesUnavailable(packageNames, user, replacing);
772 public void onPackagesSuspended(UserHandle user, String[] packageNames)
773 throws RemoteException {
775 Log.d(TAG, "onPackagesSuspended " + user.getIdentifier() + "," + packageNames);
777 synchronized (LauncherApps.this) {
778 for (CallbackMessageHandler callback : mCallbacks) {
779 callback.postOnPackagesSuspended(packageNames, user);
785 public void onPackagesUnsuspended(UserHandle user, String[] packageNames)
786 throws RemoteException {
788 Log.d(TAG, "onPackagesUnsuspended " + user.getIdentifier() + "," + packageNames);
790 synchronized (LauncherApps.this) {
791 for (CallbackMessageHandler callback : mCallbacks) {
792 callback.postOnPackagesUnsuspended(packageNames, user);
798 public void onShortcutChanged(UserHandle user, String packageName,
799 ParceledListSlice shortcuts) {
801 Log.d(TAG, "onShortcutChanged " + user.getIdentifier() + "," + packageName);
803 final List<ShortcutInfo> list = shortcuts.getList();
804 synchronized (LauncherApps.this) {
805 for (CallbackMessageHandler callback : mCallbacks) {
806 callback.postOnShortcutChanged(packageName, user, list);
812 private static class CallbackMessageHandler extends Handler {
813 private static final int MSG_ADDED = 1;
814 private static final int MSG_REMOVED = 2;
815 private static final int MSG_CHANGED = 3;
816 private static final int MSG_AVAILABLE = 4;
817 private static final int MSG_UNAVAILABLE = 5;
818 private static final int MSG_SUSPENDED = 6;
819 private static final int MSG_UNSUSPENDED = 7;
820 private static final int MSG_SHORTCUT_CHANGED = 8;
822 private LauncherApps.Callback mCallback;
824 private static class CallbackInfo {
825 String[] packageNames;
829 List<ShortcutInfo> shortcuts;
832 public CallbackMessageHandler(Looper looper, LauncherApps.Callback callback) {
833 super(looper, null, true);
834 mCallback = callback;
838 public void handleMessage(Message msg) {
839 if (mCallback == null || !(msg.obj instanceof CallbackInfo)) {
842 CallbackInfo info = (CallbackInfo) msg.obj;
845 mCallback.onPackageAdded(info.packageName, info.user);
848 mCallback.onPackageRemoved(info.packageName, info.user);
851 mCallback.onPackageChanged(info.packageName, info.user);
854 mCallback.onPackagesAvailable(info.packageNames, info.user, info.replacing);
856 case MSG_UNAVAILABLE:
857 mCallback.onPackagesUnavailable(info.packageNames, info.user, info.replacing);
860 mCallback.onPackagesSuspended(info.packageNames, info.user);
862 case MSG_UNSUSPENDED:
863 mCallback.onPackagesUnsuspended(info.packageNames, info.user);
865 case MSG_SHORTCUT_CHANGED:
866 mCallback.onShortcutsChanged(info.packageName, info.shortcuts, info.user);
871 public void postOnPackageAdded(String packageName, UserHandle user) {
872 CallbackInfo info = new CallbackInfo();
873 info.packageName = packageName;
875 obtainMessage(MSG_ADDED, info).sendToTarget();
878 public void postOnPackageRemoved(String packageName, UserHandle user) {
879 CallbackInfo info = new CallbackInfo();
880 info.packageName = packageName;
882 obtainMessage(MSG_REMOVED, info).sendToTarget();
885 public void postOnPackageChanged(String packageName, UserHandle user) {
886 CallbackInfo info = new CallbackInfo();
887 info.packageName = packageName;
889 obtainMessage(MSG_CHANGED, info).sendToTarget();
892 public void postOnPackagesAvailable(String[] packageNames, UserHandle user,
894 CallbackInfo info = new CallbackInfo();
895 info.packageNames = packageNames;
896 info.replacing = replacing;
898 obtainMessage(MSG_AVAILABLE, info).sendToTarget();
901 public void postOnPackagesUnavailable(String[] packageNames, UserHandle user,
903 CallbackInfo info = new CallbackInfo();
904 info.packageNames = packageNames;
905 info.replacing = replacing;
907 obtainMessage(MSG_UNAVAILABLE, info).sendToTarget();
910 public void postOnPackagesSuspended(String[] packageNames, UserHandle user) {
911 CallbackInfo info = new CallbackInfo();
912 info.packageNames = packageNames;
914 obtainMessage(MSG_SUSPENDED, info).sendToTarget();
917 public void postOnPackagesUnsuspended(String[] packageNames, UserHandle user) {
918 CallbackInfo info = new CallbackInfo();
919 info.packageNames = packageNames;
921 obtainMessage(MSG_UNSUSPENDED, info).sendToTarget();
924 public void postOnShortcutChanged(String packageName, UserHandle user,
925 List<ShortcutInfo> shortcuts) {
926 CallbackInfo info = new CallbackInfo();
927 info.packageName = packageName;
929 info.shortcuts = shortcuts;
930 obtainMessage(MSG_SHORTCUT_CHANGED, info).sendToTarget();