IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 移动开发 -> RK3128 Android 7 BOX SDK 修改为MID界面-近期任务 -> 正文阅读

[移动开发]RK3128 Android 7 BOX SDK 修改为MID界面-近期任务

前文

RK3128 Android 7 BOX SDK 修改为MID界面

一文中已经调整好了Launcher和SystemUI, 满足日常调试使用.

新的问题

近期任务中的任务不能拖动, 只能用于切换, 这也就导致APP开发的调试中不能通过近期任务来结束后台应用.

TV模式:
在这里插入图片描述

手机/平板模式:
在这里插入图片描述

跟踪

先看下当前的窗口信息: dumpsys window

  Window #2 Window{a225ed0 u0 com.android.systemui/com.android.systemui.recents.tv.RecentsTvActivity}:
    mDisplayId=0 stackId=0 mSession=Session{a14766e 567:u0a10013} mClient=android.os.BinderProxy@d5ffe93
    mOwnerUid=10013 mShowToOwnerOnly=true package=com.android.systemui appop=NONE
    mAttrs=WM.LayoutParams{(0,0)(fillxfill) sim=#110 ty=1 fl=#83810500 pfl=0x24000 fmt=-2 wanim=0x103046c vsysui=0x700 needsMenuKey=2}
    Requested w=800 h=408 mLayoutSeq=57
    mHasSurface=true mShownPosition=[0,0] isReadyForDisplay()=true hasSavedSurface()=false mWindowRemovalAllowed=false
    WindowStateAnimator{8110ee7 com.android.systemui/com.android.systemui.recents.tv.RecentsTvActivity}:
      Surface: shown=true layer=21010 alpha=1.0 rect=(0.0,0.0) 800.0 x 480.0
 //...
  mCurConfiguration={1.0 ?mcc?mnc [zh_CN] ldltr sw480dp w800dp h408dp 160dpi nrml land television -touch qwerty/v/h dpad/v s.5}
  mHasPermanentDpad=true
  mCurrentFocus=Window{a225ed0 u0 com.android.systemui/com.android.systemui.recents.tv.RecentsTvActivity}
  mFocusedApp=AppWindowToken{bfafe91 token=Token{b49c71b ActivityRecord{6dbfd2a u0 com.android.systemui/.recents.tv.RecentsTvActivity t18}}}

mCurrentFocus=Window{a225ed0 u0 com.android.systemui/com.android.systemui.recents.tv.RecentsTvActivity}
可知当前的窗口是RecentsTvActivity.

而期望使用的是:
mCurrentFocus=Window{7d2bd75 u0 com.android.systemui/com.android.systemui.recents.RecentsActivity}


Recent的分水领

frameworks/base/packages/SystemUI/src/com/android/systemui/recents/Recents.java

    @Override
    public void start() {
        sDebugFlags = new RecentsDebugFlags(mContext);
        sSystemServicesProxy = SystemServicesProxy.getInstance(mContext);
        sTaskLoader = new RecentsTaskLoader(mContext);
        sConfiguration = new RecentsConfiguration(mContext);
        mHandler = new Handler();
        UiModeManager uiModeManager = (UiModeManager) mContext.
                getSystemService(Context.UI_MODE_SERVICE);
        if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {
            mImpl = new RecentsTvImpl(mContext);
        } else {
            mImpl = new RecentsImpl(mContext);
        }
        ...
    }
public class RecentsTvImpl extends RecentsImpl{
    public final static String RECENTS_TV_ACTIVITY =
            "com.android.systemui.recents.tv.RecentsTvActivity";
 }
public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener {

    private final static String TAG = "RecentsImpl";

    // The minimum amount of time between each recents button press that we will handle
    private final static int MIN_TOGGLE_DELAY_MS = 350;

    // The duration within which the user releasing the alt tab (from when they pressed alt tab)
    // that the fast alt-tab animation will run.  If the user's alt-tab takes longer than this
    // duration, then we will toggle recents after this duration.
    private final static int FAST_ALT_TAB_DELAY_MS = 225;

    public final static String RECENTS_PACKAGE = "com.android.systemui";
    public final static String RECENTS_ACTIVITY = "com.android.systemui.recents.RecentsActivity";
}

取决于uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION
frameworks/base/services/core/java/com/android/server/UiModeManagerService.java

  @Override
    @Override
    public void onStart() {
        final Context context = getContext();

        final PowerManager powerManager =
                (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        mWakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, TAG);

        context.registerReceiver(mDockModeReceiver,
                new IntentFilter(Intent.ACTION_DOCK_EVENT));
        context.registerReceiver(mBatteryReceiver,
                new IntentFilter(Intent.ACTION_BATTERY_CHANGED));

        mConfiguration.setToDefaults();

        final Resources res = context.getResources();
        mDefaultUiModeType = res.getInteger(
                com.android.internal.R.integer.config_defaultUiModeType);
        mCarModeKeepsScreenOn = (res.getInteger(
                com.android.internal.R.integer.config_carDockKeepsScreenOn) == 1);
        mDeskModeKeepsScreenOn = (res.getInteger(
                com.android.internal.R.integer.config_deskDockKeepsScreenOn) == 1);
        mEnableCarDockLaunch = res.getBoolean(
                com.android.internal.R.bool.config_enableCarDockHomeLaunch);
        mUiModeLocked = res.getBoolean(com.android.internal.R.bool.config_lockUiMode);
        mNightModeLocked = res.getBoolean(com.android.internal.R.bool.config_lockDayNightMode);

        final PackageManager pm = context.getPackageManager();
        mTelevision = pm.hasSystemFeature(PackageManager.FEATURE_TELEVISION)
                || pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK);
        mWatch = pm.hasSystemFeature(PackageManager.FEATURE_WATCH);

        final int defaultNightMode = res.getInteger(
                com.android.internal.R.integer.config_defaultNightMode);
        mNightMode = Settings.Secure.getInt(context.getContentResolver(),
                Settings.Secure.UI_NIGHT_MODE, defaultNightMode);

        // Update the initial, static configurations.
        synchronized (this) {
            updateConfigurationLocked();
            sendConfigurationLocked();
        }

        publishBinderService(Context.UI_MODE_SERVICE, mService);
    }
    private void updateConfigurationLocked() {
        int uiMode = mDefaultUiModeType;
        if (mUiModeLocked) {
            // no-op, keeps default one
        } else if (mTelevision) {
            uiMode = Configuration.UI_MODE_TYPE_TELEVISION;
        } else if (mWatch) {
            uiMode = Configuration.UI_MODE_TYPE_WATCH;
        } else if (mCarModeEnabled) {
            uiMode = Configuration.UI_MODE_TYPE_CAR;
        } else if (isDeskDockState(mDockState)) {
            uiMode = Configuration.UI_MODE_TYPE_DESK;
        }

        if (mNightMode == UiModeManager.MODE_NIGHT_AUTO) {
            if (mTwilightManager != null) {
                mTwilightManager.registerListener(mTwilightListener, mHandler);
            }
            updateComputedNightModeLocked();
            uiMode |= mComputedNightMode ? Configuration.UI_MODE_NIGHT_YES
                    : Configuration.UI_MODE_NIGHT_NO;
        } else {
            if (mTwilightManager != null) {
                mTwilightManager.unregisterListener(mTwilightListener);
            }
            uiMode |= mNightMode << 4;
        }

        if (LOG) {
            Slog.d(TAG,
                "updateConfigurationLocked: mDockState=" + mDockState
                + "; mCarMode=" + mCarModeEnabled
                + "; mNightMode=" + mNightMode
                + "; uiMode=" + uiMode);
        }

        mCurUiMode = uiMode;
        if (!mHoldingConfiguration) {
            mConfiguration.uiMode = uiMode;
        }
    }

