[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####"
相关推荐
ufo00l7 分钟前
Kotlin在Android中有哪些重要的应用和知识点是需要学习或者重点关注的
android
AJi8 分钟前
Android音视频框架探索(二):Binder——系统服务的通信基础
android·ffmpeg·音视频开发
tjsoft1 小时前
Nginx配置伪静态,URL重写
android·运维·nginx
努力学习的小廉1 小时前
【C++11(中)】—— 我与C++的不解之缘(三十一)
android·java·c++
tangweiguo030519871 小时前
打破界限:Android XML与Jetpack Compose深度互操作指南
android·kotlin·compose
Watink Cpper2 小时前
[MySQL初阶]MySQL(8)索引机制:下
android·数据库·b树·mysql·b+树·myisam·innodedb
一起搞IT吧3 小时前
高通camx IOVA内存不足,导致10-15x持续拍照后,点击拍照键定屏无反应,过一会相机闪退
android·数码相机
前行的小黑炭5 小时前
设计模式:为什么使用模板设计模式(不相同的步骤进行抽取,使用不同的子类实现)减少重复代码,让代码更好维护。
android·java·kotlin
ufo00l5 小时前
2025年了,Rxjava解决的用户痛点,是否kotlin协程也能解决,他们各有什么优缺点?
android
古鸽100865 小时前
libutils android::Thread 介绍
android