can i access dumpsys file from android -


i developing tracker application need know application starting hardware (by using pid) e.g camera or gps. information logged dumpsys file in android. want access file in application ,do analysis on , extract required information. can access file through adb when same commands run form java coding permission denied error occurs. have added android.permission.dump in manifest file still error.

unfortunately "android.permission.dump" granted system apps.

unless sign application system signature , use system shared user id (android:shareduserid="android.uid.system") in manifest, won't able permission.

what redirect dumpsys output manually external storage , examine file fileinputstream , bufferedreader

ex: dumpsys > /sdcard/my_dump.txt

in .java class:

fileinputstream fis     = new fileinputstream("/sdcard/my_dump.txt"); bufferedreader  bfr     = new bufferedreader (new inputstreamreader(fis)); stringbuilder   builder = new stringbuilder  (); string          line    = "";  while ((line = br.readline()) != null) {     builder.append(line);     log.i("test", line); } 

you can check builder

string whateveryouarelookingfor = "camera"; if (builder.tostring().contains(whateveryouarelookingfor)) {     //do } 

i know it's not best solution can still out of it.

hope find solution, cheers.


Comments

Popular posts from this blog

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -

Laravel Bind Multiple Class to One Contract in The Service Provider -