有两个地方决定了UI模式:

  1. config_defaultUiModeType, 在overlay中值为4, 默认改为1.

frameworks/base/core/res/res/values/config.xml
device/rockchip/common/tv/overlay/frameworks/base/core/res/res/values/config.xml

    <!-- Control the default UI mode type to use when there is no other type override
         happening.  One of the following values (See Configuration.java):
             1  UI_MODE_TYPE_NORMAL
             4  UI_MODE_TYPE_TELEVISION
             5  UI_MODE_TYPE_APPLIANCE
             6  UI_MODE_TYPE_WATCH
         Any other values will have surprising consequences. -->
    <integer name="config_defaultUiModeType">1</integer>
  1. UiModeManagerService mTelevision
 mTelevision = pm.hasSystemFeature(PackageManager.FEATURE_TELEVISION)
                || pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK);

PakcageManager中:

public static final String FEATURE_TELEVISION = "android.hardware.type.television";

进一步确认中主板中的内容:
cat /system/etc/permissions/tv_core_hardware.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<permissions>

    <!-- These are the hardware components that all television devices must
         include.  Devices with optional hardware must also include extra hardware
         files.
    -->
    <feature name="android.hardware.audio.output" />
    <feature name="android.hardware.location" />
    <feature name="android.hardware.location.network" />
    <feature name="android.hardware.screen.landscape" />
    <feature name="android.hardware.type.television" />

    <feature name="android.software.backup" />
    <!--feature name="android.software.leanback" /-->
    <feature name="android.software.leanback_only" />
    <feature name="android.software.live_tv" />
    <feature name="android.software.picture_in_picture" />
    <feature name="android.software.voice_recognizers" />

