开发者社区> ansondroider> 正文

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" /-->

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
linphone android sdk 源码下载编译
linphone android sdk 源码下载编译
177 0
Android 使用Linphone SDK开发SIP客户端
Android 使用Linphone SDK开发SIP客户端
253 0
RK3128 Android 7 BOX SDK 应用无法接收广播自启 + 眠休不黑屏问题
RK3128 Android 7 BOX SDK 应用无法接收广播自启 + 眠休不黑屏问题
91 0
Android 讯飞离线语音听写/离线语音识别SDK
Android 讯飞离线语音听写/离线语音识别SDK
135 0
RK3128 Android 7 BOX SDK 修改为MID界面
RK3128 Android 7 BOX SDK 修改为MID界面
176 0
❤️【Android精进之路-02】安装Android Studio,认识Android SDK,一步步学习❤️
上一篇文章定好了Android学习计划,这篇文章就正式进入Android的学习之旅了。本文将重点介绍Android SDK的目录结构,如何安装Android Studio以及如何用Android Studio进行第一个Android应用的开发。
102 0
Android Studio下载SDK的链接
Android Studio下载SDK的链接
70 0
Please Select android SDK的解决办法
Please Select android SDK的解决办法
110 0
Please select Android SDK的解决
Please select Android SDK的解决
58 0
Android SDK Manager无法显示可供下载的未安装SDK解决方案
Android SDK Manager无法显示可供下载的未安装SDK解决方案
182 0
+关注
ansondroider
00000000 00000000 00000000
文章
问答
视频
文章排行榜
最热
最新
相关电子书
更多
蚂蚁聚宝Android秒级编译——Freeline
立即下载
低代码开发师(初级)实战教程
立即下载
阿里巴巴DevOps 最佳实践手册
立即下载
相关镜像