Merge "Add initial skeleton implementation of Credential Manager Test: built and tested locally"
This commit is contained in:
10
core/java/android/credentials/ICredentialManager.aidl
Normal file
10
core/java/android/credentials/ICredentialManager.aidl
Normal file
@@ -0,0 +1,10 @@
|
||||
package android.credentials;
|
||||
|
||||
/**
|
||||
* Mediator between apps and credential manager service implementations.
|
||||
*
|
||||
* {@hide}
|
||||
*/
|
||||
oneway interface ICredentialManager {
|
||||
void getCredential();
|
||||
}
|
||||
22
services/credentials/Android.bp
Normal file
22
services/credentials/Android.bp
Normal file
@@ -0,0 +1,22 @@
|
||||
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"],
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user