1 /* 2 * Copyright (C) 2022 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.ondevicepersonalization; 18 19 import static android.ondevicepersonalization.OnDevicePersonalizationManager.ON_DEVICE_PERSONALIZATION_SERVICE; 20 21 import android.annotation.SystemApi; 22 import android.app.SystemServiceRegistry; 23 import android.content.Context; 24 25 /** 26 * Class holding initialization code for the OnDevicePersonalization module. 27 * 28 * @hide 29 */ 30 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 31 public class OnDevicePersonalizationFrameworkInitializer { OnDevicePersonalizationFrameworkInitializer()32 private OnDevicePersonalizationFrameworkInitializer() { 33 } 34 35 /** 36 * Called by {@link SystemServiceRegistry}'s static initializer and registers all 37 * OnDevicePersonalization services to {@link Context}, so that 38 * {@link Context#getSystemService} can return them. 39 * 40 * @throws IllegalStateException if this is called from anywhere besides 41 * {@link SystemServiceRegistry} 42 */ registerServiceWrappers()43 public static void registerServiceWrappers() { 44 SystemServiceRegistry.registerContextAwareService( 45 ON_DEVICE_PERSONALIZATION_SERVICE, OnDevicePersonalizationManager.class, 46 (c) -> new OnDevicePersonalizationManager(c)); 47 } 48 } 49