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

Commit 585ab749 authored by Adam He's avatar Adam He Committed by Android (Google) Code Review
Browse files

Merge "Use AFM.getAutofillServiceComponentName() in Settings's AutofillPickerTrampolineActivity"

parents 8e688318 a8192e1c
Loading
Loading
Loading
Loading
+14 −14
Original line number Diff line number Diff line
@@ -14,9 +14,9 @@
package com.android.settings.applications.autofill;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.os.UserHandle;
import android.view.autofill.AutofillManager;

import com.android.settings.applications.defaultapps.DefaultAutofillPicker;
@@ -34,20 +34,9 @@ public class AutofillPickerTrampolineActivity extends Activity {
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // First check if the current user's service already belongs to the app...
        final Intent intent = getIntent();
        final String packageName = intent.getData().getSchemeSpecificPart();
        final String currentService = DefaultAutofillPicker.getDefaultKey(
                this, UserHandle.myUserId());
        if (currentService != null && currentService.startsWith(packageName)) {
            // ...and succeed right away if it does.
            setResult(RESULT_OK);
            finish();
            return;
        }

        // Then check if the Autofill is available for the current user...
        final AutofillManager afm = getSystemService(AutofillManager.class);

        // First check if the Autofill is available for the current user...
        if (afm == null || !afm.hasAutofillFeature() || !afm.isAutofillSupported()) {
            // ... and fail right away if it is not.
            setResult(RESULT_CANCELED);
@@ -55,6 +44,17 @@ public class AutofillPickerTrampolineActivity extends Activity {
            return;
        }

        // Then check if the current user's service already belongs to the app...
        final Intent intent = getIntent();
        final String packageName = intent.getData().getSchemeSpecificPart();
        final ComponentName currentService = afm.getAutofillServiceComponentName();
        if (currentService != null && currentService.getPackageName().equals(packageName)) {
            // ...and succeed right away if it does.
            setResult(RESULT_OK);
            finish();
            return;
        }

        // Otherwise, go ahead and show the real UI...
        final Intent newIntent = new Intent(this, AutofillPickerActivity.class)
                .setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT)