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

Commit b93031e0 authored by John Spurlock's avatar John Spurlock Committed by Android Git Automerger
Browse files

am 65cbcbea: Remove add widget transition jank (insecure).

* commit '65cbcbea':
  Remove add widget transition jank (insecure).
parents 8aa62362 65cbcbea
Loading
Loading
Loading
Loading
+25 −1
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package com.android.internal.policy.impl.keyguard;
import android.app.ActivityManagerNative;
import android.app.ActivityOptions;
import android.app.IActivityManager.WaitResult;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
@@ -112,6 +114,27 @@ public abstract class KeyguardActivityLauncher {
        }
    }

    public void launchWidgetPicker(int appWidgetId) {
        Intent pickIntent = new Intent(AppWidgetManager.ACTION_KEYGUARD_APPWIDGET_PICK);

        pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
        pickIntent.putExtra(AppWidgetManager.EXTRA_CUSTOM_SORT, false);
        pickIntent.putExtra(AppWidgetManager.EXTRA_CATEGORY_FILTER,
                AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD);

        Bundle options = new Bundle();
        options.putInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY,
                AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD);
        pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
        pickIntent.addFlags(
                Intent.FLAG_ACTIVITY_NEW_TASK
                | Intent.FLAG_ACTIVITY_SINGLE_TOP
                | Intent.FLAG_ACTIVITY_CLEAR_TOP
                | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

        launchActivity(pickIntent, false, false, null, null);
    }

    /**
     * Launches the said intent for the current foreground user.
     *
@@ -128,7 +151,8 @@ public abstract class KeyguardActivityLauncher {
            final Handler worker,
            final Runnable onStarted) {
        final Context context = getContext();
        final Bundle animation = ActivityOptions.makeCustomAnimation(context, 0, 0).toBundle();
        final Bundle animation = useDefaultAnimations ? null
                : ActivityOptions.makeCustomAnimation(context, 0, 0).toBundle();
        LockPatternUtils lockPatternUtils = getLockPatternUtils();
        intent.addFlags(
                Intent.FLAG_ACTIVITY_NEW_TASK
+6 −37
Original line number Diff line number Diff line
@@ -33,12 +33,10 @@ import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Looper;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemClock;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.AttributeSet;
import android.util.Log;
@@ -898,14 +896,12 @@ public class KeyguardHostView extends KeyguardViewBase {
        addWidgetButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                mCallback.setOnDismissRunnable(new Runnable() {

                    @Override
                    public void run() {
                        launchPickActivityIntent();
                int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
                if (appWidgetId != -1) {
                    mActivityLauncher.launchWidgetPicker(appWidgetId);
                } else {
                    Log.e(TAG, "Unable to allocate an AppWidget id in lock screen");
                }
                });
                mCallback.dismiss(false);
            }
        });

@@ -913,33 +909,6 @@ public class KeyguardHostView extends KeyguardViewBase {
        initializeTransportControl();
    }

    private void launchPickActivityIntent() {
        // Create intent to pick widget
        Intent pickIntent = new Intent(AppWidgetManager.ACTION_KEYGUARD_APPWIDGET_PICK);

        int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
        if (appWidgetId != -1) {
            pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            pickIntent.putExtra(AppWidgetManager.EXTRA_CUSTOM_SORT, false);
            pickIntent.putExtra(AppWidgetManager.EXTRA_CATEGORY_FILTER,
                    AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD);

            Bundle options = new Bundle();
            options.putInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY,
                    AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD);
            pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
            pickIntent.addFlags(
                    Intent.FLAG_ACTIVITY_NEW_TASK
                    | Intent.FLAG_ACTIVITY_SINGLE_TOP
                    | Intent.FLAG_ACTIVITY_CLEAR_TOP
                    | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
            mContext.startActivityAsUser(pickIntent,
                    new UserHandle(UserHandle.USER_CURRENT));
        } else {
            Log.e(TAG, "Unable to allocate an AppWidget id in lock screen");
        }
    }

    private void removeTransportFromWidgetPager() {
        int page = getWidgetPosition(R.id.keyguard_transport_control);
        if (page != -1) {