Search in sources :

Example 76 with SystemServicesProxy

use of com.android.systemui.recents.misc.SystemServicesProxy in project android_frameworks_base by AOSPA.

the class RecentsTvActivity method onResume.

@Override
public void onResume() {
    super.onResume();
    mPipRecentsOverlayManager.onRecentsResumed();
    // Update the recent tasks
    updateRecentsTasks();
    // If this is a new instance from a configuration change, then we have to manually trigger
    // the enter animation state, or if recents was relaunched by AM, without going through
    // the normal mechanisms
    RecentsConfiguration config = Recents.getConfiguration();
    RecentsActivityLaunchState launchState = config.getLaunchState();
    boolean wasLaunchedByAm = !launchState.launchedFromHome && !launchState.launchedFromApp;
    if (wasLaunchedByAm) {
        EventBus.getDefault().send(new EnterRecentsWindowAnimationCompletedEvent());
    }
    // Notify that recents is now visible
    SystemServicesProxy ssp = Recents.getSystemServices();
    EventBus.getDefault().send(new RecentsVisibilityChangedEvent(this, true));
    if (mTaskStackHorizontalGridView.getStack().getTaskCount() > 1 && !mLaunchedFromHome) {
        // If there are 2 or more tasks, and we are not launching from home
        // set the selected position to the 2nd task to allow for faster app switching
        mTaskStackHorizontalGridView.setSelectedPosition(1);
    } else {
        mTaskStackHorizontalGridView.setSelectedPosition(0);
    }
    mRecentsView.getViewTreeObserver().addOnPreDrawListener(this);
    View dismissPlaceholder = findViewById(R.id.dismiss_placeholder);
    mTalkBackEnabled = ssp.isTouchExplorationEnabled();
    if (mTalkBackEnabled) {
        dismissPlaceholder.setAccessibilityTraversalBefore(R.id.task_list);
        dismissPlaceholder.setAccessibilityTraversalAfter(R.id.dismiss_placeholder);
        mTaskStackHorizontalGridView.setAccessibilityTraversalAfter(R.id.dismiss_placeholder);
        mTaskStackHorizontalGridView.setAccessibilityTraversalBefore(R.id.pip);
        dismissPlaceholder.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                mTaskStackHorizontalGridView.requestFocus();
                mTaskStackHorizontalGridView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
                Task focusedTask = mTaskStackHorizontalGridView.getFocusedTask();
                if (focusedTask != null) {
                    mTaskStackViewAdapter.removeTask(focusedTask);
                    EventBus.getDefault().send(new DeleteTaskDataEvent(focusedTask));
                }
            }
        });
    }
    // Initialize PIP UI
    if (mPipManager.isPipShown()) {
        if (mTalkBackEnabled) {
            // If talkback is on, use the mPipView to handle focus changes
            // between recents row and PIP controls.
            mPipView.setVisibility(View.VISIBLE);
        } else {
            mPipView.setVisibility(View.GONE);
        }
        // When PIP view has focus, recents overlay view will takes the focus
        // as if it's the part of the Recents UI.
        mPipRecentsOverlayManager.requestFocus(mTaskStackViewAdapter.getItemCount() > 0);
    } else {
        mPipView.setVisibility(View.GONE);
        mPipRecentsOverlayManager.removePipRecentsOverlayView();
    }
}
Also used : EnterRecentsWindowAnimationCompletedEvent(com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationCompletedEvent) SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) Task(com.android.systemui.recents.model.Task) RecentsActivityLaunchState(com.android.systemui.recents.RecentsActivityLaunchState) RecentsConfiguration(com.android.systemui.recents.RecentsConfiguration) RecentsVisibilityChangedEvent(com.android.systemui.recents.events.component.RecentsVisibilityChangedEvent) DeleteTaskDataEvent(com.android.systemui.recents.events.ui.DeleteTaskDataEvent) RecentsTvView(com.android.systemui.recents.tv.views.RecentsTvView) TaskCardView(com.android.systemui.recents.tv.views.TaskCardView) TaskStackHorizontalGridView(com.android.systemui.recents.tv.views.TaskStackHorizontalGridView) View(android.view.View)

Example 77 with SystemServicesProxy

use of com.android.systemui.recents.misc.SystemServicesProxy in project android_frameworks_base by AOSPA.

the class TaskStack method computeComponentsRemoved.

/**
     * Computes the components of tasks in this stack that have been removed as a result of a change
     * in the specified package.
     */
public ArraySet<ComponentName> computeComponentsRemoved(String packageName, int userId) {
    // 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.
    SystemServicesProxy ssp = Recents.getSystemServices();
    ArraySet<ComponentName> existingComponents = new ArraySet<>();
    ArraySet<ComponentName> removedComponents = new ArraySet<>();
    ArrayList<Task.TaskKey> taskKeys = getTaskKeys();
    int taskKeyCount = taskKeys.size();
    for (int i = 0; i < taskKeyCount; i++) {
        Task.TaskKey t = taskKeys.get(i);
        // Skip if this doesn't apply to the current user
        if (t.userId != userId)
            continue;
        ComponentName cn = t.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 (ssp.getActivityInfo(cn, userId) != null) {
                existingComponents.add(cn);
            } else {
                removedComponents.add(cn);
            }
        }
    }
    return removedComponents;
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) ArraySet(android.util.ArraySet) ComponentName(android.content.ComponentName) Paint(android.graphics.Paint) Point(android.graphics.Point)

