项目场景:
按home键的时候,不发送home的intent,修改掉,打开其他界面
代码
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: [
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.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;
+ }
/**
* Return the intent set with {@link Intent#CATEGORY_SECONDARY_HOME} to resolve secondary home
解决方案:
这里根据NVRAM的值来获取选择,mk文件中要添加编译,nvram的使用请看