1 /* 2 * Copyright (C) 2021 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.systemui.statusbar.phone.fragment.dagger; 18 19 import com.android.systemui.battery.BatteryMeterViewController; 20 import com.android.systemui.dagger.qualifiers.RootView; 21 import com.android.systemui.statusbar.phone.HeadsUpAppearanceController; 22 import com.android.systemui.statusbar.phone.LightsOutNotifController; 23 import com.android.systemui.statusbar.phone.PhoneStatusBarTransitions; 24 import com.android.systemui.statusbar.phone.PhoneStatusBarView; 25 import com.android.systemui.statusbar.phone.PhoneStatusBarViewController; 26 import com.android.systemui.statusbar.phone.StatusBarBoundsProvider; 27 import com.android.systemui.statusbar.phone.StatusBarDemoMode; 28 import com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment; 29 30 import java.util.Set; 31 32 import dagger.BindsInstance; 33 import dagger.Subcomponent; 34 35 /** 36 * A subcomponent that gets re-created each time we create a new {@link CollapsedStatusBarFragment}. 37 * 38 * This component will also re-create all classes that depend on {@link CollapsedStatusBarFragment} 39 * and friends. Specifically, the fragment creates a new {@link PhoneStatusBarView} and multiple 40 * controllers need access to that view, so those controllers will be re-created whenever the 41 * fragment is recreated. 42 * 43 * Anything that depends on {@link CollapsedStatusBarFragment} or {@link PhoneStatusBarView} 44 * should be included here or in {@link StatusBarFragmentModule}. 45 */ 46 47 @Subcomponent(modules = { 48 StatusBarFragmentModule.class, 49 StatusBarStartablesModule.class 50 }) 51 @StatusBarFragmentScope 52 public interface StatusBarFragmentComponent { 53 /** Simple factory. */ 54 @Subcomponent.Factory 55 interface Factory { create( @indsInstance CollapsedStatusBarFragment collapsedStatusBarFragment)56 StatusBarFragmentComponent create( 57 @BindsInstance CollapsedStatusBarFragment collapsedStatusBarFragment); 58 } 59 60 /** 61 * Performs initialization logic after {@link StatusBarFragmentComponent} has been constructed. 62 */ 63 interface Startable { start()64 void start(); stop()65 void stop(); 66 67 enum State { 68 NONE, STARTING, STARTED, STOPPING, STOPPED 69 } 70 } 71 72 /** 73 * Initialize anything extra for the component. Must be called after the component is created. 74 */ init()75 default void init() { 76 // No one accesses these controllers, so we need to make sure we reference them here so they 77 // do get initialized. 78 getBatteryMeterViewController().init(); 79 getHeadsUpAppearanceController().init(); 80 getPhoneStatusBarViewController().init(); 81 getLightsOutNotifController().init(); 82 getStatusBarDemoMode().init(); 83 } 84 85 /** */ 86 @StatusBarFragmentScope getBatteryMeterViewController()87 BatteryMeterViewController getBatteryMeterViewController(); 88 89 /** */ 90 @StatusBarFragmentScope 91 @RootView getPhoneStatusBarView()92 PhoneStatusBarView getPhoneStatusBarView(); 93 94 /** */ 95 @StatusBarFragmentScope getPhoneStatusBarViewController()96 PhoneStatusBarViewController getPhoneStatusBarViewController(); 97 98 /** */ 99 @StatusBarFragmentScope getHeadsUpAppearanceController()100 HeadsUpAppearanceController getHeadsUpAppearanceController(); 101 102 /** */ 103 @StatusBarFragmentScope getLightsOutNotifController()104 LightsOutNotifController getLightsOutNotifController(); 105 106 /** */ 107 @StatusBarFragmentScope getStatusBarDemoMode()108 StatusBarDemoMode getStatusBarDemoMode(); 109 110 /** */ 111 @StatusBarFragmentScope getPhoneStatusBarTransitions()112 PhoneStatusBarTransitions getPhoneStatusBarTransitions(); 113 114 /** */ getStartables()115 Set<Startable> getStartables(); 116 117 /** */ getBoundsProvider()118 StatusBarBoundsProvider getBoundsProvider(); 119 } 120