Example 78 with SystemServicesProxy

use of com.android.systemui.recents.misc.SystemServicesProxy in project android_frameworks_base by AOSPA.

the class RecentsTvActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mFinishedOnStartup = false;
    // In the case that the activity starts up before the Recents component has initialized
    // (usually when debugging/pushing the SysUI apk), just finish this activity.
    SystemServicesProxy ssp = Recents.getSystemServices();
    if (ssp == null) {
        mFinishedOnStartup = true;
        finish();
        return;
    }
    mPipRecentsOverlayManager = PipManager.getInstance().getPipRecentsOverlayManager();
    // Register this activity with the event bus
    EventBus.getDefault().register(this, EVENT_BUS_PRIORITY);
    mPackageMonitor = new RecentsPackageMonitor();
    mPackageMonitor.register(this);
    // Set the Recents layout
    setContentView(R.layout.recents_on_tv);
    mRecentsView = (RecentsTvView) findViewById(R.id.recents_view);
    mRecentsView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
    mPipView = findViewById(R.id.pip);
    mPipView.setOnFocusChangeListener(mPipViewFocusChangeListener);
    // Place mPipView at the PIP bounds for fine tuned focus handling.
    Rect pipBounds = mPipManager.getRecentsFocusedPipBounds();
    LayoutParams lp = (LayoutParams) mPipView.getLayoutParams();
    lp.width = pipBounds.width();
    lp.height = pipBounds.height();
    lp.leftMargin = pipBounds.left;
    lp.topMargin = pipBounds.top;
    mPipView.setLayoutParams(lp);
    mPipRecentsOverlayManager.setCallback(mPipRecentsOverlayManagerCallback);
    getWindow().getAttributes().privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY;
    // Create the home intent runnable
    Intent homeIntent = new Intent(Intent.ACTION_MAIN, null);
    homeIntent.addCategory(Intent.CATEGORY_HOME);
    homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    homeIntent.putExtra(RECENTS_HOME_INTENT_EXTRA, true);
    mFinishLaunchHomeRunnable = new FinishRecentsRunnable(homeIntent);
    mPipManager.addListener(mPipListener);
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) Rect(android.graphics.Rect) LayoutParams(android.widget.FrameLayout.LayoutParams) RecentsPackageMonitor(com.android.systemui.recents.model.RecentsPackageMonitor) Intent(android.content.Intent)

Example 79 with SystemServicesProxy

use of com.android.systemui.recents.misc.SystemServicesProxy in project android_frameworks_base by AOSPA.

the class RecentsTvActivity method onBusEvent.

public final void onBusEvent(CancelEnterRecentsWindowAnimationEvent event) {
    RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
    int launchToTaskId = launchState.launchedToTaskId;
    if (launchToTaskId != -1 && (event.launchTask == null || launchToTaskId != event.launchTask.key.id)) {
        SystemServicesProxy ssp = Recents.getSystemServices();
        ssp.cancelWindowTransition(launchState.launchedToTaskId);
        ssp.cancelThumbnailTransition(getTaskId());
    }
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) RecentsActivityLaunchState(com.android.systemui.recents.RecentsActivityLaunchState)

Example 80 with SystemServicesProxy

use of com.android.systemui.recents.misc.SystemServicesProxy in project android_frameworks_base by AOSPA.

the class RecentsTaskLoadPlan method preloadPlan.

/**
     * Preloads the list of recent tasks from the system. After this call, the TaskStack will
     * have a list of all the recent tasks with their metadata, not including icons or
     * thumbnails which were not cached and have to be loaded.
     *
     * The tasks will be ordered by:
     * - least-recent to most-recent stack tasks
     * - least-recent to most-recent freeform tasks
     */
