Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dd1b1451 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Catching case where the activity we are launching from Recents no longer exists."

parents 0bfae106 c620bafd
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.recents;

import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Rect;
import android.util.DisplayMetrics;
import android.util.TypedValue;
@@ -31,6 +32,7 @@ public class RecentsConfiguration {
    DisplayMetrics mDisplayMetrics;

    public Rect systemInsets = new Rect();
    public Rect displayRect = new Rect();

    /** Private constructor */
    private RecentsConfiguration() {}
@@ -51,10 +53,11 @@ public class RecentsConfiguration {

    /** Updates the state, given the specified context */
    void update(Context context) {
        mDisplayMetrics = context.getResources().getDisplayMetrics();
        Resources res = context.getResources();
        DisplayMetrics dm = res.getDisplayMetrics();
        mDisplayMetrics = dm;

        boolean isPortrait = context.getResources().getConfiguration().orientation ==
                Configuration.ORIENTATION_PORTRAIT;
        displayRect.set(0, 0, dm.widthPixels, dm.heightPixels);
    }

    public void updateSystemInsets(Rect insets) {
+14 −6
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.recents.views;

import android.app.ActivityOptions;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
@@ -210,11 +211,14 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
                int offsetX = 0;
                int offsetY = 0;
                if (tv == null) {
                    // Launch the activity
                    // If there is no actual task view, then use the stack view as the source view
                    // and then offset to the expected transform rect, but bound this to just
                    // outside the display rect (to ensure we don't animate from too far away)
                    RecentsConfiguration config = RecentsConfiguration.getInstance();
                    sourceView = stackView;
                    transform = stackView.getStackTransform(stack.indexOfTask(task));
                    offsetX = transform.rect.left;
                    offsetY = transform.rect.top;
                    offsetY = Math.min(transform.rect.top, config.displayRect.height());
                } else {
                    transform = stackView.getStackTransform(stack.indexOfTask(task));
                }
@@ -242,11 +246,15 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
                i.setFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
                        | Intent.FLAG_ACTIVITY_TASK_ON_HOME
                        | Intent.FLAG_ACTIVITY_NEW_TASK);
                try {
                    if (opts != null) {
                        getContext().startActivityAsUser(i, opts.toBundle(), UserHandle.CURRENT);
                    } else {
                        getContext().startActivityAsUser(i, UserHandle.CURRENT);
                    }
                } catch (ActivityNotFoundException anfe) {
                    Console.logError(getContext(), "Could not start Activity");
                }

                Console.logTraceTime(Constants.DebugFlags.App.TimeRecentsLaunchTask,
                        Constants.DebugFlags.App.TimeRecentsLaunchKey, "startActivity");