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

Commit a8d80316 authored by Reema Bajwa's avatar Reema Bajwa
Browse files

Set up credman autofill service

This change also hides the service from Autofill Settings

Test: Built & deployed locally
Bug: 299320247
Bug: 299321634

Change-Id: I49cd1451757ba1ff27bb45202035ab4783943f08
parent 12e78a35
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -63,6 +63,10 @@ public final class AutofillServiceInfo {
    private static final String TAG_AUTOFILL_SERVICE = "autofill-service";
    private static final String TAG_COMPATIBILITY_PACKAGE = "compatibility-package";

    private static final ComponentName CREDMAN_SERVICE_COMPONENT_NAME =
            new ComponentName("com.android.credentialmanager",
                    "com.android.credentialmanager.autofill.CredentialAutofillService");

    private static ServiceInfo getServiceInfoOrThrow(ComponentName comp, int userHandle)
            throws PackageManager.NameNotFoundException {
        try {
@@ -307,6 +311,11 @@ public final class AutofillServiceInfo {
        for (ResolveInfo resolveInfo : resolveInfos) {
            final ServiceInfo serviceInfo = resolveInfo.serviceInfo;
            try {
                if (serviceInfo != null && isCredentialManagerAutofillService(
                        serviceInfo.getComponentName())) {
                    // Skip this service as it is for internal use only
                    continue;
                }
                services.add(new AutofillServiceInfo(context, serviceInfo));
            } catch (SecurityException e) {
                // Service does not declare the proper permission, ignore it.
@@ -316,6 +325,13 @@ public final class AutofillServiceInfo {
        return services;
    }

    private static boolean isCredentialManagerAutofillService(ComponentName componentName) {
        if (componentName == null) {
            return false;
        }
        return componentName.equals(CREDMAN_SERVICE_COMPONENT_NAME);
    }

    @Override
    public String toString() {
        final StringBuilder builder = new StringBuilder();
+29 −18
Original line number Diff line number Diff line
@@ -42,6 +42,17 @@
            android:excludeFromRecents="true"
            android:theme="@style/Theme.CredentialSelector">
        </activity>
        <service
            android:name=".autofill.CredentialAutofillService"
            android:exported="false"
            android:permission="android.permission.BIND_AUTOFILL_SERVICE">
            <meta-data
                android:name="android.autofill"
                android:resource="@xml/autofill_service_configuration"/>
            <intent-filter>
                <action android:name="android.service.autofill.AutofillService"/>
            </intent-filter>
        </service>
    </application>

</manifest>
+10 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?><!--
   Sample backup rules file; uncomment and customize as necessary.
   See https://developer.android.com/guide/topics/data/autobackup
   for details.
   Note: This file is ignored for devices older that API 31
   See https://developer.android.com/about/versions/12/backup-restore
-->
<autofill-service-configuration
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:supportsInlineSuggestions="true"/>
 No newline at end of file
+38 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.credentialmanager.autofill

import android.os.CancellationSignal
import android.service.autofill.AutofillService
import android.service.autofill.FillCallback
import android.service.autofill.FillRequest
import android.service.autofill.SaveRequest
import android.service.autofill.SaveCallback

class CredentialAutofillService : AutofillService() {
    override fun onFillRequest(
            request: FillRequest,
            cancellationSignal: CancellationSignal,
            callback: FillCallback
    ) {
        TODO("Not yet implemented")
    }

    override fun onSaveRequest(request: SaveRequest, callback: SaveCallback) {
        TODO("Not yet implemented")
    }
}
 No newline at end of file