Android获取GPU型号

JY2*_*Y2k 5 android opengl-es android-runtime android-shell

从终端运行以下命令时:

adb shell dumpsys | adb shell dumpsys | adb shell dumpsys | adb shell dumpsys | adb shell dumpsys 查询 GLES

输出是:

GLES:高通、Adreno (TM) 330、OpenGL ES 3.0 V@53.0 AU@ (CL@)

但是,以编程方式运行时我无法获得输出。

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();
}
Run Code Online (Sandbox Code Playgroud)

GPUModel 为空。

cyg*_*ery 2

您无法dumpsys从您的应用程序运行该命令。它需要 DUMP 权限,只有系统应用程序和使用与系统相同的密钥签名的应用程序才会被授予。