Skip to content

Commit

Permalink
Add Android-x86 dashboard
Browse files Browse the repository at this point in the history
Add an option to enable or disable native bridge.
More options will be added in the future.
  • Loading branch information
cwhuang authored and hmtheboy154 committed Aug 18, 2021
1 parent 40ae2ec commit 733fadd
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 0 deletions.
20 changes: 20 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3025,6 +3025,26 @@
android:value="com.android.settings.applications.AppAndNotificationDashboardFragment"/>
</activity>

<activity android:name=".Settings$AndroidX86DashboardActivity"
android:label="@string/android_x86_options_title"
android:icon="@drawable/ic_settings_applications">
<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.FRAGMENT_CLASS"
android:value="com.android.settings.system.AndroidX86DashboardFragment" />
<meta-data android:name="com.android.settings.category"
android:value="com.android.settings.category.ia.homepage" />
<meta-data android:name="com.android.settings.summary"
android:resource="@string/android_x86_dashboard_summary"/>
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
android:value="true" />
</activity>

<activity
android:name=".Settings$AccountDashboardActivity"
android:label="@string/account_dashboard_title"
Expand Down
4 changes: 4 additions & 0 deletions res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2011,6 +2011,10 @@
<string name="runningservicedetails_stop_dlg_title" msgid="6201041461740445113">"要停止系统服务吗?"</string>
<string name="runningservicedetails_stop_dlg_text" product="tablet" msgid="2076922609580490122">"如果停止此服务,您平板电脑上的某些功能也将随之停止工作,并在您将平板电脑关机然后再重新打开后才能使用。"</string>
<string name="runningservicedetails_stop_dlg_text" product="default" msgid="2625863973434309085">"如果停止此服务,您手机上的某些功能也将随之停止工作,并在您将手机关机然后再重新打开后才能使用。"</string>
<string name="android_x86_options_title">"安卓X86设置"</string>
<string name="android_x86_dashboard_summary">兼容模式、统计</string>
<string name="nativebridge_toggle_title">"兼容模式"</string>
<string name="nativebridge_toggle_summary">"可兼容於使用 arm 庫的应用"</string>
<string name="language_input_gesture_title" msgid="3292455685728572960">"语言、输入法和手势"</string>
<string name="language_input_gesture_summary_on_with_assist" msgid="8670153838520237089"></string>
<string name="language_input_gesture_summary_on_non_assist" msgid="2738661322747920463"></string>
Expand Down
4 changes: 4 additions & 0 deletions res/values-zh-rHK/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2011,6 +2011,10 @@
<string name="runningservicedetails_stop_dlg_title" msgid="6201041461740445113">"停止系統服務?"</string>
<string name="runningservicedetails_stop_dlg_text" product="tablet" msgid="2076922609580490122">"如果您停用這項服務,您平板電腦上的某些功能可能會停止正常運作,待您重新開機後才會恢復正常。"</string>
<string name="runningservicedetails_stop_dlg_text" product="default" msgid="2625863973434309085">"如果您停用這項服務,您手機上的某些功能可能會停止正常運作,待您重新開機後才會恢復正常。"</string>
<string name="android_x86_options_title">"Android-x86 設定"</string>
<string name="android_x86_dashboard_summary">原生相容模式、統計</string>
<string name="nativebridge_toggle_title">"原生相容模式"</string>
<string name="nativebridge_toggle_summary">"可相容於使用 arm 原生函式庫的應用程式"</string>
<string name="language_input_gesture_title" msgid="3292455685728572960">"語言、輸入和手勢"</string>
<string name="language_input_gesture_summary_on_with_assist" msgid="8670153838520237089"></string>
<string name="language_input_gesture_summary_on_non_assist" msgid="2738661322747920463"></string>
Expand Down
4 changes: 4 additions & 0 deletions res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2011,6 +2011,10 @@
<string name="runningservicedetails_stop_dlg_title" msgid="6201041461740445113">"停止系統服務?"</string>
<string name="runningservicedetails_stop_dlg_text" product="tablet" msgid="2076922609580490122">"如果你停用這項服務,你的平板電腦上的某些功能可能無法正常運作,待你重新開機後才會恢復正常。"</string>
<string name="runningservicedetails_stop_dlg_text" product="default" msgid="2625863973434309085">"如果你停用這項服務,你的手機上的某些功能可能無法正常運作,待你重新開機後才會恢復正常。"</string>
<string name="android_x86_options_title">"Android-x86 設定"</string>
<string name="android_x86_dashboard_summary">原生相容模式、統計</string>
<string name="nativebridge_toggle_title">"原生相容模式"</string>
<string name="nativebridge_toggle_summary">"可相容於使用 arm 原生函式庫的應用程式"</string>
<string name="language_input_gesture_title" msgid="3292455685728572960">"語言、輸入和手勢"</string>
<string name="language_input_gesture_summary_on_with_assist" msgid="8670153838520237089"></string>
<string name="language_input_gesture_summary_on_non_assist" msgid="2738661322747920463"></string>
Expand Down
6 changes: 6 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4664,6 +4664,12 @@
features of your phone may stop working correctly until you power it off
and then on again.</string>

