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

Commit 62767af3 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Merge cherrypicks of [14740967, 14741245, 14741024, 14740327, 14740328,...

Merge cherrypicks of [14740967, 14741245, 14741024, 14740327, 14740328, 14740329, 14741350, 14741106, 14741246, 14741247, 14741186, 14741107, 14740385, 14740386, 14740751, 14741025, 14741188, 14741370] into sc-release

Change-Id: I4cde4d966f2d934c2462e6383449edd1639a389d
parents fbd668b7 a19a2ce9
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -129,7 +129,22 @@
            android:layout_marginTop="@dimen/status_bar_header_height_keyguard"
            android:text="@string/report_rejected_touch"
            android:visibility="gone" />

        <com.android.systemui.statusbar.phone.TapAgainView
            android:id="@+id/shade_falsing_tap_again"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            systemui:layout_constraintLeft_toLeftOf="parent"
            systemui:layout_constraintRight_toRightOf="parent"
            systemui:layout_constraintBottom_toBottomOf="parent"
            android:layout_marginBottom="20dp"
            android:paddingHorizontal="16dp"
            android:minHeight="44dp"
            android:elevation="4dp"
            android:background="@drawable/rounded_bg_full"
            android:gravity="center"
            android:text="@string/tap_again"
            android:visibility="gone"
        />
    </com.android.systemui.statusbar.phone.NotificationsQuickSettingsContainer>

    <FrameLayout
+3 −0
Original line number Diff line number Diff line
@@ -1062,6 +1062,9 @@
    <!-- Shows to explain the double tap interaction with notifications: After tapping a notification on Keyguard, this will explain users to tap again to launch a notification. [CHAR LIMIT=60] -->
    <string name="notification_tap_again">Tap again to open</string>

    <!-- Asks for a second tap as confirmation on an item that normally requires one tap. [CHAR LIMIT=60] -->
    <string name="tap_again">Tap again</string>

    <!-- Message shown when lock screen is tapped or face authentication fails. [CHAR LIMIT=60] -->
    <string name="keyguard_unlock">Swipe up to open</string>

+6 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ public class FalsingManagerFake implements FalsingManager {
    private boolean mIsFalseRobustTap;

    private final List<FalsingBeliefListener> mFalsingBeliefListeners = new ArrayList<>();
    private final List<FalsingTapListener> mTapListeners = new ArrayList<>();

    @Override
    public void onSuccessfulUnlock() {
@@ -148,11 +149,15 @@ public class FalsingManagerFake implements FalsingManager {

    @Override
    public void addTapListener(FalsingTapListener falsingTapListener) {

        mTapListeners.add(falsingTapListener);
    }

    @Override
    public void removeTapListener(FalsingTapListener falsingTapListener) {
        mTapListeners.remove(falsingTapListener);
    }

    public List<FalsingTapListener> getTapListeners() {
        return mTapListeners;
    }
}
+28 −23
Original line number Diff line number Diff line
@@ -18,13 +18,14 @@ package com.android.systemui.qs.tiles;

import static android.provider.Settings.Secure.NFC_PAYMENT_DEFAULT_COMPONENT;

import static com.android.systemui.wallet.controller.QuickAccessWalletController.WalletChangeEvent.DEFAULT_PAYMENT_APP_CHANGE;

import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Looper;
import android.service.quickaccesswallet.GetWalletCardsError;
import android.service.quickaccesswallet.GetWalletCardsRequest;
import android.service.quickaccesswallet.GetWalletCardsResponse;
import android.service.quickaccesswallet.QuickAccessWalletClient;
import android.service.quickaccesswallet.WalletCard;
@@ -51,6 +52,7 @@ import com.android.systemui.qs.tileimpl.QSTileImpl;
import com.android.systemui.statusbar.FeatureFlags;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.util.settings.SecureSettings;
import com.android.systemui.wallet.controller.QuickAccessWalletController;
import com.android.systemui.wallet.ui.WalletActivity;

import java.util.List;
@@ -66,16 +68,15 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> {

    private final CharSequence mLabel = mContext.getString(R.string.wallet_title);
    private final WalletCardRetriever mCardRetriever = new WalletCardRetriever();
    // TODO(b/180959290): Re-create the QAW Client when the default NFC payment app changes.
    private final QuickAccessWalletClient mQuickAccessWalletClient;
    private final KeyguardStateController mKeyguardStateController;
    private final PackageManager mPackageManager;
    private final SecureSettings mSecureSettings;
    private final Executor mExecutor;
    private final QuickAccessWalletController mController;
    private final FeatureFlags mFeatureFlags;

    @VisibleForTesting Drawable mCardViewDrawable;
    private WalletCard mSelectedCard;
    @VisibleForTesting Drawable mCardViewDrawable;

    @Inject
    public QuickAccessWalletTile(
@@ -87,15 +88,15 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> {
            StatusBarStateController statusBarStateController,
            ActivityStarter activityStarter,
            QSLogger qsLogger,
            QuickAccessWalletClient quickAccessWalletClient,
            KeyguardStateController keyguardStateController,
            PackageManager packageManager,
            SecureSettings secureSettings,
            @Background Executor executor,
            @Main Executor executor,
            QuickAccessWalletController quickAccessWalletController,
            FeatureFlags featureFlags) {
        super(host, backgroundLooper, mainHandler, falsingManager, metricsLogger,
                statusBarStateController, activityStarter, qsLogger);
        mQuickAccessWalletClient = quickAccessWalletClient;
        mController = quickAccessWalletController;
        mKeyguardStateController = keyguardStateController;
        mPackageManager = packageManager;
        mSecureSettings = secureSettings;
@@ -115,7 +116,11 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> {
    protected void handleSetListening(boolean listening) {
        super.handleSetListening(listening);
        if (listening) {
            queryWalletCards();
            mController.setupWalletChangeObservers(mCardRetriever, DEFAULT_PAYMENT_APP_CHANGE);
            if (!mController.getWalletClient().isWalletServiceAvailable()) {
                mController.reCreateWalletClient();
            }
            mController.queryWalletCards(mCardRetriever);
        }
    }

@@ -139,12 +144,13 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> {
                    mContext.startActivity(intent);
                }
            } else {
                if (mQuickAccessWalletClient.createWalletIntent() == null) {
                if (mController.getWalletClient().createWalletIntent() == null) {
                    Log.w(TAG, "Could not get intent of the wallet app.");
                    return;
                }
                mActivityStarter.postStartActivityDismissingKeyguard(
                        mQuickAccessWalletClient.createWalletIntent(), /* delay= */ 0,
                        mController.getWalletClient().createWalletIntent(),
                        /* delay= */ 0,
                        animationController);
            }
        });
@@ -152,30 +158,34 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> {

    @Override
    protected void handleUpdateState(State state, Object arg) {
        CharSequence label = mQuickAccessWalletClient.getServiceLabel();
        CharSequence label = mController.getWalletClient().getServiceLabel();
        state.label = label == null ? mLabel : label;
        state.contentDescription = state.label;
        state.icon = ResourceIcon.get(R.drawable.ic_wallet_lockscreen);
        boolean isDeviceLocked = !mKeyguardStateController.isUnlocked();
        if (mQuickAccessWalletClient.isWalletServiceAvailable()) {
        if (mController.getWalletClient().isWalletServiceAvailable()) {
            if (mSelectedCard != null) {
                if (isDeviceLocked) {
                    state.state = Tile.STATE_INACTIVE;
                    state.secondaryLabel =
                            mContext.getString(R.string.wallet_secondary_label_device_locked);
                    state.sideViewCustomDrawable = null;
                } else {
                    state.state = Tile.STATE_ACTIVE;
                    state.secondaryLabel = mSelectedCard.getContentDescription();
                    state.sideViewCustomDrawable = mCardViewDrawable;
                }
            } else {
                state.state = Tile.STATE_INACTIVE;
                state.secondaryLabel = mContext.getString(R.string.wallet_secondary_label_no_card);
                state.sideViewCustomDrawable = null;
            }
            state.stateDescription = state.secondaryLabel;
        } else {
            state.state = Tile.STATE_UNAVAILABLE;
            state.secondaryLabel = null;
            state.sideViewCustomDrawable = null;
        }
        state.sideViewCustomDrawable = isDeviceLocked ? null : mCardViewDrawable;
    }

    @Override
@@ -198,19 +208,14 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> {

    @Override
    public CharSequence getTileLabel() {
        CharSequence label = mQuickAccessWalletClient.getServiceLabel();
        CharSequence label = mController.getWalletClient().getServiceLabel();
        return label == null ? mLabel : label;
    }

    private void queryWalletCards() {
        int cardWidth =
                mContext.getResources().getDimensionPixelSize(R.dimen.wallet_tile_card_view_width);
        int cardHeight =
                mContext.getResources().getDimensionPixelSize(R.dimen.wallet_tile_card_view_height);
        int iconSizePx = mContext.getResources().getDimensionPixelSize(R.dimen.wallet_icon_size);
        GetWalletCardsRequest request =
                new GetWalletCardsRequest(cardWidth, cardHeight, iconSizePx, /* maxCards= */ 1);
        mQuickAccessWalletClient.getWalletCards(mExecutor, request, mCardRetriever);
    @Override
    protected void handleDestroy() {
        super.handleDestroy();
        mController.unregisterWalletChangeObservers(DEFAULT_PAYMENT_APP_CHANGE);
    }

    private class WalletCardRetriever implements
+24 −59
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import static com.android.systemui.tuner.LockscreenFragment.LOCKSCREEN_LEFT_BUTT
import static com.android.systemui.tuner.LockscreenFragment.LOCKSCREEN_LEFT_UNLOCK;
import static com.android.systemui.tuner.LockscreenFragment.LOCKSCREEN_RIGHT_BUTTON;
import static com.android.systemui.tuner.LockscreenFragment.LOCKSCREEN_RIGHT_UNLOCK;
import static com.android.systemui.wallet.controller.QuickAccessWalletController.WalletChangeEvent.DEFAULT_PAYMENT_APP_CHANGE;
import static com.android.systemui.wallet.controller.QuickAccessWalletController.WalletChangeEvent.WALLET_PREFERENCE_CHANGE;

import android.app.ActivityManager;
import android.app.ActivityOptions;
@@ -39,7 +41,6 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
import android.database.ContentObserver;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
@@ -49,13 +50,10 @@ import android.os.Messenger;
import android.os.RemoteException;
import android.os.UserHandle;
import android.provider.MediaStore;
import android.provider.Settings;
import android.service.media.CameraPrewarmService;
import android.service.quickaccesswallet.GetWalletCardsError;
import android.service.quickaccesswallet.GetWalletCardsRequest;
import android.service.quickaccesswallet.GetWalletCardsResponse;
import android.service.quickaccesswallet.QuickAccessWalletClient;
import android.service.quickaccesswallet.QuickAccessWalletClientImpl;
import android.telecom.TelecomManager;
import android.text.TextUtils;
import android.util.AttributeSet;
@@ -71,7 +69,6 @@ import android.widget.ImageView;
import android.widget.TextView;

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

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.widget.LockPatternUtils;
@@ -97,11 +94,9 @@ import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.statusbar.policy.PreviewInflater;
import com.android.systemui.tuner.LockscreenFragment.LockButtonFactory;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.util.settings.SecureSettings;
import com.android.systemui.wallet.controller.QuickAccessWalletController;
import com.android.systemui.wallet.ui.WalletActivity;

import java.util.concurrent.Executor;

/**
 * Implementation for the bottom area of the Keyguard, including camera/phone affordance and status
 * text.
@@ -137,10 +132,9 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
    private KeyguardAffordanceView mLeftAffordanceView;

    private ImageView mWalletButton;
    private boolean mWalletEnabled = false;
    private boolean mHasCard = false;
    private WalletCardRetriever mCardRetriever = new WalletCardRetriever();
    private QuickAccessWalletClient mQuickAccessWalletClient;
    private QuickAccessWalletController mQuickAccessWalletController;

    private ViewGroup mIndicationArea;
    private TextView mIndicationText;
@@ -159,7 +153,6 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
    private StatusBar mStatusBar;
    private KeyguardAffordanceHelper mAffordanceHelper;
    private FalsingManager mFalsingManager;
    @Nullable private Executor mUiExecutor;
    private boolean mUserSetupComplete;
    private boolean mPrewarmBound;
    private Messenger mPrewarmMessenger;
@@ -193,8 +186,6 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
    private int mBurnInYOffset;
    private ActivityIntentHelper mActivityIntentHelper;
    private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
    private ContentObserver mWalletPreferenceObserver;
    private SecureSettings mSecureSettings;

    public KeyguardBottomAreaView(Context context) {
        this(context, null);
@@ -332,8 +323,9 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
        getContext().unregisterReceiver(mDevicePolicyReceiver);
        mKeyguardUpdateMonitor.removeCallback(mUpdateMonitorCallback);

        if (mWalletPreferenceObserver != null) {
            mSecureSettings.unregisterContentObserver(mWalletPreferenceObserver);
        if (mQuickAccessWalletController != null) {
            mQuickAccessWalletController.unregisterWalletChangeObservers(
                    WALLET_PREFERENCE_CHANGE, DEFAULT_PAYMENT_APP_CHANGE);
        }
    }

@@ -456,7 +448,10 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
    }

    private void updateWalletVisibility() {
        if (mDozing || !mWalletEnabled || !mHasCard) {
        if (mDozing
                || mQuickAccessWalletController == null
                || !mQuickAccessWalletController.isWalletEnabled()
                || !mHasCard) {
            mWalletButton.setVisibility(GONE);
            mIndicationArea.setPadding(0, 0, 0, 0);
        } else {
@@ -690,7 +685,9 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
    @Override
    public void onKeyguardShowingChanged() {
        if (mKeyguardStateController.isShowing()) {
            queryWalletCards();
            if (mQuickAccessWalletController != null) {
                mQuickAccessWalletController.queryWalletCards(mCardRetriever);
            }
        }
    }

@@ -935,50 +932,17 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
    /**
     * Initialize the wallet feature, only enabling if the feature is enabled within the platform.
     */
    public void initWallet(QuickAccessWalletClient client, Executor uiExecutor,
            SecureSettings secureSettings) {
        mQuickAccessWalletClient = client;
        mSecureSettings = secureSettings;
        setupWalletPreferenceObserver();
        updateWalletPreference();

        mUiExecutor = uiExecutor;
        queryWalletCards();
    public void initWallet(
            QuickAccessWalletController controller) {
        mQuickAccessWalletController = controller;
        mQuickAccessWalletController.setupWalletChangeObservers(
                mCardRetriever, WALLET_PREFERENCE_CHANGE, DEFAULT_PAYMENT_APP_CHANGE);
        mQuickAccessWalletController.updateWalletPreference();
        mQuickAccessWalletController.queryWalletCards(mCardRetriever);

        updateWalletVisibility();
    }

    private void setupWalletPreferenceObserver() {
        if (mWalletPreferenceObserver == null) {
            mWalletPreferenceObserver = new ContentObserver(null /* handler */) {
                @Override
                public void onChange(boolean selfChange) {
                    mUiExecutor.execute(() -> updateWalletPreference());
                }
            };

            mSecureSettings.registerContentObserver(
                    Settings.Secure.getUriFor(QuickAccessWalletClientImpl.SETTING_KEY),
                    false /* notifyForDescendants */,
                    mWalletPreferenceObserver);
        }
    }

    private void updateWalletPreference() {
        mWalletEnabled = mQuickAccessWalletClient.isWalletFeatureAvailable()
                && mQuickAccessWalletClient.isWalletFeatureAvailableWhenDeviceLocked();
    }

    private void queryWalletCards() {
        if (!mWalletEnabled || mUiExecutor == null) {
            return;
        }
        GetWalletCardsRequest request =
                new GetWalletCardsRequest(1 /* cardWidth */, 1 /* cardHeight */,
                        1 /* iconSizePx */, 1 /* maxCards */);
        mQuickAccessWalletClient.getWalletCards(mUiExecutor, request, mCardRetriever);
    }

    private void onWalletClick(View v) {
        // More coming here; need to inform the user about how to proceed
        if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) {
@@ -991,12 +955,13 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
                    .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
            mContext.startActivity(intent);
        } else {
            if (mQuickAccessWalletClient.createWalletIntent() == null) {
            if (mQuickAccessWalletController.getWalletClient().createWalletIntent() == null) {
                Log.w(TAG, "Could not get intent of the wallet app.");
                return;
            }
            mActivityStarter.postStartActivityDismissingKeyguard(
                    mQuickAccessWalletClient.createWalletIntent(), /* delay= */ 0);
                    mQuickAccessWalletController.getWalletClient().createWalletIntent(),
                    /* delay= */ 0);
        }
    }

Loading