OSDN Git Service

Merge remote-tracking branch 'cm/cm-14.1' into cm-14.1-x86
authorChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 20 May 2020 13:48:00 +0000 (21:48 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 20 May 2020 13:48:00 +0000 (21:48 +0800)
14 files changed:
AndroidManifest.xml
res/values-zh-rCN/strings.xml
res/values-zh-rHK/strings.xml
res/values-zh-rTW/strings.xml
res/values/strings.xml
res/xml/apps_compatibility_prefs.xml [new file with mode: 0644]
res/xml/device_info_settings.xml
src/com/android/settings/AppsCompatibility.java [new file with mode: 0644]
src/com/android/settings/ConfirmDeviceCredentialBaseActivity.java
src/com/android/settings/DeviceInfoSettings.java
src/com/android/settings/Settings.java
src/com/android/settings/SettingsActivity.java
src/com/android/settings/SmsDefaultDialog.java
src/com/android/settings/bluetooth/BluetoothPairingDialog.java

index 4871306..4b1bb7d 100755 (executable)
                        android:value="com.android.settings.applications.ManageDomainUrls" />
         </activity>
 
+        <activity android:name="Settings$AppsCompatibilityActivity"
+                android:label="@string/apps_compatibility_title"
+                android:icon="@drawable/ic_settings_applications"
+                android:taskAffinity="">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+            <intent-filter android:priority="6">
+                <action android:name="com.android.settings.action.SETTINGS" />
+            </intent-filter>
+            <meta-data android:name="com.android.settings.category"
+                android:value="com.android.settings.category.device" />
+            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+                android:value="com.android.settings.AppsCompatibility" />
+            <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
+                android:value="true" />
+        </activity>
+
         <activity android:name="Settings$MemorySettingsActivity"
                 android:label="@string/memory_settings_title"
                 android:icon="@drawable/ic_settings_memory"
index 74b54de..ede92f4 100644 (file)
     <string name="runningservicedetails_stop_dlg_title" msgid="4253292537154337233">"要停止系统服务吗?"</string>
     <string name="runningservicedetails_stop_dlg_text" product="tablet" msgid="3371302398335665793">"如果停止此服务,您平板电脑上的某些功能也将随之停止工作,并在您将平板电脑关机然后再重新打开后才能使用。"</string>
     <string name="runningservicedetails_stop_dlg_text" product="default" msgid="3920243762189484756">"如果停止此服务,您手机上的某些功能也将随之停止工作,并在您将手机关机然后再重新打开后才能使用。"</string>
+    <string name="apps_compatibility_title">"应用兼容性"</string>
+    <string name="nativebridge_toggle_title">"兼容模式"</string>
+    <string name="nativebridge_toggle_summary">"可兼容於使用 arm 庫的应用"</string>
     <string name="language_settings" msgid="8758655933029560944">"语言和输入法"</string>
     <string name="language_keyboard_settings_title" msgid="3709159207482544398">"语言和输入法"</string>
     <string name="keyboard_settings_category" msgid="8275523930352487827">"键盘和输入法"</string>
index 051663c..c1f7cd5 100644 (file)
     <string name="runningservicedetails_stop_dlg_title" msgid="4253292537154337233">"停止系統服務?"</string>
     <string name="runningservicedetails_stop_dlg_text" product="tablet" msgid="3371302398335665793">"如果您停用這項服務,您平板電腦上的某些功能可能會停止正常運作,待您重新開機後才會恢復正常。"</string>
     <string name="runningservicedetails_stop_dlg_text" product="default" msgid="3920243762189484756">"如果您停用這項服務,您手機上的某些功能可能會停止正常運作,待您重新開機後才會恢復正常。"</string>
+    <string name="apps_compatibility_title">"應用程式相容性"</string>
+    <string name="nativebridge_toggle_title">"原生相容模式"</string>
+    <string name="nativebridge_toggle_summary">"可相容於使用 arm 原生函式庫的應用程式"</string>
     <string name="language_settings" msgid="8758655933029560944">"語言及輸入"</string>
     <string name="language_keyboard_settings_title" msgid="3709159207482544398">"語言及輸入"</string>
     <string name="keyboard_settings_category" msgid="8275523930352487827">"鍵盤與輸入法"</string>
index ddddb7d..7d6bde0 100644 (file)
     <string name="system_update_settings_list_item_summary" msgid="3853057315907710747"></string>
     <string name="firmware_version" msgid="4801135784886859972">"Android 版本"</string>
     <string name="security_patch" msgid="8438384045870296634">"Android 安全性修補程式等級"</string>
+    <string name="device_manufacturer">"製造商"</string>
     <string name="model_info" msgid="1952009518045740889">"型號"</string>
     <string name="fcc_equipment_id" msgid="149114368246356737">"設備 ID"</string>
     <string name="baseband_version" msgid="1848990160763524801">"基頻版本"</string>
     <string name="kernel_version" msgid="9192574954196167602">"核心版本"</string>
+    <string name="opengl_version">"Open GL 驅動版本"</string>
     <string name="build_number" msgid="3075795840572241758">"版本號碼"</string>
     <string name="selinux_status" msgid="6212165375172061672">"SELinux 狀態"</string>
     <string name="device_info_not_available" msgid="8062521887156825182">"無法取得"</string>
     <string name="runningservicedetails_stop_dlg_title" msgid="4253292537154337233">"停止系統服務?"</string>
     <string name="runningservicedetails_stop_dlg_text" product="tablet" msgid="3371302398335665793">"如果您停用這項服務,您的平板電腦上的某些功能可能無法正常運作,待您重新開機後才會恢復正常。"</string>
     <string name="runningservicedetails_stop_dlg_text" product="default" msgid="3920243762189484756">"如果您停用這項服務,您的手機上的某些功能可能無法正常運作,待您重新開機後才會恢復正常。"</string>
+    <string name="apps_compatibility_title">"應用程式相容性"</string>
+    <string name="nativebridge_toggle_title">"原生相容模式"</string>
+    <string name="nativebridge_toggle_summary">"可相容於使用 arm 原生函式庫的應用程式"</string>
     <string name="language_settings" msgid="8758655933029560944">"語言與輸入設定"</string>
     <string name="language_keyboard_settings_title" msgid="3709159207482544398">"語言與輸入設定"</string>
     <string name="keyboard_settings_category" msgid="8275523930352487827">"鍵盤與輸入法"</string>
index b8121fb..0f0dd4a 100644 (file)
     <!-- About phone screen, status item label  [CHAR LIMIT=60] -->
     <string name="security_patch">Android security patch level</string>
     <!-- About phone screen, status item label  [CHAR LIMIT=40] -->
+    <string name="device_manufacturer">Manufacturer</string>
+    <!-- About phone screen, status item label  [CHAR LIMIT=40] -->
     <string name="model_info">Model</string>
     <!-- About phone screen, fcc equipment id label  [CHAR LIMIT=40] -->
     <string name="fcc_equipment_id">Equipment ID</string>
     <!-- About phone screen,  setting option name  [CHAR LIMIT=40] -->
     <string name="kernel_version">Kernel version</string>
     <!-- About phone screen,  setting option name  [CHAR LIMIT=40] -->
+    <string name="opengl_version">OpenGL driver version</string>
+    <!-- About phone screen,  setting option name  [CHAR LIMIT=40] -->
     <string name="build_number">Build number</string>
     <!-- About phone screen,  setting option name  [CHAR LIMIT=40] -->
     <string name="qgp_version">QGP Version</string>
         features of your phone may stop working correctly until you power it off
         and then on again.</string>
 
+    <!-- Apps compatibility settings -->
+    <string name="apps_compatibility_title">Apps compatibility</string>
+    <string name="nativebridge_toggle_title">Enable native bridge</string>
+    <string name="nativebridge_toggle_summary">To support apps with arm native libraries</string>
+
     <!-- Languages Settings --> <skip />
     <!-- Title of setting on main settings screen.  This item will take the user to the screen to tweak settings realted to locale and text -->
     <string name="language_settings">Languages&#160;&amp; input</string>
diff --git a/res/xml/apps_compatibility_prefs.xml b/res/xml/apps_compatibility_prefs.xml
new file mode 100644 (file)
index 0000000..f29f1b9
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 The Android-x86 Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+                  xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+        android:title="@string/apps_compatibility_title">
+
+    <SwitchPreference android:key="toggle_nb"
+        android:title="@string/nativebridge_toggle_title"
+        android:summary="@string/nativebridge_toggle_summary"
+        android:persistent="false" />
+
+</PreferenceScreen>
index d59486c..b22f41d 100644 (file)
                 android:title="@string/device_name"
                 android:summary="@string/device_info_default"/>
 
+        <!-- Device manufacturer -->
+        <Preference android:key="device_manufacturer"
+                style="?android:preferenceInformationStyle"
+                android:title="@string/device_manufacturer"
+                android:summary="@string/device_info_default"/>
+
         <!-- Device hardware model -->
         <com.android.settings.DividerPreference
                 android:key="device_model"
                 settings:allowDividerAbove="true"
                 settings:allowDividerBelow="true" />
 
+        <!-- OpenGL Version -->
+        <Preference android:key="opengl_version"
+                style="?android:preferenceInformationStyle"
+                android:title="@string/opengl_version"
+                android:summary="@string/device_info_default"/>
+
         <!-- Detailed build version -->
         <Preference android:key="build_number"
                 android:enabled="false"
diff --git a/src/com/android/settings/AppsCompatibility.java b/src/com/android/settings/AppsCompatibility.java
new file mode 100644 (file)
index 0000000..2e5d33c
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2015 The Android-x86 Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings;
+
+import android.os.Bundle;
+import android.os.SystemProperties;
+import android.support.v7.preference.Preference;
+import android.support.v14.preference.SwitchPreference;
+import com.android.internal.logging.MetricsProto.MetricsEvent;
+
+public class AppsCompatibility extends SettingsPreferenceFragment {
+
+    private SwitchPreference mNativeBridgePreference;
+
+    private static final String KEY_TOGGLE_NB = "toggle_nb";
+    private static final String PROPERTY_NATIVEBRIDGE = "persist.sys.nativebridge";
+
+    @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+
+        addPreferencesFromResource(R.xml.apps_compatibility_prefs);
+        mNativeBridgePreference = (SwitchPreference) findPreference(KEY_TOGGLE_NB);
+        mNativeBridgePreference.setChecked(SystemProperties.getBoolean(PROPERTY_NATIVEBRIDGE, false));
+    }
+
+    @Override
+    public boolean onPreferenceTreeClick(Preference preference) {
+        if (preference == mNativeBridgePreference) {
+            SystemProperties.set(PROPERTY_NATIVEBRIDGE, mNativeBridgePreference.isChecked() ? "1" : "0");
+        }
+        return super.onPreferenceTreeClick(preference);
+    }
+
+    @Override
+    protected int getMetricsCategory() {
+        return MetricsEvent.APPLICATION;
+    }
+}
index d488d7a..3580fcf 100644 (file)
@@ -45,6 +45,7 @@ public abstract class ConfirmDeviceCredentialBaseActivity extends SettingsActivi
             mDark = true;
         }
         super.onCreate(savedState);
