public class LauncherApps {
method public java.util.List<android.content.pm.LauncherActivityInfo> getActivityList(java.lang.String, android.os.UserHandle);
+ method public android.content.pm.ApplicationInfo getApplicationInfo(java.lang.String, int, android.os.UserHandle);
method public boolean isActivityEnabled(android.content.ComponentName, android.os.UserHandle);
method public boolean isPackageEnabled(java.lang.String, android.os.UserHandle);
method public void registerCallback(android.content.pm.LauncherApps.Callback);
method public abstract void onPackageChanged(java.lang.String, android.os.UserHandle);
method public abstract void onPackageRemoved(java.lang.String, android.os.UserHandle);
method public abstract void onPackagesAvailable(java.lang.String[], android.os.UserHandle, boolean);
+ method public void onPackagesSuspended(java.lang.String[], android.os.UserHandle);
method public abstract void onPackagesUnavailable(java.lang.String[], android.os.UserHandle, boolean);
+ method public void onPackagesUnsuspended(java.lang.String[], android.os.UserHandle);
}
public class PackageInfo implements android.os.Parcelable {
public class LauncherApps {
method public java.util.List<android.content.pm.LauncherActivityInfo> getActivityList(java.lang.String, android.os.UserHandle);
+ method public android.content.pm.ApplicationInfo getApplicationInfo(java.lang.String, int, android.os.UserHandle);
method public boolean isActivityEnabled(android.content.ComponentName, android.os.UserHandle);
method public boolean isPackageEnabled(java.lang.String, android.os.UserHandle);
method public void registerCallback(android.content.pm.LauncherApps.Callback);
method public abstract void onPackageChanged(java.lang.String, android.os.UserHandle);
method public abstract void onPackageRemoved(java.lang.String, android.os.UserHandle);
method public abstract void onPackagesAvailable(java.lang.String[], android.os.UserHandle, boolean);
+ method public void onPackagesSuspended(java.lang.String[], android.os.UserHandle);
method public abstract void onPackagesUnavailable(java.lang.String[], android.os.UserHandle, boolean);
+ method public void onPackagesUnsuspended(java.lang.String[], android.os.UserHandle);
}
public class PackageInfo implements android.os.Parcelable {
public class LauncherApps {
method public java.util.List<android.content.pm.LauncherActivityInfo> getActivityList(java.lang.String, android.os.UserHandle);
+ method public android.content.pm.ApplicationInfo getApplicationInfo(java.lang.String, int, android.os.UserHandle);
method public boolean isActivityEnabled(android.content.ComponentName, android.os.UserHandle);
method public boolean isPackageEnabled(java.lang.String, android.os.UserHandle);
method public void registerCallback(android.content.pm.LauncherApps.Callback);
method public abstract void onPackageChanged(java.lang.String, android.os.UserHandle);
method public abstract void onPackageRemoved(java.lang.String, android.os.UserHandle);
method public abstract void onPackagesAvailable(java.lang.String[], android.os.UserHandle, boolean);
+ method public void onPackagesSuspended(java.lang.String[], android.os.UserHandle);
method public abstract void onPackagesUnavailable(java.lang.String[], android.os.UserHandle, boolean);
+ method public void onPackagesUnsuspended(java.lang.String[], android.os.UserHandle);
}
public class PackageInfo implements android.os.Parcelable {
import android.content.ComponentName;
import android.content.Intent;
+import android.content.pm.ApplicationInfo;
import android.content.pm.IOnAppsChangedListener;
import android.content.pm.ParceledListSlice;
import android.content.pm.ResolveInfo;
in Bundle opts, in UserHandle user);
boolean isPackageEnabled(String packageName, in UserHandle user);
boolean isActivityEnabled(in ComponentName component, in UserHandle user);
+ ApplicationInfo getApplicationInfo(String packageName, int flags, in UserHandle user);
}
void onPackageChanged(in UserHandle user, String packageName);
void onPackagesAvailable(in UserHandle user, in String[] packageNames, boolean replacing);
void onPackagesUnavailable(in UserHandle user, in String[] packageNames, boolean replacing);
+ void onPackagesSuspended(in UserHandle user, in String[] packageNames);
+ void onPackagesUnsuspended(in UserHandle user, in String[] packageNames);
}
import android.content.Intent;
import android.content.pm.ILauncherApps;
import android.content.pm.IOnAppsChangedListener;
+import android.content.pm.PackageManager.ApplicationInfoFlags;
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.Rect;
import android.os.Bundle;
*/
abstract public void onPackagesUnavailable(String[] packageNames, UserHandle user,
boolean replacing);
+
+ /**
+ * Indicates that one or more packages have been suspended. For
+ * example, this can happen when a Device Administrator suspends
+ * an applicaton.
+ *
+ * @param packageNames The names of the packages that have just been
+ * suspended.
+ * @param user The UserHandle of the profile that generated the change.
+ */
+ public void onPackagesSuspended(String[] packageNames, UserHandle user) {
+ }
+
+ /**
+ * Indicates that one or more packages have been unsuspended. For
+ * example, this can happen when a Device Administrator unsuspends
+ * an applicaton.
+ *
+ * @param packageNames The names of the packages that have just been
+ * unsuspended.
+ * @param user The UserHandle of the profile that generated the change.
+ */
+ public void onPackagesUnsuspended(String[] packageNames, UserHandle user) {
+ }
}
/** @hide */
}
/**
+ * Retrieve all of the information we know about a particular package / application.
+ *
+ * @param packageName The package of the application
+ * @param flags Additional option flags {@link PackageManager#getApplicationInfo}
+ * @param user The UserHandle of the profile.
+ *
+ * @return An {@link ApplicationInfo} containing information about the package or
+ * null of the package isn't found.
+ */
+ public ApplicationInfo getApplicationInfo(String packageName, @ApplicationInfoFlags int flags,
+ UserHandle user) {
+ try {
+ return mService.getApplicationInfo(packageName, flags, user);
+ } catch (RemoteException re) {
+ throw new RuntimeException("Failed to call LauncherAppsService", re);
+ }
+ }
+
+ /**
* Checks if the activity exists and it enabled for a profile.
*
* @param component The activity to check.
for (CallbackMessageHandler callback : mCallbacks) {
callback.postOnPackagesUnavailable(packageNames, user, replacing);
}
- }
+ }
+ }
+
+ @Override
+ public void onPackagesSuspended(UserHandle user, String[] packageNames)
+ throws RemoteException {
+ if (DEBUG) {
+ Log.d(TAG, "onPackagesSuspended " + user.getIdentifier() + "," + packageNames);
+ }
+ synchronized (LauncherApps.this) {
+ for (CallbackMessageHandler callback : mCallbacks) {
+ callback.postOnPackagesSuspended(packageNames, user);
+ }
+ }
+ }
+
+ @Override
+ public void onPackagesUnsuspended(UserHandle user, String[] packageNames)
+ throws RemoteException {
+ if (DEBUG) {
+ Log.d(TAG, "onPackagesUnsuspended " + user.getIdentifier() + "," + packageNames);
+ }
+ synchronized (LauncherApps.this) {
+ for (CallbackMessageHandler callback : mCallbacks) {
+ callback.postOnPackagesUnsuspended(packageNames, user);
+ }
+ }
}
};
private static final int MSG_CHANGED = 3;
private static final int MSG_AVAILABLE = 4;
private static final int MSG_UNAVAILABLE = 5;
+ private static final int MSG_SUSPENDED = 6;
+ private static final int MSG_UNSUSPENDED = 7;
private LauncherApps.Callback mCallback;
case MSG_UNAVAILABLE:
mCallback.onPackagesUnavailable(info.packageNames, info.user, info.replacing);
break;
+ case MSG_SUSPENDED:
+ mCallback.onPackagesSuspended(info.packageNames, info.user);
+ break;
+ case MSG_UNSUSPENDED:
+ mCallback.onPackagesUnsuspended(info.packageNames, info.user);
+ break;
}
}
info.user = user;
obtainMessage(MSG_UNAVAILABLE, info).sendToTarget();
}
+
+ public void postOnPackagesSuspended(String[] packageNames, UserHandle user) {
+ CallbackInfo info = new CallbackInfo();
+ info.packageNames = packageNames;
+ info.user = user;
+ obtainMessage(MSG_SUSPENDED, info).sendToTarget();
+ }
+
+ public void postOnPackagesUnsuspended(String[] packageNames, UserHandle user) {
+ CallbackInfo info = new CallbackInfo();
+ info.packageNames = packageNames;
+ info.user = user;
+ obtainMessage(MSG_UNSUSPENDED, info).sendToTarget();
+ }
}
}
sPackageFilt.addDataScheme("package");
sNonDataFilt.addAction(Intent.ACTION_UID_REMOVED);
sNonDataFilt.addAction(Intent.ACTION_USER_STOPPED);
+ sNonDataFilt.addAction(Intent.ACTION_PACKAGES_SUSPENDED);
+ sNonDataFilt.addAction(Intent.ACTION_PACKAGES_UNSUSPENDED);
sExternalFilt.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
sExternalFilt.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
}
public void onPackagesUnavailable(String[] packages) {
}
-
+
+ public void onPackagesSuspended(String[] packages) {
+ }
+
+ public void onPackagesUnsuspended(String[] packages) {
+ }
+
public static final int PACKAGE_UNCHANGED = 0;
public static final int PACKAGE_UPDATING = 1;
public static final int PACKAGE_TEMPORARY_CHANGE = 2;
onPackageDisappeared(pkgList[i], mChangeType);
}
}
+ } else if (Intent.ACTION_PACKAGES_SUSPENDED.equals(action)) {
+ String[] pkgList = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
+ mSomePackagesChanged = true;
+ onPackagesSuspended(pkgList);
+ } else if (Intent.ACTION_PACKAGES_UNSUSPENDED.equals(action)) {
+ String[] pkgList = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
+ mSomePackagesChanged = true;
+ onPackagesUnsuspended(pkgList);
}
-
+
if (mSomePackagesChanged) {
onSomePackagesChanged();
}
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
+import android.content.pm.ApplicationInfo;
import android.content.pm.ILauncherApps;
import android.content.pm.IOnAppsChangedListener;
import android.content.pm.IPackageManager;
}
@Override
+ public ApplicationInfo getApplicationInfo(String packageName, int flags, UserHandle user)
+ throws RemoteException {
+ ensureInUserProfiles(user, "Cannot check package for unrelated profile " + user);
+ if (!isUserEnabled(user)) {
+ return null;
+ }
+
+ long ident = Binder.clearCallingIdentity();
+ try {
+ IPackageManager pm = AppGlobals.getPackageManager();
+ ApplicationInfo info = pm.getApplicationInfo(packageName, flags,
+ user.getIdentifier());
+ return info;
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override
public boolean isActivityEnabled(ComponentName component, UserHandle user)
throws RemoteException {
ensureInUserProfiles(user, "Cannot check component for unrelated profile " + user);
super.onPackagesUnavailable(packages);
}
+ @Override
+ public void onPackagesSuspended(String[] packages) {
+ UserHandle user = new UserHandle(getChangingUserId());
+ final int n = mListeners.beginBroadcast();
+ for (int i = 0; i < n; i++) {
+ IOnAppsChangedListener listener = mListeners.getBroadcastItem(i);
+ UserHandle listeningUser = (UserHandle) mListeners.getBroadcastCookie(i);
+ if (!isEnabledProfileOf(user, listeningUser, "onPackagesSuspended")) continue;
+ try {
+ listener.onPackagesSuspended(user, packages);
+ } catch (RemoteException re) {
+ Slog.d(TAG, "Callback failed ", re);
+ }
+ }
+ mListeners.finishBroadcast();
+
+ super.onPackagesSuspended(packages);
+ }
+
+ @Override
+ public void onPackagesUnsuspended(String[] packages) {
+ UserHandle user = new UserHandle(getChangingUserId());
+ final int n = mListeners.beginBroadcast();
+ for (int i = 0; i < n; i++) {
+ IOnAppsChangedListener listener = mListeners.getBroadcastItem(i);
+ UserHandle listeningUser = (UserHandle) mListeners.getBroadcastCookie(i);
+ if (!isEnabledProfileOf(user, listeningUser, "onPackagesUnsuspended")) continue;
+ try {
+ listener.onPackagesUnsuspended(user, packages);
+ } catch (RemoteException re) {
+ Slog.d(TAG, "Callback failed ", re);
+ }
+ }
+ mListeners.finishBroadcast();
+
+ super.onPackagesUnsuspended(packages);
+ }
+
}
class PackageCallbackList<T extends IInterface> extends RemoteCallbackList<T> {