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

Commit 805337ab authored by John Spurlock's avatar John Spurlock
Browse files

resolved conflicts for merge of ef44a77f to jb-mr1-dev-plus-aosp

Change-Id: Iad4319796be4b9ad74580f8c20a4e8cb30569f87
parents 9a962d7c ef44a77f
Loading
Loading
Loading
Loading
+26 −2
Original line number Diff line number Diff line
@@ -18,6 +18,9 @@ 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;
@@ -110,6 +113,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);
    }

    /**
     * Launches the said intent for the current foreground user.
     * @param intent
@@ -118,8 +142,8 @@ public abstract class KeyguardActivityLauncher {
     */
    public void launchActivity(final Intent intent, boolean showsWhileLocked, boolean animate) {
        final Context context = getContext();
        final Bundle animation = animate ? null :
                ActivityOptions.makeCustomAnimation(context, 0, 0).toBundle();
        final Bundle animation = animate ? 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;
@@ -888,14 +886,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);
            }
        });

@@ -903,33 +899,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) {