Add Dagger Singleton Provides method for ClockRegistry
Bug: 229771520 Test: Manually verifid ClockRegistry loaded Change-Id: I06f140b6f29f87ca42c2cb4039fe4f9bffa8d0f5
This commit is contained in:
@@ -21,7 +21,6 @@ import android.os.Handler
|
||||
import android.os.UserHandle
|
||||
import android.provider.Settings
|
||||
import android.util.Log
|
||||
import com.android.systemui.dagger.qualifiers.Main
|
||||
import com.android.internal.annotations.Keep
|
||||
import com.android.systemui.plugins.ClockController
|
||||
import com.android.systemui.plugins.ClockId
|
||||
@@ -31,7 +30,6 @@ import com.android.systemui.plugins.ClockProviderPlugin
|
||||
import com.android.systemui.plugins.PluginListener
|
||||
import com.android.systemui.shared.plugins.PluginManager
|
||||
import com.google.gson.Gson
|
||||
import javax.inject.Inject
|
||||
|
||||
private val TAG = ClockRegistry::class.simpleName
|
||||
private const val DEBUG = true
|
||||
@@ -43,13 +41,6 @@ open class ClockRegistry(
|
||||
val handler: Handler,
|
||||
defaultClockProvider: ClockProvider
|
||||
) {
|
||||
@Inject constructor(
|
||||
context: Context,
|
||||
pluginManager: PluginManager,
|
||||
@Main handler: Handler,
|
||||
defaultClockProvider: DefaultClockProvider
|
||||
) : this(context, pluginManager, handler, defaultClockProvider as ClockProvider) { }
|
||||
|
||||
// Usually this would be a typealias, but a SAM provides better java interop
|
||||
fun interface ClockChangeListener {
|
||||
fun onClockChanged()
|
||||
|
||||
@@ -21,9 +21,14 @@ import java.util.List;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
/** Dagger Module for clock package. */
|
||||
/**
|
||||
* Dagger Module for clock package.
|
||||
*
|
||||
* @deprecated Migrate to ClockRegistry
|
||||
*/
|
||||
@Module
|
||||
public abstract class ClockModule {
|
||||
@Deprecated
|
||||
public abstract class ClockInfoModule {
|
||||
|
||||
/** */
|
||||
@Provides
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.keyguard.dagger;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
|
||||
import com.android.systemui.dagger.SysUISingleton;
|
||||
import com.android.systemui.dagger.qualifiers.Application;
|
||||
import com.android.systemui.dagger.qualifiers.Main;
|
||||
import com.android.systemui.shared.clocks.ClockRegistry;
|
||||
import com.android.systemui.shared.clocks.DefaultClockProvider;
|
||||
import com.android.systemui.shared.plugins.PluginManager;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
/** Dagger Module for clocks. */
|
||||
@Module
|
||||
public abstract class ClockRegistryModule {
|
||||
/** Provide the ClockRegistry as a singleton so that it is not instantiated more than once. */
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
public static ClockRegistry getClockRegistry(
|
||||
@Application Context context,
|
||||
PluginManager pluginManager,
|
||||
@Main Handler handler,
|
||||
DefaultClockProvider defaultClockProvider) {
|
||||
return new ClockRegistry(context, pluginManager, handler, defaultClockProvider);
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,8 @@ import android.service.dreams.IDreamManager;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.internal.statusbar.IStatusBarService;
|
||||
import com.android.keyguard.clock.ClockModule;
|
||||
import com.android.keyguard.clock.ClockInfoModule;
|
||||
import com.android.keyguard.dagger.ClockRegistryModule;
|
||||
import com.android.keyguard.dagger.KeyguardBouncerComponent;
|
||||
import com.android.systemui.BootCompleteCache;
|
||||
import com.android.systemui.BootCompleteCacheImpl;
|
||||
@@ -120,7 +121,8 @@ import dagger.Provides;
|
||||
BiometricsModule.class,
|
||||
BouncerViewModule.class,
|
||||
ClipboardOverlayModule.class,
|
||||
ClockModule.class,
|
||||
ClockInfoModule.class,
|
||||
ClockRegistryModule.class,
|
||||
CoroutinesModule.class,
|
||||
DreamModule.class,
|
||||
ControlsModule.class,
|
||||
|
||||
Reference in New Issue
Block a user