Search in sources :

Example 66 with RecentsConfiguration

use of com.android.systemui.recents.RecentsConfiguration in project android_frameworks_base by ResurrectionRemix.

the class TaskStackView method onFirstLayout.

/** Handler for the first layout. */
void onFirstLayout() {
    // Setup the view for the enter animation
    mAnimationHelper.prepareForEnterAnimation();
    // Animate in the freeform workspace
    int ffBgAlpha = mLayoutAlgorithm.getStackState().freeformBackgroundAlpha;
    animateFreeformWorkspaceBackgroundAlpha(ffBgAlpha, new AnimationProps(150, Interpolators.FAST_OUT_SLOW_IN));
    // Set the task focused state without requesting view focus, and leave the focus animations
    // until after the enter-animation
    RecentsConfiguration config = Recents.getConfiguration();
    RecentsActivityLaunchState launchState = config.getLaunchState();
    // We set the initial focused task view iff the following conditions are satisfied:
    // 1. Recents is showing task views in stack layout.
    // 2. Recents is launched with ALT + TAB.
    boolean setFocusOnFirstLayout = !useGridLayout() || Recents.getConfiguration().getLaunchState().launchedWithAltTab;
    if (setFocusOnFirstLayout) {
        int focusedTaskIndex = launchState.getInitialFocusTaskIndex(mStack.getTaskCount(), useGridLayout());
        if (focusedTaskIndex != -1) {
            setFocusedTask(focusedTaskIndex, false, /* scrollToTask */
            false);
        }
    }
    updateStackActionButtonVisibility();
}
Also used : RecentsActivityLaunchState(com.android.systemui.recents.RecentsActivityLaunchState) RecentsConfiguration(com.android.systemui.recents.RecentsConfiguration)

Example 67 with RecentsConfiguration

use of com.android.systemui.recents.RecentsConfiguration in project android_frameworks_base by DirtyUnicorns.

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 68 with RecentsConfiguration

use of com.android.systemui.recents.RecentsConfiguration in project android_frameworks_base by DirtyUnicorns.

the class RecentsTaskLoader method onTrimMemory.

/**
     * Handles signals from the system, trimming memory when requested to prevent us from running
     * out of memory.
     */
public void onTrimMemory(int level) {
    RecentsConfiguration config = Recents.getConfiguration();
    switch(level) {
        case ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN:
            // Stop the loader immediately when the UI is no longer visible
            stopLoader();
            if (config.svelteLevel == RecentsConfiguration.SVELTE_NONE) {
                mThumbnailCache.trimToSize(Math.max(mNumVisibleTasksLoaded, mMaxThumbnailCacheSize / 2));
            } else if (config.svelteLevel == RecentsConfiguration.SVELTE_LIMIT_CACHE) {
                mThumbnailCache.trimToSize(mNumVisibleThumbnailsLoaded);
            } else if (config.svelteLevel >= RecentsConfiguration.SVELTE_DISABLE_CACHE) {
                mThumbnailCache.evictAll();
            }
            mIconCache.trimToSize(Math.max(mNumVisibleTasksLoaded, mMaxIconCacheSize / 2));
            break;
        case ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE:
        case ComponentCallbacks2.TRIM_MEMORY_BACKGROUND:
            // We are leaving recents, so trim the data a bit
            mThumbnailCache.trimToSize(Math.max(1, mMaxThumbnailCacheSize / 2));
            mIconCache.trimToSize(Math.max(1, mMaxIconCacheSize / 2));
            mActivityInfoCache.trimToSize(Math.max(1, ActivityManager.getMaxRecentTasksStatic() / 2));
            break;
        case ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW:
        case ComponentCallbacks2.TRIM_MEMORY_MODERATE:
            // We are going to be low on memory
            mThumbnailCache.trimToSize(Math.max(1, mMaxThumbnailCacheSize / 4));
            mIconCache.trimToSize(Math.max(1, mMaxIconCacheSize / 4));
            mActivityInfoCache.trimToSize(Math.max(1, ActivityManager.getMaxRecentTasksStatic() / 4));
            break;
        case ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL:
        case ComponentCallbacks2.TRIM_MEMORY_COMPLETE:
            // We are low on memory, so release everything
            mThumbnailCache.evictAll();
            mIconCache.evictAll();
            mActivityInfoCache.evictAll();
            // The cache is small, only clear the label cache when we are critical
            mActivityLabelCache.evictAll();
            mContentDescriptionCache.evictAll();
            break;
        default:
            break;
    }
}
Also used : RecentsConfiguration(com.android.systemui.recents.RecentsConfiguration)

