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

Commit 9760d9a5 authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge "Merge "Revise logging in RemoteCredentialService and...

Merge "Merge "Revise logging in RemoteCredentialService and CredentialProviderInfoFactory" into udc-dev am: d66ed242 am: 6ad778ff"
parents 904bdd41 392a362b
Loading
Loading
Loading
Loading
+17 −20
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ import android.os.RemoteException;
import android.os.UserHandle;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Slog;
import android.util.Xml;

@@ -181,7 +180,8 @@ public final class CredentialProviderInfoFactory {
        if (disableSystemAppVerificationForTests) {
            Bundle metadata = serviceInfo.metaData;
            if (metadata == null) {
                Slog.e(TAG, "isValidSystemProvider - metadata is null: " + serviceInfo);
                Slog.w(TAG, "metadata is null while reading "
                        + "TEST_SYSTEM_PROVIDER_META_DATA_KEY: " + serviceInfo);
                return false;
            }
            return metadata.getBoolean(
@@ -200,7 +200,7 @@ public final class CredentialProviderInfoFactory {
        // 1. Get the metadata for the service.
        final Bundle metadata = serviceInfo.metaData;
        if (metadata == null) {
            Log.i(TAG, "populateMetadata - metadata is null");
            Slog.w(TAG, "Metadata is null for provider: " + serviceInfo.getComponentName());
            return builder;
        }

@@ -209,12 +209,13 @@ public final class CredentialProviderInfoFactory {
        try {
            resources = pm.getResourcesForApplication(serviceInfo.applicationInfo);
        } catch (PackageManager.NameNotFoundException e) {
            Log.e(TAG, "Failed to get app resources", e);
            Slog.e(TAG, "Failed to get app resources", e);
        }

        // 3. Stop if we are missing data.
        if (metadata == null || resources == null) {
            Log.i(TAG, "populateMetadata - resources is null");
        if (resources == null) {
            Slog.w(TAG, "Resources are null for the serviceInfo being processed: "
                    + serviceInfo.getComponentName());
            return builder;
        }

@@ -222,7 +223,7 @@ public final class CredentialProviderInfoFactory {
        try {
            builder = extractXmlMetadata(context, serviceInfo, pm, resources);
        } catch (Exception e) {
            Log.e(TAG, "Failed to get XML metadata", e);
            Slog.e(TAG, "Failed to get XML metadata", e);
        }

        return builder;
@@ -260,7 +261,7 @@ public final class CredentialProviderInfoFactory {
                            afsAttributes.getString(
                                    R.styleable.CredentialProvider_settingsSubtitle));
                } catch (Exception e) {
                    Log.e(TAG, "Failed to get XML attr", e);
                    Slog.e(TAG, "Failed to get XML attr", e);
                } finally {
                    if (afsAttributes != null) {
                        afsAttributes.recycle();
@@ -268,10 +269,10 @@ public final class CredentialProviderInfoFactory {
                }
                builder.addCapabilities(parseXmlProviderOuterCapabilities(parser, resources));
            } else {
                Log.e(TAG, "Meta-data does not start with credential-provider-service tag");
                Slog.w(TAG, "Meta-data does not start with credential-provider-service tag");
            }
        } catch (IOException | XmlPullParserException e) {
            Log.e(TAG, "Error parsing credential provider service meta-data", e);
            Slog.e(TAG, "Error parsing credential provider service meta-data", e);
        }

        return builder;
@@ -330,7 +331,7 @@ public final class CredentialProviderInfoFactory {
                return si;
            }
        } catch (RemoteException e) {
            Slog.v(TAG, e.getMessage());
            Slog.e(TAG, "Unable to get serviceInfo", e);
        }
        throw new PackageManager.NameNotFoundException(serviceComponent.toString());
    }
@@ -378,10 +379,8 @@ public final class CredentialProviderInfoFactory {
                }

                services.add(serviceInfo);
            } catch (SecurityException e) {
                Slog.e(TAG, "Error getting info for " + serviceInfo + ": " + e);
            } catch (PackageManager.NameNotFoundException e) {
                Slog.e(TAG, "Error getting info for " + serviceInfo + ": " + e);
            } catch (SecurityException | PackageManager.NameNotFoundException e) {
                Slog.e(TAG, "Error getting info for " + serviceInfo, e);
            }
        }
        return services;
@@ -433,7 +432,7 @@ public final class CredentialProviderInfoFactory {
            return pp;
        } catch (SecurityException e) {
            // If the current user is not enrolled in DPM then this can throw a security error.
            Log.e(TAG, "Failed to get device policy: " + e);
            Slog.e(TAG, "Failed to get device policy: " + e);
        }

        return null;
@@ -594,7 +593,7 @@ public final class CredentialProviderInfoFactory {
        for (ResolveInfo resolveInfo : resolveInfos) {
            final ServiceInfo serviceInfo = resolveInfo.serviceInfo;
            if (serviceInfo == null) {
                Log.i(TAG, "No serviceInfo found for resolveInfo so skipping this provider");
                Slog.d(TAG, "No serviceInfo found for resolveInfo, so skipping provider");
                continue;
            }

@@ -609,10 +608,8 @@ public final class CredentialProviderInfoFactory {
                if (!cpi.isSystemProvider()) {
                    services.add(cpi);
                }
            } catch (SecurityException e) {
                Slog.e(TAG, "Error getting info for " + serviceInfo + ": " + e);
            } catch (Exception e) {
                Slog.e(TAG, "Error getting info for " + serviceInfo + ": " + e);
                Slog.e(TAG, "Error getting info for " + serviceInfo, e);
            }
        }
        return services;
+1 −1
Original line number Diff line number Diff line
@@ -226,7 +226,7 @@ public abstract class CredentialProviderService extends Service {
        if (SERVICE_INTERFACE.equals(intent.getAction())) {
            return mInterface.asBinder();
        }
        Log.i(TAG, "Failed to bind with intent: " + intent);
        Log.d(TAG, "Failed to bind with intent: " + intent);
        return null;
    }

+0 −4
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ import android.os.IBinder;
import android.os.Looper;
import android.os.ResultReceiver;
import android.service.credentials.CredentialProviderInfoFactory;
import android.util.Log;
import android.util.Slog;

import java.util.ArrayList;
@@ -124,7 +123,6 @@ public class CredentialManagerUi {

    public CredentialManagerUi(Context context, int userId,
            CredentialManagerUiCallback callbacks, Set<ComponentName> enabledProviders) {
        Log.i(TAG, "In CredentialManagerUi constructor");
        mContext = context;
        mUserId = userId;
        mCallbacks = callbacks;
@@ -151,8 +149,6 @@ public class CredentialManagerUi {
     */
    public PendingIntent createPendingIntent(
            RequestInfo requestInfo, ArrayList<ProviderData> providerDataList) {
        Log.i(TAG, "In createPendingIntent");

        List<CredentialProviderInfo> allProviders =
                CredentialProviderInfoFactory.getCredentialProviderServices(
                        mContext,
+2 −19
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ import android.service.credentials.IBeginGetCredentialCallback;
import android.service.credentials.IClearCredentialStateCallback;
import android.service.credentials.ICredentialProviderService;
import android.text.format.DateUtils;
import android.util.Log;
import android.util.Slog;

import com.android.internal.infra.ServiceConnector;
@@ -122,7 +121,6 @@ public class RemoteCredentialService extends ServiceConnector.Impl<ICredentialPr
     */
    public void onBeginGetCredential(@NonNull BeginGetCredentialRequest request,
            ProviderCallbacks<BeginGetCredentialResponse> callback) {
        Log.i(TAG, "In onGetCredentials in RemoteCredentialService");
        AtomicReference<ICancellationSignal> cancellationSink = new AtomicReference<>();
        AtomicReference<CompletableFuture<BeginGetCredentialResponse>> futureRef =
                new AtomicReference<>();
@@ -142,7 +140,6 @@ public class RemoteCredentialService extends ServiceConnector.Impl<ICredentialPr

                            @Override
                            public void onFailure(String errorType, CharSequence message) {
                                Log.i(TAG, "In onFailure in RemoteCredentialService");
                                String errorMsg = message == null ? "" : String.valueOf(
                                        message);
                                getCredentials.completeExceptionally(
@@ -182,7 +179,6 @@ public class RemoteCredentialService extends ServiceConnector.Impl<ICredentialPr
     */
    public void onBeginCreateCredential(@NonNull BeginCreateCredentialRequest request,
            ProviderCallbacks<BeginCreateCredentialResponse> callback) {
        Log.i(TAG, "In onCreateCredential in RemoteCredentialService");
        AtomicReference<ICancellationSignal> cancellationSink = new AtomicReference<>();
        AtomicReference<CompletableFuture<BeginCreateCredentialResponse>> futureRef =
                new AtomicReference<>();
@@ -197,14 +193,11 @@ public class RemoteCredentialService extends ServiceConnector.Impl<ICredentialPr
                                request, new IBeginCreateCredentialCallback.Stub() {
                                    @Override
                                    public void onSuccess(BeginCreateCredentialResponse response) {
                                        Log.i(TAG, "In onSuccess onBeginCreateCredential "
                                                + "in RemoteCredentialService");
                                        createCredentialFuture.complete(response);
                                    }

                                    @Override
                                    public void onFailure(String errorType, CharSequence message) {
                                        Log.i(TAG, "In onFailure in RemoteCredentialService");
                                        String errorMsg = message == null ? "" : String.valueOf(
                                                message);
                                        createCredentialFuture.completeExceptionally(
@@ -244,7 +237,6 @@ public class RemoteCredentialService extends ServiceConnector.Impl<ICredentialPr
     */
    public void onClearCredentialState(@NonNull ClearCredentialStateRequest request,
            ProviderCallbacks<Void> callback) {
        Log.i(TAG, "In onClearCredentialState in RemoteCredentialService");
        AtomicReference<ICancellationSignal> cancellationSink = new AtomicReference<>();
        AtomicReference<CompletableFuture<Void>> futureRef = new AtomicReference<>();

@@ -258,14 +250,11 @@ public class RemoteCredentialService extends ServiceConnector.Impl<ICredentialPr
                                request, new IClearCredentialStateCallback.Stub() {
                                    @Override
                                    public void onSuccess() {
                                        Log.i(TAG, "In onSuccess onClearCredentialState "
                                                + "in RemoteCredentialService");
                                        clearCredentialFuture.complete(null);
                                    }

                                    @Override
                                    public void onFailure(String errorType, CharSequence message) {
                                        Log.i(TAG, "In onFailure in RemoteCredentialService");
                                        String errorMsg = message == null ? "" :
                                                String.valueOf(message);
                                        clearCredentialFuture.completeExceptionally(
@@ -300,35 +289,29 @@ public class RemoteCredentialService extends ServiceConnector.Impl<ICredentialPr
            AtomicReference<ICancellationSignal> cancellationSink,
            ProviderCallbacks<T> callback) {
        if (error == null) {
            Log.i(TAG, "In RemoteCredentialService execute error is null");
            callback.onProviderResponseSuccess(result);
        } else {
            if (error instanceof TimeoutException) {
                Log.i(TAG, "In RemoteCredentialService execute error is timeout");
                Slog.d(TAG, "Remote provider response timed tuo for: " + mComponentName);
                dispatchCancellationSignal(cancellationSink.get());
                callback.onProviderResponseFailure(
                        CredentialProviderErrors.ERROR_TIMEOUT,
                        null);
            } else if (error instanceof CancellationException) {
                Log.i(TAG, "In RemoteCredentialService execute error is cancellation");
                Slog.d(TAG, "Cancellation exception for remote provider: " + mComponentName);
                dispatchCancellationSignal(cancellationSink.get());
                callback.onProviderResponseFailure(
                        CredentialProviderErrors.ERROR_TASK_CANCELED,
                        null);
            } else if (error instanceof GetCredentialException) {
                Log.i(TAG, "In RemoteCredentialService execute error is provider get"
                        + "error");
                callback.onProviderResponseFailure(
                        CredentialProviderErrors.ERROR_PROVIDER_FAILURE,
                        (GetCredentialException) error);
            } else if (error instanceof CreateCredentialException) {
                Log.i(TAG, "In RemoteCredentialService execute error is provider create "
                        + "error");
                callback.onProviderResponseFailure(
                        CredentialProviderErrors.ERROR_PROVIDER_FAILURE,
                        (CreateCredentialException) error);
            } else {
                Log.i(TAG, "In RemoteCredentialService execute error is unknown");
                callback.onProviderResponseFailure(
                        CredentialProviderErrors.ERROR_UNKNOWN,
                        (Exception) error);