+        getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
         mIsKeyguardLocked = savedState == null
                 ? getSystemService(KeyguardManager.class).isKeyguardLocked()
                 : savedState.getBoolean(STATE_IS_KEYGUARD_LOCKED, false);
index d8394dd..decae3c 100644 (file)
@@ -19,6 +19,18 @@ package com.android.settings;
 import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
+
+// Requirements for context creation
+import android.graphics.SurfaceTexture;
+import android.opengl.EGL14;
+import android.opengl.GLES20;
+import android.opengl.GLSurfaceView.EGLConfigChooser;
+import javax.microedition.khronos.egl.EGL10;
+import javax.microedition.khronos.egl.EGLConfig;
+import javax.microedition.khronos.egl.EGLContext;
+import javax.microedition.khronos.egl.EGLDisplay;
+import javax.microedition.khronos.egl.EGLSurface;
+
 import android.os.Build;
 import android.os.Bundle;
 import android.os.PersistableBundle;
@@ -62,6 +74,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
     private static final String PROPERTY_URL_SAFETYLEGAL = "ro.url.safetylegal";
     private static final String PROPERTY_SELINUX_STATUS = "ro.build.selinux";
     private static final String KEY_KERNEL_VERSION = "kernel_version";
+    private static final String KEY_OPENGL_VERSION = "opengl_version";
     private static final String KEY_BUILD_NUMBER = "build_number";
     private static final String KEY_DEVICE_MODEL = "device_model";
     private static final String KEY_DEVICE_NAME = "device_name";
