MTK Android12 user版本MtkLogger

目录

1.修改device/mediatek/system/common/device.mk

2.修改device/mediatek/system/common/mtklog/mtklog-config-bsp-eng.prop,修改为false是为了开机的时候不要自动启动

3.修改device/mediatek/vendor/common/device.mk

4.修改vendor/mediatek/proprietary/external/NetworkLogD/netdiag/commandlistening.cpp

5.修改vendor/mediatek/proprietary/external/mobile_log_d/config.c

6.修改vendor/mediatek/proprietary/packages/apps/EngineerMode/Android.mk

[7.修改vendor/mediatek/proprietary/packages/apps/EngineerMode/AndroidManifest.xml 添加暗码](#7.修改vendor/mediatek/proprietary/packages/apps/EngineerMode/AndroidManifest.xml 添加暗码)

8.修改vendor/mediatek/proprietary/packages/apps/EngineerMode/src/com/mediatek/engineermode/EngineerModeReceiver.java

9.vendor/mediatek/proprietary/packages/apps/MTKLogger/Android.mk

10.修改vendor/mediatek/proprietary/packages/apps/MTKLogger/AndroidManifest.xml,不显示应用图标

11.修改vendor/mediatek/proprietary/packages/apps/MTKLogger/src/com/debug/loggerui/utils/Utils.java,更换log的保存路径为内部SD卡


在user版本无法使用Mtklogger,需要客户抓log的时候非常麻烦。

现在把MtkLogger在user版本中打开,方便抓log

1.修改device/mediatek/system/common/device.mk

python 复制代码
--- a/device/mediatek/system/common/device.mk
+++ b/device/mediatek/system/common/device.mk
@@ -690,13 +690,13 @@ $(call inherit-product-if-exists, vendor/mediatek/common/device-vendor.mk)

 # mtklog config
 ifeq ($(strip $(MTK_BASIC_PACKAGE)), yes)
-  ifeq ($(TARGET_BUILD_VARIANT),eng)
+  ifneq ($(filter $(TARGET_BUILD_VARIANT),eng userdebug user),)
     PRODUCT_COPY_FILES += $(LOCAL_PATH)/mtklog/mtklog-config-basic-eng.prop:$(TARGET_COPY_OUT_SYSTEM_EXT)/etc/mtklog-config.prop:mtk
   else
     PRODUCT_COPY_FILES += $(LOCAL_PATH)/mtklog/mtklog-config-basic-user.prop:$(TARGET_COPY_OUT_SYSTEM_EXT)/etc/mtklog-config.prop:mtk
   endif
 else
-  ifeq ($(TARGET_BUILD_VARIANT),eng)
+  ifneq ($(filter $(TARGET_BUILD_VARIANT),eng userdebug user),)
     PRODUCT_COPY_FILES += $(LOCAL_PATH)/mtklog/mtklog-config-bsp-eng.prop:$(TARGET_COPY_OUT_SYSTEM_EXT)/etc/mtklog-config.prop:mtk
   else
     PRODUCT_COPY_FILES += $(LOCAL_PATH)/mtklog/mtklog-config-bsp-user.prop:$(TARGET_COPY_OUT_SYSTEM_EXT)/etc/mtklog-config.prop:mtk
@@ -2469,7 +2469,7 @@ ifneq ($(wildcard vendor/mediatek/internal/mtklog_enable),)
     MSSI_HAVE_AEE_FEATURE = no
   endif
 # Case: Customer eng/userdebug load
-else ifneq ($(strip $(TARGET_BUILD_VARIANT)),user)
+else ifneq ($(strip $(TARGET_BUILD_VARIANT)),eng  userdebug user)
   PRODUCT_SYSTEM_DEFAULT_PROPERTIES += ro.vendor.customer_logpath=/data
   PRODUCT_PACKAGES += log-handler
   PRODUCT_PACKAGES += loghidlsysservice
@@ -3736,7 +3736,7 @@ ifeq ($(strip $(MSSI_MTK_ENGINEERMODE_APP)), yes)
     PRODUCT_PACKAGES += libem_audio_jni
     PRODUCT_PACKAGES += libem_aoltest_jni
   else
-    ifneq ($(filter $(TARGET_BUILD_VARIANT),eng userdebug),)
+    ifneq ($(filter $(TARGET_BUILD_VARIANT),eng userdebug user),)
       PRODUCT_PACKAGES += EngineerMode
       PRODUCT_PACKAGES += libem_support_jni
       PRODUCT_PACKAGES += libem_usb_jni

2.修改device/mediatek/system/common/mtklog/mtklog-config-bsp-eng.prop,修改为false是为了开机的时候不要自动启动

python 复制代码
--- a/device/mediatek/system/common/mtklog/mtklog-config-bsp-eng.prop
+++ b/device/mediatek/system/common/mtklog/mtklog-config-bsp-eng.prop
@@ -1,14 +1,14 @@
 # mtk log path can be set as system_data or device_storage or portable_storage
-mtklog_path = system_data
+mtklog_path = device_storage
 com.mediatek.log.mobile.customer = MTK_Internal
-com.mediatek.log.mobile.AllMode = true
+com.mediatek.log.mobile.AllMode = false

-com.mediatek.log.mobile.enabled = true
-com.mediatek.log.modem.enabled = true
-com.mediatek.log.net.enabled = true
-com.mediatek.log.connsysfw.enabled = true
-com.mediatek.log.gpshost.enabled = true
-com.mediatek.log.bthost.enabled = true
+com.mediatek.log.mobile.enabled = false
+com.mediatek.log.modem.enabled = false
+com.mediatek.log.net.enabled = false
+com.mediatek.log.connsysfw.enabled = false
+com.mediatek.log.gpshost.enabled = false
+com.mediatek.log.bthost.enabled = false

 com.mediatek.log.mobile.maxsize = 1000
 com.mediatek.log.mobile.totalmaxsize = 1000
@@ -17,7 +17,7 @@ com.mediatek.log.net.maxsize =600
 com.mediatek.log.connsysfw.maxsize = 2000
 com.mediatek.log.bthost.maxsize = 2000

-com.mediatek.log.wifisa.enabled = true
+com.mediatek.log.wifisa.enabled = false
 com.mediatek.log.wifisa.size = 30
 com.mediatek.log.wifisa.count = 3

3.修改device/mediatek/vendor/common/device.mk

python 复制代码
--- a/device/mediatek/vendor/common/device.mk
+++ b/device/mediatek/vendor/common/device.mk
@@ -579,7 +579,7 @@ ifeq ($(strip $(MTK_ENGINEERMODE_APP)),yes)
       DEVICE_MANIFEST_FILE += $(LOCAL_PATH)/project_manifest/manifest_em.xml
       PRODUCT_PACKAGES += em_hidl
     else
-      ifneq ($(filter $(TARGET_BUILD_VARIANT),eng userdebug),)
+      ifneq ($(filter $(TARGET_BUILD_VARIANT),eng userdebug user),)
         DEVICE_MANIFEST_FILE += $(LOCAL_PATH)/project_manifest/manifest_em.xml
         PRODUCT_PACKAGES += em_hidl
       endif

4.修改vendor/mediatek/proprietary/external/NetworkLogD/netdiag/commandlistening.cpp

python 复制代码
--- a/vendor/mediatek/proprietary/external/NetworkLogD/netdiag/commandlistening.cpp
+++ b/vendor/mediatek/proprietary/external/NetworkLogD/netdiag/commandlistening.cpp
@@ -180,7 +180,7 @@ bool commandlistening::isCustomerUserLoad() {
     property_get("ro.build.type", buildtype, "user");
     if (0 == strncmp("0",internal,strlen("0"))
         && 0 == strncmp("user",buildtype,strlen("userdebug"))) {
-        result = true;
+        //result = true;
     }
     LOGD("isCustomerUserLoad()? %d,internal = %s,buildtype =%s",

5.修改vendor/mediatek/proprietary/external/mobile_log_d/config.c

python 复制代码
--- a/vendor/mediatek/proprietary/external/mobile_log_d/config.c
+++ b/vendor/mediatek/proprietary/external/mobile_log_d/config.c
@@ -775,10 +775,13 @@ int update_sd_context(const char* path) {
 }

 int load_type() {
+       return 0;
+       /*
     char build_type[BUFFER_SIZE_128] = {0};
     char internal_prpject[BUFFER_SIZE_128] = {0};
     property_get("ro.build.type", build_type, "");
     property_get("ro.vendor.mtklog_internal", internal_prpject, "");
     if (strcmp(build_type, "user") != 0 || strcmp(internal_prpject, "1") == 0) return 0;
     return 1;
+       */

6.修改vendor/mediatek/proprietary/packages/apps/EngineerMode/Android.mk

python 复制代码
--- a/vendor/mediatek/proprietary/packages/apps/EngineerMode/Android.mk
+++ b/vendor/mediatek/proprietary/packages/apps/EngineerMode/Android.mk
@@ -64,7 +64,7 @@ LOCAL_STATIC_JAVA_LIBRARIES += vendor.mediatek.hardware.mtkradioex-V3.0-java
 endif

 # Files only for eng/user_debug load
-ifeq ($(TARGET_BUILD_VARIANT), eng)
+#ifeq ($(TARGET_BUILD_VARIANT), eng user)
     ENG_ONLY_TEL_FILE := $(call all-java-files-under, $(JAVA_SRC_DIR)/amrwb) \
                          $(call all-java-files-under, $(JAVA_SRC_DIR)/sbp) \
                          $(call all-java-files-under, $(JAVA_SRC_DIR)/u3phy) \
@@ -132,7 +132,7 @@ ifeq ($(TARGET_BUILD_VARIANT), eng)
                             $(JAVA_SRC_DIR)/cip/CipPropContentActivity.java

     LOCAL_SRC_FILES := $(filter-out $(ENG_ONLY_OTHERS_FILE), $(LOCAL_SRC_FILES))
-endif
+#endif

 ifeq (,$(filter $(MSSI_MTK_TELEPHONY_ADD_ON_POLICY),1))

7.修改vendor/mediatek/proprietary/packages/apps/EngineerMode/AndroidManifest.xml 添加暗码

python 复制代码
--- a/vendor/mediatek/proprietary/packages/apps/EngineerMode/AndroidManifest.xml
+++ b/vendor/mediatek/proprietary/packages/apps/EngineerMode/AndroidManifest.xml
@@ -611,6 +611,9 @@
                 <data
                     android:host="3646633"
                     android:scheme="android_secret_code" />
+                               <data
+                    android:host="0594666"
+                    android:scheme="android_secret_code" />
             </intent-filter>
         </receiver>
         <activity

8.修改vendor/mediatek/proprietary/packages/apps/EngineerMode/src/com/mediatek/engineermode/EngineerModeReceiver.java

python 复制代码
--- a/vendor/mediatek/proprietary/packages/apps/EngineerMode/src/com/mediatek/engineermode/EngineerModeReceiver.java
+++ b/vendor/mediatek/proprietary/packages/apps/EngineerMode/src/com/mediatek/engineermode/EngineerModeReceiver.java
@@ -39,6 +39,7 @@ import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
 import android.net.Uri;
+import android.content.ComponentName;

 /**
  * Broadcast receiver for EM start secret code.
@@ -49,18 +50,35 @@ public final class EngineerModeReceiver extends BroadcastReceiver {
     private static final String TAG = "EngineerModeReceiver";
     private static final String SECRET_CODE_ACTION
                                  = "android.provider.Telephony.SECRET_CODE";
-
+    // process *#*#3646633#*#*
+    private final Uri mEmUri = Uri.parse("android_secret_code://3646633");
+    // process *#*#0594666#*#* mtklog
+    private final Uri mMtklogUri1 = Uri.parse("android_secret_code://0594666");
     @Override
     public void onReceive(Context context, Intent intent) {
         if (intent.getAction() == null) {
             Elog.e(TAG, "Null action");
             return;
         }
+
         if (intent.getAction().equals(SECRET_CODE_ACTION)) {
-            Elog.i(TAG, "Receive secret code intent");
-            Intent intentEm = new Intent(context, EngineerMode.class);
-            intentEm.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-            context.startActivity(intentEm);
-        }
+            Uri uri = intent.getData();
+            Elog.i(TAG, "Receive secret code intent and uri is " + uri);
+            if (uri.equals(mEmUri))
+            {
+               Intent intentEm = new Intent(context, EngineerMode.class);
+               intentEm.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+               context.startActivity(intentEm);
+            }else if(uri.equals(mMtklogUri1)){
+                          String packageName = "com.debug.loggerui";
+                          String className = "com.debug.loggerui.MainActivity";
+                          Intent intentEm = new Intent(Intent.ACTION_MAIN);
+                          intentEm.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                          ComponentName cn = new ComponentName(packageName, className);
+                          intentEm.setComponent(cn);
+                          context.startActivity(intentEm);
+            }
+         }
+
     }
 }

9.vendor/mediatek/proprietary/packages/apps/MTKLogger/Android.mk

python 复制代码
--- a/vendor/mediatek/proprietary/packages/apps/MTKLogger/Android.mk
+++ b/vendor/mediatek/proprietary/packages/apps/MTKLogger/Android.mk
@@ -3,9 +3,9 @@ LOCAL_PATH:= $(call my-dir)
 # Build DebugLoggerUI.apk
 include $(CLEAR_VARS)

-ifeq ($(TARGET_BUILD_VARIANT), user)
-LOCAL_MANIFEST_FILE := user/AndroidManifest.xml
-endif
+#ifeq ($(TARGET_BUILD_VARIANT), user)
+#LOCAL_MANIFEST_FILE := user/AndroidManifest.xml
+#endif

 LOCAL_MODULE_TAGS := optional
 LOCAL_AAPT_INCLUDE_ALL_RESOURCES := true

10.修改vendor/mediatek/proprietary/packages/apps/MTKLogger/AndroidManifest.xml,不显示应用图标

python 复制代码
--- a/vendor/mediatek/proprietary/packages/apps/MTKLogger/AndroidManifest.xml
+++ b/vendor/mediatek/proprietary/packages/apps/MTKLogger/AndroidManifest.xml
@@ -44,7 +44,7 @@
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />

-                <category android:name="android.intent.category.LAUNCHER" />
+                <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
         </activity>

11.修改vendor/mediatek/proprietary/packages/apps/MTKLogger/src/com/debug/loggerui/utils/Utils.java,更换log的保存路径为内部SD卡

python 复制代码
--- a/vendor/mediatek/proprietary/packages/apps/MTKLogger/src/com/debug/loggerui/utils/Utils.java
+++ b/vendor/mediatek/proprietary/packages/apps/MTKLogger/src/com/debug/loggerui/utils/Utils.java
@@ -569,7 +569,7 @@ public class Utils {
     public static final String LOG_PATH_TYPE_SYSTEM_DATA = "system_data";
     public static final String LOG_PATH_TYPE_DEVICE_STORAGE = "device_storage";
     public static final String LOG_PATH_TYPE_PORTABLE_STORAGE = "portable_storage";
-    public static final String LOG_PATH_TYPE_DEFAULT = LOG_PATH_TYPE_SYSTEM_DATA;
+    public static final String LOG_PATH_TYPE_DEFAULT = LOG_PATH_TYPE_DEVICE_STORAGE;

     public static final Map<String, Integer> LOG_PATH_TYPE_STRING_MAPS =
             new HashMap<String, Integer>();
相关推荐
Dnelic-2 小时前
【单元测试】【Android】JUnit 4 和 JUnit 5 的差异记录
android·junit·单元测试·android studio·自学笔记
长亭外的少年12 小时前
Kotlin 编译失败问题及解决方案:从守护进程到 Gradle 配置
android·开发语言·kotlin
建群新人小猿14 小时前
会员等级经验问题
android·开发语言·前端·javascript·php
1024小神15 小时前
tauri2.0版本开发苹果ios和安卓android应用,环境搭建和最后编译为apk
android·ios·tauri
兰琛16 小时前
20241121 android中树结构列表(使用recyclerView实现)
android·gitee
Y多了个想法16 小时前
RK3568 android11 适配敦泰触摸屏 FocalTech-ft5526
android·rk3568·触摸屏·tp·敦泰·focaltech·ft5526
NotesChapter17 小时前
Android吸顶效果,并有着ViewPager左右切换
android
_祝你今天愉快19 小时前
分析android :The binary version of its metadata is 1.8.0, expected version is 1.5.
android
暮志未晚Webgl19 小时前
109. UE5 GAS RPG 实现检查点的存档功能
android·java·ue5