Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f06ed7fd authored by Hawkwood Glazier's avatar Hawkwood Glazier Committed by Android (Google) Code Review
Browse files

Merge "Add Dagger Singleton Provides method for ClockRegistry" into tm-qpr-dev

parents 0e7375b1 ba2863bc
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -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()
+7 −2
Original line number Diff line number Diff line
@@ -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
+45 −0
Original line number Diff line number Diff line
/*
 * 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);
    }
}
+4 −2
Original line number Diff line number Diff line
@@ -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,