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

Commit 461c8e3b authored by Reema Bajwa's avatar Reema Bajwa
Browse files

Add initial skeleton implementation of Credential Manager

Test: built and tested locally

Change-Id: Ide7a4b586929b4175001ed02fce2f7245f9e31f2
parent 657bec85
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
package android.credentials;

/**
 * Mediator between apps and credential manager service implementations.
 *
 * {@hide}
 */
oneway interface ICredentialManager {
    void getCredential();
}
 No newline at end of file
+22 −0
Original line number Original line Diff line number Diff line
package {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "frameworks_base_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["frameworks_base_license"],
}

filegroup {
    name: "services.credentials-sources",
    srcs: ["java/**/*.java"],
    path: "java",
    visibility: ["//frameworks/base/services"],
}

java_library_static {
    name: "services.credentials",
    defaults: ["platform_service_defaults"],
    srcs: [":services.credentials-sources"],
    libs: ["services.core"],
}
+77 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2022 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.server.credentials;

import android.annotation.NonNull;
import android.annotation.UserIdInt;
import android.content.Context;
import android.credentials.ICredentialManager;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.Log;

import com.android.server.infra.AbstractMasterSystemService;
import com.android.server.infra.SecureSettingsServiceNameResolver;

/**
 * Entry point service for credential management.
 *
 * <p>This service provides the {@link ICredentialManager} implementation and keeps a list of
 * {@link CredentialManagerServiceImpl} per user; the real work is done by
 * {@link CredentialManagerServiceImpl} itself.
 */
public final class CredentialManagerService extends
        AbstractMasterSystemService<CredentialManagerService, CredentialManagerServiceImpl> {

    private static final String TAG = "CredManSysService";

    public CredentialManagerService(@NonNull Context context) {
        super(context,
                new SecureSettingsServiceNameResolver(context, Settings.Secure.AUTOFILL_SERVICE),
                null, PACKAGE_UPDATE_POLICY_REFRESH_EAGER);
    }

    @Override
    protected String getServiceSettingsProperty() {
        return Settings.Secure.AUTOFILL_SERVICE;
    }

    @Override // from AbstractMasterSystemService
    protected CredentialManagerServiceImpl newServiceLocked(@UserIdInt int resolvedUserId,
            boolean disabled) {
        return new CredentialManagerServiceImpl(this, mLock, resolvedUserId);
    }

    @Override
    public void onStart() {
        Log.i(TAG, "onStart");
    }

    final class CredentialManagerServiceStub extends ICredentialManager.Stub {
        @Override
        public void getCredential() {
            final int userId = UserHandle.getCallingUserId();
            synchronized (mLock) {
                final CredentialManagerServiceImpl service = peekServiceForUserLocked(userId);
                if (service != null) {
                    Log.i(TAG, "Got service for : " + userId);
                    service.getCredential();
                }
            }
        }
    }
}
+44 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2022 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.server.credentials;

import android.annotation.NonNull;
import android.util.Log;

import com.android.server.infra.AbstractPerUserSystemService;

/**
 * Per-user implementation of {@link CredentialManagerService}
 */
public class CredentialManagerServiceImpl extends
        AbstractPerUserSystemService<CredentialManagerServiceImpl, CredentialManagerService> {
    private static final String TAG = "CredManSysServiceImpl";

    protected CredentialManagerServiceImpl(
            @NonNull CredentialManagerService master,
            @NonNull Object lock, int userId) {
        super(master, lock, userId);
    }

    /**
     * Unimplemented getCredentials
     */
    public void getCredential() {
        Log.i(TAG, "getCredential not implemented");
        // TODO : Implement logic
    }
}