Loading packages/SystemUI/plugin/Android.mk +10 −0 Original line number Original line Diff line number Diff line Loading @@ -27,3 +27,13 @@ LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res LOCAL_JAR_EXCLUDE_FILES := none LOCAL_JAR_EXCLUDE_FILES := none include $(BUILD_STATIC_JAVA_LIBRARY) include $(BUILD_STATIC_JAVA_LIBRARY) include $(CLEAR_VARS) # Dummy to generate .toc files. LOCAL_PACKAGE_NAME := PluginDummyLib LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_JAVA_LIBRARIES := SystemUIPluginLib include $(BUILD_PACKAGE) packages/SystemUI/plugin/ExamplePlugin/src/com/android/systemui/plugin/testoverlayplugin/SampleOverlayPlugin.java +37 −0 Original line number Original line Diff line number Diff line Loading @@ -15,11 +15,14 @@ package com.android.systemui.plugin.testoverlayplugin; package com.android.systemui.plugin.testoverlayplugin; import android.content.Context; import android.content.Context; import android.graphics.Rect; import android.util.Log; import android.util.Log; import android.view.LayoutInflater; import android.view.LayoutInflater; import android.view.View; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup; import android.view.ViewTreeObserver.InternalInsetsInfo; import android.view.ViewTreeObserver.OnComputeInternalInsetsListener; import com.android.systemui.plugins.OverlayPlugin; import com.android.systemui.plugins.OverlayPlugin; public class SampleOverlayPlugin implements OverlayPlugin { public class SampleOverlayPlugin implements OverlayPlugin { Loading @@ -28,6 +31,9 @@ public class SampleOverlayPlugin implements OverlayPlugin { private View mStatusBarView; private View mStatusBarView; private View mNavBarView; private View mNavBarView; private boolean mInputSetup; private boolean mCollapseDesired; private float mStatusBarHeight; @Override @Override public int getVersion() { public int getVersion() { Loading @@ -43,6 +49,10 @@ public class SampleOverlayPlugin implements OverlayPlugin { @Override @Override public void onDestroy() { public void onDestroy() { if (mInputSetup) { mStatusBarView.getViewTreeObserver().removeOnComputeInternalInsetsListener( onComputeInternalInsetsListener); } Log.d(TAG, "onDestroy"); Log.d(TAG, "onDestroy"); if (mStatusBarView != null) { if (mStatusBarView != null) { mStatusBarView.post( mStatusBarView.post( Loading @@ -57,6 +67,9 @@ public class SampleOverlayPlugin implements OverlayPlugin { public void setup(View statusBar, View navBar) { public void setup(View statusBar, View navBar) { Log.d(TAG, "Setup"); Log.d(TAG, "Setup"); int id = mPluginContext.getResources().getIdentifier("status_bar_height", "dimen", "android"); mStatusBarHeight = mPluginContext.getResources().getDimension(id); if (statusBar instanceof ViewGroup) { if (statusBar instanceof ViewGroup) { mStatusBarView = LayoutInflater.from(mPluginContext) mStatusBarView = LayoutInflater.from(mPluginContext) .inflate(R.layout.colored_overlay, (ViewGroup) statusBar, false); .inflate(R.layout.colored_overlay, (ViewGroup) statusBar, false); Loading @@ -68,4 +81,28 @@ public class SampleOverlayPlugin implements OverlayPlugin { ((ViewGroup) navBar).addView(mNavBarView); ((ViewGroup) navBar).addView(mNavBarView); } } } } @Override public void setCollapseDesired(boolean collapseDesired) { mCollapseDesired = collapseDesired; } @Override public boolean holdStatusBarOpen() { if (!mInputSetup) { mInputSetup = true; mStatusBarView.getViewTreeObserver().addOnComputeInternalInsetsListener( onComputeInternalInsetsListener); } return true; } final OnComputeInternalInsetsListener onComputeInternalInsetsListener = inoutInfo -> { inoutInfo.setTouchableInsets(InternalInsetsInfo.TOUCHABLE_INSETS_REGION); if (mCollapseDesired) { inoutInfo.touchableRegion.set(new Rect(0, 0, 50000, (int) mStatusBarHeight)); } else { inoutInfo.touchableRegion.set(new Rect(0, 0, 50000, 50000)); } }; } } packages/SystemUI/plugin/src/com/android/systemui/plugins/OverlayPlugin.java +10 −0 Original line number Original line Diff line number Diff line Loading @@ -21,4 +21,14 @@ public interface OverlayPlugin extends Plugin { int VERSION = 1; int VERSION = 1; void setup(View statusBar, View navBar); void setup(View statusBar, View navBar); default boolean holdStatusBarOpen() { return false; } /** * Only called if the plugin has returned true to holdStatusBarOpen(). */ default void setCollapseDesired(boolean collapseDesired) { } } } packages/SystemUI/src/com/android/systemui/Dependency.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -27,6 +27,7 @@ import com.android.systemui.assist.AssistManager; import com.android.systemui.plugins.PluginManager; import com.android.systemui.plugins.PluginManager; import com.android.systemui.statusbar.phone.ManagedProfileController; import com.android.systemui.statusbar.phone.ManagedProfileController; import com.android.systemui.statusbar.phone.ManagedProfileControllerImpl; import com.android.systemui.statusbar.phone.ManagedProfileControllerImpl; import com.android.systemui.statusbar.phone.StatusBarWindowManager; import com.android.systemui.statusbar.policy.AccessibilityController; import com.android.systemui.statusbar.policy.AccessibilityController; import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.statusbar.policy.BatteryControllerImpl; import com.android.systemui.statusbar.policy.BatteryControllerImpl; Loading Loading @@ -183,6 +184,9 @@ public class Dependency extends SystemUI { mProviders.put(TunerService.class.getName(), () -> mProviders.put(TunerService.class.getName(), () -> new TunerService(mContext)); new TunerService(mContext)); mProviders.put(StatusBarWindowManager.class.getName(), () -> new StatusBarWindowManager(mContext)); // Put all dependencies above here so the factory can override them if it wants. // Put all dependencies above here so the factory can override them if it wants. SystemUIFactory.getInstance().injectDependencies(mProviders, mContext); SystemUIFactory.getInstance().injectDependencies(mProviders, mContext); } } Loading packages/SystemUI/src/com/android/systemui/SystemUIApplication.java +31 −12 Original line number Original line Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.content.res.Configuration; import android.os.Process; import android.os.Process; import android.os.SystemProperties; import android.os.SystemProperties; import android.os.UserHandle; import android.os.UserHandle; import android.util.ArraySet; import android.util.Log; import android.util.Log; import com.android.systemui.fragments.FragmentService; import com.android.systemui.fragments.FragmentService; Loading @@ -43,6 +44,7 @@ import com.android.systemui.shortcut.ShortcutKeyDispatcher; import com.android.systemui.stackdivider.Divider; import com.android.systemui.stackdivider.Divider; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.phone.StatusBarWindowManager; import com.android.systemui.tuner.TunerService; import com.android.systemui.tuner.TunerService; import com.android.systemui.usb.StorageNotification; import com.android.systemui.usb.StorageNotification; import com.android.systemui.util.NotificationChannels; import com.android.systemui.util.NotificationChannels; Loading Loading @@ -149,7 +151,6 @@ public class SystemUIApplication extends Application implements SysUiServiceProv * Makes sure that all the SystemUI services are running. If they are already running, this is a * Makes sure that all the SystemUI services are running. If they are already running, this is a * no-op. This is needed to conditinally start all the services, as we only need to have it in * no-op. This is needed to conditinally start all the services, as we only need to have it in * the main process. * the main process. * * <p>This method must only be called from the main thread.</p> * <p>This method must only be called from the main thread.</p> */ */ public void startServicesIfNeeded() { public void startServicesIfNeeded() { Loading @@ -160,7 +161,6 @@ public class SystemUIApplication extends Application implements SysUiServiceProv * Ensures that all the Secondary user SystemUI services are running. If they are already * Ensures that all the Secondary user SystemUI services are running. If they are already * running, this is a no-op. This is needed to conditinally start all the services, as we only * running, this is a no-op. This is needed to conditinally start all the services, as we only * need to have it in the main process. * need to have it in the main process. * * <p>This method must only be called from the main thread.</p> * <p>This method must only be called from the main thread.</p> */ */ void startSecondaryUserServicesIfNeeded() { void startSecondaryUserServicesIfNeeded() { Loading Loading @@ -207,6 +207,8 @@ public class SystemUIApplication extends Application implements SysUiServiceProv } } Dependency.get(PluginManager.class).addPluginListener(OverlayPlugin.ACTION, Dependency.get(PluginManager.class).addPluginListener(OverlayPlugin.ACTION, new PluginListener<OverlayPlugin>() { new PluginListener<OverlayPlugin>() { private ArraySet<OverlayPlugin> mOverlays; @Override @Override public void onPluginConnected(OverlayPlugin plugin, Context pluginContext) { public void onPluginConnected(OverlayPlugin plugin, Context pluginContext) { StatusBar statusBar = getComponent(StatusBar.class); StatusBar statusBar = getComponent(StatusBar.class); Loading @@ -214,6 +216,23 @@ public class SystemUIApplication extends Application implements SysUiServiceProv plugin.setup(statusBar.getStatusBarWindow(), plugin.setup(statusBar.getStatusBarWindow(), statusBar.getNavigationBarView()); statusBar.getNavigationBarView()); } } // Lazy init. if (mOverlays == null) mOverlays = new ArraySet<>(); if (plugin.holdStatusBarOpen()) { mOverlays.add(plugin); Dependency.get(StatusBarWindowManager.class).setStateListener(b -> mOverlays.forEach(o -> o.setCollapseDesired(b))); Dependency.get(StatusBarWindowManager.class).setForcePluginOpen( mOverlays.size() != 0); } } @Override public void onPluginDisconnected(OverlayPlugin plugin) { mOverlays.remove(plugin); Dependency.get(StatusBarWindowManager.class).setForcePluginOpen( mOverlays.size() != 0); } } }, OverlayPlugin.VERSION, true /* Allow multiple plugins */); }, OverlayPlugin.VERSION, true /* Allow multiple plugins */); Loading Loading
packages/SystemUI/plugin/Android.mk +10 −0 Original line number Original line Diff line number Diff line Loading @@ -27,3 +27,13 @@ LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res LOCAL_JAR_EXCLUDE_FILES := none LOCAL_JAR_EXCLUDE_FILES := none include $(BUILD_STATIC_JAVA_LIBRARY) include $(BUILD_STATIC_JAVA_LIBRARY) include $(CLEAR_VARS) # Dummy to generate .toc files. LOCAL_PACKAGE_NAME := PluginDummyLib LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_JAVA_LIBRARIES := SystemUIPluginLib include $(BUILD_PACKAGE)
packages/SystemUI/plugin/ExamplePlugin/src/com/android/systemui/plugin/testoverlayplugin/SampleOverlayPlugin.java +37 −0 Original line number Original line Diff line number Diff line Loading @@ -15,11 +15,14 @@ package com.android.systemui.plugin.testoverlayplugin; package com.android.systemui.plugin.testoverlayplugin; import android.content.Context; import android.content.Context; import android.graphics.Rect; import android.util.Log; import android.util.Log; import android.view.LayoutInflater; import android.view.LayoutInflater; import android.view.View; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup; import android.view.ViewTreeObserver.InternalInsetsInfo; import android.view.ViewTreeObserver.OnComputeInternalInsetsListener; import com.android.systemui.plugins.OverlayPlugin; import com.android.systemui.plugins.OverlayPlugin; public class SampleOverlayPlugin implements OverlayPlugin { public class SampleOverlayPlugin implements OverlayPlugin { Loading @@ -28,6 +31,9 @@ public class SampleOverlayPlugin implements OverlayPlugin { private View mStatusBarView; private View mStatusBarView; private View mNavBarView; private View mNavBarView; private boolean mInputSetup; private boolean mCollapseDesired; private float mStatusBarHeight; @Override @Override public int getVersion() { public int getVersion() { Loading @@ -43,6 +49,10 @@ public class SampleOverlayPlugin implements OverlayPlugin { @Override @Override public void onDestroy() { public void onDestroy() { if (mInputSetup) { mStatusBarView.getViewTreeObserver().removeOnComputeInternalInsetsListener( onComputeInternalInsetsListener); } Log.d(TAG, "onDestroy"); Log.d(TAG, "onDestroy"); if (mStatusBarView != null) { if (mStatusBarView != null) { mStatusBarView.post( mStatusBarView.post( Loading @@ -57,6 +67,9 @@ public class SampleOverlayPlugin implements OverlayPlugin { public void setup(View statusBar, View navBar) { public void setup(View statusBar, View navBar) { Log.d(TAG, "Setup"); Log.d(TAG, "Setup"); int id = mPluginContext.getResources().getIdentifier("status_bar_height", "dimen", "android"); mStatusBarHeight = mPluginContext.getResources().getDimension(id); if (statusBar instanceof ViewGroup) { if (statusBar instanceof ViewGroup) { mStatusBarView = LayoutInflater.from(mPluginContext) mStatusBarView = LayoutInflater.from(mPluginContext) .inflate(R.layout.colored_overlay, (ViewGroup) statusBar, false); .inflate(R.layout.colored_overlay, (ViewGroup) statusBar, false); Loading @@ -68,4 +81,28 @@ public class SampleOverlayPlugin implements OverlayPlugin { ((ViewGroup) navBar).addView(mNavBarView); ((ViewGroup) navBar).addView(mNavBarView); } } } } @Override public void setCollapseDesired(boolean collapseDesired) { mCollapseDesired = collapseDesired; } @Override public boolean holdStatusBarOpen() { if (!mInputSetup) { mInputSetup = true; mStatusBarView.getViewTreeObserver().addOnComputeInternalInsetsListener( onComputeInternalInsetsListener); } return true; } final OnComputeInternalInsetsListener onComputeInternalInsetsListener = inoutInfo -> { inoutInfo.setTouchableInsets(InternalInsetsInfo.TOUCHABLE_INSETS_REGION); if (mCollapseDesired) { inoutInfo.touchableRegion.set(new Rect(0, 0, 50000, (int) mStatusBarHeight)); } else { inoutInfo.touchableRegion.set(new Rect(0, 0, 50000, 50000)); } }; } }
packages/SystemUI/plugin/src/com/android/systemui/plugins/OverlayPlugin.java +10 −0 Original line number Original line Diff line number Diff line Loading @@ -21,4 +21,14 @@ public interface OverlayPlugin extends Plugin { int VERSION = 1; int VERSION = 1; void setup(View statusBar, View navBar); void setup(View statusBar, View navBar); default boolean holdStatusBarOpen() { return false; } /** * Only called if the plugin has returned true to holdStatusBarOpen(). */ default void setCollapseDesired(boolean collapseDesired) { } } }
packages/SystemUI/src/com/android/systemui/Dependency.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -27,6 +27,7 @@ import com.android.systemui.assist.AssistManager; import com.android.systemui.plugins.PluginManager; import com.android.systemui.plugins.PluginManager; import com.android.systemui.statusbar.phone.ManagedProfileController; import com.android.systemui.statusbar.phone.ManagedProfileController; import com.android.systemui.statusbar.phone.ManagedProfileControllerImpl; import com.android.systemui.statusbar.phone.ManagedProfileControllerImpl; import com.android.systemui.statusbar.phone.StatusBarWindowManager; import com.android.systemui.statusbar.policy.AccessibilityController; import com.android.systemui.statusbar.policy.AccessibilityController; import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.statusbar.policy.BatteryControllerImpl; import com.android.systemui.statusbar.policy.BatteryControllerImpl; Loading Loading @@ -183,6 +184,9 @@ public class Dependency extends SystemUI { mProviders.put(TunerService.class.getName(), () -> mProviders.put(TunerService.class.getName(), () -> new TunerService(mContext)); new TunerService(mContext)); mProviders.put(StatusBarWindowManager.class.getName(), () -> new StatusBarWindowManager(mContext)); // Put all dependencies above here so the factory can override them if it wants. // Put all dependencies above here so the factory can override them if it wants. SystemUIFactory.getInstance().injectDependencies(mProviders, mContext); SystemUIFactory.getInstance().injectDependencies(mProviders, mContext); } } Loading
packages/SystemUI/src/com/android/systemui/SystemUIApplication.java +31 −12 Original line number Original line Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.content.res.Configuration; import android.os.Process; import android.os.Process; import android.os.SystemProperties; import android.os.SystemProperties; import android.os.UserHandle; import android.os.UserHandle; import android.util.ArraySet; import android.util.Log; import android.util.Log; import com.android.systemui.fragments.FragmentService; import com.android.systemui.fragments.FragmentService; Loading @@ -43,6 +44,7 @@ import com.android.systemui.shortcut.ShortcutKeyDispatcher; import com.android.systemui.stackdivider.Divider; import com.android.systemui.stackdivider.Divider; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.phone.StatusBarWindowManager; import com.android.systemui.tuner.TunerService; import com.android.systemui.tuner.TunerService; import com.android.systemui.usb.StorageNotification; import com.android.systemui.usb.StorageNotification; import com.android.systemui.util.NotificationChannels; import com.android.systemui.util.NotificationChannels; Loading Loading @@ -149,7 +151,6 @@ public class SystemUIApplication extends Application implements SysUiServiceProv * Makes sure that all the SystemUI services are running. If they are already running, this is a * Makes sure that all the SystemUI services are running. If they are already running, this is a * no-op. This is needed to conditinally start all the services, as we only need to have it in * no-op. This is needed to conditinally start all the services, as we only need to have it in * the main process. * the main process. * * <p>This method must only be called from the main thread.</p> * <p>This method must only be called from the main thread.</p> */ */ public void startServicesIfNeeded() { public void startServicesIfNeeded() { Loading @@ -160,7 +161,6 @@ public class SystemUIApplication extends Application implements SysUiServiceProv * Ensures that all the Secondary user SystemUI services are running. If they are already * Ensures that all the Secondary user SystemUI services are running. If they are already * running, this is a no-op. This is needed to conditinally start all the services, as we only * running, this is a no-op. This is needed to conditinally start all the services, as we only * need to have it in the main process. * need to have it in the main process. * * <p>This method must only be called from the main thread.</p> * <p>This method must only be called from the main thread.</p> */ */ void startSecondaryUserServicesIfNeeded() { void startSecondaryUserServicesIfNeeded() { Loading Loading @@ -207,6 +207,8 @@ public class SystemUIApplication extends Application implements SysUiServiceProv } } Dependency.get(PluginManager.class).addPluginListener(OverlayPlugin.ACTION, Dependency.get(PluginManager.class).addPluginListener(OverlayPlugin.ACTION, new PluginListener<OverlayPlugin>() { new PluginListener<OverlayPlugin>() { private ArraySet<OverlayPlugin> mOverlays; @Override @Override public void onPluginConnected(OverlayPlugin plugin, Context pluginContext) { public void onPluginConnected(OverlayPlugin plugin, Context pluginContext) { StatusBar statusBar = getComponent(StatusBar.class); StatusBar statusBar = getComponent(StatusBar.class); Loading @@ -214,6 +216,23 @@ public class SystemUIApplication extends Application implements SysUiServiceProv plugin.setup(statusBar.getStatusBarWindow(), plugin.setup(statusBar.getStatusBarWindow(), statusBar.getNavigationBarView()); statusBar.getNavigationBarView()); } } // Lazy init. if (mOverlays == null) mOverlays = new ArraySet<>(); if (plugin.holdStatusBarOpen()) { mOverlays.add(plugin); Dependency.get(StatusBarWindowManager.class).setStateListener(b -> mOverlays.forEach(o -> o.setCollapseDesired(b))); Dependency.get(StatusBarWindowManager.class).setForcePluginOpen( mOverlays.size() != 0); } } @Override public void onPluginDisconnected(OverlayPlugin plugin) { mOverlays.remove(plugin); Dependency.get(StatusBarWindowManager.class).setForcePluginOpen( mOverlays.size() != 0); } } }, OverlayPlugin.VERSION, true /* Allow multiple plugins */); }, OverlayPlugin.VERSION, true /* Allow multiple plugins */); Loading