RK3128 Android 7 BOX SDK 修改为MID界面-近期任务

简介: RK3128 Android 7 BOX SDK 修改为MID界面-近期任务

前文


RK3128 Android 7 BOX SDK 修改为MID界面


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


新的问题


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


TV模式:

image.png


手机/平板模式:

image.png


跟踪


先看下当前的窗口信息: 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>


2.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" /-->
相关文章
|
3月前
|
JavaScript 前端开发 Java
[Android][Framework]系统jar包,sdk的制作及引用
[Android][Framework]系统jar包,sdk的制作及引用
77 0
|
3天前
|
Java Linux API
Android SDK
【10月更文挑战第21天】
15 1
|
27天前
|
Android开发
Android gradle task任务检查各个module之间资源文件冲突.md
Android gradle task任务检查各个module之间资源文件冲突.md
Android gradle task任务检查各个module之间资源文件冲突.md
|
13天前
|
程序员 开发工具 Android开发
Android|使用阿里云推流 SDK 实现双路推流不同画面
本文记录了一种使用没有原生支持多路推流的阿里云推流 Android SDK,实现同时推送两路不同画面的流的方法。
38 7
|
1月前
|
XML 数据可视化 Android开发
Android应用界面
Android应用界面中的布局和控件使用,包括相对布局、线性布局、表格布局、帧布局、扁平化布局等,以及AdapterView及其子类如ListView的使用方法和Adapter接口的应用。
20 0
Android应用界面
|
2月前
|
XML Android开发 UED
💥Android UI设计新风尚!掌握Material Design精髓,让你的界面颜值爆表!🎨
随着移动应用市场的蓬勃发展,用户对界面设计的要求日益提高。为此,掌握由Google推出的Material Design设计语言成为提升应用颜值和用户体验的关键。本文将带你深入了解Material Design的核心原则,如真实感、统一性和创新性,并通过丰富的组件库及示例代码,助你轻松打造美观且一致的应用界面。无论是色彩搭配还是动画效果,Material Design都能为你的Android应用增添无限魅力。
57 1
|
30天前
|
Android开发 Kotlin
Android面试题之Kotlin中如何实现串行和并行任务?
本文介绍了 Kotlin 中 `async` 和 `await` 在并发编程中的应用,包括并行与串行任务的处理方法。并通过示例代码展示了如何启动并收集异步任务的结果。
18 0
|
3月前
|
Android开发 iOS开发 C#
Xamarin.Forms:从零开始的快速入门指南——打造你的首个跨平台移动应用,轻松学会用C#和XAML构建iOS与Android通用界面的每一个步骤
【8月更文挑战第31天】Xamarin.Forms 是一个强大的框架,让开发者通过单一共享代码库构建跨平台移动应用,支持 iOS、Android 和 Windows。使用 C# 和 XAML,它简化了多平台开发流程并保持一致的用户体验。本指南通过创建一个简单的 “HelloXamarin” 应用演示了 Xamarin.Forms 的基本功能和工作原理。
74 0
|
3月前
|
开发工具 Android开发
Android项目架构设计问题之SDK内部减少每次回调时的冗余判断逻辑如何解决
Android项目架构设计问题之SDK内部减少每次回调时的冗余判断逻辑如何解决
37 0
|
开发工具 Android开发 Windows
Android sdk下载安装配置教程
Android sdk下载安装配置教程
Android sdk下载安装配置教程

热门文章

最新文章