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

Commit df61b513 authored by Helen Qin's avatar Helen Qin Committed by Android (Google) Code Review
Browse files

Merge "Update CredentialManager UI configuration." into main

parents 7ee5bc29 df7c0ee4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1366,7 +1366,7 @@ package android.credentials.selection {
  }

  @FlaggedApi("android.credentials.flags.configurable_selector_ui_enabled") public class IntentFactory {
    method @NonNull public static android.content.Intent createCancelUiIntent(@NonNull android.os.IBinder, boolean, @NonNull String);
    method @NonNull public static android.content.Intent createCancelUiIntent(@NonNull android.content.Context, @NonNull android.os.IBinder, boolean, @NonNull String);
    method @NonNull public static android.content.Intent createCredentialSelectorIntent(@NonNull android.content.Context, @NonNull android.credentials.selection.RequestInfo, @NonNull java.util.ArrayList<android.credentials.selection.ProviderData>, @NonNull java.util.ArrayList<android.credentials.selection.DisabledProviderData>, @NonNull android.os.ResultReceiver);
  }

+52 −54
Original line number Diff line number Diff line
@@ -80,17 +80,7 @@ public class IntentFactory {
            ArrayList<DisabledProviderData> disabledProviderDataList,
            @NonNull ResultReceiver resultReceiver) {
        Intent intent = new Intent();
        ComponentName componentName =
                ComponentName.unflattenFromString(
                        Resources.getSystem()
                                .getString(
                                        com.android.internal.R.string
                                                .config_credentialManagerDialogComponent));
        ComponentName oemOverrideComponentName = getOemOverrideComponentName(context);
        if (oemOverrideComponentName != null) {
            componentName = oemOverrideComponentName;
        }
        intent.setComponent(componentName);
        setCredentialSelectorUiComponentName(context, intent);
        intent.putParcelableArrayListExtra(
                ProviderData.EXTRA_DISABLED_PROVIDER_DATA_LIST, disabledProviderDataList);
        intent.putExtra(RequestInfo.EXTRA_REQUEST_INFO, requestInfo);
@@ -100,6 +90,24 @@ public class IntentFactory {
        return intent;
    }

    private static void setCredentialSelectorUiComponentName(@NonNull Context context,
            @NonNull Intent intent) {
        if (configurableSelectorUiEnabled()) {
            ComponentName componentName = getOemOverrideComponentName(context);
            if (componentName == null) {
                componentName = ComponentName.unflattenFromString(Resources.getSystem().getString(
                        com.android.internal.R.string
                                .config_fallbackCredentialManagerDialogComponent));
            }
            intent.setComponent(componentName);
        } else {
            ComponentName componentName = ComponentName.unflattenFromString(Resources.getSystem()
                    .getString(com.android.internal.R.string
                            .config_fallbackCredentialManagerDialogComponent));
            intent.setComponent(componentName);
        }
    }

    /**
     * Returns null if there is not an enabled and valid oem override component. It means the
     * default platform UI component name should be used instead.
@@ -107,9 +115,6 @@ public class IntentFactory {
    @Nullable
    private static ComponentName getOemOverrideComponentName(@NonNull Context context) {
        ComponentName result = null;
        if (configurableSelectorUiEnabled()) {
            if (Resources.getSystem().getBoolean(
                    com.android.internal.R.bool.config_enableOemCredentialManagerDialogComponent)) {
        String oemComponentString =
                Resources.getSystem()
                        .getString(
@@ -144,8 +149,6 @@ public class IntentFactory {
        } else {
            Slog.i(TAG, "Invalid empty OEM component name.");
        }
            }
        }
        return result;
    }

@@ -186,16 +189,11 @@ public class IntentFactory {
     * Creates an Intent that cancels any UI matching the given request token id.
     */
    @NonNull
    public static Intent createCancelUiIntent(@NonNull IBinder requestToken,
            boolean shouldShowCancellationUi, @NonNull String appPackageName) {
    public static Intent createCancelUiIntent(@NonNull Context context,
            @NonNull IBinder requestToken, boolean shouldShowCancellationUi,
            @NonNull String appPackageName) {
        Intent intent = new Intent();
        ComponentName componentName =
                ComponentName.unflattenFromString(
                        Resources.getSystem()
                                .getString(
                                        com.android.internal.R.string
                                                .config_credentialManagerDialogComponent));
        intent.setComponent(componentName);
        setCredentialSelectorUiComponentName(context, intent);
        intent.putExtra(CancelSelectionRequest.EXTRA_CANCEL_UI_REQUEST,
                new CancelSelectionRequest(new RequestToken(requestToken), shouldShowCancellationUi,
                        appPackageName));
+13 −16
Original line number Diff line number Diff line
@@ -3348,26 +3348,23 @@
    <string name="config_carrierAppInstallDialogComponent" translatable="false"
            >com.android.simappdialog/com.android.simappdialog.InstallCarrierAppActivity</string>

    <!-- Name of the default framework dialog that is used to get or save an app credential.
    <!-- Name of the fallback CredentialManager dialog that is used to get or save an app
     credential.

    This UI should be always launch-able and is used as a fallback when an oem replacement activity
    (defined at config_oemCredentialManagerDialogComponent) is undefined / not found. -->
    <string name="config_credentialManagerDialogComponent" translatable="false"
            >com.android.credentialmanager/com.android.credentialmanager.CredentialSelectorActivity</string>
    <!-- Whether to allow the credential selector activity to be replaced by an activity at
     run-time (restricted to the privileged activity specified by
     config_credentialSelectorActivityName).
     If empty, no fallback will be used. IMPORTANT: In that case the OEM dialog value specified in
     config_oemCredentialManagerDialogComponent must always launch-able. Otherwise, the
     CredentialManager API contract is broken.

     When disabled, the fallback activity defined at
     config_credentialManagerDialogComponent will be used instead. -->
    <bool name="config_enableOemCredentialManagerDialogComponent" translatable="false">true</bool>
     If specified, this UI should be always launch-able. It will be used as a fallback when the OEM
     dialog value specified in config_oemCredentialManagerDialogComponent) is undefined / not
     found. -->
    <string name="config_fallbackCredentialManagerDialogComponent" translatable="false"
            >com.android.credentialmanager/com.android.credentialmanager.CredentialSelectorActivity</string>
    <!-- Fully qualified activity name providing the credential selector UI, that serves the
     CredentialManager APIs.

     Used only when config_enableOemCredentialManagerDialogComponent is true.
     CredentialManager APIs. Must be a system app component.

     If the activity specified cannot be found or launched, then the fallback activity defined at
     config_credentialManagerDialogComponent will be used instead. -->
     If empty, or if this activity specified cannot be found or launched, then the fallback activity
     defined at config_fallbackCredentialManagerDialogComponent will be used instead. -->
    <string name="config_oemCredentialManagerDialogComponent" translatable="false"></string>

    <!-- Name of the broadcast receiver that is used to receive provider change events -->
+1 −2
Original line number Diff line number Diff line
@@ -2297,8 +2297,7 @@
  <java-symbol type="string" name="config_customVpnAlwaysOnDisconnectedDialogComponent" />
  <java-symbol type="string" name="config_platformVpnConfirmDialogComponent" />
  <java-symbol type="string" name="config_carrierAppInstallDialogComponent" />
  <java-symbol type="string" name="config_credentialManagerDialogComponent" />
  <java-symbol type="bool" name="config_enableOemCredentialManagerDialogComponent" />
  <java-symbol type="string" name="config_fallbackCredentialManagerDialogComponent" />
  <java-symbol type="string" name="config_oemCredentialManagerDialogComponent" />
  <java-symbol type="string" name="config_credentialManagerReceiverComponent" />
  <java-symbol type="string" name="config_defaultNetworkScorerPackageName" />
+2 −2
Original line number Diff line number Diff line
@@ -113,8 +113,8 @@ public class CredentialManagerUi {

    /** Creates intent that is ot be invoked to cancel an in-progress UI session. */
    public Intent createCancelIntent(IBinder requestId, String packageName) {
        return IntentFactory.createCancelUiIntent(requestId, /*shouldShowCancellationUi=*/ true,
                packageName);
        return IntentFactory.createCancelUiIntent(mContext, requestId,
                /*shouldShowCancellationUi=*/ true, packageName);
    }

    /**