public synchronized void preloadPlan(RecentsTaskLoader loader, int runningTaskId, boolean includeFrontMostExcludedTask) {
    Resources res = mContext.getResources();
    ArrayList<Task> allTasks = new ArrayList<>();
    if (mRawTasks == null) {
        preloadRawTasks(includeFrontMostExcludedTask);
    }
    SystemServicesProxy ssp = SystemServicesProxy.getInstance(mContext);
    SparseArray<Task.TaskKey> affiliatedTasks = new SparseArray<>();
    SparseIntArray affiliatedTaskCounts = new SparseIntArray();
    String dismissDescFormat = mContext.getString(R.string.accessibility_recents_item_will_be_dismissed);
    String appInfoDescFormat = mContext.getString(R.string.accessibility_recents_item_open_app_info);
    int currentUserId = ssp.getCurrentUser();
    long legacyLastStackActiveTime = migrateLegacyLastStackActiveTime(currentUserId);
    long lastStackActiveTime = Settings.Secure.getLongForUser(mContext.getContentResolver(), Secure.OVERVIEW_LAST_STACK_ACTIVE_TIME, legacyLastStackActiveTime, currentUserId);
    if (RecentsDebugFlags.Static.EnableMockTasks) {
        lastStackActiveTime = 0;
    }
    long newLastStackActiveTime = -1;
    int taskCount = mRawTasks.size();
    for (int i = 0; i < taskCount; i++) {
        ActivityManager.RecentTaskInfo t = mRawTasks.get(i);
        // Compose the task key
        Task.TaskKey taskKey = new Task.TaskKey(t.persistentId, t.stackId, t.baseIntent, t.userId, t.firstActiveTime, t.lastActiveTime);
        // This task is only shown in the stack if it satisfies the historical time or min
        // number of tasks constraints. Freeform tasks are also always shown.
        boolean isFreeformTask = SystemServicesProxy.isFreeformStack(t.stackId);
        boolean isStackTask;
        if (Recents.getConfiguration().isGridEnabled) {
            // When grid layout is enabled, we only show the first
            // TaskGridLayoutAlgorithm.MAX_LAYOUT_TASK_COUNT} tasks.
            isStackTask = t.lastActiveTime >= lastStackActiveTime && i >= taskCount - TaskGridLayoutAlgorithm.MAX_LAYOUT_TASK_COUNT;
        } else {
            isStackTask = isFreeformTask || !isHistoricalTask(t) || (t.lastActiveTime >= lastStackActiveTime && i >= (taskCount - MIN_NUM_TASKS));
        }
        boolean isLaunchTarget = taskKey.id == runningTaskId;
        // the other stack-task constraints.
        if (isStackTask && newLastStackActiveTime < 0) {
            newLastStackActiveTime = t.lastActiveTime;
        }
        // Load the title, icon, and color
        ActivityInfo info = loader.getAndUpdateActivityInfo(taskKey);
        String title = loader.getAndUpdateActivityTitle(taskKey, t.taskDescription);
        String titleDescription = loader.getAndUpdateContentDescription(taskKey, res);
        String dismissDescription = String.format(dismissDescFormat, titleDescription);
        String appInfoDescription = String.format(appInfoDescFormat, titleDescription);
        Drawable icon = isStackTask ? loader.getAndUpdateActivityIcon(taskKey, t.taskDescription, res, false) : null;
        Bitmap thumbnail = loader.getAndUpdateThumbnail(taskKey, false);
        int activityColor = loader.getActivityPrimaryColor(t.taskDescription);
        int backgroundColor = loader.getActivityBackgroundColor(t.taskDescription);
        boolean isSystemApp = (info != null) && ((info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0);
        // Add the task to the stack
        Task task = new Task(taskKey, t.affiliatedTaskId, t.affiliatedTaskColor, icon, thumbnail, title, titleDescription, dismissDescription, appInfoDescription, activityColor, backgroundColor, isLaunchTarget, isStackTask, isSystemApp, t.isDockable, t.bounds, t.taskDescription, t.resizeMode, t.topActivity);
        allTasks.add(task);
        affiliatedTaskCounts.put(taskKey.id, affiliatedTaskCounts.get(taskKey.id, 0) + 1);
        affiliatedTasks.put(taskKey.id, taskKey);
    }
    if (newLastStackActiveTime != -1) {
        Settings.Secure.putLongForUser(mContext.getContentResolver(), Secure.OVERVIEW_LAST_STACK_ACTIVE_TIME, newLastStackActiveTime, currentUserId);
    }
    // Initialize the stacks
    mStack = new TaskStack();
    mStack.setTasks(mContext, allTasks, false);
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) ArrayList(java.util.ArrayList) Drawable(android.graphics.drawable.Drawable) ActivityManager(android.app.ActivityManager) SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) SparseArray(android.util.SparseArray) Bitmap(android.graphics.Bitmap) SparseIntArray(android.util.SparseIntArray) Resources(android.content.res.Resources)

Aggregations

SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)243 Rect (android.graphics.Rect)45 ActivityManager (android.app.ActivityManager)35 ActivityInfo (android.content.pm.ActivityInfo)34 RecentsTaskLoader (com.android.systemui.recents.model.RecentsTaskLoader)30 TaskStack (com.android.systemui.recents.model.TaskStack)30 Task (com.android.systemui.recents.model.Task)25 Drawable (android.graphics.drawable.Drawable)19 Point (android.graphics.Point)16 ActivityOptions (android.app.ActivityOptions)15 ComponentName (android.content.ComponentName)15 RemoteException (android.os.RemoteException)15 MutableBoolean (android.util.MutableBoolean)15 RecentsActivityLaunchState (com.android.systemui.recents.RecentsActivityLaunchState)15 RecentsConfiguration (com.android.systemui.recents.RecentsConfiguration)15 Bitmap (android.graphics.Bitmap)14 ArrayList (java.util.ArrayList)14 BitmapDrawable (android.graphics.drawable.BitmapDrawable)12 ActivityNotFoundException (android.content.ActivityNotFoundException)10 Intent (android.content.Intent)10