@@ -83,6 +96,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
     private static final String KEY_MOD_VERSION = "mod_version";
     private static final String KEY_MOD_BUILD_DATE = "build_date";
     private static final String KEY_MOD_API_LEVEL = "mod_api_level";
+    private static final String KEY_DEVICE_MANUFACTURER = "device_manufacturer";
 
     static final int TAPS_TO_BE_A_DEVELOPER = 7;
 
@@ -115,6 +129,64 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
 
         addPreferencesFromResource(R.xml.device_info_settings);
 
+        // Create an EGL Context
+        // References:
+        // [1] http://wlog.flatlib.jp/archive/1/2013-12-22
+        // [2] packages/apps/Camera2/src/com/android/camera/SurfaceTextureRenderer.java
+
+        EGL10 egl = (EGL10) EGLContext.getEGL();
+        EGLSurface eglSurface = null;
+        EGLContext eglContext = null;
+
+        // initialize display
+        EGLDisplay eglDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
+        if (eglDisplay == EGL10.EGL_NO_DISPLAY) {
+            Log.w(LOG_TAG, "eglGetDisplay failed");
+        }
+        int[] iparam = new int[2];
+        if (!egl.eglInitialize(eglDisplay, iparam)) {
+            Log.w(LOG_TAG, "eglInitialize failed");
+        }
+
+        // choose config
+        EGLConfig[] eglConfigs = new EGLConfig[1];
+        final int[] configSpec = { EGL10.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT, EGL10.EGL_NONE };
+        if (egl.eglChooseConfig(eglDisplay, configSpec, eglConfigs, 1, iparam) && iparam[0] > 0) {
+            // create surface
+            SurfaceTexture surfaceTexture = new SurfaceTexture(0);
+            eglSurface = egl.eglCreateWindowSurface(
+                    eglDisplay, eglConfigs[0], surfaceTexture, null);
+            if (eglSurface == null || eglSurface == EGL10.EGL_NO_SURFACE) {
+                Log.w(LOG_TAG, "eglCreateWindowSurface failed");
+            } else {
+                // create context
+                final int[] attribList = { EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
+                eglContext = egl.eglCreateContext(
+                        eglDisplay, eglConfigs[0], EGL10.EGL_NO_CONTEXT, attribList);
+                if (eglContext == null || eglContext == EGL10.EGL_NO_CONTEXT) {
+                    Log.w(LOG_TAG, "eglCreateContext failed");
+                }
+
+                // bind context
+                if (!egl.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)) {
+                    Log.w(LOG_TAG, "eglMakeCurrent failed");
+                }
+            }
+        } else {
+            Log.w(LOG_TAG, "eglChooseConfig failed");
+        }
+
+        String opengl_version = "GL Vendor: " + GLES20.glGetString(GLES20.GL_VENDOR) + "\n" +
+            "GL Renderer: " + GLES20.glGetString(GLES20.GL_RENDERER) + "\n" +
+            "GL Version: " + GLES20.glGetString(GLES20.GL_VERSION);
+
+        if (eglContext != null) {
+            // release
+            egl.eglMakeCurrent(eglDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
+            egl.eglDestroyContext(eglDisplay, eglContext);
+            egl.eglDestroySurface(eglDisplay, eglSurface);
+        }
+
         setStringSummary(KEY_FIRMWARE_VERSION, Build.VERSION.RELEASE);
         findPreference(KEY_FIRMWARE_VERSION).setEnabled(true);
 
@@ -152,6 +224,8 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
         setValueSummary(KEY_MOD_BUILD_DATE, "ro.build.date");
         setExplicitValueSummary(KEY_MOD_API_LEVEL, constructApiLevelString());
         findPreference(KEY_MOD_API_LEVEL).setEnabled(true);
+        findPreference(KEY_OPENGL_VERSION).setSummary(opengl_version);
+        setStringSummary(KEY_DEVICE_MANUFACTURER, Build.MANUFACTURER);
 
         if (!SELinux.isSELinuxEnabled()) {
             String status = getResources().getString(R.string.selinux_status_disabled);
index 06f5a82..525511d 100644 (file)
@@ -54,6 +54,7 @@ public class Settings extends SettingsActivity {
     public static class NightDisplaySettingsActivity extends SettingsActivity { /* empty */ }
     public static class DeviceInfoSettingsActivity extends SettingsActivity { /* empty */ }
     public static class ApplicationSettingsActivity extends SettingsActivity { /* empty */ }
+    public static class AppsCompatibilityActivity extends SettingsActivity { /* empty */ }
     public static class ManageApplicationsActivity extends SettingsActivity { /* empty */ }
     public static class ManageAssistActivity extends SettingsActivity { /* empty */ }
     public static class AllApplicationsActivity extends SettingsActivity { /* empty */ }
index f186b29..8db6261 100755 (executable)
@@ -256,6 +256,7 @@ public class SettingsActivity extends SettingsDrawerActivity
             Settings.DisplaySettingsActivity.class.getName(),
             Settings.StorageSettingsActivity.class.getName(),
             Settings.ManageApplicationsActivity.class.getName(),
+            Settings.AppsCompatibilityActivity.class.getName(),
             Settings.PowerUsageSummaryActivity.class.getName(),
             Settings.GestureSettingsActivity.class.getName(),
             //personal_section
@@ -294,6 +295,7 @@ public class SettingsActivity extends SettingsDrawerActivity
             DisplaySettings.class.getName(),
             DeviceInfoSettings.class.getName(),
             ManageApplications.class.getName(),
+            AppsCompatibility.class.getName(),
             NotificationApps.class.getName(),
             ManageAssist.class.getName(),
             ProcessStatsUi.class.getName(),
@@ -738,7 +740,7 @@ public class SettingsActivity extends SettingsDrawerActivity
     }
 
     public void setDisplaySearchMenu(boolean displaySearch) {
-        if (displaySearch != mDisplaySearch) {
+        if (Utils.isDeviceProvisioned(this) && displaySearch != mDisplaySearch) {
             mDisplaySearch = displaySearch;
             invalidateOptionsMenu();
         }
index 73cca47..21ed424 100644 (file)
@@ -104,7 +104,7 @@ public final class SmsDefaultDialog extends AlertActivity implements
     }
 
     private boolean buildDialog(String packageName) {
-        TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
+        TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
         if (!tm.isSmsCapable()) {
             // No phone, no SMS
             return false;
@@ -214,7 +214,7 @@ public final class SmsDefaultDialog extends AlertActivity implements
             } else {
                 view.findViewById(R.id.default_label).setVisibility(View.GONE);
             }
-            ImageView imageView = (ImageView)view.findViewById(android.R.id.icon);
+            ImageView imageView = (ImageView) view.findViewById(android.R.id.icon);
             imageView.setImageDrawable(item.icon);
             return view;
         }
index d5a95f0..368b3f0 100644 (file)
@@ -218,8 +218,9 @@ public final class BluetoothPairingDialog extends AlertActivity implements
         } else {
             if ((mDevice.getBluetoothClass() != null) && (mDevice.getBluetoothClass().getDeviceClass()
                     == BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE)) {
-                contactSharing.setChecked(true);
-                mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_ALLOWED);
+                contactSharing.setChecked(false);
+                mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_REJECTED);
+                EventLog.writeEvent(0x534e4554, "73173182", -1, "");
             } else {
                 contactSharing.setChecked(false);
                 mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_REJECTED);
@@ -294,9 +295,8 @@ public final class BluetoothPairingDialog extends AlertActivity implements
         } else {
             if (mDevice.getBluetoothClass().getDeviceClass()
                     == BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE) {
-                contactSharing.setChecked(false);
-                mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_REJECTED);
-                EventLog.writeEvent(0x534e4554, "73173182", -1, "");
+                contactSharing.setChecked(true);
+                mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_ALLOWED);
             } else {
                 contactSharing.setChecked(false);
                 mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_REJECTED);