Delete attribute useTargetActivityForQuickAccess.
In practice, the value of this xml attribute is always going to a
function of whether or not getTargetActivityPendingIntent() is null--
when a QuickAccessWalletService sends us a PendingIntent, we will use
that instead of the SystemUI card switcher activity.
If the PendingIntent is null, we then fall back to our old behavior:
* If the wallet is not currently showing any cards, launch the activity
specified by getWalletIntent() (this is hardcoded in XML metadata)
* If the wallet is currently showing cards, launch the SysUI
switcher activity
Test: atest CtsQuickAccessWalletTestCases --retry-any-failure
Test: atest QuickAccessWalletControllerTest
Bug: 218860062
Change-Id: I4cfaa5b6035499c47a0ed8b1a4a5f3e1f0f50860
This commit is contained in:
@@ -1651,7 +1651,6 @@ 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
|
||||
@@ -39235,7 +39234,6 @@ package android.service.quickaccesswallet {
|
||||
public abstract class QuickAccessWalletService extends android.app.Service {
|
||||
ctor public QuickAccessWalletService();
|
||||
method @Nullable public android.app.PendingIntent getTargetActivityPendingIntent();
|
||||
method public final boolean getUseTargetActivityForQuickAccess();
|
||||
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);
|
||||
|
||||
@@ -2402,7 +2402,6 @@ package android.service.quickaccesswallet {
|
||||
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 {
|
||||
|
||||
@@ -240,15 +240,4 @@ 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();
|
||||
}
|
||||
|
||||
@@ -350,11 +350,6 @@ public class QuickAccessWalletClientImpl implements QuickAccessWalletClient, Ser
|
||||
return mServiceInfo == null ? null : mServiceInfo.getShortcutLongLabel(mContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useTargetActivityForQuickAccess() {
|
||||
return mServiceInfo.getUseTargetActivityForQuickAccess();
|
||||
}
|
||||
|
||||
private void connect() {
|
||||
mHandler.post(this::connectInternal);
|
||||
}
|
||||
|
||||
@@ -16,20 +16,12 @@
|
||||
|
||||
package android.service.quickaccesswallet;
|
||||
|
||||
import static android.content.pm.PackageManager.GET_META_DATA;
|
||||
import static android.content.pm.PackageManager.MATCH_DEFAULT_ONLY;
|
||||
import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_AWARE;
|
||||
import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_UNAWARE;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SdkConstant;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
@@ -38,8 +30,6 @@ import android.os.RemoteException;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A {@code QuickAccessWalletService} provides a list of {@code WalletCard}s shown in the Quick
|
||||
* Access Wallet. The Quick Access Wallet allows the user to change their selected payment method
|
||||
@@ -346,50 +336,19 @@ public abstract class QuickAccessWalletService extends Service {
|
||||
mHandler.post(() -> sendWalletServiceEventInternal(serviceEvent));
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a {@link PendingIntent} to be launched as the "Quick Access" activity.
|
||||
*
|
||||
* This activity will be launched directly by the system in lieu of the card switcher activity
|
||||
* provided by the system.
|
||||
*
|
||||
* In order to use the system-provided card switcher activity, return null from this method.
|
||||
*/
|
||||
@Nullable
|
||||
public PendingIntent getTargetActivityPendingIntent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value specified by the attribute
|
||||
* {@link android.R.styleable#QuickAccessWalletService_useTargetActivityForQuickAccess}
|
||||
* in the QuickAccessWalletService's metadata configuration. If the attribute or metadata is
|
||||
* not supplied, returns false.
|
||||
*/
|
||||
public final boolean getUseTargetActivityForQuickAccess() {
|
||||
Intent intent = new Intent(SERVICE_INTERFACE).setPackage(getPackageName());
|
||||
List<ResolveInfo> matchedServices = getPackageManager()
|
||||
.queryIntentServices(intent,
|
||||
PackageManager.ResolveInfoFlags.of(
|
||||
GET_META_DATA | MATCH_DIRECT_BOOT_UNAWARE | MATCH_DIRECT_BOOT_AWARE
|
||||
| MATCH_DEFAULT_ONLY));
|
||||
|
||||
ResolveInfo resolveInfo = null;
|
||||
|
||||
for (ResolveInfo info : matchedServices) {
|
||||
ServiceInfo serviceInfo = info.serviceInfo;
|
||||
if (serviceInfo == null) {
|
||||
continue;
|
||||
}
|
||||
String serviceName = serviceInfo.name;
|
||||
if (serviceName == null) {
|
||||
continue;
|
||||
}
|
||||
if (serviceName.equals(getClass().getCanonicalName())) {
|
||||
resolveInfo = info;
|
||||
}
|
||||
}
|
||||
|
||||
if (resolveInfo == null || resolveInfo.serviceInfo == null) {
|
||||
Log.i(TAG, "Matching QuickAccessWalletService not found.");
|
||||
return false;
|
||||
}
|
||||
QuickAccessWalletServiceInfo.ServiceMetadata serviceMetadata =
|
||||
QuickAccessWalletServiceInfo.parseServiceMetadata(this, resolveInfo.serviceInfo);
|
||||
return serviceMetadata != null && serviceMetadata.mUseTargetActivityForQuickAccess;
|
||||
}
|
||||
|
||||
private void sendWalletServiceEventInternal(WalletServiceEvent serviceEvent) {
|
||||
if (mEventListener == null) {
|
||||
Log.i(TAG, "No dismiss listener registered");
|
||||
|
||||
@@ -144,23 +144,20 @@ class QuickAccessWalletServiceInfo {
|
||||
private final CharSequence mShortcutShortLabel;
|
||||
@Nullable
|
||||
private final CharSequence mShortcutLongLabel;
|
||||
final boolean mUseTargetActivityForQuickAccess;
|
||||
|
||||
private static ServiceMetadata empty() {
|
||||
return new ServiceMetadata(null, null, null, null, false);
|
||||
return new ServiceMetadata(null, null, null, null);
|
||||
}
|
||||
|
||||
private ServiceMetadata(
|
||||
String targetActivity,
|
||||
String settingsActivity,
|
||||
CharSequence shortcutShortLabel,
|
||||
CharSequence shortcutLongLabel,
|
||||
boolean useTargetActivityForQuickAccess) {
|
||||
CharSequence shortcutLongLabel) {
|
||||
mTargetActivity = targetActivity;
|
||||
mSettingsActivity = settingsActivity;
|
||||
mShortcutShortLabel = shortcutShortLabel;
|
||||
mShortcutLongLabel = shortcutLongLabel;
|
||||
mUseTargetActivityForQuickAccess = useTargetActivityForQuickAccess;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,11 +191,8 @@ class QuickAccessWalletServiceInfo {
|
||||
R.styleable.QuickAccessWalletService_shortcutShortLabel);
|
||||
CharSequence shortcutLongLabel = afsAttributes.getText(
|
||||
R.styleable.QuickAccessWalletService_shortcutLongLabel);
|
||||
boolean useTargetActivityForQuickAccess = afsAttributes.getBoolean(
|
||||
R.styleable.QuickAccessWalletService_useTargetActivityForQuickAccess,
|
||||
false);
|
||||
return new ServiceMetadata(targetActivity, settingsActivity, shortcutShortLabel,
|
||||
shortcutLongLabel, useTargetActivityForQuickAccess);
|
||||
shortcutLongLabel);
|
||||
} finally {
|
||||
if (afsAttributes != null) {
|
||||
afsAttributes.recycle();
|
||||
@@ -277,8 +271,4 @@ class QuickAccessWalletServiceInfo {
|
||||
CharSequence getServiceLabel(Context context) {
|
||||
return mServiceInfo.loadLabel(context.getPackageManager());
|
||||
}
|
||||
|
||||
boolean getUseTargetActivityForQuickAccess() {
|
||||
return mServiceMetadata.mUseTargetActivityForQuickAccess;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,27 +211,24 @@ public class QuickAccessWalletController {
|
||||
public void startQuickAccessUiIntent(ActivityStarter activityStarter,
|
||||
ActivityLaunchAnimator.Controller animationController,
|
||||
boolean hasCard) {
|
||||
if (mQuickAccessWalletClient.useTargetActivityForQuickAccess() || !hasCard) {
|
||||
mQuickAccessWalletClient.getWalletPendingIntent(mCallbackExecutor,
|
||||
walletPendingIntent -> {
|
||||
if (walletPendingIntent == null) {
|
||||
Intent intent = mQuickAccessWalletClient.createWalletIntent();
|
||||
if (intent == null) {
|
||||
intent = getSysUiWalletIntent();
|
||||
}
|
||||
startQuickAccessViaIntent(intent, hasCard, activityStarter,
|
||||
animationController);
|
||||
return;
|
||||
}
|
||||
startQuickAccessViaPendingIntent(walletPendingIntent,
|
||||
activityStarter, animationController);
|
||||
});
|
||||
} else {
|
||||
startQuickAccessViaIntent(getSysUiWalletIntent(),
|
||||
hasCard,
|
||||
activityStarter,
|
||||
animationController);
|
||||
}
|
||||
mQuickAccessWalletClient.getWalletPendingIntent(mCallbackExecutor,
|
||||
walletPendingIntent -> {
|
||||
if (walletPendingIntent != null) {
|
||||
startQuickAccessViaPendingIntent(walletPendingIntent, activityStarter,
|
||||
animationController);
|
||||
return;
|
||||
}
|
||||
Intent intent = null;
|
||||
if (!hasCard) {
|
||||
intent = mQuickAccessWalletClient.createWalletIntent();
|
||||
}
|
||||
if (intent == null) {
|
||||
intent = getSysUiWalletIntent();
|
||||
}
|
||||
startQuickAccessViaIntent(intent, hasCard, activityStarter,
|
||||
animationController);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private Intent getSysUiWalletIntent() {
|
||||
|
||||
@@ -198,8 +198,7 @@ public class QuickAccessWalletControllerTest extends SysuiTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getQuickAccessUiIntent_hasCards_useTargetActivityFalse_startsWalletActivity() {
|
||||
when(mQuickAccessWalletClient.useTargetActivityForQuickAccess()).thenReturn(false);
|
||||
public void getQuickAccessUiIntent_hasCards_noPendingIntent_startsWalletActivity() {
|
||||
mController.startQuickAccessUiIntent(mActivityStarter, mAnimationController, true);
|
||||
verify(mActivityStarter).startActivity(mIntentCaptor.capture(), eq(true),
|
||||
any(ActivityLaunchAnimator.Controller.class), eq(true));
|
||||
@@ -211,8 +210,7 @@ public class QuickAccessWalletControllerTest extends SysuiTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getQuickAccessUiIntent_noCards_useTargetActivityFalse_isWalletActivity() {
|
||||
when(mQuickAccessWalletClient.useTargetActivityForQuickAccess()).thenReturn(false);
|
||||
public void getQuickAccessUiIntent_noCards_noPendingIntent_startsWalletActivity() {
|
||||
mController.startQuickAccessUiIntent(mActivityStarter, mAnimationController, false);
|
||||
verify(mActivityStarter).postStartActivityDismissingKeyguard(mIntentCaptor.capture(), eq(0),
|
||||
any(ActivityLaunchAnimator.Controller.class));
|
||||
@@ -236,7 +234,6 @@ public class QuickAccessWalletControllerTest extends SysuiTestCase {
|
||||
PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_IMMUTABLE));
|
||||
return null;
|
||||
}).when(mQuickAccessWalletClient).getWalletPendingIntent(any(), any());
|
||||
when(mQuickAccessWalletClient.useTargetActivityForQuickAccess()).thenReturn(true);
|
||||
mController.startQuickAccessUiIntent(mActivityStarter, mAnimationController, true);
|
||||
verify(mActivityStarter).postStartActivityDismissingKeyguard(mPendingIntentCaptor.capture(),
|
||||
any(ActivityLaunchAnimator.Controller.class));
|
||||
|
||||
Reference in New Issue
Block a user