【问题标题】:Writing to sysfs entry through an android app is denied in android M在 android M 中通过 android 应用程序写入 sysfs 条目被拒绝
【发布时间】:2017-01-24 16:33:51
【问题描述】:

我正在尝试使用以下代码行通过 android 应用程序写入 sysfs 条目:

String command[]={"/system/bin/sh", 
                  "-c", 
                  "echo 0 > /sys/module/lge_handle_panic/parameters/gen_modem_panic",
                 };
Process p = Runtime.getRuntime().exec(command);

在 /system/priv-app 中安装应用程序时,它运行良好,并在 android L 中创建了调制解调器恐慌。但是,在 Android M 中没有执行任何操作。

我不确定 Android M 是否需要某些 SELinux 策略权限。

【问题讨论】:

  • 您是否检查过该文件在 Android-M 上是否存在?您是否尝试过从终端手动执行相同操作?执行该命令后您检查过dmesg 的输出吗?
  • @SamProtsenko 是的,文件存在。我找到了解决方案。我们需要手动将 SeLinux 策略设置为允许 echo 以在 android M 中工作。使用的命令:adb shell su root setenforce 0。

标签: android sysfs


【解决方案1】:

我们需要手动将 SeLinux 策略设置为允许,以便 echo 在 android M 中工作。 使用的命令: adb shell su root setenforce 0

【讨论】:

  • 可能不是最好的解决方案,因为这样做会完全禁用安全性。最好为您的情况编写相应的 SELinux 规则并将 SELinux 留在enforcing 模式。检查dmesg 输出以找出问题所在。有关如何编写 SELinux 规则的详细信息,请参阅 this 文档。虽然这种方式需要修改 rootfs 映像,但在您的情况下可能不方便。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-03-20
  • 1970-01-01
  • 1970-01-01
  • 2013-05-12
  • 1970-01-01
  • 2018-11-07
  • 2012-07-12
相关资源
最近更新 更多