Example 69 with RecentsConfiguration

use of com.android.systemui.recents.RecentsConfiguration in project android_frameworks_base by DirtyUnicorns.

the class RecentsTaskLoader method getAndUpdateThumbnail.

/**
     * Returns the cached thumbnail if the task key is not expired, updating the cache if it is.
     */
Bitmap getAndUpdateThumbnail(Task.TaskKey taskKey, boolean loadIfNotCached) {
    SystemServicesProxy ssp = Recents.getSystemServices();
    // Return the cached thumbnail if it exists
    ThumbnailData thumbnailData = mThumbnailCache.getAndInvalidateIfModified(taskKey);
    if (thumbnailData != null) {
        return thumbnailData.thumbnail;
    }
    if (loadIfNotCached) {
        RecentsConfiguration config = Recents.getConfiguration();
        if (config.svelteLevel < RecentsConfiguration.SVELTE_DISABLE_LOADING) {
            // Load the thumbnail from the system
            thumbnailData = ssp.getTaskThumbnail(taskKey.id);
            if (thumbnailData.thumbnail != null) {
                mThumbnailCache.put(taskKey, thumbnailData);
                return thumbnailData.thumbnail;
            }
        }
    }
    // We couldn't load any thumbnail
    return null;
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) RecentsConfiguration(com.android.systemui.recents.RecentsConfiguration)

Example 70 with RecentsConfiguration

use of com.android.systemui.recents.RecentsConfiguration in project android_frameworks_base by DirtyUnicorns.

the class RecentsTvImpl method startRecentsActivity.

protected void startRecentsActivity(ActivityManager.RunningTaskInfo runningTask, ActivityOptions opts, boolean fromHome, boolean fromThumbnail) {
    // Update the configuration based on the launch options
    RecentsConfiguration config = Recents.getConfiguration();
    RecentsActivityLaunchState launchState = config.getLaunchState();
    launchState.launchedFromHome = fromHome;
    launchState.launchedFromApp = fromThumbnail;
    launchState.launchedToTaskId = (runningTask != null) ? runningTask.id : -1;
    launchState.launchedWithAltTab = mTriggeredFromAltTab;
    Intent intent = new Intent();
    intent.setClassName(RECENTS_PACKAGE, RECENTS_TV_ACTIVITY);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_TASK_ON_HOME);
    if (opts != null) {
        mContext.startActivityAsUser(intent, opts.toBundle(), UserHandle.CURRENT);
    } else {
        mContext.startActivityAsUser(intent, UserHandle.CURRENT);
    }
    EventBus.getDefault().send(new RecentsActivityStartingEvent());
}
Also used : RecentsActivityStartingEvent(com.android.systemui.recents.events.activity.RecentsActivityStartingEvent) RecentsActivityLaunchState(com.android.systemui.recents.RecentsActivityLaunchState) RecentsConfiguration(com.android.systemui.recents.RecentsConfiguration) Intent(android.content.Intent)

Aggregations

RecentsConfiguration (com.android.systemui.recents.RecentsConfiguration)86 RecentsActivityLaunchState (com.android.systemui.recents.RecentsActivityLaunchState)45 Resources (android.content.res.Resources)20 Task (com.android.systemui.recents.model.Task)20 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)15 TaskStack (com.android.systemui.recents.model.TaskStack)15 ValueAnimator (android.animation.ValueAnimator)10 RecentsVisibilityChangedEvent (com.android.systemui.recents.events.component.RecentsVisibilityChangedEvent)10 Animator (android.animation.Animator)5 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)5 ActivityOptions (android.app.ActivityOptions)5 Intent (android.content.Intent)5 ActivityInfo (android.content.pm.ActivityInfo)5 BitmapDrawable (android.graphics.drawable.BitmapDrawable)5 Drawable (android.graphics.drawable.Drawable)5 View (android.view.View)5 EnterRecentsWindowAnimationCompletedEvent (com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationCompletedEvent)5 RecentsActivityStartingEvent (com.android.systemui.recents.events.activity.RecentsActivityStartingEvent)5 DeleteTaskDataEvent (com.android.systemui.recents.events.ui.DeleteTaskDataEvent)5 RecentsTaskLoadPlan (com.android.systemui.recents.model.RecentsTaskLoadPlan)5