OSDN Git Service

Add Android-x86 dashboard
[android-x86/packages-apps-Settings.git] / src / com / android / settings / system / AndroidX86DashboardFragment.java
1 /*
2  * Copyright (C) 2018 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.system;
18
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;
26
27 public class AndroidX86DashboardFragment extends SettingsPreferenceFragment {
28
29     private SwitchPreference mNativeBridgePreference;
30
31     private static final String KEY_TOGGLE_NB = "toggle_nb";
32     private static final String PROPERTY_NATIVEBRIDGE = "persist.sys.nativebridge";
33
34     @Override
35     public void onCreate(Bundle icicle) {
36         super.onCreate(icicle);
37
38         addPreferencesFromResource(R.xml.android_x86_options);
39         mNativeBridgePreference = (SwitchPreference) findPreference(KEY_TOGGLE_NB);
40         mNativeBridgePreference.setChecked(SystemProperties.getBoolean(PROPERTY_NATIVEBRIDGE, false));
41     }
42
43     @Override
44     public boolean onPreferenceTreeClick(Preference preference) {
45         if (preference == mNativeBridgePreference) {
46             SystemProperties.set(PROPERTY_NATIVEBRIDGE, mNativeBridgePreference.isChecked() ? "1" : "0");
47         }
48         return super.onPreferenceTreeClick(preference);
49     }
50
51     @Override
52     public int getMetricsCategory() {
53         return MetricsEvent.APPLICATION;
54     }
55 }