RK3128 Android 7 BOX SDK 修改为MID界面

简介: RK3128 Android 7 BOX SDK 修改为MID界面

平台


RK3128 + Android 7.1


目标


1.使用Launcher3

2.显示状态栏和导航栏

3.把TvSettings替换为Settings

原图:


image.png


最终效果:


image.png


1. 模块整理


主要是增删一些编译模块, 如, 删除TvSettings, 加上Settings


device/rockchip/common/tv/tv_base.mk

device/rockchip/rk312x/device.mk

vendor/rockchip/common/apps/apps.mk


删除模块: RKTvLauncher MediaCenter TvProvider TvSettings rkmcapp-armeabi-v7a-debug

增加: Launcher3 RKVideoPlayer RkExplorer


2. Launcher3


Launcher3编译不出来, 检查下这几个OVERLAY


将对应的模块从配置中删除, 或直接注释掉.


./vendor/rockchip/common/apps/RockVRHome/Android.mk:LOCAL_OVERRIDES_PACKAGES := Launcher3
./vendor/rockchip/common/apps/RKTvLauncher/Android.mk:#LOCAL_OVERRIDES_PACKAGES := Launcher3
./vendor/rockchip/common/apps/MediaCenter/Android.mk:LOCAL_OVERRIDES_PACKAGES := Launcher3
./vendor/rockchip/common/apps/itvlauncher/Android.mk:LOCAL_OVERRIDES_PACKAGES := Launcher3
./vendor/rockchip/common/apps/ChangeLedStatus/Android.mk:LOCAL_OVERRIDES_PACKAGES := Launcher3


Launcher3 启动不了


1.am start -a android.intent.action.MAIN 不出现选择列表

主要原因是系统初始化未完成, 仅能显示android:directBootAware属性的APP, 这个后面再说

2.am start -n com.android.launcher3/.Launcher 崩溃, 且LOG很少

1970-01-01 08:01:06.113 1039-1113/com.android.launcher3 W/WallpaperManager: WallpaperService not running
1970-01-01 08:01:06.121 1039-1113/com.android.launcher3 E/AndroidRuntime: FATAL EXCEPTION: pool-1-thread-2
    Process: com.android.launcher3, PID: 1039
    DeadSystemException: The system died; earlier logs will point to the root cause


3.安装第三方NovaLauncher一样不能正常启动.

2和3是由于缺少壁纸服务导致, 解决方法有两种.


修改frameworks/base/services/java/com/android/server/SystemServer.java

if (!disableNonCoreServices/* && context.getResources().getBoolean(
                        R.bool.config_enableWallpaperService)*/) {
                traceBeginAndSlog("StartWallpaperManagerService");
                mSystemServiceManager.startService(WALLPAPER_SERVICE_CLASS);
                Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);
            }


修改配置: device/rockchip/common/tv/overlay/frameworks/base/core/res/res/values/config.xml

    <bool name="config_enableWallpaperService">true</bool>


无法使用其它桌面: RKTvLauncher优先级设置为2, 高于Launcher3


rk3128_box:/ # dumpsys package com.rockchips.android.leanbacklauncher
Activity Resolver Table:
  Non-Data Actions:
      android.intent.action.MAIN:
        cc04bd7 com.rockchips.android.leanbacklauncher/.MainActivity filter 5b7e55d
          Action: "android.intent.action.MAIN"
          Category: "android.intent.category.HOME"
          Category: "android.intent.category.DEFAULT"
          mPriority=2, mHasPartialTypes=false
          AutoVerify=false
        445fcc4 com.rockchips.android.leanbacklauncher/.DummyActivity filter ce29ea0
          Action: "android.intent.action.MAIN"
          Category: "android.intent.category.LEANBACK_LAUNCHER"
          AutoVerify=false
      com.rockchips.android.leanbacklauncher.SETTINGS:
        86887ad com.rockchips.android.leanbacklauncher/.settings.HomeScreenSettingsActivity filter a1d2ed2
          Action: "com.rockchips.android.leanbacklauncher.SETTINGS"
          Category: "android.intent.category.DEFAULT"
          AutoVerify=false
        aa6aae2 com.rockchips.android.leanbacklauncher/.settings.FullScreenSettingsActivity filter b1d1ba3
          Action: "com.rockchips.android.leanbacklauncher.SETTINGS"
          Category: "android.intent.category.DEFAULT"
          AutoVerify=false


如上mPriority=2


解决这个问题, 可以删除RkTvLauncher 或提高 Launcher3的优先级.


3. 卡Android动画


原因: 在服务启动完成的后, 执行**startHomeActivityLocked中, 找不到Activity:


ActivityManagerService.java


startHomeActivityLocked -> Slog.wtf(TAG, "No home screen found for " + intent, new Throwable());


PackageManagerService.java


//没有返回对应的Launcher组件.
PackageManagerService.resolveIntent


同样的, 和android:directBootAware有关系, 在MID的SDK中, 正常流程下, 这时候会启动设置中的FallbackHome

而在BOX的SDK中, Settings 中FallbackHome被删除了HOME属性, 导致启动后找不到Home…

