Loading packages/SystemUI/src/com/android/systemui/fragments/ExtensionFragmentListener.java +14 −4 Original line number Diff line number Diff line Loading @@ -37,9 +37,14 @@ public class ExtensionFragmentListener<T extends FragmentBase> implements Consum private final int mId; private String mOldClass; private ExtensionFragmentListener(View view, String tag, int id, Extension<T> extension) { private ExtensionFragmentListener( FragmentService fragmentService, View view, String tag, int id, Extension<T> extension) { mTag = tag; mFragmentHostManager = FragmentHostManager.get(view); mFragmentHostManager = fragmentService.getFragmentHostManager(view); mExtension = extension; mId = id; mFragmentHostManager.getFragmentManager().beginTransaction() Loading @@ -61,8 +66,13 @@ public class ExtensionFragmentListener<T extends FragmentBase> implements Consum mExtension.clearItem(true); } public static <T> void attachExtensonToFragment(View view, String tag, int id, public static <T> void attachExtensonToFragment( FragmentService fragmentService, View view, String tag, int id, Extension<T> extension) { extension.addCallback(new ExtensionFragmentListener(view, tag, id, extension)); extension.addCallback( new ExtensionFragmentListener(fragmentService, view, tag, id, extension)); } } packages/SystemUI/src/com/android/systemui/fragments/FragmentHostManager.java +17 −16 Original line number Diff line number Diff line Loading @@ -36,7 +36,6 @@ import android.view.View; import androidx.annotation.NonNull; import com.android.settingslib.applications.InterestingConfigChanges; import com.android.systemui.Dependency; import com.android.systemui.plugins.Plugin; import com.android.systemui.util.leak.LeakDetector; Loading @@ -46,12 +45,17 @@ import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.HashMap; import dagger.assisted.Assisted; import dagger.assisted.AssistedFactory; import dagger.assisted.AssistedInject; public class FragmentHostManager { private final Handler mHandler = new Handler(Looper.getMainLooper()); private final Context mContext; private final HashMap<String, ArrayList<FragmentListener>> mListeners = new HashMap<>(); private final View mRootView; private final LeakDetector mLeakDetector; private final InterestingConfigChanges mConfigChanges = new InterestingConfigChanges( ActivityInfo.CONFIG_FONT_SCALE | ActivityInfo.CONFIG_LOCALE | ActivityInfo.CONFIG_ASSETS_PATHS); Loading @@ -61,14 +65,24 @@ public class FragmentHostManager { private FragmentController mFragments; private FragmentLifecycleCallbacks mLifecycleCallbacks; FragmentHostManager(FragmentService manager, View rootView) { @AssistedInject FragmentHostManager( @Assisted View rootView, FragmentService manager, LeakDetector leakDetector) { mContext = rootView.getContext(); mManager = manager; mRootView = rootView; mLeakDetector = leakDetector; mConfigChanges.applyNewConfig(mContext.getResources()); createFragmentHost(null); } @AssistedFactory public interface Factory { FragmentHostManager create(View rootView); } private void createFragmentHost(Parcelable savedState) { mFragments = FragmentController.createController(new HostCallbacks()); mFragments.attachHost(null); Loading @@ -86,7 +100,7 @@ public class FragmentHostManager { @Override public void onFragmentDestroyed(FragmentManager fm, Fragment f) { Dependency.get(LeakDetector.class).trackGarbage(f); mLeakDetector.trackGarbage(f); } }; mFragments.getFragmentManager().registerFragmentLifecycleCallbacks(mLifecycleCallbacks, Loading Loading @@ -211,19 +225,6 @@ public class FragmentHostManager { } } public static FragmentHostManager get(View view) { try { return Dependency.get(FragmentService.class).getFragmentHostManager(view); } catch (ClassCastException e) { // TODO: Some auto handling here? throw e; } } public static void removeAndDestroy(View view) { Dependency.get(FragmentService.class).removeAndDestroy(view); } public void reloadFragments() { Trace.beginSection("FrargmentHostManager#reloadFragments"); // Save the old state. Loading packages/SystemUI/src/com/android/systemui/fragments/FragmentService.java +4 −1 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ public class FragmentService implements Dumpable { */ private final ArrayMap<String, FragmentInstantiationInfo> mInjectionMap = new ArrayMap<>(); private final Handler mHandler = new Handler(); private final FragmentHostManager.Factory mFragmentHostManagerFactory; private ConfigurationController.ConfigurationListener mConfigurationListener = new ConfigurationController.ConfigurationListener() { Loading @@ -67,8 +68,10 @@ public class FragmentService implements Dumpable { @Inject public FragmentService( FragmentCreator.Factory fragmentCreatorFactory, FragmentHostManager.Factory fragmentHostManagerFactory, ConfigurationController configurationController, DumpManager dumpManager) { mFragmentHostManagerFactory = fragmentHostManagerFactory; addFragmentInstantiationProvider(fragmentCreatorFactory.build()); configurationController.addCallback(mConfigurationListener); Loading Loading @@ -152,7 +155,7 @@ public class FragmentService implements Dumpable { public FragmentHostState(View view) { mView = view; mFragmentHostManager = new FragmentHostManager(FragmentService.this, mView); mFragmentHostManager = mFragmentHostManagerFactory.create(mView); } public void sendConfigurationChange(Configuration newConfig) { Loading packages/SystemUI/src/com/android/systemui/shade/NotificationsQSContainerController.kt +4 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import com.android.systemui.R import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.flags.FeatureFlags import com.android.systemui.flags.Flags import com.android.systemui.fragments.FragmentService import com.android.systemui.navigationbar.NavigationModeController import com.android.systemui.plugins.qs.QS import com.android.systemui.plugins.qs.QSContainerController Loading @@ -54,6 +55,7 @@ class NotificationsQSContainerController @Inject constructor( private val largeScreenShadeHeaderController: LargeScreenShadeHeaderController, private val shadeExpansionStateManager: ShadeExpansionStateManager, private val featureFlags: FeatureFlags, private val fragmentService: FragmentService, @Main private val delayableExecutor: DelayableExecutor ) : ViewController<NotificationsQuickSettingsContainer>(view), QSContainerController { Loading Loading @@ -128,6 +130,7 @@ class NotificationsQSContainerController @Inject constructor( mView.setInsetsChangedListener(delayedInsetSetter) mView.setQSFragmentAttachedListener { qs: QS -> qs.setContainerController(this) } mView.setConfigurationChangedListener { updateResources() } fragmentService.getFragmentHostManager(mView).addTagListener(QS.TAG, mView) } override fun onViewDetached() { Loading @@ -136,6 +139,7 @@ class NotificationsQSContainerController @Inject constructor( mView.removeOnInsetsChangedListener() mView.removeQSFragmentAttachedListener() mView.setConfigurationChangedListener(null) fragmentService.getFragmentHostManager(mView).removeTagListener(QS.TAG, mView) } fun updateResources() { Loading packages/SystemUI/src/com/android/systemui/shade/NotificationsQuickSettingsContainer.java +0 −13 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintSet; import com.android.systemui.R; import com.android.systemui.fragments.FragmentHostManager; import com.android.systemui.fragments.FragmentHostManager.FragmentListener; import com.android.systemui.plugins.qs.QS; import com.android.systemui.statusbar.notification.AboveShelfObserver; Loading Loading @@ -132,18 +131,6 @@ public class NotificationsQuickSettingsContainer extends ConstraintLayout mQSFragmentAttachedListener = qs -> {}; } @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); FragmentHostManager.get(this).addTagListener(QS.TAG, this); } @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); FragmentHostManager.get(this).removeTagListener(QS.TAG, this); } @Override public WindowInsets onApplyWindowInsets(WindowInsets insets) { mInsetsChangedListener.accept(insets); Loading Loading
packages/SystemUI/src/com/android/systemui/fragments/ExtensionFragmentListener.java +14 −4 Original line number Diff line number Diff line Loading @@ -37,9 +37,14 @@ public class ExtensionFragmentListener<T extends FragmentBase> implements Consum private final int mId; private String mOldClass; private ExtensionFragmentListener(View view, String tag, int id, Extension<T> extension) { private ExtensionFragmentListener( FragmentService fragmentService, View view, String tag, int id, Extension<T> extension) { mTag = tag; mFragmentHostManager = FragmentHostManager.get(view); mFragmentHostManager = fragmentService.getFragmentHostManager(view); mExtension = extension; mId = id; mFragmentHostManager.getFragmentManager().beginTransaction() Loading @@ -61,8 +66,13 @@ public class ExtensionFragmentListener<T extends FragmentBase> implements Consum mExtension.clearItem(true); } public static <T> void attachExtensonToFragment(View view, String tag, int id, public static <T> void attachExtensonToFragment( FragmentService fragmentService, View view, String tag, int id, Extension<T> extension) { extension.addCallback(new ExtensionFragmentListener(view, tag, id, extension)); extension.addCallback( new ExtensionFragmentListener(fragmentService, view, tag, id, extension)); } }
packages/SystemUI/src/com/android/systemui/fragments/FragmentHostManager.java +17 −16 Original line number Diff line number Diff line Loading @@ -36,7 +36,6 @@ import android.view.View; import androidx.annotation.NonNull; import com.android.settingslib.applications.InterestingConfigChanges; import com.android.systemui.Dependency; import com.android.systemui.plugins.Plugin; import com.android.systemui.util.leak.LeakDetector; Loading @@ -46,12 +45,17 @@ import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.HashMap; import dagger.assisted.Assisted; import dagger.assisted.AssistedFactory; import dagger.assisted.AssistedInject; public class FragmentHostManager { private final Handler mHandler = new Handler(Looper.getMainLooper()); private final Context mContext; private final HashMap<String, ArrayList<FragmentListener>> mListeners = new HashMap<>(); private final View mRootView; private final LeakDetector mLeakDetector; private final InterestingConfigChanges mConfigChanges = new InterestingConfigChanges( ActivityInfo.CONFIG_FONT_SCALE | ActivityInfo.CONFIG_LOCALE | ActivityInfo.CONFIG_ASSETS_PATHS); Loading @@ -61,14 +65,24 @@ public class FragmentHostManager { private FragmentController mFragments; private FragmentLifecycleCallbacks mLifecycleCallbacks; FragmentHostManager(FragmentService manager, View rootView) { @AssistedInject FragmentHostManager( @Assisted View rootView, FragmentService manager, LeakDetector leakDetector) { mContext = rootView.getContext(); mManager = manager; mRootView = rootView; mLeakDetector = leakDetector; mConfigChanges.applyNewConfig(mContext.getResources()); createFragmentHost(null); } @AssistedFactory public interface Factory { FragmentHostManager create(View rootView); } private void createFragmentHost(Parcelable savedState) { mFragments = FragmentController.createController(new HostCallbacks()); mFragments.attachHost(null); Loading @@ -86,7 +100,7 @@ public class FragmentHostManager { @Override public void onFragmentDestroyed(FragmentManager fm, Fragment f) { Dependency.get(LeakDetector.class).trackGarbage(f); mLeakDetector.trackGarbage(f); } }; mFragments.getFragmentManager().registerFragmentLifecycleCallbacks(mLifecycleCallbacks, Loading Loading @@ -211,19 +225,6 @@ public class FragmentHostManager { } } public static FragmentHostManager get(View view) { try { return Dependency.get(FragmentService.class).getFragmentHostManager(view); } catch (ClassCastException e) { // TODO: Some auto handling here? throw e; } } public static void removeAndDestroy(View view) { Dependency.get(FragmentService.class).removeAndDestroy(view); } public void reloadFragments() { Trace.beginSection("FrargmentHostManager#reloadFragments"); // Save the old state. Loading
packages/SystemUI/src/com/android/systemui/fragments/FragmentService.java +4 −1 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ public class FragmentService implements Dumpable { */ private final ArrayMap<String, FragmentInstantiationInfo> mInjectionMap = new ArrayMap<>(); private final Handler mHandler = new Handler(); private final FragmentHostManager.Factory mFragmentHostManagerFactory; private ConfigurationController.ConfigurationListener mConfigurationListener = new ConfigurationController.ConfigurationListener() { Loading @@ -67,8 +68,10 @@ public class FragmentService implements Dumpable { @Inject public FragmentService( FragmentCreator.Factory fragmentCreatorFactory, FragmentHostManager.Factory fragmentHostManagerFactory, ConfigurationController configurationController, DumpManager dumpManager) { mFragmentHostManagerFactory = fragmentHostManagerFactory; addFragmentInstantiationProvider(fragmentCreatorFactory.build()); configurationController.addCallback(mConfigurationListener); Loading Loading @@ -152,7 +155,7 @@ public class FragmentService implements Dumpable { public FragmentHostState(View view) { mView = view; mFragmentHostManager = new FragmentHostManager(FragmentService.this, mView); mFragmentHostManager = mFragmentHostManagerFactory.create(mView); } public void sendConfigurationChange(Configuration newConfig) { Loading
packages/SystemUI/src/com/android/systemui/shade/NotificationsQSContainerController.kt +4 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import com.android.systemui.R import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.flags.FeatureFlags import com.android.systemui.flags.Flags import com.android.systemui.fragments.FragmentService import com.android.systemui.navigationbar.NavigationModeController import com.android.systemui.plugins.qs.QS import com.android.systemui.plugins.qs.QSContainerController Loading @@ -54,6 +55,7 @@ class NotificationsQSContainerController @Inject constructor( private val largeScreenShadeHeaderController: LargeScreenShadeHeaderController, private val shadeExpansionStateManager: ShadeExpansionStateManager, private val featureFlags: FeatureFlags, private val fragmentService: FragmentService, @Main private val delayableExecutor: DelayableExecutor ) : ViewController<NotificationsQuickSettingsContainer>(view), QSContainerController { Loading Loading @@ -128,6 +130,7 @@ class NotificationsQSContainerController @Inject constructor( mView.setInsetsChangedListener(delayedInsetSetter) mView.setQSFragmentAttachedListener { qs: QS -> qs.setContainerController(this) } mView.setConfigurationChangedListener { updateResources() } fragmentService.getFragmentHostManager(mView).addTagListener(QS.TAG, mView) } override fun onViewDetached() { Loading @@ -136,6 +139,7 @@ class NotificationsQSContainerController @Inject constructor( mView.removeOnInsetsChangedListener() mView.removeQSFragmentAttachedListener() mView.setConfigurationChangedListener(null) fragmentService.getFragmentHostManager(mView).removeTagListener(QS.TAG, mView) } fun updateResources() { Loading
packages/SystemUI/src/com/android/systemui/shade/NotificationsQuickSettingsContainer.java +0 −13 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintSet; import com.android.systemui.R; import com.android.systemui.fragments.FragmentHostManager; import com.android.systemui.fragments.FragmentHostManager.FragmentListener; import com.android.systemui.plugins.qs.QS; import com.android.systemui.statusbar.notification.AboveShelfObserver; Loading Loading @@ -132,18 +131,6 @@ public class NotificationsQuickSettingsContainer extends ConstraintLayout mQSFragmentAttachedListener = qs -> {}; } @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); FragmentHostManager.get(this).addTagListener(QS.TAG, this); } @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); FragmentHostManager.get(this).removeTagListener(QS.TAG, this); } @Override public WindowInsets onApplyWindowInsets(WindowInsets insets) { mInsetsChangedListener.accept(insets); Loading