• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.app.ecm;
18 
19 import android.annotation.FlaggedApi;
20 import android.annotation.SystemApi;
21 import android.annotation.TargetApi;
22 import android.app.SystemServiceRegistry;
23 import android.content.Context;
24 import android.os.Build;
25 import android.permission.flags.Flags;
26 
27 /**
28  * Class holding initialization code for enhanced confirmation code in the permission module.
29  *
30  * @hide
31  */
32 @FlaggedApi(Flags.FLAG_ENHANCED_CONFIRMATION_MODE_APIS_ENABLED)
33 @TargetApi(Build.VERSION_CODES.VANILLA_ICE_CREAM)
34 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
35 public class EnhancedConfirmationFrameworkInitializer {
EnhancedConfirmationFrameworkInitializer()36     private EnhancedConfirmationFrameworkInitializer() {}
37 
38     /**
39      * Called by {@link SystemServiceRegistry}'s static initializer and registers
40      * {@link EnhancedConfirmationManager} to {@link Context}, so that
41      * {@link Context#getSystemService} can return it.
42      *
43      * <p>If this is called from other places, it throws a {@link IllegalStateException}.
44      */
registerServiceWrappers()45     public static void registerServiceWrappers() {
46         SystemServiceRegistry.registerContextAwareService(Context.ECM_ENHANCED_CONFIRMATION_SERVICE,
47                 EnhancedConfirmationManager.class,
48                 (context, serviceBinder) -> new EnhancedConfirmationManager(context,
49                         IEnhancedConfirmationManager.Stub.asInterface(serviceBinder)));
50     }
51 }
52