diff --git a/peripheralmanager/AndroidManifest.xml b/peripheralmanager/AndroidManifest.xml
index 6306546..e267245 100644
--- a/peripheralmanager/AndroidManifest.xml
+++ b/peripheralmanager/AndroidManifest.xml
@@ -43,5 +43,18 @@
android:resource="@string/stylus_summary" />
+
+
+
+
+
+
+
+
diff --git a/peripheralmanager/res/values/strings.xml b/peripheralmanager/res/values/strings.xml
index 2102654..e1acef8 100644
--- a/peripheralmanager/res/values/strings.xml
+++ b/peripheralmanager/res/values/strings.xml
@@ -15,4 +15,11 @@
Force recognize stylus
Enable this settings to allow using third party styluses
Stylus Mode limits display\'s max refresh rate to 120Hz
+
+
+ Smart Cover
+ Smart Cover Settings
+ Toggle Smart Cover behaivor
+ This toggles the behaivor of the smart lid
+
diff --git a/peripheralmanager/res/xml/lid_settings.xml b/peripheralmanager/res/xml/lid_settings.xml
new file mode 100644
index 0000000..e70316b
--- /dev/null
+++ b/peripheralmanager/res/xml/lid_settings.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
diff --git a/peripheralmanager/src/org/lineageos/xiaomiperipheralmanager/LidSettingsActivity.java b/peripheralmanager/src/org/lineageos/xiaomiperipheralmanager/LidSettingsActivity.java
new file mode 100644
index 0000000..9b20059
--- /dev/null
+++ b/peripheralmanager/src/org/lineageos/xiaomiperipheralmanager/LidSettingsActivity.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2023-2025 The LineageOS Project
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.lineageos.xiaomiperipheralmanager;
+
+import android.os.Bundle;
+import android.util.Log;
+
+import com.android.settingslib.collapsingtoolbar.CollapsingToolbarBaseActivity;
+
+/**
+ * Settings activity for stylus/pen configuration
+ * Hosts the StylusSettingsFragment for user configuration
+ */
+public class LidSettingsActivity extends CollapsingToolbarBaseActivity {
+
+ private static final String TAG = "XiaomiLidSettings";
+ private static final String TAG_LID = "lid";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ Log.i(TAG, "Opening lid settings");
+
+ getFragmentManager().beginTransaction().replace(
+ com.android.settingslib.collapsingtoolbar.R.id.content_frame,
+ new LidSettingsFragment(), TAG_LID).commit();
+ }
+}
diff --git a/peripheralmanager/src/org/lineageos/xiaomiperipheralmanager/LidSettingsFragment.java b/peripheralmanager/src/org/lineageos/xiaomiperipheralmanager/LidSettingsFragment.java
new file mode 100644
index 0000000..202d480
--- /dev/null
+++ b/peripheralmanager/src/org/lineageos/xiaomiperipheralmanager/LidSettingsFragment.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2023-2025 The LineageOS Project
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.lineageos.xiaomiperipheralmanager;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.os.SystemProperties;
+import android.util.Log;
+
+import android.preference.PreferenceManager;
+import androidx.preference.ListPreference;
+import androidx.preference.Preference;
+import androidx.preference.Preference.OnPreferenceChangeListener;
+import androidx.preference.PreferenceFragment;
+import androidx.preference.SwitchPreference;
+import com.android.settingslib.widget.MainSwitchPreference;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+import android.provider.Settings;
+
+/**
+ * Settings fragment for lid configuration
+ * Allows users to manually enable/disable the smart cover
+ */
+public class LidSettingsFragment extends PreferenceFragment implements
+ SharedPreferences.OnSharedPreferenceChangeListener {
+
+ private static final String TAG = "XiaomiLidSettings";
+ private static final String LID_KEY = "lid_switch_key";
+
+ private SharedPreferences mLidPreference;
+
+ @Override
+ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
+ try {
+ addPreferencesFromResource(R.xml.lid_settings);
+
+ mLidPreference = PreferenceManager.getDefaultSharedPreferences(getContext());
+ SwitchPreference switchPreference = (SwitchPreference) findPreference(LID_KEY);
+
+ if (switchPreference != null) {
+ switchPreference.setChecked(mLidPreference.getBoolean(LID_KEY, false));
+ switchPreference.setEnabled(true);
+ } else {
+ logError("Could not find lid switch preference");
+ }
+
+ logInfo("Lid settings fragment created");
+ } catch (Exception e) {
+ logError("Error creating lid settings: " + e.getMessage());
+ }
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ try {
+ mLidPreference.registerOnSharedPreferenceChangeListener(this);
+ } catch (Exception e) {
+ logError("Error in onResume: " + e.getMessage());
+ }
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ try {
+ mLidPreference.unregisterOnSharedPreferenceChangeListener(this);
+ } catch (Exception e) {
+ logError("Error in onPause: " + e.getMessage());
+ }
+ }
+
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreference, String key) {
+ if (LID_KEY.equals(key)) {
+ try {
+ boolean newStatus = mLidPreference.getBoolean(key, false);
+ logInfo("Lid preference changed to: " + newStatus);
+ Settings.Global.putInt(getActivity().getContentResolver(),
+ "lid_behavior", newStatus ? 1 : 0);
+ } catch (Exception e) {
+ logError("Error handling preference change: " + e.getMessage());
+ }
+ }
+ }
+
+ private void logInfo(String message) {
+ Log.i(TAG, getTimestamp() + message);
+ }
+
+ private void logError(String message) {
+ Log.e(TAG, getTimestamp() + message);
+ }
+
+ private String getTimestamp() {
+ return "[" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US).format(new Date()) + "] ";
+ }
+}