介绍
Android 13上是可以根据dpi来判断机器是平板模式还是手机模式,我的设备分辨率是2000x1200,当我们利用 adb shell -> wm density 获取当前dpi然后执行 wm density 320会发现Launcher发生了变化,此时会有布局改变以及锁屏改变,还有hotseat显示不全,导航栏变小靠右等问题,所以我们的思路是在变为平板模式后不要让Launcher和SystemUI改变即可。
改完后我们还需验证下QQ和微信是否为平板模式
修改
#density
FREEME_DEVICE_LCD_DENSITY = 320
路径:vendor/mediatek/proprietary/packages/apps/Launcher3/quickstep/src/com/android/launcher3/taskbar/
private void recreateTaskbar() {
destroyExistingTaskbar();
DeviceProfile dp =
mUserUnlocked ? (mContext).getDeviceProfile(mContext) : null;
//*/soda water.20230906 Tablet mode
boolean isTaskBarEnabled = false;
/*/
boolean isTaskBarEnabled = dp != null && ;
//*/
if (!isTaskBarEnabled) {
(mContext)
.notifyTaskbarStatus(/* visible */ false, /* stashed */ false);
return;
}
路径:vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/util/
public boolean isTablet(WindowBounds bounds) {
//*/soda water.20230906 Tablet mode
return false;
/*/
return smallestSizeDp(bounds) >= MIN_TABLET_WIDTH;
//*/
}
路径:vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/util/window/
public WindowInsets normalizeWindowInsets(Context context, WindowInsets oldInsets,
Rect outInsets) {
if (!Utilities.ATLEAST_R || !mTaskbarDrawnInProcess) {
((), (),
(), ());
return oldInsets;
}
insetsBuilder = new (oldInsets);
Insets navInsets = (());
Resources systemRes = ();
Configuration config = ();
//*/soda water.20230906 Tablet mode
boolean isTablet = false;
/*/
boolean isTablet = > MIN_TABLET_WIDTH;
//*/
boolean isGesture = isGestureNav(context);
boolean isPortrait = > ;
//第二处修改
Resources systemRes;
{
Configuration conf = new Configuration();
= swDp;
systemRes = (conf).getResources();
}
//*/soda water.20230906 Tablet mode
boolean isTablet = false;
/*/
boolean isTablet = swDp >= MIN_TABLET_WIDTH;
/*/
boolean isTabletOrGesture = isTablet
|| (Utilities.ATLEAST_R && isGestureNav(context));
int statusBarHeightPortrait = getDimenByName(systemRes,
STATUS_BAR_HEIGHT_PORTRAIT, STATUS_BAR_HEIGHT);
int statusBarHeightLandscape = getDimenByName(systemRes,
STATUS_BAR_HEIGHT_LANDSCAPE, STATUS_BAR_HEIGHT);
以上 Launcher3修改是防止 launcher变为平板模式的样式导致显示不全
路径: overlay/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values-sw600dp-port/
修改:下拉栏左右边距问题
<resources>
<dimen name="notification_panel_margin_horizontal">0dp</dimen>
</resources>
路径:vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/navigationbar/
mStatusBarKeyguardViewManager = statusBarKeyguardViewManager;
(commandQueue, overviewProxyService,
navBarHelper, navigationModeController, sysUiFlagsContainer,
dumpManager, autoHideController, lightBarController, pipOptional,
(null));
//*/soda water.20230906 Tablet mode
mIsTablet = false;
/*/
mIsTablet = isTablet(mContext);
//*/
(this);
}
@Override
public void onConfigChanged(Configuration newConfig) {
boolean isOldConfigTablet = mIsTablet;
//*/soda water.20230906 Tablet mode
mIsTablet = false;
/*/
mIsTablet = isTablet(mContext);
//*/
boolean largeScreenChanged = mIsTablet != isOldConfigTablet;
// If we folded/unfolded while in 3 button, show navbar in folded state, hide in unfolded
if (largeScreenChanged && updateNavbarForTaskbar()) {
return;
}
public void onDisplayReady(int displayId) {
Display display = (displayId);
//*/soda water.20230906 Tablet mode
mIsTablet = false;
/*/
mIsTablet = isTablet(mContext);
//*/
createNavigationBar(display, null /* savedState */, null /* result */);
}
路径:vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/navigationbar/
private void setNavigationIconHints(int hints) {
if (hints == mNavigationIconHints) return;
//*/soda water.20230906 Tablet mode
if (true) {
/*/
if (!isTablet(mContext)) {
//*/
// All IME functions handled by launcher via Sysui flags for large screen
final boolean newBackAlt = (hints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0;
路径:vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/recents/
if (!(mNavBarMode)
&& (()) /*&& !isTablet(mContext)) soda water.20230906 Tablet mode*/) {
(View.LAYOUT_DIRECTION_LOCALE);
swapChildrenIfRtlAndVertical(buttons);
}
以上修改防止UI界面变得现实不全 导航栏显示问题
完成后微信会识别成平板模式但QQ不会
路径:build/core/product_config.mk
ifndef PRODUCT_CHARACTERISTICS
TARGET_AAPT_CHARACTERISTICS := tablet
else
TARGET_AAPT_CHARACTERISTICS := $(PRODUCT_CHARACTERISTICS)
endif
改完后QQ就会变为平板模式