Debian Codegraph @

apex/jobscheduler/framework/java/android/app/job/JobSchedulerFrameworkInitializer.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2019 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.job;
18
19 import android.annotation.SystemApi;
20 import android.app.JobSchedulerImpl;
21 import android.app.SystemServiceRegistry;
22 import android.app.tare.EconomyManager;
23 import android.content.Context;
24 import android.os.DeviceIdleManager;
25 import android.os.IDeviceIdleController;
26 import android.os.PowerExemptionManager;
27 import android.os.PowerWhitelistManager;
28
29 /**
30 * Class holding initialization code for the job scheduler module.
31 *
32 * @hide
33 */
34 @SystemApi
35 public class JobSchedulerFrameworkInitializer {
36 private JobSchedulerFrameworkInitializer() {
37 }
38
39 /**
40 * Called by {@link SystemServiceRegistry}'s static initializer and registers
41 * {@link JobScheduler} and other services to {@link Context}, so
42 * {@link Context#getSystemService} can return them.
43 *
44 * <p>If this is called from other places, it throws a {@link IllegalStateException).
45 */
46 public static void registerServiceWrappers() {
47 SystemServiceRegistry.registerStaticService(
48 Context.JOB_SCHEDULER_SERVICE, JobScheduler.class,
49 (b) -> new JobSchedulerImpl(IJobScheduler.Stub.asInterface(b)));
50 SystemServiceRegistry.registerContextAwareService(
51 Context.DEVICE_IDLE_CONTROLLER, DeviceIdleManager.class,
52 (context, b) -> new DeviceIdleManager(
53 context, IDeviceIdleController.Stub.asInterface(b)));
54 SystemServiceRegistry.registerContextAwareService(
55 Context.POWER_WHITELIST_MANAGER, PowerWhitelistManager.class,
56 PowerWhitelistManager::new);
57 SystemServiceRegistry.registerContextAwareService(
58 Context.POWER_EXEMPTION_SERVICE, PowerExemptionManager.class,
59 PowerExemptionManager::new);
60 SystemServiceRegistry.registerStaticService(
61 Context.RESOURCE_ECONOMY_SERVICE, EconomyManager.class, EconomyManager::new);
62 }
63 }