title: How to run adb shell commands like dumpsys in my app in Oreo?
body: <p>I am creating a basic benchmark app and need to display the total GPU usage of the device on it. The shell command <code>dumpsys gfxinfo</code> displays the information in android oreo. The issue is that I am unable to run this command from my app.</p>
  
  <p>Please find below my Android Manifest here:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  coreApp = "true"
  package="com.vis.benchmark"&gt;
  &lt;!-- android:sharedUserId="android.uid.system" --&gt;
   &lt;uses-permission
      android:name="android.permission.PACKAGE_USAGE_STATS"
      tools:ignore="ProtectedPermissions" /&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme"&gt;
      &lt;activity android:name=".MainActivity"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  
      &lt;activity android:name=".GFX_info"&gt;&lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>And the java code:</p>
  
  <pre><code>public class GFX_info extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_actest);
      TextView tv = findViewById(R.id.t4);
      String[] cmd = {"dumpsys gfxinfo"};
      Process prc;
      try {
          Log.d("PINFO","step 1");
          prc = Runtime.getRuntime().exec(cmd);
          Log.d("PINFO","step 2");
          OutputStream op = prc.getOutputStream();
          BufferedReader bf = new BufferedReader(new InputStreamReader((prc.getInputStream())));
          bf.markSupported();
          String line = bf.readLine();
          tv.setText(bf.readLine());
          for(int i = 0 ;i &lt; 5 ; i++){
              tv.append(line);
              Log.d("GFX",line);
              line = bf.readLine();
          }
  
      } catch (IOException e) {
          e.printStackTrace();
          Log.d("PINFO","error");
      } }
  </code></pre>
  
  <p>In my console I get step 1 and then error , so it doesn't reach till step 2.</p>