diff --git a/CloverParts/Android.bp b/CloverParts/Android.bp
index ca463c89..260a5a95 100644
--- a/CloverParts/Android.bp
+++ b/CloverParts/Android.bp
@@ -31,6 +31,7 @@ android_app {
required: [
"privapp-permissions_io.alcatraz.cloverparts",
"config-io.alcatraz.cloverparts",
+ "DisableChargingRippleOverlay",
],
}
diff --git a/CloverParts/AndroidManifest.xml b/CloverParts/AndroidManifest.xml
index e0a0ef8e..7374b73e 100644
--- a/CloverParts/AndroidManifest.xml
+++ b/CloverParts/AndroidManifest.xml
@@ -23,6 +23,10 @@
+
+
+
+
+
+
+
+
+
diff --git a/CloverParts/ctl-overlays/DisableChargingRippleOverlay/res/values/flags.xml b/CloverParts/ctl-overlays/DisableChargingRippleOverlay/res/values/flags.xml
new file mode 100644
index 00000000..340843be
--- /dev/null
+++ b/CloverParts/ctl-overlays/DisableChargingRippleOverlay/res/values/flags.xml
@@ -0,0 +1,20 @@
+
+
+
+
+ false
+
\ No newline at end of file
diff --git a/CloverParts/privapp-permissions_io.alcatraz.cloverparts.xml b/CloverParts/privapp-permissions_io.alcatraz.cloverparts.xml
index d57eb5cb..58cbe5d2 100644
--- a/CloverParts/privapp-permissions_io.alcatraz.cloverparts.xml
+++ b/CloverParts/privapp-permissions_io.alcatraz.cloverparts.xml
@@ -17,5 +17,9 @@
+
+
+
+
\ No newline at end of file
diff --git a/CloverParts/res/drawable/ic_baseline_charging_station_24.xml b/CloverParts/res/drawable/ic_baseline_charging_station_24.xml
new file mode 100644
index 00000000..11335373
--- /dev/null
+++ b/CloverParts/res/drawable/ic_baseline_charging_station_24.xml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/CloverParts/res/drawable/ic_baseline_no_meeting_room_24.xml b/CloverParts/res/drawable/ic_baseline_no_meeting_room_24.xml
new file mode 100644
index 00000000..2e38c824
--- /dev/null
+++ b/CloverParts/res/drawable/ic_baseline_no_meeting_room_24.xml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/CloverParts/res/values-zh-rCN/strings.xml b/CloverParts/res/values-zh-rCN/strings.xml
index 05311cb1..4bc2ae68 100644
--- a/CloverParts/res/values-zh-rCN/strings.xml
+++ b/CloverParts/res/values-zh-rCN/strings.xml
@@ -32,4 +32,7 @@
将电量限制在40%-60%以保护电池
限制最高电量为80%左右
电量在80%左右时停止充电以保护电池(持续模式优先)
+ 充电限制器 - 额外
+ 关闭充电圆形动画
+ 提高充电限制器体验(需要重启系统以生效)
diff --git a/CloverParts/res/values/strings.xml b/CloverParts/res/values/strings.xml
index d25177a5..9d4d5f1b 100644
--- a/CloverParts/res/values/strings.xml
+++ b/CloverParts/res/values/strings.xml
@@ -32,4 +32,7 @@
Limit the battery percent between 40% and 60% to protect battery
Limit to around 80%
Suspend charging when the percent is around 80% to protect battery(Always connected mode will make this never happen)
+ Charge limiter helper
+ Disable charge ripple animation
+ Helps to get a better experience for charge limiter(Requires a reboot to take effect)
diff --git a/CloverParts/res/xml/bms_settings.xml b/CloverParts/res/xml/bms_settings.xml
index e423c973..ed393c58 100644
--- a/CloverParts/res/xml/bms_settings.xml
+++ b/CloverParts/res/xml/bms_settings.xml
@@ -37,7 +37,7 @@
android:title="@string/bms_charge_limiter_notice" />
@@ -50,4 +50,16 @@
+
+
+
+
+
+
diff --git a/CloverParts/src/io/alcatraz/cloverparts/BMSFragment.java b/CloverParts/src/io/alcatraz/cloverparts/BMSFragment.java
index 98e7dce5..173b6cb5 100755
--- a/CloverParts/src/io/alcatraz/cloverparts/BMSFragment.java
+++ b/CloverParts/src/io/alcatraz/cloverparts/BMSFragment.java
@@ -14,7 +14,12 @@
package io.alcatraz.cloverparts;
+import android.app.ActivityManager;
+import android.content.Context;
+import android.content.om.IOverlayManager;
import android.os.Bundle;
+import android.os.RemoteException;
+import android.os.ServiceManager;
import android.util.Log;
import androidx.preference.Preference;
@@ -24,9 +29,13 @@ import androidx.preference.SwitchPreference;
import static io.alcatraz.cloverparts.Constants.BMS_STEP_CHG_SWITCH;
import static io.alcatraz.cloverparts.Constants.BMS_ALWAYS_CONNECTED_MODE;
import static io.alcatraz.cloverparts.Constants.BMS_LIMIT_TO_EIGHTY;
+import static io.alcatraz.cloverparts.Constants.BMS_DISABLE_CHARGING_RIPPLE_EFFECT_SWITCH;
+import static io.alcatraz.cloverparts.Constants.BMS_OVERLAY_DISABLE_CHARGING_RIPPLE;
public class BMSFragment extends PreferenceFragment implements Preference.OnPreferenceChangeListener {
- private SwitchPreference mStepChargingSwitch;
+ private static final String TAG = "BMSFragment";
+
+ private SwitchPreference mStepChargingSwitch, mDisableChargingRippleEffectSwitch;
@Override
public void onCreatePreferences(Bundle bundle, String key) {
@@ -44,20 +53,41 @@ public class BMSFragment extends PreferenceFragment implements Preference.OnPref
ShellUtils.execCommand("echo " + (enabled ? "1" : "0") + " > /sys/class/power_supply/battery/step_charging_enabled", false);
ShellUtils.execCommand("echo " + (enabled ? "1" : "0") + " > /sys/class/power_supply/battery/sw_jeita_enabled", false);
break;
+ case BMS_DISABLE_CHARGING_RIPPLE_EFFECT_SWITCH:
+ boolean disabled = (boolean) o;
+ toggleRippleDisableOverlay(disabled);
+ break;
}
return true;
}
private void findPreferences() {
mStepChargingSwitch = findPreference(BMS_STEP_CHG_SWITCH);
+ mDisableChargingRippleEffectSwitch = findPreference(BMS_DISABLE_CHARGING_RIPPLE_EFFECT_SWITCH);
}
private void bindListeners() {
mStepChargingSwitch.setOnPreferenceChangeListener(this);
+ mDisableChargingRippleEffectSwitch.setOnPreferenceChangeListener(this);
}
private void updateSwitches() {
ShellUtils.CommandResult result = ShellUtils.execCommand("cat /sys/class/power_supply/battery/step_charging_enabled", false);
mStepChargingSwitch.setChecked(result.responseMsg.contains("1"));
}
+
+ private void toggleRippleDisableOverlay(boolean disabled) {
+ final IOverlayManager iom = IOverlayManager.Stub.asInterface(
+ ServiceManager.getService(Context.OVERLAY_SERVICE));
+ final int userId = ActivityManager.getCurrentUser();
+ try {
+ iom.setEnabled(BMS_OVERLAY_DISABLE_CHARGING_RIPPLE, disabled, userId);
+ if (disabled) {
+ iom.setHighestPriority(BMS_OVERLAY_DISABLE_CHARGING_RIPPLE, userId);
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to " + (disabled ? "enable" : "disable")
+ + " overlay " + BMS_OVERLAY_DISABLE_CHARGING_RIPPLE + " for user " + userId);
+ }
+ }
}
diff --git a/CloverParts/src/io/alcatraz/cloverparts/BootReceiver.java b/CloverParts/src/io/alcatraz/cloverparts/BootReceiver.java
index 2dd543f1..ddfc0082 100755
--- a/CloverParts/src/io/alcatraz/cloverparts/BootReceiver.java
+++ b/CloverParts/src/io/alcatraz/cloverparts/BootReceiver.java
@@ -18,6 +18,8 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import static io.alcatraz.cloverparts.Constants.BMS_STEP_CHG_SWITCH;
+
public class BootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
@@ -27,7 +29,7 @@ public class BootReceiver extends BroadcastReceiver {
context.startService(new Intent(context, BMSService.class));
SharedPreferenceUtil sharedPreferenceUtil = SharedPreferenceUtil.getInstance();
- boolean stepChargingManualOverride = (boolean) sharedPreferenceUtil.get(context, "bms_step_charging_switch",
+ boolean stepChargingManualOverride = (boolean) sharedPreferenceUtil.get(context, BMS_STEP_CHG_SWITCH,
true);
ShellUtils.execCommand("echo " + (stepChargingManualOverride ? "1" : "0") + " > /sys/class/power_supply/battery/step_charging_enabled", false);
diff --git a/CloverParts/src/io/alcatraz/cloverparts/Constants.java b/CloverParts/src/io/alcatraz/cloverparts/Constants.java
index e96164f5..15a683fc 100755
--- a/CloverParts/src/io/alcatraz/cloverparts/Constants.java
+++ b/CloverParts/src/io/alcatraz/cloverparts/Constants.java
@@ -18,4 +18,7 @@ public class Constants {
public static final String BMS_STEP_CHG_SWITCH = "bms_step_charging_switch";
public static final String BMS_ALWAYS_CONNECTED_MODE = "bms_always_connected_mode";
public static final String BMS_LIMIT_TO_EIGHTY = "bms_limit_to_eighty";
+ public static final String BMS_DISABLE_CHARGING_RIPPLE_EFFECT_SWITCH = "bms_disable_charging_ripple_effect";
+
+ public static final String BMS_OVERLAY_DISABLE_CHARGING_RIPPLE = "io.alcatraz.cloverparts.disablechargingripple";
}
diff --git a/sepolicy/private/cloverparts_app.te b/sepolicy/private/cloverparts_app.te
index a7d1d5db..d11601c5 100644
--- a/sepolicy/private/cloverparts_app.te
+++ b/sepolicy/private/cloverparts_app.te
@@ -1,3 +1,4 @@
+typeattribute cloverparts_app coredomain;
typeattribute cloverparts_app mlstrustedsubject;
app_domain(cloverparts_app)
@@ -16,6 +17,7 @@ allow cloverparts_app netstats_service:service_manager find;
allow cloverparts_app voiceinteraction_service:service_manager find;
allow cloverparts_app batterystats_service:service_manager find;
allow cloverparts_app batteryproperties_service:service_manager find;
+allow cloverparts_app overlay_service:service_manager find;
# ro.input.resampling, viewroot.profile_rendering
dontaudit cloverparts_app default_prop:file read;