JY2k
JY2k

Reputation: 2909

Android get GPU model

When running the following command from termial:

adb shell dumpsys | grep GLES

The output is:

GLES: Qualcomm, Adreno (TM) 330, OpenGL ES 3.0 [email protected] 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.

Upvotes: 5

Views: 6286

Answers (2)

keaukraine
keaukraine

Reputation: 5364

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);

Upvotes: 2

cygery
cygery

Reputation: 2319

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.

Upvotes: 2

Related Questions