缺少了


<category android:name="android.intent.category.HOME" />


加上即可


<!-- Triggered when user-selected home app isn't encryption aware -->
<activity android:name=".FallbackHome"
          android:excludeFromRecents="true"
          android:screenOrientation="nosensor"
          android:theme="@style/FallbackHome">
    <intent-filter android:priority="-1000">
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.HOME" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>


4. SystemUI


在BOX中, 状态栏和导航栏是不显示的, 修改以下代码让它显示出来:


修改组件,使用PhoneStatusBar: device/rockchip/common/tv/overlay/frameworks/base/packages/SystemUI/res/values/config.xml


<string name="config_statusBarComponent" translatable="false">com.android.systemui.statusbar.phone.PhoneStatusBar</string>


修改代码关于BOX的判断: frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/SystemBars.java


diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/SystemBars.java b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/SystemBars.java
old mode 100644
new mode 100755
index da6265d..e8c6d84
--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/SystemBars.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/SystemBars.java
@@ -87,9 +87,9 @@ public class SystemBars extends SystemUI implements ServiceMonitor.Callbacks {
     private void createStatusBarFromConfig() {
         if (DEBUG) Log.d(TAG, "createStatusBarFromConfig");
         String clsName = mContext.getString(R.string.config_statusBarComponent);
-        if ("box".equals(SystemProperties.get("ro.target.product", "tablet"))){
+        /*if ("box".equals(SystemProperties.get("ro.target.product", "tablet"))){
             clsName = "com.android.systemui.statusbar.tv.TvStatusBar";
-        }
+        }*/
         if (clsName == null || clsName.length() == 0) {
             throw andLog("No status bar component configured", null);
         }


修改布局高度:device/rockchip/common/tv/overlay/frameworks/base/core/res/res/values/dimens.xml


<resources>
    <!-- Height of the status bar -->
    <dimen name="status_bar_height">24dp</dimen>
    <!-- Height of the bottom navigation / system bar -->
    <dimen name="navigation_bar_height">48dp</dimen>
    <!-- Height of the bottom navigation bar in landscape -->
    <dimen name="navigation_bar_height_landscape">48dp</dimen>
    <!-- Width of the navigation bar when it is placed vertically on the screen -->
    <dimen name="navigation_bar_width">42dp</dimen>
</resources>


修改显示位置 frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java


diff --git a/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java b/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 7dfc835..dd737ce 100755
--- a/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -2088,7 +2088,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
         int longSizeDp = longSize * DisplayMetrics.DENSITY_DEFAULT / density;
         // Allow the navigation bar to move on non-square small devices (phones).
-        mNavigationBarCanMove = width != height && shortSizeDp < 600;
+        mNavigationBarCanMove = false;// width != height && shortSizeDp < 600;
         mHasNavigationBar = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar);
@@ -4524,6 +4524,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
     }
     private int navigationBarPosition(int displayWidth, int displayHeight, int displayRotation) {
+        if(true)return NAV_BAR_BOTTOM;
         if (mNavigationBarCanMove && displayWidth > displayHeight) {
             if (displayRotation == Surface.ROTATION_270) {
                 return NAV_BAR_LEFT;
@@ -8270,6 +8271,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                     pw.print(" mForceClearedSystemUiFlags=0x");
                     pw.println(Integer.toHexString(mForceClearedSystemUiFlags));
         }
+        pw.print(" mHasNavigationBar="); pw.print(mHasNavigationBar);
         if (mLastFocusNeedsMenu) {
             pw.print(prefix); pw.print("mLastFocusNeedsMenu=");
                     pw.println(mLastFocusNeedsMenu);


5. 壁纸


默认使用黑背景图片


device/rockchip/common/tv/overlay/frameworks/base/core/res/res/drawable-nodpi/default_wallpaper.png


image.png


6. 扩展


1.若不使用Settings的FallbackHome 而 直接使用Launcher3 开机, 需要做以下修改

diff --git a/packages/apps/Launcher3/Android.mk b/packages/apps/Launcher3/Android.mk
old mode 100644
new mode 100755
diff --git a/packages/apps/Launcher3/AndroidManifest.xml b/packages/apps/Launcher3/AndroidManifest.xml
old mode 100644
new mode 100755
index 6c5990d..7816dfb
--- a/packages/apps/Launcher3/AndroidManifest.xml
+++ b/packages/apps/Launcher3/AndroidManifest.xml
@@ -52,6 +52,7 @@
     <application
         android:backupAgent="com.android.launcher3.LauncherBackupAgent"
         android:fullBackupOnly="true"
+               android:directBootAware="true"
         android:fullBackupContent="@xml/backupscheme"
         android:hardwareAccelerated="true"
         android:icon="@mipmap/ic_launcher_home"
diff --git a/packages/apps/Launcher3/src/com/android/launcher3/LauncherAppWidgetHost.java b/packages/apps/Launcher3/src/com/android/launcher3/LauncherAppWidgetHost.java
old mode 100644
new mode 100755
index d3e5350..a4c5a3b
--- a/packages/apps/Launcher3/src/com/android/launcher3/LauncherAppWidgetHost.java
+++ b/packages/apps/Launcher3/src/com/android/launcher3/LauncherAppWidgetHost.java
@@ -62,7 +62,7 @@ public class LauncherAppWidgetHost extends AppWidgetHost {
                 // have been established by this point, and we will end up populating the
                 // widgets upon bind anyway. See issue 14255011 for more context.
             } else {
-                throw new RuntimeException(e);
+                //throw new RuntimeException(e);
             }
         }
     }
diff --git a/packages/apps/Launcher3/src/com/android/launcher3/QsbContainerView.java b/packages/apps/Launcher3/src/com/android/launcher3/QsbContainerView.java
index ffed8fc..39170d9 100755
--- a/packages/apps/Launcher3/src/com/android/launcher3/QsbContainerView.java
+++ b/packages/apps/Launcher3/src/com/android/launcher3/QsbContainerView.java
@@ -249,7 +249,10 @@ public class QsbContainerView extends FrameLayout {
     public static AppWidgetProviderInfo getSearchWidgetProvider(Context context) {
         SearchManager searchManager =
                 (SearchManager) context.getSystemService(Context.SEARCH_SERVICE);
-        ComponentName searchComponent = searchManager.getGlobalSearchActivity();
+        ComponentName searchComponent = null;
+        try{
+            searchComponent = searchManager.getGlobalSearchActivity();
+        }catch(Exception ignore){}
         if (searchComponent == null) return null;
         String providerPkg = searchComponent.getPackageName();


主要解决


1.AMS找不到Home导致卡动画问题.

2.启动Launcher3后自身崩溃问题, LOG如下:


Launcher3 崩溃


1970-01-01 08:01:05.414 2963-2963/com.android.launcher3 D/AndroidRuntime: Shutting down VM
1970-01-01 08:01:05.417 2963-2963/com.android.launcher3 E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.android.launcher3, PID: 2963
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.launcher3/com.android.launcher3.Launcher}: java.lang.RuntimeException: java.lang.IllegalStateException: User 0 must be unlocked for widgets to be available
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2666)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727)
        at android.app.ActivityThread.-wrap12(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6121)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)
     Caused by: java.lang.RuntimeException: java.lang.IllegalStateException: User 0 must be unlocked for widgets to be available
        at com.android.launcher3.LauncherAppWidgetHost.startListening(LauncherAppWidgetHost.java:65)
        at com.android.launcher3.Launcher.onCreate(Launcher.java:417)
        at android.app.Activity.performCreate(Activity.java:6709)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2619)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727) 
        at android.app.ActivityThread.-wrap12(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:154) 
        at android.app.ActivityThread.main(ActivityThread.java:6121) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802) 
     Caused by: java.lang.IllegalStateException: User 0 must be unlocked for widgets to be available
        at android.os.Parcel.readException(Parcel.java:1692)
        at android.os.Parcel.readException(Parcel.java:1637)
        at com.android.internal.appwidget.IAppWidgetService$Stub$Proxy.startListening(IAppWidgetService.java:494)
        at android.appwidget.AppWidgetHost.startListening(AppWidgetHost.java:191)
        at com.android.launcher3.LauncherAppWidgetHost.startListening(LauncherAppWidgetHost.java:56)
        at com.android.launcher3.Launcher.onCreate(Launcher.java:417) 
        at android.app.Activity.performCreate(Activity.java:6709) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2619) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727) 
        at android.app.ActivityThread.-wrap12(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:154) 
        at android.app.ActivityThread.main(ActivityThread.java:6121) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)


