sdm660-common: implement the switch to turn off charging ripple animation
* we may not want that animation when using a charge limiter Signed-off-by: pix106 <sbordenave@gmail.com>
This commit is contained in:
parent
9ab5292b0b
commit
ccab114cee
15 changed files with 129 additions and 3 deletions
|
@ -31,6 +31,7 @@ android_app {
|
|||
required: [
|
||||
"privapp-permissions_io.alcatraz.cloverparts",
|
||||
"config-io.alcatraz.cloverparts",
|
||||
"DisableChargingRippleOverlay",
|
||||
],
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,10 @@
|
|||
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.BATTERY_STATS" />
|
||||
<uses-permission android:name="android.permission.MODIFY_THEME_OVERLAY" />
|
||||
<uses-permission android:name="android.permission.CHANGE_OVERLAY_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
|
||||
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
|
||||
|
||||
<application
|
||||
android:directBootAware="true"
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
runtime_resource_overlay {
|
||||
name: "DisableChargingRippleOverlay",
|
||||
theme: "DisableChargingRippleOverlay",
|
||||
sdk_version: "current",
|
||||
product_specific: true
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2023 Alcatraz323 <alcatraz32323@gmail.com>
|
||||
|
||||
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="io.alcatraz.cloverparts.disablechargingripple"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
<application android:hasCode="false" android:label="DisableChargingRippleOverlay"/>
|
||||
<overlay
|
||||
android:targetPackage="com.android.systemui"
|
||||
android:targetName="DisableChargingRippleOverlay"
|
||||
android:priority="1"/>
|
||||
</manifest>
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2021 The Android Open Source 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>
|
||||
<bool name="flag_charging_ripple">false</bool>
|
||||
</resources>
|
|
@ -17,5 +17,9 @@
|
|||
<permission name="android.permission.WRITE_SETTINGS" />
|
||||
<permission name="android.permission.WRITE_SECURE_SETTINGS" />
|
||||
<permission name="android.permission.BATTERY_STATS" />
|
||||
<permission name="android.permission.MODIFY_THEME_OVERLAY" />
|
||||
<permission name="android.permission.CHANGE_OVERLAY_PACKAGES" />
|
||||
<permission name="android.permission.INTERACT_ACROSS_USERS" />
|
||||
<permission name="android.permission.INTERACT_ACROSS_USERS_FULL" />
|
||||
</privapp-permissions>
|
||||
</permissions>
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="?attr/colorControlNormal"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#000" android:pathData="M14.5,11l-3,6v-4h-2l3,-6v4H14.5zM7,1h10c1.1,0 2,0.9 2,2v18c0,1.1 -0.9,2 -2,2H7c-1.1,0 -2,-0.9 -2,-2V3C5,1.9 5.9,1 7,1zM7,6v12h10V6H7z"/>
|
||||
</vector>
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="?attr/colorControlNormal"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#000" android:pathData="M11,11h-1v2h2v-1l9.73,9.73L20.46,23 14,16.54L14,21L3,21v-2h2L5,7.54l-4,-4 1.27,-1.27L11,11zM14,11.49L5.51,3L14,3v1h5v12.49l-2,-2L17,6h-3v5.49z"/>
|
||||
</vector>
|
|
@ -32,4 +32,7 @@
|
|||
<string name="bms_always_connected_mode_summary" formatted="false">将电量限制在40%-60%以保护电池</string>
|
||||
<string name="bms_limit_to_eighty" formatted="false">限制最高电量为80%左右</string>
|
||||
<string name="bms_limit_to_eighty_summary" formatted="false">电量在80%左右时停止充电以保护电池(持续模式优先)</string>
|
||||
<string name="bms_category_charge_limiter_helper">充电限制器 - 额外</string>
|
||||
<string name="bms_disable_charging_ripple_effect" formatted="false">关闭充电圆形动画</string>
|
||||
<string name="bms_disable_charging_ripple_effect_summary" formatted="false">提高充电限制器体验(需要重启系统以生效)</string>
|
||||
</resources>
|
||||
|
|
|
@ -32,4 +32,7 @@
|
|||
<string name="bms_always_connected_mode_summary" formatted="false">Limit the battery percent between 40% and 60% to protect battery</string>
|
||||
<string name="bms_limit_to_eighty" formatted="false">Limit to around 80%</string>
|
||||
<string name="bms_limit_to_eighty_summary" formatted="false">Suspend charging when the percent is around 80% to protect battery(Always connected mode will make this never happen)</string>
|
||||
<string name="bms_category_charge_limiter_helper">Charge limiter helper</string>
|
||||
<string name="bms_disable_charging_ripple_effect" formatted="false">Disable charge ripple animation</string>
|
||||
<string name="bms_disable_charging_ripple_effect_summary" formatted="false">Helps to get a better experience for charge limiter(Requires a reboot to take effect)</string>
|
||||
</resources>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
android:title="@string/bms_charge_limiter_notice" />
|
||||
|
||||
<SwitchPreference
|
||||
android:icon="@drawable/ic_baseline_whatshot_24"
|
||||
android:icon="@drawable/ic_baseline_charging_station_24"
|
||||
android:key="bms_always_connected_mode"
|
||||
android:summary="@string/bms_always_connected_mode_summary"
|
||||
android:title="@string/bms_always_connected_mode" />
|
||||
|
@ -50,4 +50,16 @@
|
|||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="cat_charge_limiter_helper"
|
||||
android:title="@string/bms_category_charge_limiter_helper">
|
||||
|
||||
<SwitchPreference
|
||||
android:icon="@drawable/ic_baseline_no_meeting_room_24"
|
||||
android:key="bms_disable_charging_ripple_effect"
|
||||
android:summary="@string/bms_disable_charging_ripple_effect_summary"
|
||||
android:title="@string/bms_disable_charging_ripple_effect" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue