blob: 434e2d3f47919a7cb75f39745f9c5c2b42307ca0 [file] [log] [blame]
Dave Mankofff4736812019-10-18 17:25:50 -04001/*
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
17package com.android.systemui.dagger;
18
19import android.annotation.Nullable;
20import android.annotation.SuppressLint;
21import android.app.ActivityManager;
22import android.app.AlarmManager;
23import android.app.IActivityManager;
24import android.app.IWallpaperManager;
25import android.app.WallpaperManager;
26import android.content.Context;
27import android.content.res.Resources;
28import android.hardware.SensorPrivacyManager;
29import android.os.Handler;
30import android.os.PowerManager;
31import android.os.ServiceManager;
32import android.os.UserHandle;
33import android.view.IWindowManager;
34import android.view.WindowManager;
35import android.view.WindowManagerGlobal;
36
37import com.android.settingslib.bluetooth.LocalBluetoothManager;
38import com.android.systemui.dagger.qualifiers.BgHandler;
39import com.android.systemui.dagger.qualifiers.MainResources;
40import com.android.systemui.shared.system.PackageManagerWrapper;
41
42import javax.inject.Singleton;
43
44import dagger.Module;
45import dagger.Provides;
46
47/**
48 * Provides Non-SystemUI, Framework-Owned instances to the dependency graph.
49 */
50@Module
51public class SystemServicesModule {
52
53 @Singleton
54 @Provides
55 static AlarmManager provideAlarmManager(Context context) {
56 return context.getSystemService(AlarmManager.class);
57 }
58
59 @Singleton
60 @Provides
61 static IActivityManager providesIActivityManager() {
62 return ActivityManager.getService();
63 }
64
65 @Provides
66 static IWallpaperManager provideWallPaperManager() {
67 return IWallpaperManager.Stub.asInterface(
68 ServiceManager.getService(Context.WALLPAPER_SERVICE));
69 }
70
71 @Singleton
72 @Provides
73 static IWindowManager provideIWindowManager() {
74 return WindowManagerGlobal.getWindowManagerService();
75 }
76
77 @SuppressLint("MissingPermission")
78 @Singleton
79 @Provides
80 @Nullable
81 static LocalBluetoothManager provideLocalBluetoothController(Context context,
82 @BgHandler Handler bgHandler) {
83 return LocalBluetoothManager.create(context, bgHandler, UserHandle.ALL);
84 }
85
86 @Singleton
87 @Provides
88 static PackageManagerWrapper providePackageManagerWrapper() {
89 return PackageManagerWrapper.getInstance();
90 }
91
92 /** */
93 @Singleton
94 @Provides
95 static PowerManager providePowerManager(Context context) {
96 return context.getSystemService(PowerManager.class);
97 }
98
99 @Provides
100 @MainResources
101 static Resources provideResources(Context context) {
102 return context.getResources();
103 }
104
105 @Singleton
106 @Provides
107 static SensorPrivacyManager provideSensorPrivacyManager(Context context) {
108 return context.getSystemService(SensorPrivacyManager.class);
109 }
110
111 @Provides
112 static WallpaperManager providesWallpaperManager(Context context) {
113 return (WallpaperManager) context.getSystemService(Context.WALLPAPER_SERVICE);
114 }
115
116 @Singleton
117 @Provides
118 static WindowManager providesWindowManager(Context context) {
119 return context.getSystemService(WindowManager.class);
120 }
121
122}