packages/apps/Settings
Révision | c3305a18cbc49f28e9476db630325c8a7fd2f84d (tree) |
---|---|
l'heure | 2021-11-05 10:36:41 |
Auteur | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Mauro Rossi |
Add information about OpenGL driver version
In order to get Mesa / OpenGL ES info, an EGL context is required.
Without it, GLES20.glGetString returns NULL.
@@ -1336,6 +1336,7 @@ | ||
1336 | 1336 | <string name="fcc_equipment_id" msgid="6596668314025646129">"设备 ID"</string> |
1337 | 1337 | <string name="baseband_version" msgid="2600182227599835857">"基带版本"</string> |
1338 | 1338 | <string name="kernel_version" msgid="3513538109381366881">"内核版本"</string> |
1339 | + <string name="opengl_version">"Open GL 驱动版本"</string> | |
1339 | 1340 | <string name="build_number" msgid="9009733242117579826">"版本号"</string> |
1340 | 1341 | <string name="module_version" msgid="1787518340082046658">"Google Play 系统更新"</string> |
1341 | 1342 | <string name="device_info_not_available" msgid="4804474466616712326">"无法获取"</string> |
@@ -1336,6 +1336,7 @@ | ||
1336 | 1336 | <string name="fcc_equipment_id" msgid="6596668314025646129">"設備 ID"</string> |
1337 | 1337 | <string name="baseband_version" msgid="2600182227599835857">"基頻版本"</string> |
1338 | 1338 | <string name="kernel_version" msgid="3513538109381366881">"核心版本"</string> |
1339 | + <string name="opengl_version">"Open GL 驅動版本"</string> | |
1339 | 1340 | <string name="build_number" msgid="9009733242117579826">"版本號碼"</string> |
1340 | 1341 | <string name="module_version" msgid="1787518340082046658">"Google Play 系統更新"</string> |
1341 | 1342 | <string name="device_info_not_available" msgid="4804474466616712326">"無法取得"</string> |
@@ -3069,6 +3069,8 @@ | ||
3069 | 3069 | <!-- About phone screen, setting option name [CHAR LIMIT=40] --> |
3070 | 3070 | <string name="kernel_version">Kernel version</string> |
3071 | 3071 | <!-- About phone screen, setting option name [CHAR LIMIT=40] --> |
3072 | + <string name="opengl_version">OpenGL driver version</string> | |
3073 | + <!-- About phone screen, setting option name [CHAR LIMIT=40] --> | |
3072 | 3074 | <string name="build_number">Build number</string> |
3073 | 3075 | <!-- About phone screen, tapping this button will take user to a seperate UI to check Google Play system update [CHAR LIMIT=60] --> |
3074 | 3076 | <string name="module_version">Google Play system update</string> |
@@ -63,6 +63,14 @@ | ||
63 | 63 | settings:enableCopying="true" |
64 | 64 | settings:controller="com.android.settings.deviceinfo.firmwareversion.KernelVersionPreferenceController"/> |
65 | 65 | |
66 | + <!-- OpenGL driver --> | |
67 | + <Preference | |
68 | + android:key="opengl_version" | |
69 | + android:title="@string/opengl_version" | |
70 | + android:summary="@string/summary_placeholder" | |
71 | + settings:enableCopying="true" | |
72 | + settings:controller="com.android.settings.deviceinfo.firmwareversion.OpenGLVersionPreferenceController"/> | |
73 | + | |
66 | 74 | <!-- Build --> |
67 | 75 | <Preference |
68 | 76 | android:key="os_build_number" |
@@ -0,0 +1,110 @@ | ||
1 | +/* | |
2 | + * Copyright (C) 2019 The Android-x86 Open Source Project | |
3 | + * | |
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | + * you may not use this file except in compliance with the License. | |
6 | + * You may obtain a copy of the License at | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | + * Unless required by applicable law or agreed to in writing, software | |
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | + * See the License for the specific language governing permissions and | |
14 | + * limitations under the License. | |
15 | + */ | |
16 | + | |
17 | +package com.android.settings.deviceinfo.firmwareversion; | |
18 | + | |
19 | +import android.content.Context; | |
20 | +import android.graphics.SurfaceTexture; | |
21 | +import android.opengl.EGL14; | |
22 | +import android.opengl.GLES20; | |
23 | +import android.util.Log; | |
24 | +import com.android.settings.core.BasePreferenceController; | |
25 | + | |
26 | +import javax.microedition.khronos.egl.EGL10; | |
27 | +import javax.microedition.khronos.egl.EGLConfig; | |
28 | +import javax.microedition.khronos.egl.EGLContext; | |
29 | +import javax.microedition.khronos.egl.EGLDisplay; | |
30 | +import javax.microedition.khronos.egl.EGLSurface; | |
31 | + | |
32 | +public class OpenGLVersionPreferenceController extends BasePreferenceController { | |
33 | + | |
34 | + private static final String LOG_TAG = "opengl_version"; | |
35 | + | |
36 | + private String mResult; | |
37 | + | |
38 | + public OpenGLVersionPreferenceController(Context context, String preferenceKey) { | |
39 | + super(context, preferenceKey); | |
40 | + initialize(); | |
41 | + } | |
42 | + | |
43 | + @Override | |
44 | + public int getAvailabilityStatus() { | |
45 | + return AVAILABLE; | |
46 | + } | |
47 | + | |
48 | + @Override | |
49 | + public CharSequence getSummary() { | |
50 | + return mResult; | |
51 | + } | |
52 | + | |
53 | + private void initialize() { | |
54 | + // Create an EGL Context | |
55 | + // References: | |
56 | + // [1] http://wlog.flatlib.jp/archive/1/2013-12-22 | |
57 | + // [2] packages/apps/Camera2/src/com/android/camera/SurfaceTextureRenderer.java | |
58 | + | |
59 | + EGL10 egl = (EGL10) EGLContext.getEGL(); | |
60 | + EGLSurface eglSurface = null; | |
61 | + EGLContext eglContext = null; | |
62 | + | |
63 | + // Initialize display | |
64 | + EGLDisplay eglDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); | |
65 | + if (eglDisplay == EGL10.EGL_NO_DISPLAY) { | |
66 | + Log.w(LOG_TAG, "eglGetDisplay failed"); | |
67 | + } | |
68 | + int[] iparam = new int[2]; | |
69 | + if (!egl.eglInitialize(eglDisplay, iparam)) { | |
70 | + Log.w(LOG_TAG, "eglInitialize failed"); | |
71 | + } | |
72 | + | |
73 | + // Choose config | |
74 | + EGLConfig[] eglConfigs = new EGLConfig[1]; | |
75 | + final int[] configSpec = { EGL10.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT, EGL10.EGL_NONE }; | |
76 | + if (egl.eglChooseConfig(eglDisplay, configSpec, eglConfigs, 1, iparam) && iparam[0] > 0) { | |
77 | + // create surface | |
78 | + SurfaceTexture surfaceTexture = new SurfaceTexture(0); | |
79 | + eglSurface = egl.eglCreateWindowSurface(eglDisplay, eglConfigs[0], surfaceTexture, null); | |
80 | + if (eglSurface == null || eglSurface == EGL10.EGL_NO_SURFACE) { | |
81 | + Log.w(LOG_TAG, "eglCreateWindowSurface failed"); | |
82 | + } else { | |
83 | + // Create context | |
84 | + final int[] attribList = { EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE }; | |
85 | + eglContext = egl.eglCreateContext( | |
86 | + eglDisplay, eglConfigs[0], EGL10.EGL_NO_CONTEXT, attribList); | |
87 | + if (eglContext == null || eglContext == EGL10.EGL_NO_CONTEXT) { | |
88 | + Log.w(LOG_TAG, "eglCreateContext failed"); | |
89 | + } | |
90 | + | |
91 | + // Bind context | |
92 | + if (!egl.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)) { | |
93 | + Log.w(LOG_TAG, "eglMakeCurrent failed"); | |
94 | + } | |
95 | + } | |
96 | + } else { | |
97 | + Log.w(LOG_TAG, "eglChooseConfig failed"); | |
98 | + } | |
99 | + | |
100 | + mResult = "GL Vendor: " + GLES20.glGetString(GLES20.GL_VENDOR) + "\n" + | |
101 | + "GL Renderer: " + GLES20.glGetString(GLES20.GL_RENDERER) + "\n" + | |
102 | + "GL Version: " + GLES20.glGetString(GLES20.GL_VERSION); | |
103 | + | |
104 | + if (eglContext != null) { | |
105 | + egl.eglMakeCurrent(eglDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT); | |
106 | + egl.eglDestroyContext(eglDisplay, eglContext); | |
107 | + egl.eglDestroySurface(eglDisplay, eglSurface); | |
108 | + } | |
109 | + } | |
110 | +} |