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

Commit 21d16aec authored by Scottie Biddle's avatar Scottie Biddle
Browse files

Add new config and API for QuickAccessWallet features.

Adds a new configuration attribute for use in
QuickAccessWalletService:
* useTargetActivityForQuickAccess - this is a boolean, false by default.
When true, the system will use the component specified by the
android:targetActivity attribute instead of the SysUi's WalletActivity.

Adds a new API method to QuickAccessWalletService: the method returns a
PendingIntent that can be used in place of the targetActivity specified
in the service's manifest entry. The method is not abstract; by default
it returns null so that existing services will not have to make any
changes to target android T.

To make use of this feature, define a new method in
QuickAccessWalletClient: useTargetActivityForQuickAccess() which
provides the configuration for use by QuickAccessWalletController.

Updates QuickAccessWalletController to define a new method: startQuickAccessUiIntent(),
which reads the configuration as well as whether the service is
providing any cards, and provides a centralized place to launch
the correct Quick Access intent.
The logic there is:
1. If a PendingIntent is provided from the service, use that.
2. If not, check for an active activity from the metadata in XML.
3. If that isn't available OR useTargetActivityForQuickAccess is false and the system is displaying cards, use WalletActivity provided by SystemUi.

Addes tests for QuickAccessWalletController. CTS Test for
QuickAccessWalletClient has new tests in a separate change in the same
topic. In the course of development, discovered that unit tests for
QuickAccessWalletController has been failing for as long as a year. Will
fix that and update in a follow-up.

Test: atest QuickAccessWalletControllerTest
Test: atest QuickAccessWalletClientTest
Bug: 215725263

