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>();
相关推荐
拭心1 小时前
Google 提供的 Android 端上大模型组件:MediaPipe LLM 介绍
android
带电的小王4 小时前
WhisperKit: Android 端测试 Whisper -- Android手机(Qualcomm GPU)部署音频大模型
android·智能手机·whisper·qualcomm
梦想平凡4 小时前
PHP 微信棋牌开发全解析:高级教程
android·数据库·oracle
元争栈道4 小时前
webview和H5来实现的android短视频(短剧)音视频播放依赖控件
android·音视频
阿甘知识库5 小时前
宝塔面板跨服务器数据同步教程:双机备份零停机
android·运维·服务器·备份·同步·宝塔面板·建站
元争栈道6 小时前
webview+H5来实现的android短视频(短剧)音视频播放依赖控件资源
android·音视频
MuYe6 小时前
Android Hook - 动态加载so库
android
居居飒7 小时前
Android学习(四)-Kotlin编程语言-for循环
android·学习·kotlin
Henry_He9 小时前
桌面列表小部件不能点击的问题分析
android
工程师老罗10 小时前
Android笔试面试题AI答之Android基础(1)
android