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

Commit 4c48d574 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Do not launch home disambiguation screen when home is not known" into tm-qpr-dev

parents 3ddec483 4a35dd4f
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -23,16 +23,15 @@ import static com.android.launcher3.GestureNavContract.EXTRA_ICON_POSITION;
import static com.android.launcher3.GestureNavContract.EXTRA_ICON_SURFACE;
import static com.android.launcher3.GestureNavContract.EXTRA_ON_FINISH_CALLBACK;
import static com.android.launcher3.GestureNavContract.EXTRA_REMOTE_CALLBACK;
import static com.android.launcher3.Utilities.createHomeIntent;
import static com.android.launcher3.anim.AnimatorListeners.forEndCallback;
import static com.android.launcher3.anim.Interpolators.ACCEL;
import static com.android.quickstep.OverviewComponentObserver.startHomeIntentSafely;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME;

import android.animation.ObjectAnimator;
import android.annotation.TargetApi;
import android.app.ActivityManager.RunningTaskInfo;
import android.app.ActivityOptions;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.graphics.Matrix;
@@ -161,11 +160,7 @@ public class FallbackSwipeHandler extends
        if (gestureContractAnimationFactory != null && runningTaskTarget != null) {
            gestureContractAnimationFactory.addGestureContract(intent, runningTaskTarget.taskInfo);
        }
        try {
            mContext.startActivity(intent, options.toBundle());
        } catch (NullPointerException | ActivityNotFoundException | SecurityException e) {
            mContext.startActivity(createHomeIntent());
        }
        startHomeIntentSafely(mContext, intent, options.toBundle());
    }

    @Override
+35 −1
Original line number Diff line number Diff line
@@ -20,11 +20,11 @@ import static android.content.Intent.ACTION_PACKAGE_ADDED;
import static android.content.Intent.ACTION_PACKAGE_CHANGED;
import static android.content.Intent.ACTION_PACKAGE_REMOVED;

import static com.android.launcher3.Utilities.createHomeIntent;
import static com.android.launcher3.config.FeatureFlags.SEPARATE_RECENTS_ACTIVITY;
import static com.android.launcher3.util.PackageManagerHelper.getPackageFilter;
import static com.android.systemui.shared.system.PackageManagerWrapper.ACTION_PREFERRED_ACTIVITY_CHANGED;

