Search in sources :

Example 41 with ActivityInfo

use of android.content.pm.ActivityInfo in project android_frameworks_base by ResurrectionRemix.

the class RecentsTaskLoader method getAndUpdateActivityTitle.

/**
     * Returns the cached task label if the task key is not expired, updating the cache if it is.
     */
String getAndUpdateActivityTitle(Task.TaskKey taskKey, ActivityManager.TaskDescription td) {
    SystemServicesProxy ssp = Recents.getSystemServices();
    // Return the task description label if it exists
    if (td != null && td.getLabel() != null) {
        return td.getLabel();
    }
    // Return the cached activity label if it exists
    String label = mActivityLabelCache.getAndInvalidateIfModified(taskKey);
    if (label != null) {
        return label;
    }
    // All short paths failed, load the label from the activity info and cache it
    ActivityInfo activityInfo = getAndUpdateActivityInfo(taskKey);
    if (activityInfo != null) {
        label = ssp.getBadgedActivityLabel(activityInfo, taskKey.userId);
        mActivityLabelCache.put(taskKey, label);
        return label;
    }
    // but do not cache it
    return "";
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) ActivityInfo(android.content.pm.ActivityInfo)

Example 42 with ActivityInfo

use of android.content.pm.ActivityInfo in project android_frameworks_base by ResurrectionRemix.

the class RecentsTaskLoader method getAndUpdateActivityIcon.

/**
     * Returns the cached task icon if the task key is not expired, updating the cache if it is.
     */
Drawable getAndUpdateActivityIcon(Task.TaskKey taskKey, ActivityManager.TaskDescription td, Resources res, boolean loadIfNotCached) {
    SystemServicesProxy ssp = Recents.getSystemServices();
    // Return the cached activity icon if it exists
    Drawable icon = mIconCache.getAndInvalidateIfModified(taskKey);
    if (icon != null) {
        return icon;
    }
    if (loadIfNotCached) {
        // Return and cache the task description icon if it exists
        icon = ssp.getBadgedTaskDescriptionIcon(td, taskKey.userId, res);
        if (icon != null) {
            mIconCache.put(taskKey, icon);
            return icon;
        }
        // Load the icon from the activity info and cache it
        ActivityInfo activityInfo = getAndUpdateActivityInfo(taskKey);
        if (activityInfo != null) {
            icon = ssp.getBadgedActivityIcon(activityInfo, taskKey.userId);
            if (icon != null) {
                mIconCache.put(taskKey, icon);
                return icon;
            }
        }
    }
    // We couldn't load any icon
    return null;
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) ActivityInfo(android.content.pm.ActivityInfo) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Drawable(android.graphics.drawable.Drawable)

Example 43 with ActivityInfo

use of android.content.pm.ActivityInfo in project android_frameworks_base by ResurrectionRemix.

the class RecentsTaskLoader method run.

@Override
public void run() {
    while (true) {
        if (mCancelled) {
            // We have to unset the context here, since the background thread may be using it
            // when we call stop()
            mContext = null;
            // If we are cancelled, then wait until we are started again
            synchronized (mLoadThread) {
                try {
                    mLoadThread.wait();
                } catch (InterruptedException ie) {
                    ie.printStackTrace();
                }
            }
        } else {
            RecentsConfiguration config = Recents.getConfiguration();
            SystemServicesProxy ssp = Recents.getSystemServices();
            // the load thread
            if (ssp != null) {
                // Load the next item from the queue
                final Task t = mLoadQueue.nextTask();
                if (t != null) {
                    Drawable cachedIcon = mIconCache.get(t.key);
                    ThumbnailData cachedThumbnailData = mThumbnailCache.get(t.key);
                    // Load the icon if it is stale or we haven't cached one yet
                    if (cachedIcon == null) {
                        cachedIcon = ssp.getBadgedTaskDescriptionIcon(t.taskDescription, t.key.userId, mContext.getResources());
                        if (cachedIcon == null) {
                            ActivityInfo info = ssp.getActivityInfo(t.key.getComponent(), t.key.userId);
                            if (info != null) {
                                if (DEBUG)
                                    Log.d(TAG, "Loading icon: " + t.key);
                                cachedIcon = ssp.getBadgedActivityIcon(info, t.key.userId);
                            }
                        }
                        if (cachedIcon == null) {
                            cachedIcon = mDefaultIcon;
                        }
                        // At this point, even if we can't load the icon, we will set the
                        // default icon.
                        mIconCache.put(t.key, cachedIcon);
                    }
                    // Load the thumbnail if it is stale or we haven't cached one yet
                    if (cachedThumbnailData == null) {
                        if (config.svelteLevel < RecentsConfiguration.SVELTE_DISABLE_LOADING) {
                            if (DEBUG)
                                Log.d(TAG, "Loading thumbnail: " + t.key);
                            cachedThumbnailData = ssp.getTaskThumbnail(t.key.id);
                        }
                        if (cachedThumbnailData.thumbnail == null) {
                            cachedThumbnailData.thumbnail = mDefaultThumbnail;
                        } else {
                            // Kick off an early upload of the bitmap to GL so
                            // that this won't jank the first frame it's drawn in.
                            cachedThumbnailData.thumbnail.prepareToDraw();
                        }
                        // them from scratch each time)
                        if (config.svelteLevel < RecentsConfiguration.SVELTE_LIMIT_CACHE) {
                            mThumbnailCache.put(t.key, cachedThumbnailData);
                        }
                    }
                    if (!mCancelled) {
                        // Notify that the task data has changed
                        final Drawable newIcon = cachedIcon;
                        final ThumbnailData newThumbnailData = cachedThumbnailData;
                        mMainThreadHandler.post(new Runnable() {

                            @Override
                            public void run() {
                                t.notifyTaskDataLoaded(newThumbnailData.thumbnail, newIcon, newThumbnailData.thumbnailInfo);
                            }
                        });
                    }
                }
            }
            // If there are no other items in the list, then just wait until something is added
            if (!mCancelled && mLoadQueue.isEmpty()) {
                synchronized (mLoadQueue) {
                    try {
                        mWaitingOnLoadQueue = true;
                        while (mLoadQueue.isEmpty()) {
                            mLoadQueue.wait();
                        }
                        mWaitingOnLoadQueue = false;
                    } catch (InterruptedException ie) {
                        ie.printStackTrace();
                    }
                }
            }
        }
    }
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) ActivityInfo(android.content.pm.ActivityInfo) RecentsConfiguration(com.android.systemui.recents.RecentsConfiguration) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Drawable(android.graphics.drawable.Drawable)

