[rk3399 android11]收到广播执行相应的adb命令

diff 复制代码
--- a/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -230,7 +229,17 @@ import java.io.PrintWriter;
 import java.util.HashSet;
 import java.util.List;
 
+import java.io.DataInputStream;
+import android.util.Log;
+import java.io.BufferedReader;//rocky
+import java.io.DataOutputStream;//rocky
+import java.io.InputStream;//rocky
+import java.io.InputStreamReader;//rocky
+//import java.lang.Process;
+
+
 /**
+ *
  * WindowManagerPolicy implementation for the Android phone UI.  This
  * introduces a new method suffix, Lp, for an internal lock of the
  * PhoneWindowManager.  This is used to protect some internal state, and
@@ -2053,6 +2062,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
         filter.addAction("com.android.action.display_navigationbar");
         context.registerReceiver(mdisplay_navigationbarReceiver, filter);
 
+        filter = new IntentFilter();
+           filter.addAction("android.intent.action.exsoft.zkzr.pcmcontrol");
+           context.registerReceiver(mPcmControlReceiver, filter);
+
         mVibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
         mLongPressVibePattern = getLongIntArray(mContext.getResources(),
                 com.android.internal.R.array.config_longPressVibePattern);
@@ -4582,9 +4596,54 @@ public class PhoneWindowManager implements WindowManagerPolicy {
             Intent mIntent = new Intent("action.SHOW_STATUSBAR");
             mContext.sendOrderedBroadcastAsUser(mIntent, UserHandle.CURRENT,
                             null, null, null, 0, null, null);
        }
    };
+
+     BroadcastReceiver mPcmControlReceiver = new BroadcastReceiver(){
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            Log.v("cjy", "in pcm control");
+            String sz = intent.getStringExtra("args");
+            if (sz != null && !sz.isEmpty()){
+                String szrun = "";
+                szrun += "echo ";
+                szrun += sz;
+                szrun += " > /sys/devices/platform/ff110000.i2c/i2c-1/1-0010/es8323_sound/enable_send";
+                adbcommand(szrun);
+                Log.v("adbcommand", szrun);
+            }
         }
     };
 
+    public String adbcommand(String command) {              
+        java.lang.Process process = null;
+        //Process process = null;
+        DataOutputStream os = null;
+        String excresult = "";
+        try {
+            process = Runtime.getRuntime().exec("su");
+            os = new DataOutputStream(process.getOutputStream());
+            os.writeBytes(command + "\n");
+            os.writeBytes("exit\n");
+            os.flush();
+            BufferedReader in = new BufferedReader(new InputStreamReader(
+                    process.getInputStream()));
+            StringBuffer stringBuffer = new StringBuffer();
+            String line = null;
+            while ((line = in.readLine()) != null) {
+                stringBuffer.append(line + " ");
+            }
+            excresult = stringBuffer.toString();
+            in.close();
+            process.destroy();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }finally {
+        }
+        return excresult;
+    }
+
     // Called on the PowerManager's Notifier thread.
     @Override
     public void startedGoingToSleep(int why) {

通过adb发布广播即可将micloop####写入到/sys/devices/platform/ff110000.i2c/i2c-1/1-0010/es8323_sound/enable_send。

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