Change-Id: Ifa3427d5e6f6b02e4afffa40453d1cb0f4f8ed67
parent 2262a4a7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1642,6 +1642,7 @@ package android {
    field public static final int useEmbeddedDex = 16844190; // 0x101059e
    field public static final int useIntrinsicSizeAsMinimum = 16843536; // 0x1010310
    field public static final int useLevel = 16843167; // 0x101019f
    field public static final int useTargetActivityForQuickAccess;
    field public static final int userVisible = 16843409; // 0x1010291
    field public static final int usesCleartextTraffic = 16844012; // 0x10104ec
    field public static final int usesPermissionFlags = 16844356; // 0x1010644
@@ -38990,6 +38991,7 @@ package android.service.quickaccesswallet {
  public abstract class QuickAccessWalletService extends android.app.Service {
    ctor public QuickAccessWalletService();
    method @Nullable public android.app.PendingIntent getTargetActivityPendingIntent();
    method @Nullable public android.os.IBinder onBind(@NonNull android.content.Intent);
    method public abstract void onWalletCardSelected(@NonNull android.service.quickaccesswallet.SelectWalletCardRequest);
    method public abstract void onWalletCardsRequested(@NonNull android.service.quickaccesswallet.GetWalletCardsRequest, @NonNull android.service.quickaccesswallet.GetWalletCardsCallback);
+6 −0
Original line number Diff line number Diff line
@@ -2357,12 +2357,14 @@ package android.service.quickaccesswallet {
    method public void disconnect();
    method public void getWalletCards(@NonNull android.service.quickaccesswallet.GetWalletCardsRequest, @NonNull android.service.quickaccesswallet.QuickAccessWalletClient.OnWalletCardsRetrievedCallback);
    method public void getWalletCards(@NonNull java.util.concurrent.Executor, @NonNull android.service.quickaccesswallet.GetWalletCardsRequest, @NonNull android.service.quickaccesswallet.QuickAccessWalletClient.OnWalletCardsRetrievedCallback);
    method public void getWalletPendingIntent(@NonNull java.util.concurrent.Executor, @NonNull android.service.quickaccesswallet.QuickAccessWalletClient.WalletPendingIntentCallback);
    method public boolean isWalletFeatureAvailable();
    method public boolean isWalletFeatureAvailableWhenDeviceLocked();
    method public boolean isWalletServiceAvailable();
    method public void notifyWalletDismissed();
    method public void removeWalletServiceEventListener(@NonNull android.service.quickaccesswallet.QuickAccessWalletClient.WalletServiceEventListener);
    method public void selectWalletCard(@NonNull android.service.quickaccesswallet.SelectWalletCardRequest);
    method public boolean useTargetActivityForQuickAccess();
  }

  public static interface QuickAccessWalletClient.OnWalletCardsRetrievedCallback {
@@ -2370,6 +2372,10 @@ package android.service.quickaccesswallet {
    method public void onWalletCardsRetrieved(@NonNull android.service.quickaccesswallet.GetWalletCardsResponse);
  }

  public static interface QuickAccessWalletClient.WalletPendingIntentCallback {
    method public void onWalletPendingIntentRetrieved(@Nullable android.app.PendingIntent);
  }

  public static interface QuickAccessWalletClient.WalletServiceEventListener {
    method public void onWalletServiceEvent(@NonNull android.service.quickaccesswallet.WalletServiceEvent);
  }
+3 −1
Original line number Diff line number Diff line
@@ -41,4 +41,6 @@ interface IQuickAccessWalletService {
        in IQuickAccessWalletServiceCallbacks callback);
    // Unregister an event listener
    oneway void unregisterWalletServiceEventListener(in WalletServiceEventListenerRequest request);
    // Request to get a PendingIntent to launch an activity from which the user can manage their cards.
    oneway void onTargetActivityIntentRequested(in IQuickAccessWalletServiceCallbacks callbacks);
   }
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.service.quickaccesswallet;

import android.app.PendingIntent;
import android.service.quickaccesswallet.GetWalletCardsError;
import android.service.quickaccesswallet.GetWalletCardsResponse;
import android.service.quickaccesswallet.WalletServiceEvent;
@@ -34,4 +35,6 @@ interface IQuickAccessWalletServiceCallbacks {
    // Called in response to registerWalletServiceEventListener. May be called multiple times as
    // long as the event listener is registered.
    oneway void onWalletServiceEvent(in WalletServiceEvent event);
    // Called in response to onTargetActivityIntentRequested. May only be called once per request.
    oneway void onTargetActivityPendingIntentReceived(in PendingIntent pendingIntent);
}
 No newline at end of file
+27 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.TestApi;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
@@ -152,6 +153,21 @@ public interface QuickAccessWalletClient extends Closeable {
     */
    void disconnect();

    /**
     * The QuickAccessWalletService may provide a {@link PendingIntent} to start the activity that
     * hosts the Wallet view. This is typically the home screen of the Wallet application. If this
     * method returns null, the value returned by getWalletIntent() will be used instead.
     */
    void getWalletPendingIntent(@NonNull @CallbackExecutor Executor executor,
            @NonNull WalletPendingIntentCallback walletPendingIntentCallback);

    /**
     * Callback for getWalletPendingIntent.
     */
    interface WalletPendingIntentCallback {
        void onWalletPendingIntentRetrieved(@Nullable PendingIntent walletPendingIntent);
    }

    /**
     * The manifest entry for the QuickAccessWalletService may also publish information about the
     * activity that hosts the Wallet view. This is typically the home screen of the Wallet
@@ -212,4 +228,15 @@ public interface QuickAccessWalletClient extends Closeable {
     */
    @Nullable
    CharSequence getShortcutLongLabel();

    /**
     * Return whether the system should use the component specified by the
     * {@link android:targetActivity} or
     * {@link QuickAccessWalletService#getTargetActivityPendingIntent()}
     * as the "quick access" , invoked directly by the system.
     * If false, the system will use the built-in UI instead of the component specified
     * in {@link android:targetActivity} or
     * {@link QuickAccessWalletService#getTargetActivityPendingIntent()}.
     */
    boolean useTargetActivityForQuickAccess();
}
Loading