Example 44 with ActivityInfo

use of android.content.pm.ActivityInfo in project android_frameworks_base by ResurrectionRemix.

the class RecentsTaskLoader method getAndUpdateActivityInfo.

/**
     * Returns the activity info for the given task key, retrieving one from the system if the
     * task key is expired.
     */
ActivityInfo getAndUpdateActivityInfo(Task.TaskKey taskKey) {
    SystemServicesProxy ssp = Recents.getSystemServices();
    ComponentName cn = taskKey.getComponent();
    ActivityInfo activityInfo = mActivityInfoCache.get(cn);
    if (activityInfo == null) {
        activityInfo = ssp.getActivityInfo(cn, taskKey.userId);
        if (cn == null || activityInfo == null) {
            Log.e(TAG, "Unexpected null component name or activity info: " + cn + ", " + activityInfo);
            return null;
        }
        mActivityInfoCache.put(cn, activityInfo);
    }
    return activityInfo;
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) ActivityInfo(android.content.pm.ActivityInfo) ComponentName(android.content.ComponentName)

Example 45 with ActivityInfo

use of android.content.pm.ActivityInfo in project android_frameworks_base by ResurrectionRemix.

the class DefaultPermissionGrantPolicy method getDefaultSystemHandlerActivityPackageLPr.

private PackageParser.Package getDefaultSystemHandlerActivityPackageLPr(Intent intent, int userId) {
    ResolveInfo handler = mService.resolveIntent(intent, intent.resolveType(mService.mContext.getContentResolver()), DEFAULT_FLAGS, userId);
    if (handler == null || handler.activityInfo == null) {
        return null;
    }
    ActivityInfo activityInfo = handler.activityInfo;
    if (activityInfo.packageName.equals(mService.mResolveActivity.packageName) && activityInfo.name.equals(mService.mResolveActivity.name)) {
        return null;
    }
    return getSystemPackageLPr(handler.activityInfo.packageName);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ActivityInfo(android.content.pm.ActivityInfo)

Aggregations

ActivityInfo (android.content.pm.ActivityInfo)886 ResolveInfo (android.content.pm.ResolveInfo)360 Intent (android.content.Intent)339 ComponentName (android.content.ComponentName)324 PackageManager (android.content.pm.PackageManager)215 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)141 ArrayList (java.util.ArrayList)139 ApplicationInfo (android.content.pm.ApplicationInfo)115 Test (org.junit.Test)113 RemoteException (android.os.RemoteException)82 Bundle (android.os.Bundle)68 PendingIntent (android.app.PendingIntent)62 Drawable (android.graphics.drawable.Drawable)61 IOException (java.io.IOException)60 PackageInfo (android.content.pm.PackageInfo)59 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)54 XmlResourceParser (android.content.res.XmlResourceParser)43 Point (android.graphics.Point)35 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)34 Context (android.content.Context)33