frameworks/base/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java


             

"User " + userId + " must be unlocked for widgets to be available");


相关文章
|
3月前
|
JavaScript 前端开发 Java
[Android][Framework]系统jar包,sdk的制作及引用
[Android][Framework]系统jar包,sdk的制作及引用
77 0
|
3天前
|
Java Linux API
Android SDK
【10月更文挑战第21天】
15 1
|
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
|
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
|
6月前
|
JavaScript Java Maven
云效产品使用常见问题之android sdk 构建出aar后,上传到私有maven仓库失败如何解决
云效作为一款全面覆盖研发全生命周期管理的云端效能平台,致力于帮助企业实现高效协同、敏捷研发和持续交付。本合集收集整理了用户在使用云效过程中遇到的常见问题,问题涉及项目创建与管理、需求规划与迭代、代码托管与版本控制、自动化测试、持续集成与发布等方面。
|
3月前
|
开发工具 Android开发
解决Android运行出现NDK at /Library/Android/sdk/ndk-bundle did not have a source.properties file
解决Android运行出现NDK at /Library/Android/sdk/ndk-bundle did not have a source.properties file
163 4
解决Android运行出现NDK at /Library/Android/sdk/ndk-bundle did not have a source.properties file
|
3月前
|
Dart 开发工具 Android开发
Android Studio导入Flutter项目提示Dart SDK is not configured
Android Studio导入Flutter项目提示Dart SDK is not configured
264 4

热门文章

最新文章