其中左侧为 TASKBAR 右侧为 NavigationBar
Launcher 中TaskBar的显示控制在 packages\apps\Launcher3\src\com\android\launcher3\config\FeatureFlags.java
public static final BooleanFlag ENABLE_TASKBAR = getDebugFlag( "ENABLE_TASKBAR", false, "Allows a system Taskbar to be shown on larger devices.");
packages\apps\Launcher3\src\com\android\launcher3\DeviceProfile.java 使用 ENABLE_TASKBAR
isTablet = info.isTablet(windowBounds);
isTaskbarPresent = isTablet && ApiWrapper.TASKBAR_DRAWN_IN_PROCESS && FeatureFlags.ENABLE_TASKBAR.get();
if (isTaskbarPresent) {
taskbarSize = res.getDimensionPixelSize(R.dimen.taskbar_size);
}
在 systemUI里 也有相关的控制
/** @return {@code true} if taskbar is enabled, false otherwise */ private boolean initializeTaskbarIfNecessary() { if (mIsTablet) { // Remove navigation bar when taskbar is showing removeNavigationBar(mContext.getDisplayId()); mTaskbarDelegate.init(mContext.getDisplayId()); } else { mTaskbarDelegate.destroy(); } return mIsTablet; }
mIsTablet = isTablet(mContext);
frameworks\base\packages\SystemUI\shared\src\com\android\systemui\shared\recents\utilities\Utilities.java
/** @return whether or not {@param context} represents that of a large screen device or not */ @TargetApi(Build.VERSION_CODES.R) public static boolean isTablet(Context context) { final WindowManager windowManager = context.getSystemService(WindowManager.class); final Rect bounds = windowManager.getCurrentWindowMetrics().getBounds(); float smallestWidth = dpiFromPx(Math.min(bounds.width(), bounds.height()), context.getResources().getConfiguration().densityDpi); return smallestWidth >= TABLET_MIN_DPS; }
创建NavigationBars的时候会判断是否创建了Taskbar
// TODO(b/117478341): I use {@code includeDefaultDisplay} to make this method compatible to // CarStatusBar because they have their own nav bar. Think about a better way for it. /** * Creates navigation bars when car/status bar initializes. * * @param includeDefaultDisplay {@code true} to create navigation bar on default display. */ public void createNavigationBars(final boolean includeDefaultDisplay, RegisterStatusBarResult result) { updateAccessibilityButtonModeIfNeeded(); // Don't need to create nav bar on the default display if we initialize TaskBar. final boolean shouldCreateDefaultNavbar = includeDefaultDisplay && !initializeTaskbarIfNecessary(); Display[] displays = mDisplayManager.getDisplays(); for (Display display : displays) { if (shouldCreateDefaultNavbar || display.getDisplayId() != DEFAULT_DISPLAY) { createNavigationBar(display, null /* savedState */, result); } } }
/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java会调用 createNavigationBars
// TODO(b/117478341): This was left such that CarStatusBar can override this method. // Try to remove this. protected void createNavigationBar(@Nullable RegisterStatusBarResult result) { mNavigationBarController.createNavigationBars(true /* includeDefaultDisplay */, result); }
start----》createAndAddWindows---》makeStatusBarView----》createNavigationBar----》mNavigationBarController.createNavigationBars
public class StatusBar extends SystemUI implements ActivityStarter, LifecycleOwner {
public abstract class SystemUI implements Dumpable { protected final Context mContext; public SystemUI(Context context) { mContext = context; } public abstract void start();
frameworks\base\services\java\com\android\server\SystemServer.java 启动 startSystemUi
t.traceBegin("StartSystemUI"); try { startSystemUi(context, windowManagerF); } catch (Throwable e) { reportWtf("starting System UI", e); } t.traceEnd();
private static void startSystemUi(Context context, WindowManagerService windowManager) { PackageManagerInternal pm = LocalServices.getService(PackageManagerInternal.class); Intent intent = new Intent(); intent.setComponent(pm.getSystemUiServiceComponent()); intent.addFlags(Intent.FLAG_DEBUG_TRIAGED_MISSING); //Slog.d(TAG, "Starting service: " + intent); context.startServiceAsUser(intent, UserHandle.SYSTEM); windowManager.onSystemUiStarted(); }
frameworks\base\services\core\java\com\android\server\pm\PackageManagerService.java
@Override public ComponentName getSystemUiServiceComponent() { return ComponentName.unflattenFromString(mContext.getResources().getString( com.android.internal.R.string.config_systemUIServiceComponent)); }
frameworks\base\core\res\res\values\config.xml
<!-- SystemUi service component --> <string name="config_systemUIServiceComponent" translatable="false" >com.android.systemui/com.android.systemui.SystemUIService</string>
frameworks\base\packages\SystemUI\src\com\android\systemui\SystemUIService.java
@Override public void onCreate() { super.onCreate(); // Start all of SystemUI ((SystemUIApplication) getApplication()).startServicesIfNeeded(); // Finish initializing dump logic mLogBufferFreezer.attach(mBroadcastDispatcher); // If configured, set up a battery notification if (getResources().getBoolean(R.bool.config_showNotificationForUnknownBatteryState)) { mBatteryStateNotifier.startListening(); } // For debugging RescueParty if (Build.IS_DEBUGGABLE && SystemProperties.getBoolean("debug.crash_sysui", false)) { throw new RuntimeException(); } if (Build.IS_DEBUGGABLE) { // b/71353150 - looking for leaked binder proxies BinderInternal.nSetBinderProxyCountEnabled(true); BinderInternal.nSetBinderProxyCountWatermarks(1000,900); BinderInternal.setBinderProxyCountCallback( new BinderInternal.BinderProxyLimitListener() { @Override public void onLimitReached(int uid) { Slog.w(SystemUIApplication.TAG, "uid " + uid + " sent too many Binder proxies to uid " + Process.myUid()); } }, mMainHandler); } // Bind the dump service so we can dump extra info during a bug report startServiceAsUser( new Intent(getApplicationContext(), SystemUIAuxiliaryDumpService.class), UserHandle.SYSTEM); }
frameworks\base\packages\SystemUI\src\com\android\systemui\SystemUIApplication.java
public void startServicesIfNeeded() { String[] names = SystemUIFactory.getInstance().getSystemUIServiceComponents(getResources()); startServicesIfNeeded(/* metricsPrefix= */ "StartServices", names); }
frameworks\base\packages\SystemUI\src\com\android\systemui\SystemUIFactory.java
public String[] getSystemUIServiceComponents(Resources resources) { return resources.getStringArray(R.array.config_systemUIServiceComponents); }
frameworks\base\packages\SystemUI\res\values\config.xml
<!-- SystemUI Services: The classes of the stuff to start. --> <string-array name="config_systemUIServiceComponents" translatable="false"> <item>com.android.systemui.util.NotificationChannels</item> <item>com.android.systemui.keyguard.KeyguardViewMediator</item> <item>com.android.systemui.recents.Recents</item> <item>com.android.systemui.volume.VolumeUI</item> <item>com.android.systemui.statusbar.phone.StatusBar</item> <item>com.android.systemui.usb.StorageNotification</item> <item>com.android.systemui.power.PowerUI</item> <item>com.android.systemui.media.RingtonePlayer</item> <item>com.android.systemui.keyboard.KeyboardUI</item> <item>com.android.systemui.shortcut.ShortcutKeyDispatcher</item> <item>@string/config_systemUIVendorServiceComponent</item> <item>com.android.systemui.util.leak.GarbageMonitor$Service</item> <item>com.android.systemui.LatencyTester</item> <item>com.android.systemui.globalactions.GlobalActionsComponent</item> <item>com.android.systemui.ScreenDecorations</item> <item>com.android.systemui.biometrics.AuthController</item> <item>com.android.systemui.SliceBroadcastRelayHandler</item> <item>com.android.systemui.statusbar.notification.InstantAppNotifier</item> <item>com.android.systemui.theme.ThemeOverlayController</item> <item>com.android.systemui.accessibility.WindowMagnification</item> <item>com.android.systemui.accessibility.SystemActions</item> <item>com.android.systemui.toast.ToastUI</item> <item>com.android.systemui.wmshell.WMShell</item> </string-array>
private void startServicesIfNeeded(String metricsPrefix, String[] services) { if (mServicesStarted) { return; } mServices = new SystemUI[services.length]; if (!mBootCompleteCache.isBootComplete()) { // check to see if maybe it was already completed long before we began // see ActivityManagerService.finishBooting() if ("1".equals(SystemProperties.get("sys.boot_completed"))) { mBootCompleteCache.setBootComplete(); if (DEBUG) { Log.v(TAG, "BOOT_COMPLETED was already sent"); } } } final DumpManager dumpManager = mSysUIComponent.createDumpManager(); Log.v(TAG, "Starting SystemUI services for user " + Process.myUserHandle().getIdentifier() + "."); TimingsTraceLog log = new TimingsTraceLog("SystemUIBootTiming", Trace.TRACE_TAG_APP); log.traceBegin(metricsPrefix); final int N = services.length; for (int i = 0; i < N; i++) { String clsName = services[i]; if (DEBUG) Log.d(TAG, "loading: " + clsName); log.traceBegin(metricsPrefix + clsName); long ti = System.currentTimeMillis(); try { SystemUI obj = mComponentHelper.resolveSystemUI(clsName); if (obj == null) { Constructor constructor = Class.forName(clsName).getConstructor(Context.class); obj = (SystemUI) constructor.newInstance(this); } mServices[i] = obj; } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException ex) { throw new RuntimeException(ex); } if (DEBUG) Log.d(TAG, "running: " + mServices[i]); mServices[i].start(); log.traceEnd(); // Warn if initialization of component takes too long ti = System.currentTimeMillis() - ti; if (ti > 1000) { Log.w(TAG, "Initialization of " + clsName + " took " + ti + " ms"); } if (mBootCompleteCache.isBootComplete()) { mServices[i].onBootCompleted(); } dumpManager.registerDumpable(mServices[i].getClass().getName(), mServices[i]); } mSysUIComponent.getInitController().executePostInitTasks(); log.traceEnd(); mServicesStarted = true; }
标签:12,java,Tablet,public,SystemUI,靠右,android,com,systemui From: https://www.cnblogs.com/wanglongjiang/p/17638643.html