Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

packages-apps-Settings: Commit

packages/apps/Settings


Commit MetaInfo

Revision7fa290dbcda3565c50de73c5322cef1d93866adc (tree)
Time2020-04-14 23:49:48
AuthorChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

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.

Change Summary

Incremental Difference

--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
@@ -1366,6 +1366,7 @@
13661366 <string name="fcc_equipment_id" msgid="6596668314025646129">"设备 ID"</string>
13671367 <string name="baseband_version" msgid="2600182227599835857">"基带版本"</string>
13681368 <string name="kernel_version" msgid="3513538109381366881">"内核版本"</string>
1369+ <string name="opengl_version">"Open GL 驱动版本"</string>
13691370 <string name="build_number" msgid="9009733242117579826">"版本号"</string>
13701371 <string name="module_version" msgid="1787518340082046658">"Google Play 系统更新"</string>
13711372 <string name="device_info_not_available" msgid="4804474466616712326">"无法获取"</string>
--- a/res/values-zh-rTW/strings.xml
+++ b/res/values-zh-rTW/strings.xml
@@ -1366,6 +1366,7 @@
13661366 <string name="fcc_equipment_id" msgid="6596668314025646129">"設備 ID"</string>
13671367 <string name="baseband_version" msgid="2600182227599835857">"基頻版本"</string>
13681368 <string name="kernel_version" msgid="3513538109381366881">"核心版本"</string>
1369+ <string name="opengl_version">"Open GL 驅動版本"</string>
13691370 <string name="build_number" msgid="9009733242117579826">"版本號碼"</string>
13701371 <string name="module_version" msgid="1787518340082046658">"Google Play 系統更新"</string>
13711372 <string name="device_info_not_available" msgid="4804474466616712326">"無法取得"</string>
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3142,6 +3142,8 @@
31423142 <!-- About phone screen, setting option name [CHAR LIMIT=40] -->
31433143 <string name="kernel_version">Kernel version</string>
31443144 <!-- About phone screen, setting option name [CHAR LIMIT=40] -->
3145+ <string name="opengl_version">OpenGL driver version</string>
3146+ <!-- About phone screen, setting option name [CHAR LIMIT=40] -->
31453147 <string name="build_number">Build number</string>
31463148 <!-- About phone screen, tapping this button will take user to a seperate UI to check Google Play system update [CHAR LIMIT=60] -->
31473149 <string name="module_version">Google Play system update</string>
--- a/res/xml/firmware_version.xml
+++ b/res/xml/firmware_version.xml
@@ -61,6 +61,14 @@
6161 settings:enableCopying="true"
6262 settings:controller="com.android.settings.deviceinfo.firmwareversion.KernelVersionPreferenceController"/>
6363
64+ <!-- OpenGL driver -->
65+ <Preference
66+ android:key="opengl_version"
67+ android:title="@string/opengl_version"
68+ android:summary="@string/summary_placeholder"
69+ settings:enableCopying="true"
70+ settings:controller="com.android.settings.deviceinfo.firmwareversion.OpenGLVersionPreferenceController"/>
71+
6472 <!-- Build -->
6573 <Preference
6674 android:key="os_build_number"
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/firmwareversion/OpenGLVersionPreferenceController.java
@@ -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+}
Show on old repository browser