import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -33,8 +33,12 @@ import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.util.SparseIntArray;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.launcher3.tracing.OverviewComponentObserverProto;
import com.android.launcher3.tracing.TouchInteractionServiceProto;
import com.android.launcher3.util.SimpleBroadcastReceiver;
@@ -276,4 +280,34 @@ public final class OverviewComponentObserver {
        overviewComponentObserver.setOverviewActivityResumed(mActivityInterface.isResumed());
        serviceProto.setOverviewComponentObvserver(overviewComponentObserver);
    }

    /**
     * Starts the intent for the current home activity.
     */
    public static void startHomeIntentSafely(@NonNull Context context, @Nullable Bundle options) {
        RecentsAnimationDeviceState deviceState = new RecentsAnimationDeviceState(context);
        OverviewComponentObserver observer = new OverviewComponentObserver(context, deviceState);
        Intent intent = observer.getHomeIntent();
        observer.onDestroy();
        deviceState.destroy();
        startHomeIntentSafely(context, intent, options);
    }

    /**
     * Starts the intent for the current home activity.
     */
    public static void startHomeIntentSafely(
            @NonNull Context context, @NonNull Intent homeIntent, @Nullable Bundle options) {
        try {
            context.startActivity(homeIntent, options);
        } catch (NullPointerException | ActivityNotFoundException | SecurityException e) {
            context.startActivity(createHomeIntent(), options);
        }
    }

    private static Intent createHomeIntent() {
        return new Intent(Intent.ACTION_MAIN)
                .addCategory(Intent.CATEGORY_HOME)
                .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -21,11 +21,11 @@ import static android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE;
import static com.android.launcher3.QuickstepTransitionManager.RECENTS_LAUNCH_DURATION;
import static com.android.launcher3.QuickstepTransitionManager.STATUS_BAR_TRANSITION_DURATION;
import static com.android.launcher3.QuickstepTransitionManager.STATUS_BAR_TRANSITION_PRE_DELAY;
import static com.android.launcher3.Utilities.createHomeIntent;
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
import static com.android.launcher3.graphics.SysUiScrim.SYSUI_PROGRESS;
import static com.android.launcher3.testing.TestProtocol.BAD_STATE;
import static com.android.launcher3.testing.TestProtocol.OVERVIEW_STATE_ORDINAL;
import static com.android.quickstep.OverviewComponentObserver.startHomeIntentSafely;
import static com.android.quickstep.TaskUtils.taskIsATargetWithMode;
import static com.android.quickstep.TaskViewUtils.createRecentsWindowAnimator;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING;
@@ -428,7 +428,7 @@ public final class RecentsActivity extends StatefulActivity<RecentsState> {
        RemoteAnimationAdapterCompat adapterCompat =
                new RemoteAnimationAdapterCompat(runner, HOME_APPEAR_DURATION, 0,
                        getIApplicationThread());
        startActivity(createHomeIntent(),
        startHomeIntentSafely(this,
                ActivityOptionsCompat.makeRemoteAnimation(adapterCompat).toBundle());
    }

+4 −3
Original line number Diff line number Diff line
@@ -19,12 +19,12 @@ import static android.view.MotionEvent.ACTION_CANCEL;
import static android.view.MotionEvent.ACTION_POINTER_DOWN;
import static android.view.MotionEvent.ACTION_UP;

import static com.android.launcher3.Utilities.createHomeIntent;
import static com.android.launcher3.Utilities.squaredHypot;
import static com.android.launcher3.Utilities.squaredTouchSlop;
import static com.android.launcher3.util.VelocityUtils.PX_PER_MS;
import static com.android.quickstep.AbsSwipeUpHandler.MIN_PROGRESS_FOR_OVERVIEW;
import static com.android.quickstep.MultiStateCallback.DEBUG_STATES;
import static com.android.quickstep.OverviewComponentObserver.startHomeIntentSafely;
import static com.android.quickstep.util.ActiveGestureLog.INTENT_EXTRA_LOG_TRACE_ID;

import android.animation.Animator;
@@ -205,8 +205,9 @@ public class DeviceLockedInputConsumer implements InputConsumer,
                @Override
                public void onAnimationEnd(Animator animation) {
                    if (dismissTask) {
                        // For now, just start the home intent so user is prompted to unlock the device.
                        mContext.startActivity(createHomeIntent());
                        // For now, just start the home intent so user is prompted to
                        // unlock the device.
                        startHomeIntentSafely(mContext, mGestureState.getHomeIntent(), null);
                        mHomeLaunched = true;
                    }
                    mStateCallback.setState(STATE_HANDLER_INVALIDATED);
+2 −7
Original line number Diff line number Diff line
@@ -15,12 +15,11 @@
 */
package com.android.quickstep.inputconsumers;

import static com.android.launcher3.Utilities.createHomeIntent;
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_BACKGROUND;
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOME_GESTURE;
import static com.android.quickstep.OverviewComponentObserver.startHomeIntentSafely;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.graphics.PointF;
import android.view.MotionEvent;
@@ -79,11 +78,7 @@ public class OverviewWithoutFocusInputConsumer implements InputConsumer,

    @Override
    public void onSwipeUp(boolean wasFling, PointF finalVelocity) {
        try {
            mContext.startActivity(mGestureState.getHomeIntent());
        } catch (NullPointerException | ActivityNotFoundException | SecurityException e) {
            mContext.startActivity(createHomeIntent());
        }
        startHomeIntentSafely(mContext, mGestureState.getHomeIntent(), null);
        ActiveGestureLog.INSTANCE.addLog("startQuickstep");
        BaseActivity activity = BaseDraggingActivity.fromContext(mContext);
        int state = (mGestureState != null && mGestureState.getEndTarget() != null)
Loading