|
17 | 17 |
|
18 | 18 | import android.content.Context; |
19 | 19 | import android.os.SELinux; |
20 | | -import android.os.SystemProperties; |
21 | 20 | import androidx.preference.Preference; |
22 | 21 | import androidx.preference.PreferenceScreen; |
23 | | -import android.text.TextUtils; |
24 | 22 |
|
25 | 23 | import com.android.settings.R; |
26 | | -import com.android.settings.core.PreferenceControllerMixin; |
27 | | -import com.android.settingslib.core.AbstractPreferenceController; |
| 24 | +import com.android.settings.core.BasePreferenceController; |
28 | 25 |
|
29 | | -public class SELinuxStatusPreferenceController extends AbstractPreferenceController implements |
30 | | - PreferenceControllerMixin { |
| 26 | +public class SELinuxStatusPreferenceController extends BasePreferenceController { |
31 | 27 |
|
32 | 28 | private static final String KEY_SELINUX_STATUS = "selinux_status"; |
| 29 | + private static final String TAG = "SELinuxStatusPreferenceController"; |
33 | 30 |
|
34 | | - public SELinuxStatusPreferenceController(Context context) { |
35 | | - super(context); |
| 31 | + public SELinuxStatusPreferenceController(Context context, String key) { |
| 32 | + super(context, key); |
36 | 33 | } |
37 | 34 |
|
38 | 35 | @Override |
39 | | - public boolean isAvailable() { |
40 | | - return true; |
| 36 | + public int getAvailabilityStatus() { |
| 37 | + return AVAILABLE; |
41 | 38 | } |
42 | 39 |
|
43 | 40 | @Override |
44 | | - public String getPreferenceKey() { |
45 | | - return KEY_SELINUX_STATUS; |
46 | | - } |
47 | | - |
48 | | - @Override |
49 | | - public void displayPreference(PreferenceScreen screen) { |
50 | | - super.displayPreference(screen); |
51 | | - final Preference pref = screen.findPreference(KEY_SELINUX_STATUS); |
52 | | - if (pref == null) { |
53 | | - return; |
54 | | - } |
| 41 | + public CharSequence getSummary() { |
55 | 42 | if (!SELinux.isSELinuxEnabled()) { |
56 | | - String status = mContext.getResources().getString(R.string.selinux_status_disabled); |
57 | | - pref.setSummary(status); |
58 | | - } else if (!SELinux.isSELinuxEnforced()) { |
59 | | - String status = mContext.getResources().getString(R.string.selinux_status_permissive); |
60 | | - pref.setSummary(status); |
| 43 | + return mContext.getResources().getString(R.string.selinux_status_disabled); |
| 44 | + } else if (SELinux.isSELinuxEnforced()) { |
| 45 | + return mContext.getResources().getString(R.string.selinux_status_enforcing); |
| 46 | + } else { |
| 47 | + return mContext.getResources().getString(R.string.selinux_status_permissive); |
61 | 48 | } |
62 | 49 | } |
63 | | -} |
64 | 50 |
|
| 51 | +} |
0 commit comments