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

Commit e9890579 authored by Joy Babafemi's avatar Joy Babafemi Committed by Android (Google) Code Review
Browse files

Merge "Get activity info for oem enabled component from the current user context" into main

parents 095e4bd2 b910ec4f
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1402,9 +1402,9 @@ package android.credentials.selection {
    method @NonNull public android.credentials.selection.GetCredentialProviderData.Builder setRemoteEntry(@Nullable android.credentials.selection.Entry);
  }

  @FlaggedApi("android.credentials.flags.configurable_selector_ui_enabled") public class IntentFactory {
    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);
  @FlaggedApi("android.credentials.flags.propagate_user_context_for_intent_creation") public class IntentFactory {
    method @NonNull public static android.content.Intent createCancelUiIntent(@NonNull android.content.Context, @NonNull android.os.IBinder, boolean, @NonNull String, int);
    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, int);
  }

  @FlaggedApi("android.credentials.flags.configurable_selector_ui_enabled") public abstract class ProviderData implements android.os.Parcelable {
+52 −36
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package android.credentials.selection;

import static android.credentials.flags.Flags.FLAG_CONFIGURABLE_SELECTOR_UI_ENABLED;
import static android.credentials.flags.Flags.FLAG_PROPAGATE_USER_CONTEXT_FOR_INTENT_CREATION;
import static android.credentials.flags.Flags.configurableSelectorUiEnabled;

import android.annotation.FlaggedApi;
@@ -24,6 +24,8 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SuppressLint;
import android.annotation.TestApi;
import android.annotation.UserIdInt;
import android.app.AppGlobals;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -32,6 +34,7 @@ import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.IBinder;
import android.os.Parcel;
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.text.TextUtils;
import android.util.Slog;
@@ -46,7 +49,7 @@ import java.util.ArrayList;
 * @hide
 */
@TestApi
@FlaggedApi(FLAG_CONFIGURABLE_SELECTOR_UI_ENABLED)
@FlaggedApi(FLAG_PROPAGATE_USER_CONTEXT_FOR_INTENT_CREATION)
public class IntentFactory {

    /**
@@ -65,9 +68,10 @@ public class IntentFactory {
            @SuppressLint("ConcreteCollection") // Concrete collection needed for marshalling.
            @NonNull
            ArrayList<DisabledProviderData> disabledProviderDataList,
            @NonNull ResultReceiver resultReceiver) {
            @NonNull ResultReceiver resultReceiver,
            @UserIdInt int userId) {
        return createCredentialSelectorIntentInternal(context, requestInfo,
                disabledProviderDataList, resultReceiver);
                disabledProviderDataList, resultReceiver, userId);
    }

    /**
@@ -96,9 +100,10 @@ public class IntentFactory {
            @SuppressLint("ConcreteCollection") // Concrete collection needed for marshalling.
            @NonNull
            ArrayList<DisabledProviderData> disabledProviderDataList,
            @NonNull ResultReceiver resultReceiver) {
            @NonNull ResultReceiver resultReceiver,
            @UserIdInt int userId) {
        IntentCreationResult result = createCredentialSelectorIntentInternal(context, requestInfo,
                disabledProviderDataList, resultReceiver);
                disabledProviderDataList, resultReceiver, userId);
        result.getIntent().putParcelableArrayListExtra(
                ProviderData.EXTRA_ENABLED_PROVIDER_DATA_LIST, enabledProviderDataList);
        return result;
@@ -130,9 +135,10 @@ public class IntentFactory {
            @SuppressLint("ConcreteCollection") // Concrete collection needed for marshalling.
            @NonNull
            ArrayList<DisabledProviderData> disabledProviderDataList,
            @NonNull ResultReceiver resultReceiver) {
            @NonNull ResultReceiver resultReceiver, @UserIdInt int userId) {
        return createCredentialSelectorIntentForCredMan(context, requestInfo,
                enabledProviderDataList, disabledProviderDataList, resultReceiver).getIntent();
            enabledProviderDataList, disabledProviderDataList, resultReceiver,
            userId).getIntent();
    }

    /**
@@ -142,10 +148,10 @@ public class IntentFactory {
    @NonNull
    public static Intent createCancelUiIntent(@NonNull Context context,
            @NonNull IBinder requestToken, boolean shouldShowCancellationUi,
            @NonNull String appPackageName) {
            @NonNull String appPackageName, @UserIdInt int userId) {
        Intent intent = new Intent();
        IntentCreationResult.Builder intentResultBuilder = new IntentCreationResult.Builder(intent);
        setCredentialSelectorUiComponentName(context, intent, intentResultBuilder);
        setCredentialSelectorUiComponentName(context, intent, intentResultBuilder, userId);
        intent.putExtra(CancelSelectionRequest.EXTRA_CANCEL_UI_REQUEST,
                new CancelSelectionRequest(new RequestToken(requestToken), shouldShowCancellationUi,
                        appPackageName));
@@ -162,10 +168,10 @@ public class IntentFactory {
            @SuppressLint("ConcreteCollection") // Concrete collection needed for marshalling.
            @NonNull
            ArrayList<DisabledProviderData> disabledProviderDataList,
            @NonNull ResultReceiver resultReceiver) {
            @NonNull ResultReceiver resultReceiver, @UserIdInt int userId) {
        Intent intent = new Intent();
        IntentCreationResult.Builder intentResultBuilder = new IntentCreationResult.Builder(intent);
        setCredentialSelectorUiComponentName(context, intent, intentResultBuilder);
        setCredentialSelectorUiComponentName(context, intent, intentResultBuilder, userId);
        intent.putParcelableArrayListExtra(
                ProviderData.EXTRA_DISABLED_PROVIDER_DATA_LIST, disabledProviderDataList);
        intent.putExtra(RequestInfo.EXTRA_REQUEST_INFO, requestInfo);
@@ -175,9 +181,11 @@ public class IntentFactory {
    }

    private static void setCredentialSelectorUiComponentName(@NonNull Context context,
            @NonNull Intent intent, @NonNull IntentCreationResult.Builder intentResultBuilder) {
            @NonNull Intent intent, @NonNull IntentCreationResult.Builder intentResultBuilder,
            @UserIdInt int userId) {
        if (configurableSelectorUiEnabled()) {
            ComponentName componentName = getOemOverrideComponentName(context, intentResultBuilder);
            ComponentName componentName = getOemOverrideComponentName(context,
                    intentResultBuilder, userId);

            ComponentName fallbackUiComponentName = null;
            try {
@@ -210,7 +218,7 @@ public class IntentFactory {
     */
    @Nullable
    private static ComponentName getOemOverrideComponentName(@NonNull Context context,
            @NonNull IntentCreationResult.Builder intentResultBuilder) {
            @NonNull IntentCreationResult.Builder intentResultBuilder, @UserIdInt int userId) {
        ComponentName result = null;
        String oemComponentString =
                Resources.getSystem()
@@ -228,11 +236,18 @@ public class IntentFactory {
            if (oemComponentName != null) {
                try {
                    intentResultBuilder.setOemUiPackageName(oemComponentName.getPackageName());
                    ActivityInfo info = context.getPackageManager().getActivityInfo(
                            oemComponentName,
                    ActivityInfo info;
                    if (android.credentials.flags.Flags.propagateUserContextForIntentCreation()) {
                      info = context.getPackageManager().getActivityInfo(oemComponentName,
                          PackageManager.ComponentInfoFlags.of(
                              PackageManager.MATCH_SYSTEM_ONLY));
                    boolean oemComponentEnabled = info.enabled;
                    } else {
                      info = AppGlobals.getPackageManager().getActivityInfo(
                          oemComponentName, 0, userId);
                    }
                    boolean oemComponentEnabled = false;
                    if (info != null) {
                      oemComponentEnabled = info.enabled;
                      int runtimeComponentEnabledState = context.getPackageManager()
                          .getComponentEnabledSetting(oemComponentName);
                      if (runtimeComponentEnabledState == PackageManager
@@ -256,7 +271,8 @@ public class IntentFactory {
                                  "Found enabled oem CredMan UI component but it was not "
                                      + "enabled.");
                      }
                } catch (PackageManager.NameNotFoundException e) {
                    }
                } catch (RemoteException | PackageManager.NameNotFoundException e) {
                    intentResultBuilder.setOemUiUsageStatus(IntentCreationResult.OemUiUsageStatus
                            .OEM_UI_CONFIG_SPECIFIED_BUT_NOT_FOUND);
                    Slog.i(TAG, "Unable to find oem CredMan UI component: "
+3 −3
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ 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(mContext, requestId,
                /*shouldShowCancellationUi=*/ true, packageName);
                /*shouldShowCancellationUi=*/ true, packageName, mUserId);
    }

    /**
@@ -177,7 +177,7 @@ public class CredentialManagerUi {

        IntentCreationResult intentCreationResult = IntentFactory
                .createCredentialSelectorIntentForCredMan(mContext, requestInfo, providerDataList,
                        new ArrayList<>(disabledProviderDataList), mResultReceiver);
                        new ArrayList<>(disabledProviderDataList), mResultReceiver, mUserId);
        requestSessionMetric.collectUiConfigurationResults(
                mContext, intentCreationResult, mUserId);
        Intent intent = intentCreationResult.getIntent();
@@ -211,7 +211,7 @@ public class CredentialManagerUi {
            RequestSessionMetric requestSessionMetric) {
        IntentCreationResult intentCreationResult = IntentFactory
                .createCredentialSelectorIntentForAutofill(mContext, requestInfo, new ArrayList<>(),
                        mResultReceiver);
                        mResultReceiver, mUserId);
        requestSessionMetric.collectUiConfigurationResults(
                mContext, intentCreationResult, mUserId);
        return intentCreationResult.getIntent();