diff options
Diffstat (limited to 'configpanel')
24 files changed, 0 insertions, 636 deletions
diff --git a/configpanel/Android.mk b/configpanel/Android.mk deleted file mode 100644 index 0bb699a..0000000 --- a/configpanel/Android.mk +++ /dev/null @@ -1,32 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := $(call all-java-files-under, src) -LOCAL_CERTIFICATE := platform -LOCAL_PRIVILEGED_MODULE := true -LOCAL_PACKAGE_NAME := ConfigPanel -LOCAL_PRIVATE_PLATFORM_APIS := true - -LOCAL_USE_AAPT2 := true - -LOCAL_STATIC_ANDROID_LIBRARIES := \ - android-support-v4 \ - android-support-v7-appcompat \ - android-support-v7-preference \ - android-support-v7-recyclerview \ - android-support-v13 \ - android-support-v14-preference \ - -LOCAL_STATIC_JAVA_LIBRARIES := \ - org.lineageos.platform.internal - -LOCAL_RESOURCE_DIR := \ - $(LOCAL_PATH)/res \ - $(TOP)/packages/resources/devicesettings/res - -LOCAL_PROGUARD_FLAG_FILES := proguard.flags - -LOCAL_PRIVILEGED_MODULE := true -LOCAL_MODULE_TAGS := optional - -include $(BUILD_PACKAGE) diff --git a/configpanel/AndroidManifest.xml b/configpanel/AndroidManifest.xml deleted file mode 100644 index bf3741f..0000000 --- a/configpanel/AndroidManifest.xml +++ /dev/null @@ -1,64 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (C) 2016 The CyanogenMod Project - Copyright (C) 2017-2018 The LineageOS 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. ---> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="org.lineageos.settings.device" - android:versionCode="6" - android:versionName="2.5" - android:sharedUserId="android.uid.system"> - - <uses-permission android:name="lineageos.permission.HARDWARE_ABSTRACTION_ACCESS" /> - - <uses-sdk - android:minSdkVersion="27" /> - - <application - android:icon="@mipmap/ic_launcher" - android:label="@string/device_settings_app_name" - android:theme="@style/Theme.Main" - android:defaultToDeviceProtectedStorage="true" - android:directBootAware="true"> - - <provider - android:name=".ConfigPanelSearchIndexablesProvider" - android:authorities="org.lineageos.settings.device" - android:multiprocess="false" - android:grantUriPermissions="true" - android:permission="android.permission.READ_SEARCH_INDEXABLES" - android:exported="true"> - <intent-filter> - <action android:name="android.content.action.SEARCH_INDEXABLES_PROVIDER" /> - </intent-filter> - </provider> - - <activity - android:name=".ButtonSettingsActivity" - android:label="@string/button_panel_title"> - <intent-filter> - <action android:name="org.lineageos.settings.device.ADDITIONAL_BUTTONS_SETTINGS" /> - <category android:name="android.intent.category.DEFAULT" /> - </intent-filter> - </activity> - - <receiver android:name=".Startup" > - <intent-filter> - <action android:name="lineageos.intent.action.INITIALIZE_LINEAGE_HARDWARE" /> - </intent-filter> - </receiver> - </application> - -</manifest> diff --git a/configpanel/proguard.flags b/configpanel/proguard.flags deleted file mode 100644 index 43b57d9..0000000 --- a/configpanel/proguard.flags +++ /dev/null @@ -1,3 +0,0 @@ --keepclasseswithmembers class * { - public <init>(android.content.Context, android.util.AttributeSet); -} diff --git a/configpanel/res/drawable/ic_settings_additional_buttons.xml b/configpanel/res/drawable/ic_settings_additional_buttons.xml deleted file mode 100644 index 044fc23..0000000 --- a/configpanel/res/drawable/ic_settings_additional_buttons.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (c) 2016 The CyanogenMod 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. ---> -<vector xmlns:android="http://schemas.android.com/apk/res/android" - android:width="24dp" - android:height="24dp" - android:viewportWidth="24" - android:viewportHeight="24"> - - <path - android:fillColor="@android:color/white" - android:pathData="M17,1L7,1C5.9,1,5,1.9,5,3v2h2v4H5v12c0,1.1,0.9,2,2,2h10c1.1,0,2-0.9,2-2V3C19,1.9,18.1,1,17,1z -M11,21H7v-2h4V21z M17,21 h-4v-2h4V21z" /> -</vector> diff --git a/configpanel/res/mipmap-anydpi/ic_launcher.xml b/configpanel/res/mipmap-anydpi/ic_launcher.xml deleted file mode 100644 index d8649ba..0000000 --- a/configpanel/res/mipmap-anydpi/ic_launcher.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (c) 2018 The LineageOS 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. ---> -<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> - <background android:drawable="@mipmap/ic_background"/> - <foreground android:drawable="@mipmap/ic_foreground"/> -</adaptive-icon> - diff --git a/configpanel/res/mipmap-hdpi/ic_background.png b/configpanel/res/mipmap-hdpi/ic_background.png Binary files differdeleted file mode 100644 index f01deeb..0000000 --- a/configpanel/res/mipmap-hdpi/ic_background.png +++ /dev/null diff --git a/configpanel/res/mipmap-hdpi/ic_foreground.png b/configpanel/res/mipmap-hdpi/ic_foreground.png Binary files differdeleted file mode 100644 index 97158bc..0000000 --- a/configpanel/res/mipmap-hdpi/ic_foreground.png +++ /dev/null diff --git a/configpanel/res/mipmap-mdpi/ic_background.png b/configpanel/res/mipmap-mdpi/ic_background.png Binary files differdeleted file mode 100644 index 58bcf52..0000000 --- a/configpanel/res/mipmap-mdpi/ic_background.png +++ /dev/null diff --git a/configpanel/res/mipmap-mdpi/ic_foreground.png b/configpanel/res/mipmap-mdpi/ic_foreground.png Binary files differdeleted file mode 100644 index 7b9bc07..0000000 --- a/configpanel/res/mipmap-mdpi/ic_foreground.png +++ /dev/null diff --git a/configpanel/res/mipmap-xhdpi/ic_background.png b/configpanel/res/mipmap-xhdpi/ic_background.png Binary files differdeleted file mode 100644 index 681a199..0000000 --- a/configpanel/res/mipmap-xhdpi/ic_background.png +++ /dev/null diff --git a/configpanel/res/mipmap-xhdpi/ic_foreground.png b/configpanel/res/mipmap-xhdpi/ic_foreground.png Binary files differdeleted file mode 100644 index c079116..0000000 --- a/configpanel/res/mipmap-xhdpi/ic_foreground.png +++ /dev/null diff --git a/configpanel/res/mipmap-xxhdpi/ic_background.png b/configpanel/res/mipmap-xxhdpi/ic_background.png Binary files differdeleted file mode 100644 index 1e707e8..0000000 --- a/configpanel/res/mipmap-xxhdpi/ic_background.png +++ /dev/null diff --git a/configpanel/res/mipmap-xxhdpi/ic_foreground.png b/configpanel/res/mipmap-xxhdpi/ic_foreground.png Binary files differdeleted file mode 100644 index ecc70af..0000000 --- a/configpanel/res/mipmap-xxhdpi/ic_foreground.png +++ /dev/null diff --git a/configpanel/res/mipmap-xxxhdpi/ic_background.png b/configpanel/res/mipmap-xxxhdpi/ic_background.png Binary files differdeleted file mode 100644 index b6e860b..0000000 --- a/configpanel/res/mipmap-xxxhdpi/ic_background.png +++ /dev/null diff --git a/configpanel/res/mipmap-xxxhdpi/ic_foreground.png b/configpanel/res/mipmap-xxxhdpi/ic_foreground.png Binary files differdeleted file mode 100644 index 3133594..0000000 --- a/configpanel/res/mipmap-xxxhdpi/ic_foreground.png +++ /dev/null diff --git a/configpanel/res/values/styles.xml b/configpanel/res/values/styles.xml deleted file mode 100644 index 8dbdd4f..0000000 --- a/configpanel/res/values/styles.xml +++ /dev/null @@ -1,50 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (C) 2014-2016 The CyanogenMod Project - (C) 2017 The LineageOS 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. ---> -<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <style name="Theme.Main" parent="@android:style/Theme.DeviceDefault.Settings"> - <item name="preferenceCategoryStyle">@style/Theme.Main.PreferenceCategoryStyle</item> - <item name="preferenceFragmentStyle">@style/Theme.Main.PreferenceFragmentStyle</item> - <item name="preferenceStyle">@style/Theme.Main.PreferenceStyle</item> - <item name="preferenceTheme">@style/Theme.Main.PreferenceTheme</item> - <item name="switchPreferenceStyle">@style/Theme.Main.SwitchPreferenceStyle</item> - </style> - - <style name="Theme.Main.PreferenceCategoryStyle" parent="@*android:style/Preference.DeviceDefault.Category"> - <item name="allowDividerAbove">true</item> - <item name="allowDividerBelow">true</item> - <item name="android:layout">@layout/preference_category_material_settings</item> - </style> - - <style name="Theme.Main.PreferenceFragmentStyle" parent="@*android:style/PreferenceFragment.Material"> - <item name="allowDividerAfterLastItem">false</item> - </style> - - <style name="Theme.Main.PreferenceStyle" parent="@*android:style/Preference.DeviceDefault"> - <item name="allowDividerAbove">false</item> - <item name="allowDividerBelow">true</item> - <item name="singleLineTitle">false</item> - <item name="android:layout">@layout/preference_material_settings</item> - </style> - - <style name="Theme.Main.PreferenceTheme"> - </style> - - <style name="Theme.Main.SwitchPreferenceStyle" parent="@style/Theme.Main.PreferenceStyle"> - <item name="widgetLayout">@*android:layout/preference_widget_switch</item> - </style> -</resources> diff --git a/configpanel/res/xml/button_panel.xml b/configpanel/res/xml/button_panel.xml deleted file mode 100644 index 7950ee2..0000000 --- a/configpanel/res/xml/button_panel.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (C) 2016 The CyanogenMod Project - (C) 2017 The LineageOS 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"> - - <SwitchPreference - android:key="button_swap" - android:title="@string/button_swap_title" - android:summary="@string/button_swap_summary" /> - -</PreferenceScreen> diff --git a/configpanel/src/org/lineageos/settings/device/ButtonSettingsActivity.java b/configpanel/src/org/lineageos/settings/device/ButtonSettingsActivity.java deleted file mode 100644 index 737dbd5..0000000 --- a/configpanel/src/org/lineageos/settings/device/ButtonSettingsActivity.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2016 The CyanogenMod Project - * (C) 2017 The LineageOS 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 org.lineageos.settings.device; - -import android.os.Bundle; -import android.preference.PreferenceActivity; - -public class ButtonSettingsActivity extends PreferenceActivity { - - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - getFragmentManager().beginTransaction().replace(android.R.id.content, - new ButtonSettingsFragment()).commit(); - } -} diff --git a/configpanel/src/org/lineageos/settings/device/ButtonSettingsFragment.java b/configpanel/src/org/lineageos/settings/device/ButtonSettingsFragment.java deleted file mode 100644 index 493aac9..0000000 --- a/configpanel/src/org/lineageos/settings/device/ButtonSettingsFragment.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2016 The CyanogenMod Project - * (C) 2017 The LineageOS 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 org.lineageos.settings.device; - -import android.app.ActionBar; -import android.content.SharedPreferences; -import android.os.Bundle; -import android.support.v14.preference.PreferenceFragment; -import android.support.v14.preference.SwitchPreference; -import android.support.v7.preference.ListPreference; -import android.support.v7.preference.Preference; -import android.support.v7.preference.Preference.OnPreferenceChangeListener; -import android.support.v7.preference.PreferenceCategory; -import android.support.v7.preference.PreferenceManager; -import android.text.TextUtils; -import android.view.MenuItem; - -import org.lineageos.internal.util.FileUtils; -import org.lineageos.internal.util.PackageManagerUtils; - -public class ButtonSettingsFragment extends PreferenceFragment - implements OnPreferenceChangeListener { - - @Override - public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { - addPreferencesFromResource(R.xml.button_panel); - final ActionBar actionBar = getActivity().getActionBar(); - actionBar.setDisplayHomeAsUpEnabled(true); - } - - @Override - public boolean onPreferenceChange(Preference pref, Object newValue) { - SwitchPreferenceBackend backend = Constants.sBackendsMap.get(pref.getKey()); - Boolean value = (Boolean) newValue; - - backend.setValue(value); - - return true; - } - - @Override - public void addPreferencesFromResource(int preferencesResId) { - super.addPreferencesFromResource(preferencesResId); - - // Initialize node preferences - for (String key : Constants.sBackendsMap.keySet()) { - SwitchPreference pref = (SwitchPreference) findPreference(key); - if (pref == null) { - continue; - } - - pref.setOnPreferenceChangeListener(this); - - SwitchPreferenceBackend backend = Constants.sBackendsMap.get(key); - if (!backend.isValid()) { - pref.setEnabled(false); - } else { - pref.setChecked(backend.getValue()); - } - } - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - if (item.getItemId() == android.R.id.home) { - getActivity().onBackPressed(); - return true; - } - return false; - } -} diff --git a/configpanel/src/org/lineageos/settings/device/ConfigPanelSearchIndexablesProvider.java b/configpanel/src/org/lineageos/settings/device/ConfigPanelSearchIndexablesProvider.java deleted file mode 100644 index b91d8b1..0000000 --- a/configpanel/src/org/lineageos/settings/device/ConfigPanelSearchIndexablesProvider.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2016 The CyanogenMod Project - * (C) 2017 The LineageOS 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 org.lineageos.settings.device; - -import android.database.Cursor; -import android.database.MatrixCursor; -import android.provider.SearchIndexableResource; -import android.provider.SearchIndexablesProvider; - -import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_CLASS_NAME; -import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_ICON_RESID; -import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_ACTION; -import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS; -import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE; -import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_RANK; -import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_RESID; -import static android.provider.SearchIndexablesContract.INDEXABLES_RAW_COLUMNS; -import static android.provider.SearchIndexablesContract.INDEXABLES_XML_RES_COLUMNS; -import static android.provider.SearchIndexablesContract.NON_INDEXABLES_KEYS_COLUMNS; - -public class ConfigPanelSearchIndexablesProvider extends SearchIndexablesProvider { - private static final String TAG = "ConfigPanelSearchIndexablesProvider"; - - public static final int SEARCH_IDX_BUTTON_PANEL = 0; - - private static SearchIndexableResource[] INDEXABLE_RES = new SearchIndexableResource[]{ - new SearchIndexableResource(1, R.xml.button_panel, - ButtonSettingsActivity.class.getName(), - R.drawable.ic_settings_additional_buttons), - }; - - @Override - public boolean onCreate() { - return true; - } - - @Override - public Cursor queryXmlResources(String[] projection) { - MatrixCursor cursor = new MatrixCursor(INDEXABLES_XML_RES_COLUMNS); - cursor.addRow(generateResourceRef(INDEXABLE_RES[SEARCH_IDX_BUTTON_PANEL])); - return cursor; - } - - private static Object[] generateResourceRef(SearchIndexableResource sir) { - Object[] ref = new Object[7]; - ref[COLUMN_INDEX_XML_RES_RANK] = sir.rank; - ref[COLUMN_INDEX_XML_RES_RESID] = sir.xmlResId; - ref[COLUMN_INDEX_XML_RES_CLASS_NAME] = null; - ref[COLUMN_INDEX_XML_RES_ICON_RESID] = sir.iconResId; - ref[COLUMN_INDEX_XML_RES_INTENT_ACTION] = "com.android.settings.action.EXTRA_SETTINGS"; - ref[COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE] = "org.lineageos.settings.device"; - ref[COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS] = sir.className; - return ref; - } - - @Override - public Cursor queryRawData(String[] projection) { - MatrixCursor cursor = new MatrixCursor(INDEXABLES_RAW_COLUMNS); - return cursor; - } - - @Override - public Cursor queryNonIndexableKeys(String[] projection) { - MatrixCursor cursor = new MatrixCursor(NON_INDEXABLES_KEYS_COLUMNS); - return cursor; - } -} diff --git a/configpanel/src/org/lineageos/settings/device/Constants.java b/configpanel/src/org/lineageos/settings/device/Constants.java deleted file mode 100644 index fd77073..0000000 --- a/configpanel/src/org/lineageos/settings/device/Constants.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2016 The CyanogenMod Project - * (C) 2017-2018 The LineageOS 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 org.lineageos.settings.device; - -import org.lineageos.internal.util.FileUtils; - -import java.util.HashMap; -import java.util.Map; - -public class Constants { - - // Preference keys - public static final String BUTTON_SWAP_KEY = "button_swap"; - - // Nodes - public static final String BUTTON_SWAP_PATH = "/proc/touchpanel/reversed_keys_enable"; - - // Holds <preference_key> -> <proc_node> mapping - public static final Map<String, SwitchPreferenceBackend> sBackendsMap = new HashMap<>(); - - static { - sBackendsMap.put(BUTTON_SWAP_KEY, - new SwitchPreferenceFilesBackend(BUTTON_SWAP_PATH, false)); - } -} diff --git a/configpanel/src/org/lineageos/settings/device/Startup.java b/configpanel/src/org/lineageos/settings/device/Startup.java deleted file mode 100644 index d3af1de..0000000 --- a/configpanel/src/org/lineageos/settings/device/Startup.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2016 The CyanogenMod Project - * (C) 2017-2018 The LineageOS 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 org.lineageos.settings.device; - -import android.content.BroadcastReceiver; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.SharedPreferences; -import android.support.v7.preference.PreferenceManager; -import android.util.Log; - -import org.lineageos.internal.util.FileUtils; - -public class Startup extends BroadcastReceiver { - - private static final String TAG = Startup.class.getSimpleName(); - - @Override - public void onReceive(Context context, Intent intent) { - final String action = intent.getAction(); - if (lineageos.content.Intent.ACTION_INITIALIZE_LINEAGE_HARDWARE.equals(action)) { - enableComponent(context, ButtonSettingsActivity.class.getName()); - - // Restore saved preference values - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); - for (String key : Constants.sBackendsMap.keySet()) { - SwitchPreferenceBackend backend = Constants.sBackendsMap.get(key); - Boolean value = preferences.getBoolean(key, backend.getDefaultValue()); - - backend.setValue(value); - } - } - } - - private void enableComponent(Context context, String component) { - ComponentName name = new ComponentName(context, component); - PackageManager pm = context.getPackageManager(); - if (pm.getComponentEnabledSetting(name) - == PackageManager.COMPONENT_ENABLED_STATE_DISABLED) { - pm.setComponentEnabledSetting(name, - PackageManager.COMPONENT_ENABLED_STATE_ENABLED, - PackageManager.DONT_KILL_APP); - } - } -} diff --git a/configpanel/src/org/lineageos/settings/device/SwitchPreferenceBackend.java b/configpanel/src/org/lineageos/settings/device/SwitchPreferenceBackend.java deleted file mode 100644 index 3100f4a..0000000 --- a/configpanel/src/org/lineageos/settings/device/SwitchPreferenceBackend.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2018 The LineageOS 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 org.lineageos.settings.device; - -public abstract class SwitchPreferenceBackend { - protected Boolean mDefaultValue; - protected Boolean mValue; - - public SwitchPreferenceBackend(Boolean defaultValue) { - mDefaultValue = defaultValue; - mValue = defaultValue; - } - - public Boolean getValue() { - return mValue; - } - - public Boolean getDefaultValue() { - return mDefaultValue; - } - - public void setDefaultValue() { - setValue(mDefaultValue); - } - - public abstract void setValue(Boolean value); - - public abstract Boolean isValid(); -} diff --git a/configpanel/src/org/lineageos/settings/device/SwitchPreferenceFilesBackend.java b/configpanel/src/org/lineageos/settings/device/SwitchPreferenceFilesBackend.java deleted file mode 100644 index f701bbc..0000000 --- a/configpanel/src/org/lineageos/settings/device/SwitchPreferenceFilesBackend.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2018 The LineageOS 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 org.lineageos.settings.device; - -import org.lineageos.internal.util.FileUtils; - -public class SwitchPreferenceFilesBackend extends SwitchPreferenceBackend { - - private String[] mPaths; - private Boolean mValid; - - public SwitchPreferenceFilesBackend(String[] paths, Boolean defaultValue) { - super(defaultValue); - mPaths = paths; - updateValidity(); - } - - public SwitchPreferenceFilesBackend(String path, Boolean defaultValue) { - this(new String[]{path}, defaultValue); - } - - @Override - public void setValue(Boolean value) { - for (String path : mPaths) { - if (!FileUtils.isFileWritable(path)) { - continue; - } - - FileUtils.writeLine(path, value ? "1" : "0"); - } - - mValue = value; - } - - @Override - public Boolean isValid() { - return mValid; - } - - private void updateValidity() { - Boolean valid = false; - - /* - * Only one path might be available on a specific device, - * but we need to try multiple to handle multiple kernel drivers. - * Cache the validity to avoid slow fragment rendering times. - */ - for (String path : mPaths) { - if (FileUtils.isFileReadable(path) && FileUtils.isFileWritable(path)) { - valid = true; - break; - } - } - - mValid = valid; - } -} |