</permissions>

辅助检测命令:adb shell dumpsys uimode

Current UI Mode Service state:
  mDockState=0 mLastBroadcastState=0
  mNightMode=1 mNightModeLocked=false mCarModeEnabled=false mComputedNightMode=false mCarModeEnableFlags=0 mEnableCarDockLaunch=true
  mCurUiMode=0x14 mUiModeLocked=false mSetUiMode=0x14
  mHoldingConfiguration=false mSystemReady=true
  mTwilightService.getLastTwilightState()=nul

修改

diff --git a/device/rockchip/common/tv/overlay/frameworks/base/core/res/res/values/config.xml b/device/rockchip/common/tv/overlay/frameworks/base/core/res/res/values/config.xml
index 903365b..76ab129 100755
--- a/device/rockchip/common/tv/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/device/rockchip/common/tv/overlay/frameworks/base/core/res/res/values/config.xml
@@ -35,7 +35,7 @@
              4  UI_MODE_TYPE_TELEVISION
              5  UI_MODE_TYPE_APPLIANCE
          Any other values will have surprising consequences. -->
-    <integer name="config_defaultUiModeType">4</integer>
+    <integer name="config_defaultUiModeType">1</integer>
 
     <!-- Control the behavior when the user long presses the home button.
             0 - Nothing
diff --git a/device/rockchip/common/tv/permissions/tv_core_hardware.xml b/device/rockchip/common/tv/permissions/tv_core_hardware.xml
index 4b9eee6..a4852fd 100644
--- a/device/rockchip/common/tv/permissions/tv_core_hardware.xml
+++ b/device/rockchip/common/tv/permissions/tv_core_hardware.xml
@@ -24,7 +24,7 @@
     <feature name="android.hardware.location" />
     <feature name="android.hardware.location.network" />
     <feature name="android.hardware.screen.landscape" />
-    <feature name="android.hardware.type.television" />
+    <!--feature name="android.hardware.type.television" /-->
 
     <feature name="android.software.backup" />
     <!--feature name="android.software.leanback" /-->

  移动开发 最新文章
Vue3装载axios和element-ui
android adb cmd
【xcode】Xcode常用快捷键与技巧
Android开发中的线程池使用
Java 和 Android 的 Base64
Android 测试文字编码格式
微信小程序支付
安卓权限记录
知乎之自动养号
【Android Jetpack】DataStore
上一篇文章      下一篇文章      查看所有文章
加:2021-11-17 12:52:17  更:2021-11-17 12:52:51 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/24 3:54:54-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码