Merge "Delete attribute useTargetActivityForQuickAccess." into tm-dev

This commit is contained in:
Simran Basi
2022-03-31 18:26:52 +00:00
committed by Android (Google) Code Review
8 changed files with 31 additions and 57 deletions

View File

@@ -1651,7 +1651,6 @@ package android {
field public static final int useEmbeddedDex = 16844190; // 0x101059e field public static final int useEmbeddedDex = 16844190; // 0x101059e
field public static final int useIntrinsicSizeAsMinimum = 16843536; // 0x1010310 field public static final int useIntrinsicSizeAsMinimum = 16843536; // 0x1010310
field public static final int useLevel = 16843167; // 0x101019f 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 userVisible = 16843409; // 0x1010291
field public static final int usesCleartextTraffic = 16844012; // 0x10104ec field public static final int usesCleartextTraffic = 16844012; // 0x10104ec
field public static final int usesPermissionFlags = 16844356; // 0x1010644 field public static final int usesPermissionFlags = 16844356; // 0x1010644

View File

@@ -2404,7 +2404,6 @@ package android.service.quickaccesswallet {
method public void notifyWalletDismissed(); method public void notifyWalletDismissed();
method public void removeWalletServiceEventListener(@NonNull android.service.quickaccesswallet.QuickAccessWalletClient.WalletServiceEventListener); method public void removeWalletServiceEventListener(@NonNull android.service.quickaccesswallet.QuickAccessWalletClient.WalletServiceEventListener);
method public void selectWalletCard(@NonNull android.service.quickaccesswallet.SelectWalletCardRequest); method public void selectWalletCard(@NonNull android.service.quickaccesswallet.SelectWalletCardRequest);
method public boolean useTargetActivityForQuickAccess();
} }
public static interface QuickAccessWalletClient.OnWalletCardsRetrievedCallback { public static interface QuickAccessWalletClient.OnWalletCardsRetrievedCallback {

View File

@@ -240,15 +240,4 @@ public interface QuickAccessWalletClient extends Closeable {
*/ */
@Nullable @Nullable
CharSequence getShortcutLongLabel(); 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();
} }

View File

@@ -350,11 +350,6 @@ public class QuickAccessWalletClientImpl implements QuickAccessWalletClient, Ser
return mServiceInfo == null ? null : mServiceInfo.getShortcutLongLabel(mContext); return mServiceInfo == null ? null : mServiceInfo.getShortcutLongLabel(mContext);
} }
@Override
public boolean useTargetActivityForQuickAccess() {
return mServiceInfo.getUseTargetActivityForQuickAccess();
}
private void connect() { private void connect() {
mHandler.post(this::connectInternal); mHandler.post(this::connectInternal);
} }

View File

