4

When running the following command from termial:

adb shell dumpsys | grep GLES

The output is:

GLES: Qualcomm, Adreno (TM) 330, OpenGL ES 3.0 V@53.0 AU@ (CL@)

However I am unable to get the output when running programatically.

String GPUModel = "";
String command = "adb shell dumpsys | grep GLES";

try {

    InputStream inputStream = Runtime.getRuntime()
                                         .exec(command)
                                         .getInputStream();

    InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
    BufferedReader bufferedReader = new BufferedReader(inputStreamReader);

    GPUModel = bufferedReader.readLine();

} catch (IOException e) {
        e.printStackTrace();
}

GPUModel is null.

genpfault
  • 51,148
  • 11
  • 85
  • 139
JY2k
  • 2,879
  • 1
  • 31
  • 60

2 Answers2

2

You can't run the dumpsys command from your app. It'd require the DUMP permission which only system apps and apps signed with the same key as the system are granted.

cygery
  • 2,309
  • 3
  • 18
  • 25
2

You should use glGetString to get GPU type:

String renderer = GLES20.glGetString(GLES20.GL_RENDERER);

However, if you need to check for certain feature of GPU you better not to check GPU name but check if necessary GL extension is available instead. You can retrieve all of them by requesting GL_EXTENSIONS:

String extensions = GLES20.glGetString(GLES20.GL_EXTENSIONS);
keaukraine
  • 5,315
  • 29
  • 54