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.service.remotelockscreenvalidation; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.content.ComponentName; 22 import android.content.Context; 23 24 import java.util.concurrent.Executor; 25 26 /** 27 * Client for {@link RemoteLockscreenValidationService} 28 * @hide 29 */ 30 public interface RemoteLockscreenValidationClient { 31 32 /** 33 * Create a client for the {@link RemoteLockscreenValidationService} specified by the 34 * {@link ComponentName} 35 * @hide 36 */ 37 @NonNull create(@onNull Context context, @NonNull ComponentName serviceComponent)38 static RemoteLockscreenValidationClient create(@NonNull Context context, 39 @NonNull ComponentName serviceComponent) { 40 return new RemoteLockscreenValidationClientImpl( 41 context, 42 /* bgExecutor= */ null, 43 serviceComponent); 44 } 45 46 /** 47 * Create a client for the {@link RemoteLockscreenValidationService} specified by the 48 * {@link ComponentName} 49 * @param context Context. 50 * @param bgExecutor A background {@link Executor} for service registration. 51 * @hide 52 */ 53 @NonNull create(@onNull Context context, @Nullable Executor bgExecutor, @NonNull ComponentName serviceComponent)54 static RemoteLockscreenValidationClient create(@NonNull Context context, 55 @Nullable Executor bgExecutor, @NonNull ComponentName serviceComponent) { 56 return new RemoteLockscreenValidationClientImpl(context, bgExecutor, serviceComponent); 57 } 58 59 /** 60 * Returns whether the {@link RemoteLockscreenValidationService} defined by the 61 * {@code ComponentName} provided in the constructor is available. 62 * 63 * <p>Calling API methods like {@link #validateLockscreenGuess} will fail if unavailable. 64 */ isServiceAvailable()65 boolean isServiceAvailable(); 66 67 /** 68 * Unbinds from the {@link RemoteLockscreenValidationService} 69 */ disconnect()70 void disconnect(); 71 72 /** 73 * Validates the lockscreen guess. 74 * 75 * @param guess lockscreen guess 76 * @param callback object used to relay the response of the guess validation 77 */ validateLockscreenGuess(byte[] guess, IRemoteLockscreenValidationCallback callback)78 void validateLockscreenGuess(byte[] guess, IRemoteLockscreenValidationCallback callback); 79 } 80