Loading packages/SystemUI/src/com/android/systemui/controls/dagger/ControlsComponent.kt 0 → 100644 +55 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 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.controls.dagger import com.android.systemui.controls.controller.ControlsController import com.android.systemui.controls.management.ControlsListingController import com.android.systemui.controls.ui.ControlsUiController import dagger.Lazy import java.util.Optional import javax.inject.Inject import javax.inject.Singleton /** * Pseudo-component to inject into classes outside `com.android.systemui.controls`. * * If `featureEnabled` is false, all the optionals should be empty. The controllers will only be * instantiated if `featureEnabled` is true. */ @Singleton class ControlsComponent @Inject constructor( @ControlsFeatureEnabled private val featureEnabled: Boolean, private val lazyControlsController: Lazy<ControlsController>, private val lazyControlsUiController: Lazy<ControlsUiController>, private val lazyControlsListingController: Lazy<ControlsListingController> ) { fun getControlsController(): Optional<ControlsController> { return if (featureEnabled) Optional.of(lazyControlsController.get()) else Optional.empty() } fun getControlsUiController(): Optional<ControlsUiController> { return if (featureEnabled) Optional.of(lazyControlsUiController.get()) else Optional.empty() } fun getControlsListingController(): Optional<ControlsListingController> { return if (featureEnabled) { Optional.of(lazyControlsListingController.get()) } else { Optional.empty() } } } No newline at end of file packages/SystemUI/src/com/android/systemui/controls/dagger/ControlsFeatureEnabled.kt 0 → 100644 +24 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 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.controls.dagger import javax.inject.Qualifier @Qualifier @MustBeDocumented @Retention(AnnotationRetention.RUNTIME) annotation class ControlsFeatureEnabled No newline at end of file packages/SystemUI/src/com/android/systemui/controls/dagger/ControlsModule.kt +23 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.controls.dagger import android.app.Activity import android.content.pm.PackageManager import com.android.systemui.controls.controller.ControlsBindingController import com.android.systemui.controls.controller.ControlsBindingControllerImpl import com.android.systemui.controls.controller.ControlsController Loading @@ -28,19 +29,39 @@ import com.android.systemui.controls.management.ControlsListingController import com.android.systemui.controls.management.ControlsListingControllerImpl import com.android.systemui.controls.management.ControlsProviderSelectorActivity import com.android.systemui.controls.management.ControlsRequestDialog import com.android.systemui.controls.ui.ControlsUiController import com.android.systemui.controls.ui.ControlsUiControllerImpl import com.android.systemui.controls.ui.ControlActionCoordinator import com.android.systemui.controls.ui.ControlActionCoordinatorImpl import com.android.systemui.controls.ui.ControlsUiController import com.android.systemui.controls.ui.ControlsUiControllerImpl import dagger.Binds import dagger.BindsOptionalOf import dagger.Module import dagger.Provides import dagger.multibindings.ClassKey import dagger.multibindings.IntoMap import javax.inject.Singleton /** * Module for injecting classes in `com.android.systemui.controls`- * * Classes provided by this module should only be injected directly into other classes in this * module. For injecting outside of this module (for example, [GlobalActionsDialog], inject * [ControlsComponent] and obtain the corresponding optionals from it. */ @Module abstract class ControlsModule { @Module companion object { @JvmStatic @Provides @Singleton @ControlsFeatureEnabled fun providesControlsFeatureEnabled(pm: PackageManager): Boolean { return pm.hasSystemFeature(PackageManager.FEATURE_CONTROLS) } } @Binds abstract fun provideControlsListingController( controller: ControlsListingControllerImpl Loading packages/SystemUI/src/com/android/systemui/controls/management/ControlsRequestReceiver.kt +3 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,9 @@ class ControlsRequestReceiver : BroadcastReceiver() { } override fun onReceive(context: Context, intent: Intent) { if (!context.packageManager.hasSystemFeature(PackageManager.FEATURE_CONTROLS)) { return } val packageName = intent.getParcelableExtra<ComponentName>(Intent.EXTRA_COMPONENT_NAME) ?.packageName Loading packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt +0 −2 Original line number Diff line number Diff line Loading @@ -60,7 +60,6 @@ import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.globalactions.GlobalActionsPopupMenu import com.android.systemui.plugins.ActivityStarter import com.android.systemui.statusbar.phone.ShadeController import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.concurrency.DelayableExecutor import dagger.Lazy import java.text.Collator Loading @@ -80,7 +79,6 @@ class ControlsUiControllerImpl @Inject constructor ( @Main val sharedPreferences: SharedPreferences, val controlActionCoordinator: ControlActionCoordinator, private val activityStarter: ActivityStarter, private val keyguardStateController: KeyguardStateController, private val shadeController: ShadeController ) : ControlsUiController { Loading Loading
packages/SystemUI/src/com/android/systemui/controls/dagger/ControlsComponent.kt 0 → 100644 +55 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 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.controls.dagger import com.android.systemui.controls.controller.ControlsController import com.android.systemui.controls.management.ControlsListingController import com.android.systemui.controls.ui.ControlsUiController import dagger.Lazy import java.util.Optional import javax.inject.Inject import javax.inject.Singleton /** * Pseudo-component to inject into classes outside `com.android.systemui.controls`. * * If `featureEnabled` is false, all the optionals should be empty. The controllers will only be * instantiated if `featureEnabled` is true. */ @Singleton class ControlsComponent @Inject constructor( @ControlsFeatureEnabled private val featureEnabled: Boolean, private val lazyControlsController: Lazy<ControlsController>, private val lazyControlsUiController: Lazy<ControlsUiController>, private val lazyControlsListingController: Lazy<ControlsListingController> ) { fun getControlsController(): Optional<ControlsController> { return if (featureEnabled) Optional.of(lazyControlsController.get()) else Optional.empty() } fun getControlsUiController(): Optional<ControlsUiController> { return if (featureEnabled) Optional.of(lazyControlsUiController.get()) else Optional.empty() } fun getControlsListingController(): Optional<ControlsListingController> { return if (featureEnabled) { Optional.of(lazyControlsListingController.get()) } else { Optional.empty() } } } No newline at end of file
packages/SystemUI/src/com/android/systemui/controls/dagger/ControlsFeatureEnabled.kt 0 → 100644 +24 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 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.controls.dagger import javax.inject.Qualifier @Qualifier @MustBeDocumented @Retention(AnnotationRetention.RUNTIME) annotation class ControlsFeatureEnabled No newline at end of file
packages/SystemUI/src/com/android/systemui/controls/dagger/ControlsModule.kt +23 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.controls.dagger import android.app.Activity import android.content.pm.PackageManager import com.android.systemui.controls.controller.ControlsBindingController import com.android.systemui.controls.controller.ControlsBindingControllerImpl import com.android.systemui.controls.controller.ControlsController Loading @@ -28,19 +29,39 @@ import com.android.systemui.controls.management.ControlsListingController import com.android.systemui.controls.management.ControlsListingControllerImpl import com.android.systemui.controls.management.ControlsProviderSelectorActivity import com.android.systemui.controls.management.ControlsRequestDialog import com.android.systemui.controls.ui.ControlsUiController import com.android.systemui.controls.ui.ControlsUiControllerImpl import com.android.systemui.controls.ui.ControlActionCoordinator import com.android.systemui.controls.ui.ControlActionCoordinatorImpl import com.android.systemui.controls.ui.ControlsUiController import com.android.systemui.controls.ui.ControlsUiControllerImpl import dagger.Binds import dagger.BindsOptionalOf import dagger.Module import dagger.Provides import dagger.multibindings.ClassKey import dagger.multibindings.IntoMap import javax.inject.Singleton /** * Module for injecting classes in `com.android.systemui.controls`- * * Classes provided by this module should only be injected directly into other classes in this * module. For injecting outside of this module (for example, [GlobalActionsDialog], inject * [ControlsComponent] and obtain the corresponding optionals from it. */ @Module abstract class ControlsModule { @Module companion object { @JvmStatic @Provides @Singleton @ControlsFeatureEnabled fun providesControlsFeatureEnabled(pm: PackageManager): Boolean { return pm.hasSystemFeature(PackageManager.FEATURE_CONTROLS) } } @Binds abstract fun provideControlsListingController( controller: ControlsListingControllerImpl Loading
packages/SystemUI/src/com/android/systemui/controls/management/ControlsRequestReceiver.kt +3 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,9 @@ class ControlsRequestReceiver : BroadcastReceiver() { } override fun onReceive(context: Context, intent: Intent) { if (!context.packageManager.hasSystemFeature(PackageManager.FEATURE_CONTROLS)) { return } val packageName = intent.getParcelableExtra<ComponentName>(Intent.EXTRA_COMPONENT_NAME) ?.packageName Loading
packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt +0 −2 Original line number Diff line number Diff line Loading @@ -60,7 +60,6 @@ import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.globalactions.GlobalActionsPopupMenu import com.android.systemui.plugins.ActivityStarter import com.android.systemui.statusbar.phone.ShadeController import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.concurrency.DelayableExecutor import dagger.Lazy import java.text.Collator Loading @@ -80,7 +79,6 @@ class ControlsUiControllerImpl @Inject constructor ( @Main val sharedPreferences: SharedPreferences, val controlActionCoordinator: ControlActionCoordinator, private val activityStarter: ActivityStarter, private val keyguardStateController: KeyguardStateController, private val shadeController: ShadeController ) : ControlsUiController { Loading