<!-- Android-x86 settings -->
<string name="android_x86_options_title">Android-x86 options</string>
<string name="android_x86_dashboard_summary">Native bridge, statistics</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 Language, input & gestures setting on main settings screen. -->
<string name="language_input_gesture_title">Languages, input &amp; gestures</string>
Expand Down
26 changes: 26 additions & 0 deletions res/xml/android_x86_options.xml
Original file line number Diff line number Diff line change
@@ -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/android_x86_options_title">

<SwitchPreference android:key="toggle_nb"
android:title="@string/nativebridge_toggle_title"
android:summary="@string/nativebridge_toggle_summary"
android:persistent="false" />

</PreferenceScreen>
1 change: 1 addition & 0 deletions src/com/android/settings/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public static class NightDisplaySuggestionActivity extends NightDisplaySettingsA
public static class MyDeviceInfoActivity extends SettingsActivity { /* empty */ }
public static class ModuleLicensesActivity extends SettingsActivity { /* empty */ }
public static class ApplicationSettingsActivity extends SettingsActivity { /* empty */ }
public static class AndroidX86DashboardActivity extends SettingsActivity { /* empty */ }
public static class ManageApplicationsActivity extends SettingsActivity { /* empty */ }
public static class ManageAssistActivity extends SettingsActivity { /* empty */ }
public static class HighPowerApplicationsActivity extends SettingsActivity { /* empty */ }
Expand Down
3 changes: 3 additions & 0 deletions src/com/android/settings/core/gateway/SettingsGateway.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
import com.android.settings.shortcut.CreateShortcut;
import com.android.settings.sound.MediaControlsSettings;
import com.android.settings.support.SupportDashboardActivity;
import com.android.settings.system.AndroidX86DashboardFragment;
import com.android.settings.system.ResetDashboardFragment;
import com.android.settings.system.SystemDashboardFragment;
import com.android.settings.tts.TextToSpeechSettings;
Expand Down Expand Up @@ -296,6 +297,7 @@ public class SettingsGateway {
AppAndNotificationDashboardFragment.class.getName(),
WifiCallingDisclaimerFragment.class.getName(),
AccountDashboardFragment.class.getName(),
AndroidX86DashboardFragment.class.getName(),
EnterprisePrivacySettings.class.getName(),
WebViewAppPicker.class.getName(),
LockscreenDashboardFragment.class.getName(),
Expand Down Expand Up @@ -324,6 +326,7 @@ public class SettingsGateway {
Settings.NetworkDashboardActivity.class.getName(),
Settings.ConnectedDeviceDashboardActivity.class.getName(),
Settings.AppAndNotificationDashboardActivity.class.getName(),
Settings.AndroidX86DashboardActivity.class.getName(),
Settings.DisplaySettingsActivity.class.getName(),
Settings.SoundSettingsActivity.class.getName(),
Settings.StorageDashboardActivity.class.getName(),
Expand Down
55 changes: 55 additions & 0 deletions src/com/android/settings/system/AndroidX86DashboardFragment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (C) 2018 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.system;

import android.os.Bundle;
import android.os.SystemProperties;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;

public class AndroidX86DashboardFragment 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.android_x86_options);
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
public int getMetricsCategory() {
return MetricsEvent.APPLICATION;
}
}

0 comments on commit 733fadd

Please sign in to comment.