Android-x86
Fork
Spenden

  • R/O
  • HTTP
  • SSH
  • HTTPS

packages-apps-Settings: Commit

packages/apps/Settings


Commit MetaInfo

Revision47a656d6cafa9e26f1f03aee8dfd21393ac7d8cf (tree)
Zeit2019-10-09 19:08:38
AutorChih-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.

Ändern Zusammenfassung

Diff

--- a/res/layout/dialog_firmware_version.xml
+++ b/res/layout/dialog_firmware_version.xml
@@ -77,6 +77,18 @@
7777
7878 <TextView
7979 style="@style/device_info_dialog_label"
80+ android:id="@+id/opengl_version_label"
81+ android:layout_width="match_parent"
82+ android:layout_height="wrap_content"
83+ android:text="@string/opengl_version"/>
84+ <TextView
85+ style="@style/device_info_dialog_value"
86+ android:id="@+id/opengl_version_value"
87+ android:layout_width="match_parent"
88+ android:layout_height="wrap_content"/>
89+
90+ <TextView
91+ style="@style/device_info_dialog_label"
8092 android:id="@+id/build_number_label"
8193 android:layout_width="match_parent"
8294 android:layout_height="wrap_content"
--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
@@ -1205,6 +1205,7 @@
12051205 <string name="fcc_equipment_id" msgid="149114368246356737">"设备 ID"</string>
12061206 <string name="baseband_version" msgid="1848990160763524801">"基带版本"</string>
12071207 <string name="kernel_version" msgid="9192574954196167602">"内核版本"</string>
1208+ <string name="opengl_version">"Open GL 驱动版本"</string>
12081209 <string name="build_number" msgid="3075795840572241758">"版本号"</string>
12091210 <string name="device_info_not_available" msgid="8062521887156825182">"无法获取"</string>
12101211 <string name="device_status_activity_title" msgid="1411201799384697904">"状态信息"</string>
--- a/res/values-zh-rTW/strings.xml
+++ b/res/values-zh-rTW/strings.xml
@@ -1205,6 +1205,7 @@
12051205 <string name="fcc_equipment_id" msgid="149114368246356737">"設備 ID"</string>
12061206 <string name="baseband_version" msgid="1848990160763524801">"基頻版本"</string>
12071207 <string name="kernel_version" msgid="9192574954196167602">"核心版本"</string>
1208+ <string name="opengl_version">"Open GL 驅動版本"</string>
12081209 <string name="build_number" msgid="3075795840572241758">"版本號碼"</string>
12091210 <string name="device_info_not_available" msgid="8062521887156825182">"無法取得"</string>
12101211 <string name="device_status_activity_title" msgid="1411201799384697904">"狀態"</string>
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2783,6 +2783,8 @@
27832783 <!-- About phone screen, setting option name [CHAR LIMIT=40] -->
27842784 <string name="kernel_version">Kernel version</string>
27852785 <!-- About phone screen, setting option name [CHAR LIMIT=40] -->
2786+ <string name="opengl_version">OpenGL driver version</string>
2787+ <!-- About phone screen, setting option name [CHAR LIMIT=40] -->
27862788 <string name="build_number">Build number</string>
27872789
27882790 <!-- About phone screen, show when a value of some status item is unavailable. -->
--- a/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDialogFragment.java
+++ b/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDialogFragment.java
@@ -88,6 +88,7 @@ public class FirmwareVersionDialogFragment extends InstrumentedDialogFragment {
8888 new SecurityPatchLevelDialogController(this).initialize();
8989 new BasebandVersionDialogController(this).initialize();
9090 new KernelVersionDialogController(this).initialize();
91+ new OpenGLVersionDialogController(this).initialize();
9192 new BuildNumberDialogController(this).initialize();
9293 }
9394 }
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/firmwareversion/OpenGLVersionDialogController.java
@@ -0,0 +1,98 @@
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+package com.android.settings.deviceinfo.firmwareversion;
17+
18+import android.graphics.SurfaceTexture;
19+import android.opengl.EGL14;
20+import android.opengl.GLES20;
21+import android.util.Log;
22+import com.android.settings.R;
23+import javax.microedition.khronos.egl.EGL10;
24+import javax.microedition.khronos.egl.EGLConfig;
25+import javax.microedition.khronos.egl.EGLContext;
26+import javax.microedition.khronos.egl.EGLDisplay;
27+import javax.microedition.khronos.egl.EGLSurface;
28+
29+public class OpenGLVersionDialogController {
30+
31+ private static final int OPENGL_VERSION_VALUE_ID = R.id.opengl_version_value;
32+ private static final String LOG_TAG = "opengl_version";
33+
34+ private final FirmwareVersionDialogFragment mDialog;
35+
36+ public OpenGLVersionDialogController(FirmwareVersionDialogFragment dialog) {
37+ mDialog = dialog;
38+ }
39+
40+ public void initialize() {
41+ // Create an EGL Context
42+ // References:
43+ // [1] http://wlog.flatlib.jp/archive/1/2013-12-22
44+ // [2] packages/apps/Camera2/src/com/android/camera/SurfaceTextureRenderer.java
45+
46+ EGL10 egl = (EGL10) EGLContext.getEGL();
47+ EGLSurface eglSurface = null;
48+ EGLContext eglContext = null;
49+
50+ // Initialize display
51+ EGLDisplay eglDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
52+ if (eglDisplay == EGL10.EGL_NO_DISPLAY) {
53+ Log.w(LOG_TAG, "eglGetDisplay failed");
54+ }
55+ int[] iparam = new int[2];
56+ if (!egl.eglInitialize(eglDisplay, iparam)) {
57+ Log.w(LOG_TAG, "eglInitialize failed");
58+ }
59+
60+ // Choose config
61+ EGLConfig[] eglConfigs = new EGLConfig[1];
62+ final int[] configSpec = { EGL10.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT, EGL10.EGL_NONE };
63+ if (egl.eglChooseConfig(eglDisplay, configSpec, eglConfigs, 1, iparam) && iparam[0] > 0) {
64+ // create surface
65+ SurfaceTexture surfaceTexture = new SurfaceTexture(0);
66+ eglSurface = egl.eglCreateWindowSurface(eglDisplay, eglConfigs[0], surfaceTexture, null);
67+ if (eglSurface == null || eglSurface == EGL10.EGL_NO_SURFACE) {
68+ Log.w(LOG_TAG, "eglCreateWindowSurface failed");
69+ } else {
70+ // Create context
71+ final int[] attribList = { EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
72+ eglContext = egl.eglCreateContext(
73+ eglDisplay, eglConfigs[0], EGL10.EGL_NO_CONTEXT, attribList);
74+ if (eglContext == null || eglContext == EGL10.EGL_NO_CONTEXT) {
75+ Log.w(LOG_TAG, "eglCreateContext failed");
76+ }
77+
78+ // Bind context
79+ if (!egl.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)) {
80+ Log.w(LOG_TAG, "eglMakeCurrent failed");
81+ }
82+ }
83+ } else {
84+ Log.w(LOG_TAG, "eglChooseConfig failed");
85+ }
86+
87+ mDialog.setText(OPENGL_VERSION_VALUE_ID,
88+ "GL Vendor: " + GLES20.glGetString(GLES20.GL_VENDOR) + "\n" +
89+ "GL Renderer: " + GLES20.glGetString(GLES20.GL_RENDERER) + "\n" +
90+ "GL Version: " + GLES20.glGetString(GLES20.GL_VERSION));
91+
92+ if (eglContext != null) {
93+ egl.eglMakeCurrent(eglDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
94+ egl.eglDestroyContext(eglDisplay, eglContext);
95+ egl.eglDestroySurface(eglDisplay, eglSurface);
96+ }
97+ }
98+}
Show on old repository browser