@@ -336,6 +336,14 @@ public abstract class QuickAccessWalletService extends Service {
mHandler.post(() -> sendWalletServiceEventInternal(serviceEvent)); 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 @Nullable
public PendingIntent getTargetActivityPendingIntent() { public PendingIntent getTargetActivityPendingIntent() {
return null; return null;

View File

@@ -144,23 +144,20 @@ class QuickAccessWalletServiceInfo {
private final CharSequence mShortcutShortLabel; private final CharSequence mShortcutShortLabel;
@Nullable @Nullable
private final CharSequence mShortcutLongLabel; private final CharSequence mShortcutLongLabel;
private final boolean mUseTargetActivityForQuickAccess;
private static ServiceMetadata empty() { private static ServiceMetadata empty() {
return new ServiceMetadata(null, null, null, null, false); return new ServiceMetadata(null, null, null, null);
} }
private ServiceMetadata( private ServiceMetadata(
String targetActivity, String targetActivity,
String settingsActivity, String settingsActivity,
CharSequence shortcutShortLabel, CharSequence shortcutShortLabel,
CharSequence shortcutLongLabel, CharSequence shortcutLongLabel) {
boolean useTargetActivityForQuickAccess) {
mTargetActivity = targetActivity; mTargetActivity = targetActivity;
mSettingsActivity = settingsActivity; mSettingsActivity = settingsActivity;
mShortcutShortLabel = shortcutShortLabel; mShortcutShortLabel = shortcutShortLabel;
mShortcutLongLabel = shortcutLongLabel; mShortcutLongLabel = shortcutLongLabel;
mUseTargetActivityForQuickAccess = useTargetActivityForQuickAccess;
} }
} }
@@ -194,11 +191,8 @@ class QuickAccessWalletServiceInfo {
R.styleable.QuickAccessWalletService_shortcutShortLabel); R.styleable.QuickAccessWalletService_shortcutShortLabel);
CharSequence shortcutLongLabel = afsAttributes.getText( CharSequence shortcutLongLabel = afsAttributes.getText(
R.styleable.QuickAccessWalletService_shortcutLongLabel); R.styleable.QuickAccessWalletService_shortcutLongLabel);
boolean useTargetActivityForQuickAccess = afsAttributes.getBoolean(
R.styleable.QuickAccessWalletService_useTargetActivityForQuickAccess,
false);
return new ServiceMetadata(targetActivity, settingsActivity, shortcutShortLabel, return new ServiceMetadata(targetActivity, settingsActivity, shortcutShortLabel,
shortcutLongLabel, useTargetActivityForQuickAccess); shortcutLongLabel);
} finally { } finally {
if (afsAttributes != null) { if (afsAttributes != null) {
afsAttributes.recycle(); afsAttributes.recycle();
@@ -277,8 +271,4 @@ class QuickAccessWalletServiceInfo {
CharSequence getServiceLabel(Context context) { CharSequence getServiceLabel(Context context) {
return mServiceInfo.loadLabel(context.getPackageManager()); return mServiceInfo.loadLabel(context.getPackageManager());
} }
boolean getUseTargetActivityForQuickAccess() {
return mServiceMetadata.mUseTargetActivityForQuickAccess;
}
} }

View File

@@ -211,27 +211,24 @@ public class QuickAccessWalletController {
public void startQuickAccessUiIntent(ActivityStarter activityStarter, public void startQuickAccessUiIntent(ActivityStarter activityStarter,
ActivityLaunchAnimator.Controller animationController, ActivityLaunchAnimator.Controller animationController,
boolean hasCard) { boolean hasCard) {
if (mQuickAccessWalletClient.useTargetActivityForQuickAccess() || !hasCard) { mQuickAccessWalletClient.getWalletPendingIntent(mCallbackExecutor,
mQuickAccessWalletClient.getWalletPendingIntent(mCallbackExecutor, walletPendingIntent -> {
walletPendingIntent -> { if (walletPendingIntent != null) {
if (walletPendingIntent == null) { startQuickAccessViaPendingIntent(walletPendingIntent, activityStarter,
Intent intent = mQuickAccessWalletClient.createWalletIntent(); animationController);
if (intent == null) { return;
intent = getSysUiWalletIntent(); }
} Intent intent = null;
startQuickAccessViaIntent(intent, hasCard, activityStarter, if (!hasCard) {
animationController); intent = mQuickAccessWalletClient.createWalletIntent();
return; }
} if (intent == null) {
startQuickAccessViaPendingIntent(walletPendingIntent, intent = getSysUiWalletIntent();
activityStarter, animationController); }
}); startQuickAccessViaIntent(intent, hasCard, activityStarter,
} else { animationController);
startQuickAccessViaIntent(getSysUiWalletIntent(),
hasCard, });
activityStarter,
animationController);
}
} }
private Intent getSysUiWalletIntent() { private Intent getSysUiWalletIntent() {

View File

@@ -198,8 +198,7 @@ public class QuickAccessWalletControllerTest extends SysuiTestCase {
} }
@Test @Test
public void getQuickAccessUiIntent_hasCards_useTargetActivityFalse_startsWalletActivity() { public void getQuickAccessUiIntent_hasCards_noPendingIntent_startsWalletActivity() {
when(mQuickAccessWalletClient.useTargetActivityForQuickAccess()).thenReturn(false);
mController.startQuickAccessUiIntent(mActivityStarter, mAnimationController, true); mController.startQuickAccessUiIntent(mActivityStarter, mAnimationController, true);
verify(mActivityStarter).startActivity(mIntentCaptor.capture(), eq(true), verify(mActivityStarter).startActivity(mIntentCaptor.capture(), eq(true),
any(ActivityLaunchAnimator.Controller.class), eq(true)); any(ActivityLaunchAnimator.Controller.class), eq(true));
@@ -211,8 +210,7 @@ public class QuickAccessWalletControllerTest extends SysuiTestCase {
} }
@Test @Test
public void getQuickAccessUiIntent_noCards_useTargetActivityFalse_isWalletActivity() { public void getQuickAccessUiIntent_noCards_noPendingIntent_startsWalletActivity() {
when(mQuickAccessWalletClient.useTargetActivityForQuickAccess()).thenReturn(false);
mController.startQuickAccessUiIntent(mActivityStarter, mAnimationController, false); mController.startQuickAccessUiIntent(mActivityStarter, mAnimationController, false);
verify(mActivityStarter).postStartActivityDismissingKeyguard(mIntentCaptor.capture(), eq(0), verify(mActivityStarter).postStartActivityDismissingKeyguard(mIntentCaptor.capture(), eq(0),
any(ActivityLaunchAnimator.Controller.class)); any(ActivityLaunchAnimator.Controller.class));
@@ -236,7 +234,6 @@ public class QuickAccessWalletControllerTest extends SysuiTestCase {
PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_IMMUTABLE)); PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_IMMUTABLE));
return null; return null;
}).when(mQuickAccessWalletClient).getWalletPendingIntent(any(), any()); }).when(mQuickAccessWalletClient).getWalletPendingIntent(any(), any());
when(mQuickAccessWalletClient.useTargetActivityForQuickAccess()).thenReturn(true);
mController.startQuickAccessUiIntent(mActivityStarter, mAnimationController, true); mController.startQuickAccessUiIntent(mActivityStarter, mAnimationController, true);
verify(mActivityStarter).postStartActivityDismissingKeyguard(mPendingIntentCaptor.capture(), verify(mActivityStarter).postStartActivityDismissingKeyguard(mPendingIntentCaptor.capture(),
any(ActivityLaunchAnimator.Controller.class)); any(ActivityLaunchAnimator.Controller.class));