这里的写值在NVram中,恢复出厂设置也不影响这个值,只有刷机才会更新;
一般来说home键打开launcher的intent是固定的,但是,我们可以修改打开homeintent的逻辑,从而打开不同的launcher;
先了解一下NvRam在app层的使用 NvRAM App层的使用
以及在uboot和kernel中的使用 MTK修改动态切换开机logo,恢复出厂设置不还原
diff --git a/alps/frameworks/base/Android.bp b/alps/frameworks/base/Android.bp
index 37bfc439aa..3e78c82846 100644
--- a/alps/frameworks/base/Android.bp
+++ b/alps/frameworks/base/Android.bp
@@ -785,6 +785,7 @@ java_defaults {
"android.hardware.vibrator-V1.3-java",
"android.hardware.wifi-V1.0-java-constants",
"devicepolicyprotosnano",
+ "vendor.mediatek.hardware.nvram-V1.0-java",
],
required: [
diff --git a/alps/frameworks/base/services/Android.bp b/alps/frameworks/base/services/Android.bp
index b08d1a8095..25ca50ed37 100644
--- a/alps/frameworks/base/services/Android.bp
+++ b/alps/frameworks/base/services/Android.bp
@@ -36,6 +36,7 @@ java_library {
"services.usb",
"services.voiceinteraction",
"android.hidl.base-V1.0-java",
+ "vendor.mediatek.hardware.nvram-V1.0-java",
],
libs: [
android10的在ActivityTaskManagerService.java,10以前的有点区别 搜一下getHomeIntent的方法在哪里就行,
注意private int mOffset=774; 这个值,是指数据存储位置偏移,前言里面两篇文章有mOffset的定义是怎么来的
diff --git a/alps/frameworks/base/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/alps/frameworks/base/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
index 7c39d29a70..3be814e23b 100755
--- a/alps/frameworks/base/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
+++ b/alps/frameworks/base/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@@ -298,6 +298,8 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
+import com.android.internal.util.HexDump;
+import vendor.mediatek.hardware.nvram.V1_0.INvram;
@@ -5874,10 +5876,46 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
Intent getHomeIntent() {
Intent intent = new Intent(mTopAction, mTopData != null ? Uri.parse(mTopData) : null);
intent.setComponent(mTopComponent);
intent.addFlags(Intent.FLAG_DEBUG_TRIAGED_MISSING);
if (mFactoryTest != FactoryTest.FACTORY_TEST_LOW_LEVEL) {
- intent.addCategory(Intent.CATEGORY_HOME);
+ //intent.addCategory(Intent.CATEGORY_HOME);
+ int launcherindex=readNvRAMData();
+ if(launcherindex==0){
+ intent.addCategory("android.intent.category.HOME_CLIFE");
+ }else{
+ intent.addCategory(Intent.CATEGORY_HOME);
+ }
}
return intent;
}
+
+ private final String NVTAG="NvRAMUtil";
+ private final String PRODUCT_INFO_FILENAME = "/mnt/vendor/nvdata/APCFG/APRDEB/PRODUCT_INFO";
+ private int mSize=1024;
+ private int mOffset=774;
+ public int readNvRAMData() {
+ int targets = 0;
+ try {
+ String buff = null;
+ INvram agent = INvram.getService();
+ Log.i(NVTAG, "readData from "+PRODUCT_INFO_FILENAME);
+ if (agent != null) {
+ buff = agent.readFileByName(PRODUCT_INFO_FILENAME, mSize);
+ }
+ byte[] buffArr = HexDump.hexStringToByteArray(buff.substring(0, buff.length() - 1));
+ byte[] dataArr=new byte[4];
+
+ System.arraycopy(buffArr,mOffset,dataArr,0,4);
+ Log.i(NVTAG, "readData 1111: buffArr=" + Arrays.toString(dataArr));
+
+// targets = (dataArr[0] & 0xff) | ((dataArr[1] << 8) & 0xff00) | ((dataArr[2] << 24) >>> 8) | (dataArr[3] << 24);
+ targets = (dataArr[0] & 0xff) | ((dataArr[1] << 8) & 0xff00) | ((dataArr[2] << 24) >> 8 & 0xff0000) | (dataArr[3] << 24);
+
+ Log.i(NVTAG, "readData: buffArr=" + Arrays.toString(dataArr) + ", targets == " + targets);
+ } catch (Exception e) {
+ Log.e(NVTAG, "readData exception:" + e.getLocalizedMessage());
+ e.printStackTrace();
+ }
+ return targets;
+ }
代码如下(示例):
diff --git a/alps/device/mediatek/mt8168/sepolicy/basic/system_server.te b/alps/device/mediatek/mt8168/sepolicy/basic/system_server.te
index 5e4c9eab44..7e458d60a2 100644
--- a/alps/device/mediatek/mt8168/sepolicy/basic/system_server.te
+++ b/alps/device/mediatek/mt8168/sepolicy/basic/system_server.te
@@ -20,3 +20,5 @@ allow system_server media_rw_data_file:file open;
allow system_server media_rw_data_file:file create;
allow system_server sdcardfs:file rw_file_perms;
allow system_server sdcardfs:file create;
+allow system_server nvram_agent_binder_hwservice:hwservice_manager find;
+allow system_server nvram_agent_binder:binder call;
这里的写值在NVram中,恢复出厂设置也不影响这个值,只有刷机才会更新,
NvRam在app层的使用 NvRAM App层的使用
以及在uboot和kernel中的使用 MTK修改动态切换开机logo,恢复出厂设置不还原