背景:
近来有学员反馈说wms课程中讲解的借壳Shell帮忙执行一些shell命令有问题,具体啥问题呢?
在ShellProvider的call方法加入如下代码:
目的就是想让shell帮我们执行一下settings值的写入,这里其实可以更加简单的settings put命令既可以,但学员就想知道为这样是不是也可以执行,其实也肯定是可以的哈。
但他发现如果在system_server中调用会报错如下:
08-26 15:21:35.004 19922 19922 E AndroidRuntime: Process: com.example.injectmotion, PID: 19922
08-26 15:21:35.004 19922 19922 E AndroidRuntime: java.lang.SecurityException: Given calling package android does not match caller’s uid 10189
原因分析
先看看这个源码是怎么写的