PixelParts: Nuke ChargeControl

Signed-off-by: AnierinB <anierin@evolution-x.org>
This commit is contained in:
2025-04-13 17:15:41 -07:00
parent 786b150ee3
commit 5af9b6a3a6
10 changed files with 0 additions and 274 deletions

View File

@@ -78,22 +78,6 @@
android:value="true" />
</service>
<!-- Charge control activity -->
<activity
android:name=".chargecontrol.ChargeControlActivity"
android:label="@string/charge_control_title"
android:exported="true">
<intent-filter>
<action android:name="com.android.settings.action.IA_SETTINGS" />
</intent-filter>
<meta-data
android:name="com.android.settings.category"
android:value="com.android.settings.category.ia.battery" />
<meta-data
android:name="com.android.settings.summary"
android:resource="@string/charge_control_summary" />
</activity>
<!-- Pixel torch activity -->
<activity
android:name=".pixeltorch.PixelTorchActivity"

View File

@@ -4,7 +4,6 @@
| Category | Feature | Description | QS Tile | Required kernel changes |
| --- | --- | --- | --- | --- |
| | `Charge control` | Start/stop charging at specific percentages | N/A | N/A |
| **Display** | `Automatic high brightness mode (HBM)` | Enable peak luminance based on sunlight | Yes | N/A |
| | `Saturation` | Control the saturation level of the display | Yes | N/A |
| **Leds** | `Pixel torch` | Adjust the brightness of the PixelParts flashlight QS-Tile | PixelParts Flashlight QS | N/A |

View File

@@ -1,11 +1,5 @@
on property:sys.boot_completed=1
# Stop/Start charging
chown system system /sys/devices/platform/google,charger/charge_stop_level
chmod 0666 /sys/devices/platform/google,charger/charge_stop_level
chown system system /sys/devices/platform/google,charger/charge_start_level
chmod 0666 /sys/devices/platform/google,charger/charge_start_level
# HBM
chown system system /sys/class/backlight/panel0-backlight/hbm_mode
chmod 0666 /sys/class/backlight/panel0-backlight/hbm_mode

View File

@@ -18,18 +18,6 @@
<string name="tile_off">Off</string>
<string name="tile_camera_in_use">Camera in use</string>
<!-- Charge control -->
<string name="charge_control_title">Percentage-based charge control</string>
<string name="charge_control_summary">Control when the device stops and starts charging</string>
<string name="charge_control_main_switch_title">Use percentage-based charge control</string>
<string name="stop_charging_title">Stop charging level</string>
<string name="stop_charging_summary">Stop charging when the set percentage is reached</string>
<string name="start_charging_title">Start charging level</string>
<string name="start_charging_summary">Resume charging when the set percentage is reached</string>
<string name="stop_below_start_error">Stop level must be above start level!</string>
<string name="start_above_stop_error">Start level must be below stop level!</string>
<string name="charge_control_footer_summary">Charge control may interfere with adaptive charging.</string>
<!-- Pixel torch -->
<string name="pixel_torch_title">Pixel torch</string>
<string name="pixel_torch_summary">A configurable flashlight tile and volume button service</string>

View File

@@ -1,40 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2023-2024 The Evolution X Project
SPDX-License-Identifier: Apache-2.0
-->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto">
<com.android.settingslib.widget.TopIntroPreference
android:key="charge_control_intro"
android:title="@string/charge_control_summary" />
<com.android.settingslib.widget.MainSwitchPreference
android:key="charge_control"
android:title="@string/charge_control_main_switch_title"
android:defaultValue="false" />
<org.evolution.pixelparts.CustomSeekBarPreference
android:key="stop_charging"
android:title="@string/stop_charging_title"
android:max="100"
android:min="1"
settings:units="%"
android:defaultValue="100" />
<org.evolution.pixelparts.CustomSeekBarPreference
android:key="start_charging"
android:title="@string/start_charging_title"
android:max="99"
android:min="0"
settings:units="%"
android:defaultValue="0" />
<com.android.settingslib.widget.FooterPreference
android:key="charge_control_footer"
android:title="@string/charge_control_footer_summary"
android:selectable="false" />
</PreferenceScreen>

View File

@@ -30,11 +30,9 @@ allow pixelparts_app system_app_data_file:{ file lnk_file } create_file_perms;
allow pixelparts_app system_data_file:dir search;
allow pixelparts_app {
sysfs_batteryinfo
sysfs_leds
}:file rw_file_perms;
allow pixelparts_app {
sysfs_batteryinfo
sysfs_leds
}:dir r_dir_perms;

View File

