本文適用于觸覺智能所有支持Android11系統的開發板設置APP開機自啟和隱藏導航欄/狀態欄。觸覺智能的Purple Pi OH鴻蒙開源主板,是華為Laval官方社區主薦的一款鴻蒙開發主板。
該主板主要針對學生黨,極客,工程師,極大降低了開源鴻蒙開發者的入門門檻,具有以下幾點優勢:
支持開源鴻蒙/Linux /Andriod 11/麒麟,兼容樹莓派 ;
四核A55,最高1.8G主頻,Mali G52-2EE GPU ;
支持OpenGL/CL/Vulkan/1T NPU/8M ISP ;
支持TensorFlow/MXNet/PyTorch/ Caffe ;
支持1*千兆以太網、3*USB2.0、1*USB3.0、3*UART、2*SPI、2*I2C、28*GPIO、1*MIPI DSI、1*HDMI ;
支持OpenHarmony3.2/4.0/4.1版本,開放SDK源代碼 ;
活躍的開發者社區, 更多牛人在線技術支持 ;
超小尺寸,極致性價比,只需249元 ;
一、APP自啟
1.1 添加自啟服務
修改文件:
frameworks\base\core\java\com\android\internal\app\ResolverActivity.java
--- a/frameworks/base/core/java/com/android/internal/app/ResolverActivity.java +++ b/frameworks/base/core/java/com/android/internal/app/ResolverActivity.java @@ -101,6 +101,10 @@ import java.util.List; import java.util.Objects; import java.util.Set; +import java.util.concurrent.Executor; +import java.util.function.Consumer; +import android.os.SystemProperties; +import android.app.role.RoleManager; /** * This activity is displayed when the system attempts to start an Intent for @@ -341,6 +345,18 @@ public class ResolverActivity extends Activity implements protected void onCreate(Bundle savedInstanceState, Intent intent, CharSequence title, int defaultTitleRes, Intent[] initialIntents, List rList, boolean supportsAlwaysUseOption) { + + //by Lyle,220923 + String LauncherPkg = SystemProperties.get("persist.sys.def_launherpag"); + if(LauncherPkg!=null/* && !isDefaultLauncher(this,LauncherPkg)*/){ + Log.v("defaultLauncher","-----found default launcher pkg:"+LauncherPkg); + setDefaltLauncher(this,LauncherPkg); + startDefaultLauncher(this,LauncherPkg); + finish(); + return; + } + //end + setTheme(appliedThemeResId()); super.onCreate(savedInstanceState); @@ -433,6 +449,47 @@ public class ResolverActivity extends Activity implements intent.getAction() + ":" + intent.getType() + ":" + (categories != null ? Arrays.toString(categories.toArray()) : "")); } + + + public void setDefaltLauncher(Context context, String packageName) {//by Lyle,220923 + String roleName = "android.app.role.HOME"; + boolean add = true; + int flags = 0; + UserHandle user = android.os.Process.myUserHandle(); + + RoleManager roleManager = context.getSystemService(RoleManager.class); + Executor executor = context.getMainExecutor(); + Consumer< Boolean > callback = successful -> { + if (successful) { + Log.v("defaultLauncher","set Defalt Launcher successful" ); + } else { + Log.v("defaultLauncher","set Defalt Launcher failed "); + } + }; + roleManager.addRoleHolderAsUser(roleName, packageName, flags, user, executor, callback); + } + + public void startDefaultLauncher(Context context, String packageName) { + Intent intent = new Intent(); + PackageManager pm = context.getPackageManager(); + intent = pm.getLaunchIntentForPackage(packageName); + if (intent != null) + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + try { + context.startActivity(intent); + } catch (Exception e) { + Log.v("defaultLauncher","start Default Launcher failed,not find package:"+packageName ); + } + } + + public boolean isDefaultLauncher(Context context,String launcherPkg){ + Intent intent = new Intent(Intent.ACTION_MAIN); + intent.addCategory(Intent.CATEGORY_HOME); + ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); + String currentHomePackage = resolveInfo.activityInfo.packageName; + Log.v("defaultLauncher","-currentHomePackage:"+currentHomePackage); + return launcherPkg.equals(currentHomePackage); + } private boolean isIntentPicker() { return getClass().equals(ResolverActivity.class);
1.2 添加APP
將需要自啟的APP放置
device/rockchip/rk356x/rk3566_r/preinstall_del/目錄下
(沒有preinstall_del目錄就手動創建一個即可),并添加以下文件:
Android.mk
xxx.apk(APP)
preinstall.mk
Android.mk文件內容:
include $(call all-subdir-makefiles)
preinstall.mk文件內容:
PRODUCT_PACKAGES += neu
注意:
neu為APP名字,例如neu.apk。
該目錄也是APK的預安裝目錄,如果有新的APK要預安裝,可把APK拷貝到preinstall_del/目錄下,并且把APK名字添加到preinstall.mk文件即可。
1.3 添加APP包名
修改文件:
device/rockchip/rk356x/rk3566_r/rk3566_r.mk
例如包名為:
com.mdptech.neuronappandroidhu
--- a/device/rockchip/rk356x/rk3566_r/rk3566_r.mk +++ b/device/rockchip/rk356x/rk3566_r/rk3566_r.mk @@ -46,4 +46,5 @@ PRODUCT_PROPERTY_OVERRIDES += persist.bt.power.down=true PRODUCT_PROPERTY_OVERRIDES += persist.sys.timezone=Asia/Shanghai PRODUCT_PROPERTY_OVERRIDES += ro.vendor.hdmirotationlock=true #PRODUCT_PROPERTY_OVERRIDES += vendor.hwc.device.primary=HDMI-A-1 PRODUCT_PROPERTY_OVERRIDES += vendor.hwc.device.primary=DSI +PRODUCT_PROPERTY_OVERRIDES += persist.sys.def_launherpag=com.mdptech.neuronappandroidhu
包名命令行方式查看:pm list package -3,修改后 make 編譯源碼即可。
二、修改導航欄/狀態欄
2.1 導航欄
修改文件:
frameworks/base/packages/SystemUI/res/layout/navigation_bar.xml
--- a/frameworks/base/packages/SystemUI/res/layout/navigation_bar.xml +++ b/frameworks/base/packages/SystemUI/res/layout/navigation_bar.xml @@ -22,6 +22,7 @@ xmlns:systemui="http://schemas.android.com/apk/res-auto" android:layout_height="match_parent" android:layout_width="match_parent" + android:visibility="gone" android:background="@drawable/system_bar_background"> + android:layout_height="match_parent" + android:visibility="gone"/>
2.2 狀態欄
修改文件:
frameworks/base/packages/SystemUI/res/layout/status_bar.xml
--- a/frameworks/base/packages/SystemUI/res/layout/status_bar.xml +++ b/frameworks/base/packages/SystemUI/res/layout/status_bar.xml @@ -26,6 +26,7 @@ android:id="@+id/status_bar" android:orientation="vertical" android:focusable="false" + android:visibility="gone" android:descendantFocusability="afterDescendants" android:accessibilityPaneTitle="@string/status_bar" >
修改后重新make編譯即可。
Purle Pi OH已過XTS兼容性認證
-
嵌入式硬件
+關注
關注
1文章
929瀏覽量
8243 -
鴻蒙開發板
+關注
關注
1文章
23瀏覽量
4471 -
OpenHarmony
+關注
關注
25文章
3713瀏覽量
16254 -
RK3566
+關注
關注
0文章
145瀏覽量
4824
發布評論請先 登錄
相關推薦
評論