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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With