问题描述
我想获得dumpsys统计[喜欢dumpsys cpuinfo中,dumpsys电池。我在java中执行这些并将其写入文件。但我得到,
2012.06.20 7时32分19秒
权限拒绝:不能私自从PID = 862,UID = 10040倾倒cpuinfo的android.permission.DUMP
所有dumpsys命令。
我已经加入和android.permission.BATTERY_STATS
的权限android.permission.DUMP android.manifest。但是,没有获得resulyPlease帮助其critical.The code我用的是如下其中cmd包含dumpsys cpuinfo的或dumpsys电池[人]
日历CAL = Calendar.getInstance();
SimpleDateFormat的SDF =新的SimpleDateFormat(YYYY.MM.DD HH:MM:SS);
System.setOut(新的PrintStream(新的FileOutputStream(/ SD卡/显示器/+文件+TXT,FALSE)));
的System.out.println(\ñ\ N+ sdf.format(cal.getTime()));
Log.w(CMD-FN,CMD);
。工艺=调用Runtime.getRuntime()EXEC(CMD);
process.waitFor();
BufferedReader中的BufferedReader =新的BufferedReader(新的InputStreamReader(process.getInputStream()));
字符串缓冲区=;
而((缓冲= bufferedReader.readLine())!= NULL)
{
//fileobj.write(buffer);
的System.out.println(缓冲液);
//output.write(buffer);
}
缓冲=;
的BufferedReader缓冲=新的BufferedReader(新的InputStreamReader(process.getErrorStream()));
而((缓冲= buffered.readLine())!= NULL)
{
Log.w(异常,缓冲区);
}
下面是我的清单项目
<使用-权限的Android:名称=android.permission.WRITE_EXTERNAL_STORAGE/>
<使用-权限的Android:名称=android.permission.INTERNET对/>
<使用-权限的Android:名称=android.permission.DUMP/>
<使用-权限的Android:名称=android.permission.BATTERY_STATS/>
<使用-权限的Android:名称=android.permission.READ_PHONE_STATE/>
转储权限被定义为安卓的ProtectionLevel =signatureOrSystem
所以你不能把它除非您的应用程序与平台密钥签名,或安装在系统分区。
I am trying to obtain the dumpsys statistics [like dumpsys cpuinfo, dumpsys battery]. I executing these in java and writing it to a file. But I am getting,
2012.06.20 07:32:19
Permission Denial: can't dump cpuinfo from from pid=862, uid=10040 without permission android.permission.DUMP
for all dumpsys commands.
I have added the permission "android.permission.DUMP"
and "android.permission.BATTERY_STATS"
in android.manifest. But, not obtaining the resulyPlease help as its critical.The code I use is as below where cmd contains dumpsys cpuinfo or dumpsys battery [anyone]
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
System.setOut(new PrintStream(new FileOutputStream("/sdcard/Monitor/"+file+".txt",false)));
System.out.println("\n\n"+sdf.format(cal.getTime()));
Log.w("cmd-fn", cmd);
process=Runtime.getRuntime().exec(cmd);
process.waitFor();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String buffer="";
while((buffer=bufferedReader.readLine())!=null)
{
//fileobj.write(buffer);
System.out.println(buffer);
//output.write(buffer);
}
buffer="";
BufferedReader buffered = new BufferedReader(new InputStreamReader(process.getErrorStream()));
while((buffer=buffered.readLine())!=null)
{
Log.w("exception",buffer);
}
Below is my manifest entries
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.DUMP" />
<uses-permission android:name="android.permission.BATTERY_STATS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
The DUMP permission is defined as android:protectionLevel="signatureOrSystem"
so you can't get it unless your app is signed with the platform key, or installed in the system partition.
这篇关于Dumpsys许可拒绝在java中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!