@@ -7,15 +7,6 @@ package org.evolution.pixelparts;
public class Constants {
// Charge control
public static final String KEY_CHARGE_CONTROL = "charge_control";
public static final String KEY_STOP_CHARGING = "stop_charging";
public static final String KEY_START_CHARGING = "start_charging";
public static final String NODE_STOP_CHARGING = "/sys/devices/platform/google,charger/charge_stop_level";
public static final String NODE_START_CHARGING = "/sys/devices/platform/google,charger/charge_start_level";
public static final String DEFAULT_STOP_CHARGING = "100";
public static final String DEFAULT_START_CHARGING = "0";
// Pixel torch
public static final String KEY_PIXEL_TORCH_CYCLE_MODES = "pixel_torch_cycle_modes";
public static final String KEY_PIXEL_TORCH_BUTTON_SERVICE = "pixel_torch_button_service";

View File

@@ -12,7 +12,6 @@ import android.content.Intent;
import org.evolution.pixelparts.autohbm.AutoHbmActivity;
import org.evolution.pixelparts.autohbm.AutoHbmFragment;
import org.evolution.pixelparts.autohbm.AutoHbmTileService;
import org.evolution.pixelparts.chargecontrol.ChargeControlFragment;
import org.evolution.pixelparts.pixeltorch.PixelTorchActivity;
import org.evolution.pixelparts.pixeltorch.PixelTorchFragment;
import org.evolution.pixelparts.pixeltorch.PixelTorchButtonService;
@@ -42,10 +41,6 @@ public class Startup extends BroadcastReceiver {
AutoHbmFragment.isHbmSupported(context)
);
// Charge control
ChargeControlFragment.restoreStartChargingSetting(context);
ChargeControlFragment.restoreStopChargingSetting(context);
// PixelTorch
ComponentUtils.toggleComponent(
context,

View File

@@ -1,23 +0,0 @@
/*
* Copyright (C) 2023-2024 The Evolution X Project
* SPDX-License-Identifier: Apache-2.0
*/
package org.evolution.pixelparts.chargecontrol;
import android.os.Bundle;
import com.android.settingslib.collapsingtoolbar.CollapsingToolbarBaseActivity;
public class ChargeControlActivity extends CollapsingToolbarBaseActivity {
private static final String TAG = "ChargeControl";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportFragmentManager().beginTransaction().replace(com.android.settingslib.collapsingtoolbar.R.id.content_frame,
new ChargeControlFragment(), TAG).commit();
}
}

View File

@@ -1,160 +0,0 @@
/*
* Copyright (C) 2023-2024 The Evolution X Project
* SPDX-License-Identifier: Apache-2.0
*/
package org.evolution.pixelparts.chargecontrol;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.Toast;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import com.android.settingslib.widget.MainSwitchPreference;
import org.evolution.pixelparts.Constants;
import org.evolution.pixelparts.CustomSeekBarPreference;
import org.evolution.pixelparts.R;
import org.evolution.pixelparts.utils.FileUtils;
public class ChargeControlFragment extends PreferenceFragmentCompat
implements OnCheckedChangeListener, Preference.OnPreferenceChangeListener {
// Charge control preference
private MainSwitchPreference mChargeControlSwitch;
// Stop/Start preferences
private CustomSeekBarPreference mStopChargingPreference;
private CustomSeekBarPreference mStartChargingPreference;
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.charge_control, rootKey);
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getContext());
// Charge control preference
mChargeControlSwitch = findPreference(Constants.KEY_CHARGE_CONTROL);
mChargeControlSwitch.setChecked(sharedPrefs.getBoolean(Constants.KEY_CHARGE_CONTROL, false));
mChargeControlSwitch.addOnSwitchChangeListener(this);
// Stop preference
mStopChargingPreference = findPreference(Constants.KEY_STOP_CHARGING);
if (FileUtils.isFileWritable(Constants.NODE_STOP_CHARGING)) {
mStopChargingPreference.setValue(sharedPrefs.getInt(Constants.KEY_STOP_CHARGING,
Integer.parseInt(FileUtils.getFileValue(Constants.NODE_STOP_CHARGING, Constants.DEFAULT_STOP_CHARGING))));
mStopChargingPreference.setOnPreferenceChangeListener(this);
} else {
mStopChargingPreference.setSummary(getString(R.string.kernel_node_access_error));
mStopChargingPreference.setEnabled(false);
}
mStopChargingPreference.setVisible(mChargeControlSwitch.isChecked());
// Start preference
mStartChargingPreference = findPreference(Constants.KEY_START_CHARGING);
if (FileUtils.isFileWritable(Constants.NODE_START_CHARGING)) {
mStartChargingPreference.setValue(sharedPrefs.getInt(Constants.KEY_START_CHARGING,
Integer.parseInt(FileUtils.getFileValue(Constants.NODE_START_CHARGING, Constants.DEFAULT_START_CHARGING))));
mStartChargingPreference.setOnPreferenceChangeListener(this);
} else {
mStartChargingPreference.setSummary(getString(R.string.kernel_node_access_error));
mStartChargingPreference.setEnabled(false);
}
mStartChargingPreference.setVisible(mChargeControlSwitch.isChecked());
}
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SharedPreferences.Editor prefChange = PreferenceManager.getDefaultSharedPreferences(getContext()).edit();
prefChange.putBoolean(Constants.KEY_CHARGE_CONTROL, isChecked).apply();
mStopChargingPreference.setVisible(isChecked);
mStartChargingPreference.setVisible(isChecked);
if (!isChecked) {
// Stop preference
int defaultStopCharging = 100;
prefChange.putInt(Constants.KEY_STOP_CHARGING, defaultStopCharging).apply();
FileUtils.writeValue(Constants.NODE_STOP_CHARGING, Integer.toString(defaultStopCharging));
mStopChargingPreference.refresh(defaultStopCharging);
// Start preference
int defaultStartCharging = 0;
prefChange.putInt(Constants.KEY_START_CHARGING, defaultStartCharging).apply();
FileUtils.writeValue(Constants.NODE_START_CHARGING, Integer.toString(defaultStartCharging));
mStartChargingPreference.refresh(defaultStartCharging);
}
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
// Stop preference
if (preference == mStopChargingPreference) {
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getContext());
int value = Integer.parseInt(newValue.toString());
int stopLevel = Integer.parseInt(newValue.toString());
int startLevel = sharedPrefs.getInt(Constants.KEY_START_CHARGING, 0);
if (startLevel >= stopLevel) {
startLevel = stopLevel - 1;
sharedPrefs.edit().putInt(Constants.KEY_START_CHARGING, startLevel).apply();
FileUtils.writeValue(Constants.NODE_START_CHARGING, String.valueOf(startLevel));
mStartChargingPreference.refresh(startLevel);
Toast.makeText(getContext(), R.string.stop_below_start_error, Toast.LENGTH_SHORT).show();
}
sharedPrefs.edit().putInt(Constants.KEY_STOP_CHARGING, value).apply();
FileUtils.writeValue(Constants.NODE_STOP_CHARGING, String.valueOf(value));
return true;
}
// Start preference
else if (preference == mStartChargingPreference) {
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getContext());
int value = Integer.parseInt(newValue.toString());
int startLevel = Integer.parseInt(newValue.toString());
int stopLevel = sharedPrefs.getInt(Constants.KEY_STOP_CHARGING, 100);
if (stopLevel <= startLevel) {
stopLevel = startLevel + 1;
sharedPrefs.edit().putInt(Constants.KEY_STOP_CHARGING, stopLevel).apply();
FileUtils.writeValue(Constants.NODE_STOP_CHARGING, String.valueOf(stopLevel));
mStopChargingPreference.refresh(stopLevel);
Toast.makeText(getContext(), R.string.start_above_stop_error, Toast.LENGTH_SHORT).show();
}
sharedPrefs.edit().putInt(Constants.KEY_START_CHARGING, value).apply();
FileUtils.writeValue(Constants.NODE_START_CHARGING, String.valueOf(value));
return true;
}
return false;
}
// Stop preference
public static void restoreStopChargingSetting(Context context) {
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean chargeControlEnabled = sharedPrefs.getBoolean(Constants.KEY_CHARGE_CONTROL, true);
if (chargeControlEnabled && FileUtils.isFileWritable(Constants.NODE_STOP_CHARGING)) {
int value = sharedPrefs.getInt(Constants.KEY_STOP_CHARGING,
Integer.parseInt(FileUtils.getFileValue(Constants.NODE_STOP_CHARGING, Constants.DEFAULT_STOP_CHARGING)));
FileUtils.writeValue(Constants.NODE_STOP_CHARGING, String.valueOf(value));
}
}
// Start preference
public static void restoreStartChargingSetting(Context context) {
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean chargeControlEnabled = sharedPrefs.getBoolean(Constants.KEY_CHARGE_CONTROL, true);
if (chargeControlEnabled && FileUtils.isFileWritable(Constants.NODE_START_CHARGING)) {
int value = sharedPrefs.getInt(Constants.KEY_START_CHARGING,
Integer.parseInt(FileUtils.getFileValue(Constants.NODE_START_CHARGING, Constants.DEFAULT_START_CHARGING)));
FileUtils.writeValue(Constants.NODE_START_CHARGING, String.valueOf(value));
}
}
}