2 * Copyright (C) 2018 The Android-x86 Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.settings.system;
19 import android.os.Bundle;
20 import android.os.SystemProperties;
21 import androidx.preference.Preference;
22 import androidx.preference.SwitchPreference;
23 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
24 import com.android.settings.R;
25 import com.android.settings.SettingsPreferenceFragment;
27 public class AndroidX86DashboardFragment extends SettingsPreferenceFragment {
29 private SwitchPreference mNativeBridgePreference;
31 private static final String KEY_TOGGLE_NB = "toggle_nb";
32 private static final String PROPERTY_NATIVEBRIDGE = "persist.sys.nativebridge";
35 public void onCreate(Bundle icicle) {
36 super.onCreate(icicle);
38 addPreferencesFromResource(R.xml.android_x86_options);
39 mNativeBridgePreference = (SwitchPreference) findPreference(KEY_TOGGLE_NB);
40 mNativeBridgePreference.setChecked(SystemProperties.getBoolean(PROPERTY_NATIVEBRIDGE, false));
44 public boolean onPreferenceTreeClick(Preference preference) {
45 if (preference == mNativeBridgePreference) {
46 SystemProperties.set(PROPERTY_NATIVEBRIDGE, mNativeBridgePreference.isChecked() ? "1" : "0");
48 return super.onPreferenceTreeClick(preference);
52 public int getMetricsCategory() {
53 return MetricsEvent.APPLICATION;