• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 com.android.systemui.dagger;
18 
19 import android.annotation.Nullable;
20 import android.annotation.SuppressLint;
21 import android.app.ActivityManager;
22 import android.app.ActivityTaskManager;
23 import android.app.AlarmManager;
24 import android.app.AppOpsManager;
25 import android.app.IActivityManager;
26 import android.app.IActivityTaskManager;
27 import android.app.INotificationManager;
28 import android.app.IUriGrantsManager;
29 import android.app.IWallpaperManager;
30 import android.app.KeyguardManager;
31 import android.app.NotificationManager;
32 import android.app.StatsManager;
33 import android.app.StatusBarManager;
34 import android.app.UiModeManager;
35 import android.app.WallpaperManager;
36 import android.app.admin.DevicePolicyManager;
37 import android.app.ambientcontext.AmbientContextManager;
38 import android.app.job.JobScheduler;
39 import android.app.role.RoleManager;
40 import android.app.smartspace.SmartspaceManager;
41 import android.app.trust.TrustManager;
42 import android.bluetooth.BluetoothAdapter;
43 import android.bluetooth.BluetoothManager;
44 import android.companion.virtual.VirtualDeviceManager;
45 import android.content.ClipboardManager;
46 import android.content.ContentResolver;
47 import android.content.Context;
48 import android.content.SharedPreferences;
49 import android.content.om.OverlayManager;
50 import android.content.pm.IPackageManager;
51 import android.content.pm.LauncherApps;
52 import android.content.pm.PackageInstaller;
53 import android.content.pm.PackageManager;
54 import android.content.pm.ShortcutManager;
55 import android.content.res.AssetManager;
56 import android.content.res.Resources;
57 import android.graphics.Color;
58 import android.hardware.SensorManager;
59 import android.hardware.SensorPrivacyManager;
60 import android.hardware.biometrics.BiometricManager;
61 import android.hardware.camera2.CameraManager;
62 import android.hardware.devicestate.DeviceStateManager;
63 import android.hardware.display.AmbientDisplayConfiguration;
64 import android.hardware.display.ColorDisplayManager;
65 import android.hardware.display.DisplayManager;
66 import android.hardware.face.FaceManager;
67 import android.hardware.fingerprint.FingerprintManager;
68 import android.hardware.input.InputManager;
69 import android.location.LocationManager;
70 import android.media.AudioManager;
71 import android.media.IAudioService;
72 import android.media.MediaRouter2Manager;
73 import android.media.projection.IMediaProjectionManager;
74 import android.media.projection.MediaProjectionManager;
75 import android.media.session.MediaSessionManager;
76 import android.nearby.NearbyManager;
77 import android.net.ConnectivityManager;
78 import android.net.NetworkScoreManager;
79 import android.net.wifi.WifiManager;
80 import android.os.BatteryStats;
81 import android.os.IDeviceIdleController;
82 import android.os.PowerExemptionManager;
83 import android.os.PowerManager;
84 import android.os.ServiceManager;
85 import android.os.SystemUpdateManager;
86 import android.os.UserManager;
87 import android.os.Vibrator;
88 import android.os.storage.StorageManager;
89 import android.permission.PermissionManager;
90 import android.safetycenter.SafetyCenterManager;
91 import android.service.dreams.DreamService;
92 import android.service.dreams.IDreamManager;
93 import android.service.vr.IVrManager;
94 import android.telecom.TelecomManager;
95 import android.telephony.CarrierConfigManager;
96 import android.telephony.SubscriptionManager;
97 import android.telephony.TelephonyManager;
98 import android.telephony.satellite.SatelliteManager;
99 import android.view.Choreographer;
100 import android.view.CrossWindowBlurListeners;
101 import android.view.IWindowManager;
102 import android.view.LayoutInflater;
103 import android.view.ViewConfiguration;
104 import android.view.WindowManager;
105 import android.view.WindowManagerGlobal;
106 import android.view.accessibility.AccessibilityManager;
107 import android.view.accessibility.CaptioningManager;
108 import android.view.inputmethod.InputMethodManager;
109 import android.view.textclassifier.TextClassificationManager;
110 
111 import androidx.asynclayoutinflater.view.AsyncLayoutInflater;
112 import androidx.core.app.NotificationManagerCompat;
113 
114 import com.android.internal.app.IBatteryStats;
115 import com.android.internal.appwidget.IAppWidgetService;
116 import com.android.internal.jank.InteractionJankMonitor;
117 import com.android.internal.statusbar.IStatusBarService;
118 import com.android.internal.util.LatencyTracker;
119 import com.android.systemui.Prefs;
120 import com.android.systemui.dagger.qualifiers.Application;
121 import com.android.systemui.dagger.qualifiers.DisplayId;
122 import com.android.systemui.dagger.qualifiers.Main;
123 import com.android.systemui.dagger.qualifiers.TestHarness;
124 import com.android.systemui.shared.system.PackageManagerWrapper;
125 import com.android.systemui.user.utils.UserScopedService;
126 import com.android.systemui.user.utils.UserScopedServiceImpl;
127 
128 import dagger.Module;
129 import dagger.Provides;
130 
131 import java.util.Optional;
132 
133 import javax.inject.Singleton;
134 
135 /**
136  * Provides Non-SystemUI, Framework-Owned instances to the dependency graph.
137  */
138 @SuppressLint("NonInjectedService")
139 @Module
140 public class FrameworkServicesModule {
141     @Provides
142     @Singleton
provideAccessibilityManager(Context context)143     static AccessibilityManager provideAccessibilityManager(Context context) {
144         return context.getSystemService(AccessibilityManager.class);
145     }
146 
147     @Provides
148     @Singleton
provideActivityManager(Context context)149     static ActivityManager provideActivityManager(Context context) {
150         return context.getSystemService(ActivityManager.class);
151     }
152 
153     @Provides
154     @Singleton
provideAlarmManager(Context context)155     static AlarmManager provideAlarmManager(Context context) {
156         return context.getSystemService(AlarmManager.class);
157     }
158 
159     @Provides
160     @Singleton
provideSystemUpdateManager(Context context)161     static Optional<SystemUpdateManager> provideSystemUpdateManager(Context context) {
162         return Optional.ofNullable(context.getSystemService(SystemUpdateManager.class));
163     }
164 
165     @Provides
166     @Nullable
167     @Singleton
provideAmbientContextManager(Context context)168     static AmbientContextManager provideAmbientContextManager(Context context) {
169         return context.getSystemService(AmbientContextManager.class);
170     }
171 
172     /** */
173     @Provides
provideAmbientDisplayConfiguration(Context context)174     public AmbientDisplayConfiguration provideAmbientDisplayConfiguration(Context context) {
175         return new AmbientDisplayConfiguration(context);
176     }
177 
178     @Provides
179     @Singleton
provideAppOpsManager(Context context)180     static AppOpsManager provideAppOpsManager(Context context) {
181         return context.getSystemService(AppOpsManager.class);
182     }
183 
184     @Provides
185     @Singleton
provideAudioManager(Context context)186     static AudioManager provideAudioManager(Context context) {
187         return context.getSystemService(AudioManager.class);
188     }
189 
190     @Provides
191     @Singleton
provideCaptioningManager(Context context)192     static CaptioningManager provideCaptioningManager(Context context) {
193         return context.getSystemService(CaptioningManager.class);
194     }
195 
196     /** */
197     @Provides
198     @Singleton
providesChoreographer()199     public Choreographer providesChoreographer() {
200         return Choreographer.getInstance();
201     }
202 
203     @Provides
204     @Singleton
provideColorDisplayManager(Context context)205     static ColorDisplayManager provideColorDisplayManager(Context context) {
206         return context.getSystemService(ColorDisplayManager.class);
207     }
208 
209     @Provides
210     @Singleton
provideConnectivityManagager(Context context)211     static ConnectivityManager provideConnectivityManagager(Context context) {
212         return context.getSystemService(ConnectivityManager.class);
213     }
214 
215     @Provides
216     @Singleton
provideContentResolver(Context context)217     static ContentResolver provideContentResolver(Context context) {
218         return context.getContentResolver();
219     }
220 
221     @Provides
222     @Singleton
provideDevicePolicyManager(Context context)223     static DevicePolicyManager provideDevicePolicyManager(Context context) {
224         return context.getSystemService(DevicePolicyManager.class);
225     }
226 
227     @Provides
228     @Singleton
provideScopedColorDisplayManager( Context context)229     static UserScopedService<ColorDisplayManager> provideScopedColorDisplayManager(
230             Context context) {
231         return new UserScopedServiceImpl<>(context, ColorDisplayManager.class);
232     }
233 
234     @Provides
235     @Singleton
provideCrossWindowBlurListeners()236     static CrossWindowBlurListeners provideCrossWindowBlurListeners() {
237         return CrossWindowBlurListeners.getInstance();
238     }
239 
240     @Provides
241     @DisplayId
provideDisplayId(Context context)242     static int provideDisplayId(Context context) {
243         return context.getDisplayId();
244     }
245 
246     @Provides
247     @Singleton
provideDisplayManager(Context context)248     static DisplayManager provideDisplayManager(Context context) {
249         return context.getSystemService(DisplayManager.class);
250     }
251 
252     @Provides
253     @Singleton
provideVirtualDeviceManager(Context context)254     static VirtualDeviceManager provideVirtualDeviceManager(Context context) {
255         return context.getSystemService(VirtualDeviceManager.class);
256     }
257 
258     @Provides
259     @Singleton
provideDeviceStateManager(Context context)260     static DeviceStateManager provideDeviceStateManager(Context context) {
261         return context.getSystemService(DeviceStateManager.class);
262     }
263 
264     @Provides
265     @Singleton
provideIActivityManager()266     static IActivityManager provideIActivityManager() {
267         return ActivityManager.getService();
268     }
269 
270     @Provides
271     @Singleton
provideActivityTaskManager()272     static ActivityTaskManager provideActivityTaskManager() {
273         return ActivityTaskManager.getInstance();
274     }
275 
276     @Provides
277     @Singleton
provideIActivityTaskManager()278     static IActivityTaskManager provideIActivityTaskManager() {
279         return ActivityTaskManager.getService();
280     }
281 
282     @Provides
283     @Singleton
provideIAudioService()284     static IAudioService provideIAudioService() {
285         return IAudioService.Stub.asInterface(ServiceManager.getService(Context.AUDIO_SERVICE));
286     }
287 
288 
289     @Provides
290     @Singleton
provideIBatteryStats()291     static IBatteryStats provideIBatteryStats() {
292         return IBatteryStats.Stub.asInterface(
293                 ServiceManager.getService(BatteryStats.SERVICE_NAME));
294     }
295 
296     @Provides
297     @Singleton
provideIDreamManager()298     static IDreamManager provideIDreamManager() {
299         return IDreamManager.Stub.asInterface(
300                 ServiceManager.getService(DreamService.DREAM_SERVICE));
301     }
302 
303     @Provides
304     @Singleton
305     @Nullable
provideIVrManager()306     static IVrManager provideIVrManager() {
307         return IVrManager.Stub.asInterface(ServiceManager.getService(Context.VR_SERVICE));
308     }
309 
310     @Provides
311     @Singleton
312     @Nullable
provideFaceManager(Context context)313     static FaceManager provideFaceManager(Context context) {
314         if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE)) {
315             return context.getSystemService(FaceManager.class);
316         }
317         return null;
318     }
319 
320     @Provides
321     @Singleton
322     @Nullable
providesFingerprintManager(Context context)323     static FingerprintManager providesFingerprintManager(Context context) {
324         if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) {
325             return context.getSystemService(FingerprintManager.class);
326         }
327         return null;
328     }
329 
330     /**
331      * @return null if both faceManager and fingerprintManager are null.
332      */
333     @Provides
334     @Singleton
335     @Nullable
providesBiometricManager(Context context, @Nullable FaceManager faceManager, @Nullable FingerprintManager fingerprintManager)336     static BiometricManager providesBiometricManager(Context context,
337             @Nullable FaceManager faceManager, @Nullable FingerprintManager fingerprintManager) {
338         return faceManager == null && fingerprintManager == null ? null :
339                 context.getSystemService(BiometricManager.class);
340     }
341 
342     @Provides
343     @Singleton
provideJobScheduler(Context context)344     static JobScheduler provideJobScheduler(Context context) {
345         return context.getSystemService(JobScheduler.class);
346     }
347 
348     @Provides
349     @Singleton
provideInteractionJankMonitor()350     static InteractionJankMonitor provideInteractionJankMonitor() {
351         InteractionJankMonitor jankMonitor = InteractionJankMonitor.getInstance();
352         jankMonitor.configDebugOverlay(Color.YELLOW, 0.75);
353         return jankMonitor;
354     }
355 
356     @Provides
357     @Singleton
provideInputManager(Context context)358     static InputManager provideInputManager(Context context) {
359         return context.getSystemService(InputManager.class);
360     }
361 
362     @Provides
363     @Singleton
provideInputMethodManager(Context context)364     static InputMethodManager provideInputMethodManager(Context context) {
365         return context.getSystemService(InputMethodManager.class);
366     }
367 
368     @Provides
369     @Singleton
provideIAppWidgetService()370     static IAppWidgetService provideIAppWidgetService() {
371         return IAppWidgetService.Stub.asInterface(
372                 ServiceManager.getService(Context.APPWIDGET_SERVICE));
373     }
374 
375     @Provides
376     @Singleton
provideIPackageManager()377     static IPackageManager provideIPackageManager() {
378         return IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
379     }
380 
381     @Provides
382     @Singleton
provideIStatusBarService()383     static IStatusBarService provideIStatusBarService() {
384         return IStatusBarService.Stub.asInterface(
385                 ServiceManager.getService(Context.STATUS_BAR_SERVICE));
386     }
387 
388     @Provides
389     @Nullable
provideIWallPaperManager()390     static IWallpaperManager provideIWallPaperManager() {
391         return IWallpaperManager.Stub.asInterface(
392                 ServiceManager.getService(Context.WALLPAPER_SERVICE));
393     }
394 
395     @Provides
396     @Singleton
provideIWindowManager()397     static IWindowManager provideIWindowManager() {
398         return WindowManagerGlobal.getWindowManagerService();
399     }
400 
401     @Provides
402     @Singleton
provideKeyguardManager(Context context)403     static KeyguardManager provideKeyguardManager(Context context) {
404         return context.getSystemService(KeyguardManager.class);
405     }
406 
407     @Provides
408     @Singleton
provideLatencyTracker(Context context)409     static LatencyTracker provideLatencyTracker(Context context) {
410         return LatencyTracker.getInstance(context);
411     }
412 
413     @Provides
414     @Singleton
provideLauncherApps(Context context)415     static LauncherApps provideLauncherApps(Context context) {
416         return context.getSystemService(LauncherApps.class);
417     }
418 
419     /** */
420     @Provides
421     @Singleton
providerLayoutInflater(Context context)422     public LayoutInflater providerLayoutInflater(Context context) {
423         return LayoutInflater.from(context);
424     }
425 
426     /** */
427     @Provides
428     @Singleton
provideAsyncLayoutInflater(Context context)429     public AsyncLayoutInflater provideAsyncLayoutInflater(Context context) {
430         return new AsyncLayoutInflater(context);
431     }
432 
433     @Provides
provideMediaProjectionManager(Context context)434     static MediaProjectionManager provideMediaProjectionManager(Context context) {
435         return context.getSystemService(MediaProjectionManager.class);
436     }
437 
438     @Provides
439     @Singleton
provideIMediaProjectionManager()440     static IMediaProjectionManager provideIMediaProjectionManager() {
441         return IMediaProjectionManager.Stub.asInterface(
442                 ServiceManager.getService(Context.MEDIA_PROJECTION_SERVICE));
443     }
444 
445     @Provides
provideMediaRouter2Manager(Context context)446     static MediaRouter2Manager provideMediaRouter2Manager(Context context) {
447         return MediaRouter2Manager.getInstance(context);
448     }
449 
450     @Provides
provideMediaSessionManager(Context context)451     static MediaSessionManager provideMediaSessionManager(Context context) {
452         return context.getSystemService(MediaSessionManager.class);
453     }
454 
455     @Provides
456     @Singleton
provideNearbyManager(Context context)457     static NearbyManager provideNearbyManager(Context context) {
458         return context.getSystemService(NearbyManager.class);
459     }
460 
461     @Provides
462     @Singleton
provideNetworkScoreManager(Context context)463     static NetworkScoreManager provideNetworkScoreManager(Context context) {
464         return context.getSystemService(NetworkScoreManager.class);
465     }
466 
467     @Provides
468     @Singleton
provideNotificationManager(Context context)469     static NotificationManager provideNotificationManager(Context context) {
470         return context.getSystemService(NotificationManager.class);
471     }
472 
473     @Provides
474     @Singleton
provideNotificationManagerCompat(Context context)475     static NotificationManagerCompat provideNotificationManagerCompat(Context context) {
476         return NotificationManagerCompat.from(context);
477     }
478 
479     /** */
480     @Provides
481     @Singleton
provideINotificationManager()482     public INotificationManager provideINotificationManager() {
483         return INotificationManager.Stub.asInterface(
484                 ServiceManager.getService(Context.NOTIFICATION_SERVICE));
485     }
486 
487     @Provides
488     @Singleton
providePackageManager(Context context)489     static PackageManager providePackageManager(Context context) {
490         return context.getPackageManager();
491     }
492 
493     @Provides
494     @Singleton
providePackageInstaller(PackageManager packageManager)495     static PackageInstaller providePackageInstaller(PackageManager packageManager) {
496         return packageManager.getPackageInstaller();
497     }
498 
499     @Provides
500     @Singleton
providePackageManagerWrapper()501     static PackageManagerWrapper providePackageManagerWrapper() {
502         return PackageManagerWrapper.getInstance();
503     }
504 
505     /** */
506     @Provides
507     @Singleton
providePowerManager(Context context)508     static PowerManager providePowerManager(Context context) {
509         return context.getSystemService(PowerManager.class);
510     }
511 
512     /** */
513     @Provides
514     @Singleton
providePowerExemptionManager(Context context)515     static PowerExemptionManager providePowerExemptionManager(Context context) {
516         return context.getSystemService(PowerExemptionManager.class);
517     }
518 
519     /** */
520     @Provides
521     @Main
provideSharePreferences(Context context)522     public SharedPreferences provideSharePreferences(Context context) {
523         return Prefs.get(context);
524     }
525 
526     /** */
527     @Provides
528     @Singleton
provideUiModeManager(Context context)529     static UiModeManager provideUiModeManager(Context context) {
530         return context.getSystemService(UiModeManager.class);
531     }
532 
533     @Provides
534     @Main
provideResources(Context context)535     static Resources provideResources(Context context) {
536         return context.getResources();
537     }
538 
539     @Provides
540     @Application
provideAssetManager(@pplication Context context)541     static AssetManager provideAssetManager(@Application Context context) {
542         return context.getAssets();
543     }
544 
545     @Provides
546     @Singleton
provideRoleManager(Context context)547     static RoleManager provideRoleManager(Context context) {
548         return context.getSystemService(RoleManager.class);
549     }
550 
551     @Provides
552     @Singleton
providesSensorManager(Context context)553     static SensorManager providesSensorManager(Context context) {
554         return context.getSystemService(SensorManager.class);
555     }
556 
557     @Provides
558     @Singleton
provideSensorPrivacyManager(Context context)559     static SensorPrivacyManager provideSensorPrivacyManager(Context context) {
560         return context.getSystemService(SensorPrivacyManager.class);
561     }
562 
563     @Provides
564     @Singleton
provideShortcutManager(Context context)565     static ShortcutManager provideShortcutManager(Context context) {
566         return context.getSystemService(ShortcutManager.class);
567     }
568 
569     @Provides
570     @Singleton
provideStatsManager(Context context)571     static StatsManager provideStatsManager(Context context) {
572         return context.getSystemService(StatsManager.class);
573     }
574 
575     @Provides
576     @Singleton
provideStorageManager(Context context)577     static StorageManager provideStorageManager(Context context) {
578         return context.getSystemService(StorageManager.class);
579     }
580 
581     @Provides
582     @Singleton
provideSubscriptionManager(Context context)583     static SubscriptionManager provideSubscriptionManager(Context context) {
584         return context.getSystemService(SubscriptionManager.class).createForAllUserProfiles();
585     }
586 
587     @Provides
588     @Singleton
589     @Nullable
provideTelecomManager(Context context)590     static TelecomManager provideTelecomManager(Context context) {
591         return context.getSystemService(TelecomManager.class);
592     }
593 
594     @Provides
595     @Singleton
provideOptionalTelecomManager(Context context)596     static Optional<TelecomManager> provideOptionalTelecomManager(Context context) {
597         return Optional.ofNullable(context.getSystemService(TelecomManager.class));
598     }
599 
600     @Provides
601     @Singleton
provideTelephonyManager(Context context)602     static TelephonyManager provideTelephonyManager(Context context) {
603         return context.getSystemService(TelephonyManager.class);
604     }
605 
606     @Provides
607     @Singleton
608     @TestHarness
provideIsTestHarness()609     static boolean provideIsTestHarness() {
610         return ActivityManager.isRunningInUserTestHarness();
611     }
612 
613     @Provides
614     @Singleton
provideTrustManager(Context context)615     static TrustManager provideTrustManager(Context context) {
616         return context.getSystemService(TrustManager.class);
617     }
618 
619     @Provides
620     @Singleton
621     @Nullable
provideVibrator(Context context)622     static Vibrator provideVibrator(Context context) {
623         return context.getSystemService(Vibrator.class);
624     }
625 
626     @Provides
627     @Singleton
provideOptionalVibrator(Context context)628     static Optional<Vibrator> provideOptionalVibrator(Context context) {
629         return Optional.ofNullable(context.getSystemService(Vibrator.class));
630     }
631 
632     @Provides
633     @Singleton
provideViewConfiguration(Context context)634     static ViewConfiguration provideViewConfiguration(Context context) {
635         return ViewConfiguration.get(context);
636     }
637 
638     @Provides
639     @Singleton
provideUserManager(Context context)640     static UserManager provideUserManager(Context context) {
641         return context.getSystemService(UserManager.class);
642     }
643 
644     @Provides
645     @Singleton
provideScopedUserManager(@pplication Context context)646     static UserScopedService<UserManager> provideScopedUserManager(@Application Context context) {
647         return new UserScopedServiceImpl<>(context, UserManager.class);
648     }
649 
650     @Provides
provideWallpaperManager(Context context)651     static WallpaperManager provideWallpaperManager(Context context) {
652         return context.getSystemService(WallpaperManager.class);
653     }
654 
655     @Provides
656     @Singleton
657     @Nullable
provideWifiManager(Context context)658     static WifiManager provideWifiManager(Context context) {
659         return context.getSystemService(WifiManager.class);
660     }
661 
662     @Provides
663     @Singleton
provideOverlayManager(Context context)664     static OverlayManager provideOverlayManager(Context context) {
665         return context.getSystemService(OverlayManager.class);
666     }
667 
668     @Provides
669     @Singleton
670     @Nullable
provideCarrierConfigManager(Context context)671     static CarrierConfigManager provideCarrierConfigManager(Context context) {
672         return context.getSystemService(CarrierConfigManager.class);
673     }
674 
675     @Provides
676     @Singleton
provideWindowManager(Context context)677     static WindowManager provideWindowManager(Context context) {
678         return context.getSystemService(WindowManager.class);
679     }
680 
681     @Provides
682     @Singleton
providePermissionManager(Context context)683     static PermissionManager providePermissionManager(Context context) {
684         PermissionManager pm = context.getSystemService(PermissionManager.class);
685         if (pm != null) {
686             pm.initializeUsageHelper();
687         }
688         return pm;
689     }
690 
691     @Provides
692     @Singleton
provideLocationManager(Context context)693     static LocationManager provideLocationManager(Context context) {
694         return context.getSystemService(LocationManager.class);
695     }
696 
697     @Provides
698     @Singleton
provideClipboardManager(Context context)699     static ClipboardManager provideClipboardManager(Context context) {
700         return context.getSystemService(ClipboardManager.class);
701     }
702 
703     @Provides
704     @Singleton
705     @Nullable
provideSmartspaceManager(Context context)706     static SmartspaceManager provideSmartspaceManager(Context context) {
707         return context.getSystemService(SmartspaceManager.class);
708     }
709 
710     @Provides
711     @Singleton
provideSafetyCenterManager(Context context)712     static SafetyCenterManager provideSafetyCenterManager(Context context) {
713         return context.getSystemService(SafetyCenterManager.class);
714     }
715 
716     @Provides
717     @Singleton
provideCameraManager(Context context)718     static CameraManager provideCameraManager(Context context) {
719         return context.getSystemService(CameraManager.class);
720     }
721 
722     @Provides
723     @Singleton
provideBluetoothManager(Context context)724     static BluetoothManager provideBluetoothManager(Context context) {
725         return context.getSystemService(BluetoothManager.class);
726     }
727 
728     @Provides
729     @Singleton
730     @Nullable
provideBluetoothAdapter(BluetoothManager bluetoothManager)731     static BluetoothAdapter provideBluetoothAdapter(BluetoothManager bluetoothManager) {
732         return bluetoothManager.getAdapter();
733     }
734 
735     @Provides
736     @Singleton
provideTextClassificationManager(Context context)737     static TextClassificationManager provideTextClassificationManager(Context context) {
738         return context.getSystemService(TextClassificationManager.class);
739     }
740 
741     @Provides
742     @Singleton
provideStatusBarManager(Context context)743     static StatusBarManager provideStatusBarManager(Context context) {
744         return context.getSystemService(StatusBarManager.class);
745     }
746 
747     @Provides
748     @Singleton
provideIUriGrantsManager()749     static IUriGrantsManager provideIUriGrantsManager() {
750         return IUriGrantsManager.Stub.asInterface(
751                 ServiceManager.getService(Context.URI_GRANTS_SERVICE)
752         );
753     }
754 
755     @Provides
756     @Singleton
provideSatelliteManager(Context context)757     static Optional<SatelliteManager> provideSatelliteManager(Context context) {
758         return Optional.ofNullable(context.getSystemService(SatelliteManager.class));
759     }
760 
761     @Provides
762     @Singleton
provideDeviceIdleController()763     static IDeviceIdleController provideDeviceIdleController() {
764         return IDeviceIdleController.Stub.asInterface(
765                 ServiceManager.getService(Context.DEVICE_IDLE_CONTROLLER));
766     }
767 }
768