1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.credentials.cts;
18 
19 import android.credentials.ClearCredentialStateException;
20 import android.credentials.CreateCredentialException;
21 import android.credentials.GetCredentialException;
22 import android.os.CancellationSignal;
23 import android.os.OutcomeReceiver;
24 import android.service.credentials.BeginCreateCredentialRequest;
25 import android.service.credentials.BeginCreateCredentialResponse;
26 import android.service.credentials.BeginGetCredentialRequest;
27 import android.service.credentials.BeginGetCredentialResponse;
28 import android.service.credentials.ClearCredentialStateRequest;
29 import android.service.credentials.CredentialProviderService;
30 import android.util.Log;
31 
32 /**
33  * {@link CredentialProviderService} implementation that does not do anything.
34  */
35 public class CtsNoOpCredentialProviderService extends CredentialProviderService {
36     private static final String TAG = "CtsNoOpCredentialProviderService";
37     private static final String FAKE_APP_PACKAGE = "cts.crm.cps";
38 
39     @Override
onBeginGetCredential(BeginGetCredentialRequest request, CancellationSignal cancellationSignal, OutcomeReceiver< BeginGetCredentialResponse, GetCredentialException> callback)40     public void onBeginGetCredential(BeginGetCredentialRequest request,
41             CancellationSignal cancellationSignal,
42             OutcomeReceiver<
43                     BeginGetCredentialResponse, GetCredentialException> callback) {
44         Log.i(TAG, "onBeginGetCredential() final service");
45         callback.onResult(new BeginGetCredentialResponse());
46     }
47 
48     @Override
onBeginCreateCredential(BeginCreateCredentialRequest request, CancellationSignal cancellationSignal, OutcomeReceiver<BeginCreateCredentialResponse, CreateCredentialException> callback)49     public void onBeginCreateCredential(BeginCreateCredentialRequest request,
50             CancellationSignal cancellationSignal,
51             OutcomeReceiver<BeginCreateCredentialResponse,
52                     CreateCredentialException> callback) {
53         Log.i(TAG, "onBeginCreateCredential() final service");
54         callback.onResult(new BeginCreateCredentialResponse());
55     }
56 
57     @Override
onClearCredentialState(ClearCredentialStateRequest request, CancellationSignal cancellationSignal, OutcomeReceiver<Void, ClearCredentialStateException> callback)58     public void onClearCredentialState(ClearCredentialStateRequest request,
59             CancellationSignal cancellationSignal,
60             OutcomeReceiver<Void, ClearCredentialStateException> callback) {
61         Log.i(TAG, "onClearCredentialState() final service");
62         callback.onResult(null);
63     }
64 }
65