[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####"
相关推荐
文 丰13 分钟前
【Android Studio】2024.1.1最新版本AS调试老项目(老版AS项目文件、旧gradle)导入其他人的项目
android·ide·android studio
Yongqiang Cheng1 小时前
在线查看 Android 系统源代码 Android Code Search
android·在线查看·android 系统源代码·code search
CYRUS STUDIO1 小时前
LineageOS源码下载和编译(Xiaomi Mi 6X,wayne)
android·刷机·lineageos·android源码编译
竹等寒2 小时前
中间件常见漏洞
android·web安全·网络安全·中间件
CCTV果冻爽4 小时前
ADB ROOT开启流程
adb
zeruns8024 小时前
如何用安卓玩Java版Minecraft,安卓手机安装我的世界Java版游戏的教程
android·java·智能手机·minecraft·mc
WZF-Sang6 小时前
【MySQL】数据类型【mysql当中各自经典的数据类型的学习和使用】
linux·数据库·sql·学习·mysql·adb
我命由我123456 小时前
ADB 之 logcat 极简小抄(过滤日志、保存日志到文件)
android·运维·adb·android studio·安卓·运维开发·android-studio
不吃饭的猪6 小时前
mysql一主2从部署
android·mysql·adb
振华OPPO7 小时前
我的5周年创作纪念日,不忘初心,方得始终。
android·java·android studio·安卓·安卓app