FileDocCategorySizeDatePackage
RecentsPackageMonitor.javaAPI DocAndroid 5.1 API4345Thu Mar 12 22:22:42 GMT 2015com.android.systemui.recents.model

RecentsPackageMonitor

public class RecentsPackageMonitor extends com.android.internal.content.PackageMonitor
The package monitor listens for changes from PackageManager to update the contents of the Recents list.

Fields Summary
PackageCallbacks
mCb
com.android.systemui.recents.misc.SystemServicesProxy
mSystemServicesProxy
Constructors Summary
Methods Summary
public java.util.HashSetcomputeComponentsRemoved(java.util.List taskKeys, java.lang.String packageName, int userId)
Computes the components that have been removed as a result of a change in the specified package.

        // Identify all the tasks that should be removed as a result of the package being removed.
        // Using a set to ensure that we callback once per unique component.
        HashSet<ComponentName> existingComponents = new HashSet<ComponentName>();
        HashSet<ComponentName> removedComponents = new HashSet<ComponentName>();
        for (Task.TaskKey t : taskKeys) {
            // Skip if this doesn't apply to the current user
            if (t.userId != userId) continue;

            ComponentName cn = t.baseIntent.getComponent();
            if (cn.getPackageName().equals(packageName)) {
                if (existingComponents.contains(cn)) {
                    // If we know that the component still exists in the package, then skip
                    continue;
                }
                if (mSystemServicesProxy.getActivityInfo(cn, userId) != null) {
                    existingComponents.add(cn);
                } else {
                    removedComponents.add(cn);
                }
            }
        }
        return removedComponents;
    
public booleanonPackageChanged(java.lang.String packageName, int uid, java.lang.String[] components)

        onPackageModified(packageName);
        return true;
    
public voidonPackageModified(java.lang.String packageName)

        if (mCb == null) return;

        // Notify callbacks that a package has changed
        final int eventUserId = getChangingUserId();
        mCb.onPackagesChanged(this, packageName, eventUserId);
    
public voidonPackageRemoved(java.lang.String packageName, int uid)

        if (mCb == null) return;

        // Notify callbacks that a package has changed
        final int eventUserId = getChangingUserId();
        mCb.onPackagesChanged(this, packageName, eventUserId);
    
public voidregister(android.content.Context context, com.android.systemui.recents.model.RecentsPackageMonitor$PackageCallbacks cb)
Registers the broadcast receivers with the specified callbacks.

        mSystemServicesProxy = new SystemServicesProxy(context);
        mCb = cb;
        try {
            // We register for events from all users, but will cross-reference them with
            // packages for the current user and any profiles they have
            register(context, Looper.getMainLooper(), UserHandle.ALL, true);
        } catch (IllegalStateException e) {
            e.printStackTrace();
        }
    
public voidunregister()
Unregisters the broadcast receivers.

        try {
            super.unregister();
        } catch (IllegalStateException e) {
            e.printStackTrace();
        }
        mSystemServicesProxy = null;
        mCb = null;