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

Commit 0861012a authored by Silin Huang's avatar Silin Huang
Browse files

Use isServiceAvailable for wallet tile availability

Also update the title of the wallet tile, no longer read it from
gmscore.

Test: test on device
Fix: 180959290
Fix: 185159805
Change-Id: I1bc0bfdf1f8debdda0c44d1c7894bde424e69eae
parent e30c3b4e
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -138,12 +138,11 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> {


    @Override
    @Override
    protected void handleUpdateState(State state, Object arg) {
    protected void handleUpdateState(State state, Object arg) {
        CharSequence qawLabel = mQuickAccessWalletClient.getServiceLabel();
        state.label = mLabel;
        state.label = qawLabel == null ? mLabel : qawLabel;
        state.contentDescription = state.label;
        state.contentDescription = state.label;
        state.icon = ResourceIcon.get(R.drawable.ic_qs_wallet);
        state.icon = ResourceIcon.get(R.drawable.ic_qs_wallet);
        boolean isDeviceLocked = !mKeyguardStateController.isUnlocked();
        boolean isDeviceLocked = !mKeyguardStateController.isUnlocked();
        if (mQuickAccessWalletClient.isWalletFeatureAvailable()) {
        if (mQuickAccessWalletClient.isWalletServiceAvailable()) {
            if (mHasCard) {
            if (mHasCard) {
                if (isDeviceLocked) {
                if (isDeviceLocked) {
                    state.state = Tile.STATE_INACTIVE;
                    state.state = Tile.STATE_INACTIVE;
+4 −10
Original line number Original line Diff line number Diff line
@@ -141,6 +141,7 @@ public class QuickAccessWalletTileTest extends SysuiTestCase {
        when(mHost.getUiEventLogger()).thenReturn(mUiEventLogger);
        when(mHost.getUiEventLogger()).thenReturn(mUiEventLogger);
        when(mFeatureFlags.isQuickAccessWalletEnabled()).thenReturn(true);
        when(mFeatureFlags.isQuickAccessWalletEnabled()).thenReturn(true);
        when(mQuickAccessWalletClient.isWalletFeatureAvailable()).thenReturn(true);
        when(mQuickAccessWalletClient.isWalletFeatureAvailable()).thenReturn(true);
        when(mQuickAccessWalletClient.isWalletServiceAvailable()).thenReturn(true);


        mTile = new QuickAccessWalletTile(
        mTile = new QuickAccessWalletTile(
                mHost,
                mHost,
@@ -171,13 +172,7 @@ public class QuickAccessWalletTileTest extends SysuiTestCase {
    }
    }


    @Test
    @Test
    public void testIsAvailable_qawServiceNotAvailable() {
    public void testIsAvailable_qawFeatureAvailable() {
        when(mQuickAccessWalletClient.isWalletServiceAvailable()).thenReturn(false);
        assertFalse(mTile.isAvailable());
    }

    @Test
    public void testIsAvailable_qawServiceAvailable() {
        when(mPackageManager.hasSystemFeature(FEATURE_NFC_HOST_CARD_EMULATION)).thenReturn(true);
        when(mPackageManager.hasSystemFeature(FEATURE_NFC_HOST_CARD_EMULATION)).thenReturn(true);
        when(mPackageManager.hasSystemFeature("org.chromium.arc")).thenReturn(false);
        when(mPackageManager.hasSystemFeature("org.chromium.arc")).thenReturn(false);
        when(mSecureSettings.getString(NFC_PAYMENT_DEFAULT_COMPONENT)).thenReturn("Component");
        when(mSecureSettings.getString(NFC_PAYMENT_DEFAULT_COMPONENT)).thenReturn("Component");
@@ -229,11 +224,10 @@ public class QuickAccessWalletTileTest extends SysuiTestCase {
    public void testHandleUpdateState_updateLabelAndIcon() {
    public void testHandleUpdateState_updateLabelAndIcon() {
        QSTile.State state = new QSTile.State();
        QSTile.State state = new QSTile.State();
        QSTile.Icon icon = QSTileImpl.ResourceIcon.get(R.drawable.ic_qs_wallet);
        QSTile.Icon icon = QSTileImpl.ResourceIcon.get(R.drawable.ic_qs_wallet);
        when(mQuickAccessWalletClient.getServiceLabel()).thenReturn("QuickAccessWallet");


        mTile.handleUpdateState(state, null);
        mTile.handleUpdateState(state, null);


        assertEquals("QuickAccessWallet", state.label.toString());
        assertEquals(mContext.getString(R.string.wallet_title), state.label.toString());
        assertTrue(state.label.toString().contentEquals(state.contentDescription));
        assertTrue(state.label.toString().contentEquals(state.contentDescription));
        assertEquals(icon, state.icon);
        assertEquals(icon, state.icon);
    }
    }
@@ -288,7 +282,7 @@ public class QuickAccessWalletTileTest extends SysuiTestCase {


    @Test
    @Test
    public void testHandleUpdateState_qawFeatureUnavailable_tileUnavailable() {
    public void testHandleUpdateState_qawFeatureUnavailable_tileUnavailable() {
        when(mQuickAccessWalletClient.isWalletFeatureAvailable()).thenReturn(false);
        when(mQuickAccessWalletClient.isWalletServiceAvailable()).thenReturn(false);
        QSTile.State state = new QSTile.State();
        QSTile.State state = new QSTile.State();


        mTile.handleUpdateState(state, null);
        mTile.handleUpdateState(state, null);