• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 com.android.keyguard.dagger;
18 
19 import android.content.Context;
20 import android.content.res.Resources;
21 import android.view.LayoutInflater;
22 
23 import com.android.systemui.R;
24 import com.android.systemui.dagger.SysUISingleton;
25 import com.android.systemui.dagger.qualifiers.Application;
26 import com.android.systemui.dagger.qualifiers.Background;
27 import com.android.systemui.dagger.qualifiers.Main;
28 import com.android.systemui.flags.FeatureFlags;
29 import com.android.systemui.flags.Flags;
30 import com.android.systemui.plugins.PluginManager;
31 import com.android.systemui.shared.clocks.ClockRegistry;
32 import com.android.systemui.shared.clocks.DefaultClockProvider;
33 
34 import dagger.Module;
35 import dagger.Provides;
36 import kotlinx.coroutines.CoroutineDispatcher;
37 import kotlinx.coroutines.CoroutineScope;
38 
39 /** Dagger Module for clocks. */
40 @Module
41 public abstract class ClockRegistryModule {
42     /** Provide the ClockRegistry as a singleton so that it is not instantiated more than once. */
43     @Provides
44     @SysUISingleton
getClockRegistry( @pplication Context context, PluginManager pluginManager, @Application CoroutineScope scope, @Main CoroutineDispatcher mainDispatcher, @Background CoroutineDispatcher bgDispatcher, FeatureFlags featureFlags, @Main Resources resources, LayoutInflater layoutInflater)45     public static ClockRegistry getClockRegistry(
46             @Application Context context,
47             PluginManager pluginManager,
48             @Application CoroutineScope scope,
49             @Main CoroutineDispatcher mainDispatcher,
50             @Background CoroutineDispatcher bgDispatcher,
51             FeatureFlags featureFlags,
52             @Main Resources resources,
53             LayoutInflater layoutInflater) {
54         ClockRegistry registry = new ClockRegistry(
55                 context,
56                 pluginManager,
57                 scope,
58                 mainDispatcher,
59                 bgDispatcher,
60                 featureFlags.isEnabled(Flags.LOCKSCREEN_CUSTOM_CLOCKS),
61                 /* handleAllUsers= */ true,
62                 new DefaultClockProvider(context, layoutInflater, resources),
63                 context.getString(R.string.lockscreen_clock_id_fallback));
64         registry.registerListeners();
65         return registry;
66     }
67 }
68