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

Commit 8276fac6 authored by Dave Mankoff's avatar Dave Mankoff Committed by Automerger Merge Worker
Browse files

Merge "Cleanup GlobalModule." into tm-dev am: 6584dbb6 am: 37b6e8da

parents 52f06605 37b6e8da
Loading
Loading
Loading
Loading
+12 −2
Original line number Original line Diff line number Diff line
@@ -19,9 +19,13 @@ package com.android.systemui.dagger;
import android.content.Context;
import android.content.Context;


import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.UiEventLogger;
import com.android.internal.logging.UiEventLoggerImpl;
import com.android.internal.util.NotificationMessagingUtil;
import com.android.internal.util.NotificationMessagingUtil;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockPatternUtils;


import javax.inject.Singleton;

import dagger.Module;
import dagger.Module;
import dagger.Provides;
import dagger.Provides;


@@ -32,14 +36,14 @@ import dagger.Provides;
public class AndroidInternalsModule {
public class AndroidInternalsModule {
    /** */
    /** */
    @Provides
    @Provides
    @SysUISingleton
    @Singleton
    public LockPatternUtils provideLockPatternUtils(Context context) {
    public LockPatternUtils provideLockPatternUtils(Context context) {
        return new LockPatternUtils(context);
        return new LockPatternUtils(context);
    }
    }


    /** */
    /** */
    @Provides
    @Provides
    @SysUISingleton
    @Singleton
    public MetricsLogger provideMetricsLogger() {
    public MetricsLogger provideMetricsLogger() {
        return new MetricsLogger();
        return new MetricsLogger();
    }
    }
@@ -50,4 +54,10 @@ public class AndroidInternalsModule {
        return new NotificationMessagingUtil(context);
        return new NotificationMessagingUtil(context);
    }
    }


    /** Provides an instance of {@link com.android.internal.logging.UiEventLogger} */
    @Provides
    @Singleton
    static UiEventLogger provideUiEventLogger() {
        return new UiEventLoggerImpl();
    }
}
}
+0 −1
Original line number Original line Diff line number Diff line
@@ -27,7 +27,6 @@ import dagger.Module;
 */
 */
@Deprecated
@Deprecated
@Module(includes = {
@Module(includes = {
        AndroidInternalsModule.class,
        BroadcastDispatcherModule.class,
        BroadcastDispatcherModule.class,
        LeakModule.class,
        LeakModule.class,
        NightDisplayListenerModule.class,
        NightDisplayListenerModule.class,
+8 −0
Original line number Original line Diff line number Diff line
@@ -90,6 +90,7 @@ import com.android.internal.util.LatencyTracker;
import com.android.systemui.Prefs;
import com.android.systemui.Prefs;
import com.android.systemui.dagger.qualifiers.DisplayId;
import com.android.systemui.dagger.qualifiers.DisplayId;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dagger.qualifiers.TestHarness;
import com.android.systemui.shared.system.PackageManagerWrapper;
import com.android.systemui.shared.system.PackageManagerWrapper;


import java.util.Optional;
import java.util.Optional;
@@ -443,6 +444,13 @@ public class FrameworkServicesModule {
        return context.getSystemService(TelephonyManager.class);
        return context.getSystemService(TelephonyManager.class);
    }
    }


    @Provides
    @Singleton
    @TestHarness
    static boolean provideIsTestHarness() {
        return ActivityManager.isRunningInUserTestHarness();
    }

    @Provides
    @Provides
    @Singleton
    @Singleton
    static TrustManager provideTrustManager(Context context) {
    static TrustManager provideTrustManager(Context context) {
+14 −36
Original line number Original line Diff line number Diff line
@@ -16,23 +16,15 @@


package com.android.systemui.dagger;
package com.android.systemui.dagger;


import android.app.ActivityManager;
import android.content.Context;
import android.content.Context;
import android.util.DisplayMetrics;
import android.util.DisplayMetrics;
import android.view.Display;


import com.android.internal.logging.UiEventLogger;
import com.android.systemui.dagger.qualifiers.Application;
import com.android.internal.logging.UiEventLoggerImpl;
import com.android.systemui.dagger.qualifiers.TestHarness;
import com.android.systemui.dagger.qualifiers.UiBackground;
import com.android.systemui.plugins.PluginsModule;
import com.android.systemui.plugins.PluginsModule;
import com.android.systemui.unfold.UnfoldTransitionModule;
import com.android.systemui.unfold.UnfoldTransitionModule;
import com.android.systemui.util.concurrency.GlobalConcurrencyModule;
import com.android.systemui.util.concurrency.GlobalConcurrencyModule;


import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Module;
import dagger.Provides;
import dagger.Provides;


@@ -52,43 +44,29 @@ import dagger.Provides;
 * Please use discretion when adding things to the global scope.
 * Please use discretion when adding things to the global scope.
 */
 */
@Module(includes = {
@Module(includes = {
        AndroidInternalsModule.class,
        FrameworkServicesModule.class,
        FrameworkServicesModule.class,
        GlobalConcurrencyModule.class,
        GlobalConcurrencyModule.class,
        UnfoldTransitionModule.class,
        UnfoldTransitionModule.class,
        PluginsModule.class,
        PluginsModule.class,
})
})
public class GlobalModule {
public class GlobalModule {

    /**
    /** */
     * TODO(b/229228871): This should be the default. No undecorated context should be available.
    @Provides
     */
    public DisplayMetrics provideDisplayMetrics(Context context) {
        DisplayMetrics displayMetrics = new DisplayMetrics();
        context.getDisplay().getMetrics(displayMetrics);
        return displayMetrics;
    }

    /** Provides an instance of {@link com.android.internal.logging.UiEventLogger} */
    @Provides
    @Singleton
    static UiEventLogger provideUiEventLogger() {
        return new UiEventLoggerImpl();
    }

    @Provides
    @Provides
    @TestHarness
    @Application
    static boolean provideIsTestHarness() {
    public Context provideApplicationContext(Context context) {
        return ActivityManager.isRunningInUserTestHarness();
        return context.getApplicationContext();
    }
    }


    /**
    /**
     * Provide an Executor specifically for running UI operations on a separate thread.
     * @deprecated Deprecdated because {@link Display#getMetrics} is deprecated.
     *
     * Keep submitted runnables short and to the point, just as with any other UI code.
     */
     */
    @Provides
    @Provides
    @Singleton
    public DisplayMetrics provideDisplayMetrics(Context context) {
    @UiBackground
        DisplayMetrics displayMetrics = new DisplayMetrics();
    public static Executor provideUiBackgroundExecutor() {
        context.getDisplay().getMetrics(displayMetrics);
        return Executors.newSingleThreadExecutor();
        return displayMetrics;
    }
    }
}
}
+35 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2019 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.systemui.dagger.qualifiers;

import static java.lang.annotation.RetentionPolicy.RUNTIME;

import android.content.Context;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;

import javax.inject.Qualifier;

/**
 * Used to qualify a context as {@link Context#getApplicationContext}
 */
@Qualifier
@Documented
@Retention(RUNTIME)
public @interface Application {
}
Loading