首页 > 其他分享 >Android 12 Tablet 任务栏及虚拟按键靠右问题

Android 12 Tablet 任务栏及虚拟按键靠右问题

时间:2023-08-17 19:34:40浏览次数:51  
标签:12 java Tablet public SystemUI 靠右 android com systemui

 其中左侧为 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;
    }

 

SystemUI启动流程_ck_67的博客-CSDN博客

标签:12,java,Tablet,public,SystemUI,靠右,android,com,systemui
From: https://www.cnblogs.com/wanglongjiang/p/17638643.html

相关文章

  • Linux centos7.6 在线及离线安装postgresql12 详细教程
    一、在线安装官网找到对应的版本PostgreSQL: https://www.postgresql.org/     1.配置yum源sudoyuminstall-yhttps://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm 2.在线安装PostgreSQLsudoyuminsta......
  • winserver2012安装.net3.5问题
    背景环境winserver2012r2,sqlserver2012因第三方公司开发用到sqlserver,只能安装window系统,但从win2012自带了.net4.5,.net3.5默认是没有的,即使从添加角色和功能向导去添加,也是报缺失源文件解决办法使用安装包离线安装,例如双击2012的iso文件,默认会变成可读盘符,所有的安装包在x:......
  • Kettle 连接失败 Oracle 数据库报 ora-12505 的解决方法(转)
      用kettle新建DB连接的时候总是报错,可是用plsql连接是可以连上,错误信息大致如下:错误连接数据库[MIS]:org.pentaho.di.core.exception.KettleDatabaseException:ErroroccuredwhiletryingtoconnecttothedatabaseErrorconnectingtodatabase:(usingclassorac......
  • C# Microsoft.Win32.TaskScheduler方式创建任务计划程序报错: System.ArgumentExceptio
    使用Microsoft.Win32.TaskScheduler创建任务计划程序可参考本人之前的一篇文章:https://www.cnblogs.com/log9527blog/p/17329755.html最新发现个别账户使用Microsoft.Win32.TaskScheduler创建任务计划程序报错:System.ArgumentException:(12,21):UserId:Account一种情况是账户......
  • 8-17|2023-08-16 12:33:55,972 [salt.master :1643][ERROR ][20321] Received
    该日志条目显示了来自于Saltminion(在这里标识为`[master]`,这可能是minion的名称或者是由于其他原因导致的日志格式)的错误,表示minion在执行一个函数时发生了异常。日志内容“`Theminionfunctioncausedanexception`”表示在minion端执行的特定Salt函数引发了一个错误或异常。......
  • 代码随想录算法训练营第十八天| 513.找树左下角的值 112. 路径总和 106.从中序与
     找树左下角的值     卡哥建议:本地递归偏难,反而迭代简单属于模板题, 两种方法掌握一下   题目链接/文章讲解/视频讲解:https://programmercarl.com/0513.%E6%89%BE%E6%A0%91%E5%B7%A6%E4%B8%8B%E8%A7%92%E7%9A%84%E5%80%BC.html   做题思路:   题目说......
  • 华为数通方向HCIP-DataCom H12-821题库(单选题:101-120)
    第101题可用于多种路由协议,由if-match和apply子句组成的路由选择工具是A、route-policyB、IP-PrefixC、commnityfilterD、as-path-filter答案:A解析:Route-policy(路由策略)是一个用于多种路由协议的工具,它由if-match子句和apply子句组成。if-match子句用于匹配路由属性条件,而apply......
  • 二手天选4(12700h+4060)的一些测试
    R23单核屏幕这个是我4k屏幕的数据:自己加的2t固态跑分:天选自带硬盘跑分:......
  • 12 个不可错过的 Vue UI 组件库,请查收!
    Vue.js是一个渐进式javascript框架,用于构建UIS(用户界面)和SPA(单页应用程序)。UI组件库的出现提高了我们的开发效率,增强了应用的整体外观、感觉、交互性和可访问性,下面就来看看有哪些适用于Vue的UI组件库。 1.ElementUIElementUI是一套为开发者、设计师和产品经理......
  • Qt for ARM_Linux环境搭建-Qt5.7+iTop4412嵌入式平台移植
    原文:https://blog.csdn.net/hechao3225/article/details/52981148经过为期3天的编译、移植,终于将Qt5.7成功移植到iTop4412开发板,板载exynos4412处理器,基于ARMCortex-A9内核。因此,本篇教程以iTop4412示例,适用于Qt5.7在ARM_Linux平台上的移植。---------------------------------......