These may be interesting to other apps.
Change-Id: If662e4edc71d21026af2c143ab14755e115870a2
Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
It does not make sense to hide away such lovely code.
Let it be used by others, given that it lives within
the sdk.
Change-Id: Iab4605e77fd3425049df68ebbeaa3bd247874795
Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
Fix a typo and hide a validator, which was not hidden
by mistake.
```
lineage-sdk/sdk/src/java/lineageos/providers/LineageSettings.java:2776: warning: Field LineageSettings.Secure.GESTURE_BACK_EXCLUDE_TOP_VALIDATOR references hidden type lineageos.providers.LineageSettings.Validator. (ErrorWhenNew) [HiddenT
ypeParameter]
lineage-sdk/sdk/src/java/lineageos/providers/LineageSettings.java:2776: error: Class lineageos.providers.LineageSettings.Validator is hidden but was referenced (in field type) from public field lineageos.providers.LineageSettings.Secure.G
ESTURE_BACK_EXCLUDE_TOP_VALIDATOR [ReferencesHidden]
lineage-sdk/sdk/src/java/lineageos/providers/LineageSettings.java:2942: warning: Field LineageSettings.Secure.VOLUME_PANEL_ON_LEFT_VALIDATOR references hidden type lineageos.providers.LineageSettings.Validator. (ErrorWhenNew) [HiddenTypeP
arameter]
lineage-sdk/sdk/src/java/lineageos/providers/LineageSettings.java:2942: error: Class lineageos.providers.LineageSettings.Validator is hidden but was referenced (in field type) from public field lineageos.providers.LineageSettings.Secure.V
OLUME_PANEL_ON_LEFT_VALIDATOR [ReferencesHidden]
```
Change-Id: I71db41bc6f797d77fb281c989d9dcd7299036a25
Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
Also cancel a possibly existing charging control notification.
Previously charging control was turned on when settings were changed and
on system start even if no charger was plugged in, thus possibly showing
the charging control notification.
Fixes: https://gitlab.com/LineageOS/issues/android/-/issues/8610
Change-Id: I78c47f026aa47ac756cc6eca12157ea58bda58fd
Fixes the following crash on boot when trying to use deadline mode:
E AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: android.display
E AndroidRuntime: java.lang.RuntimeException: Failed to boot service org.lineageos.platform.internal.health.HealthInterfaceService: onBootPhase threw an exception during phase 1000
E AndroidRuntime: at com.android.server.SystemServiceManager.startBootPhase(SystemServiceManager.java:321)
E AndroidRuntime: at com.android.server.am.ActivityManagerService.finishBooting(ActivityManagerService.java:5199)
E AndroidRuntime: at com.android.server.am.ActivityManagerService.bootAnimationComplete(ActivityManagerService.java:5330)
E AndroidRuntime: at com.android.server.wm.WindowManagerService.performEnableScreen(WindowManagerService.java:3970)
E AndroidRuntime: at com.android.server.wm.WindowManagerService.-$$Nest$mperformEnableScreen(WindowManagerService.java:0)
E AndroidRuntime: at com.android.server.wm.WindowManagerService$H.handleMessage(WindowManagerService.java:5885)
E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:109)
E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:232)
E AndroidRuntime: at android.os.Looper.loop(Looper.java:317)
E AndroidRuntime: at android.os.HandlerThread.run(HandlerThread.java:85)
E AndroidRuntime: at com.android.server.ServiceThread.run(ServiceThread.java:49)
E AndroidRuntime: Caused by: java.lang.RuntimeException: Unsupported operation
E AndroidRuntime: at org.lineageos.platform.internal.health.ccprovider.ChargingControlProvider.onBatteryChanged(ChargingControlProvider.java:107)
E AndroidRuntime: at org.lineageos.platform.internal.health.ccprovider.ChargingControlProvider.update(ChargingControlProvider.java:40)
E AndroidRuntime: at org.lineageos.platform.internal.health.ChargingControlController.updateChargeControl(ChargingControlController.java:412)
E AndroidRuntime: at org.lineageos.platform.internal.health.ChargingControlController.handleSettingChange(ChargingControlController.java:447)
E AndroidRuntime: at org.lineageos.platform.internal.health.ChargingControlController.onStart(ChargingControlController.java:265)
E AndroidRuntime: at org.lineageos.platform.internal.LineageBaseFeature.start(LineageBaseFeature.java:39)
E AndroidRuntime: at org.lineageos.platform.internal.health.HealthInterfaceService.onBootPhase(HealthInterfaceService.java:86)
E AndroidRuntime: at com.android.server.SystemServiceManager.startBootPhase(SystemServiceManager.java:318)
E AndroidRuntime: ... 10 more
E Zygote : System zygote died with fatal exception
Change-Id: Id177ec9fe814b4cf33d2853e7674463c5fd5b7ca
Log:
12-04 00:04:42.661 1499 1499 E AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: main
12-04 00:04:42.661 1499 1499 E AndroidRuntime: java.lang.RuntimeException: Error receiving broadcast Intent { act=android.intent.action.ACTION_POWER_DISCONNECTED flg=0x4000010 (has extras) } in org.lineageos.platform.internal.health.ChargingControlController$2@7432f8e
12-04 00:04:42.661 1499 1499 E AndroidRuntime: at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0(LoadedApk.java:1822)
12-04 00:04:42.661 1499 1499 E AndroidRuntime: at android.app.LoadedApk$ReceiverDispatcher$Args.$r8$lambda$mcNAAl1SQ4MyJPyDg8TJ2x2h0Rk(Unknown Source:0)
12-04 00:04:42.661 1499 1499 E AndroidRuntime: at android.app.LoadedApk$ReceiverDispatcher$Args$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
12-04 00:04:42.661 1499 1499 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:959)
12-04 00:04:42.661 1499 1499 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:100)
12-04 00:04:42.661 1499 1499 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:232)
12-04 00:04:42.661 1499 1499 E AndroidRuntime: at android.os.Looper.loop(Looper.java:317)
12-04 00:04:42.661 1499 1499 E AndroidRuntime: at com.android.server.SystemServer.run(SystemServer.java:985)
12-04 00:04:42.661 1499 1499 E AndroidRuntime: at com.android.server.SystemServer.main(SystemServer.java:669)
12-04 00:04:42.661 1499 1499 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
12-04 00:04:42.661 1499 1499 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:583)
12-04 00:04:42.661 1499 1499 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:864)
12-04 00:04:42.661 1499 1499 E AndroidRuntime: Caused by: java.lang.IllegalArgumentException: Receiver not registered: org.lineageos.platform.internal.health.ChargingControlController$LineageHealthBatteryBroadcastReceiver@7c6b69a
12-04 00:04:42.661 1499 1499 E AndroidRuntime: at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:1674)
12-04 00:04:42.661 1499 1499 E AndroidRuntime: at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1901)
12-04 00:04:42.661 1499 1499 E AndroidRuntime: at org.lineageos.platform.internal.health.ChargingControlController.onPowerDisconnected(ChargingControlController.java:325)
12-04 00:04:42.661 1499 1499 E AndroidRuntime: at org.lineageos.platform.internal.health.ChargingControlController.onPowerStatus(ChargingControlController.java:336)
12-04 00:04:42.661 1499 1499 E AndroidRuntime: at org.lineageos.platform.internal.health.ChargingControlController.-$$Nest$monPowerStatus(Unknown Source:0)
12-04 00:04:42.661 1499 1499 E AndroidRuntime: at org.lineageos.platform.internal.health.ChargingControlController$2.onReceive(ChargingControlController.java:290)
12-04 00:04:42.661 1499 1499 E AndroidRuntime: at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0(LoadedApk.java:1814)
12-04 00:04:42.661 1499 1499 E AndroidRuntime: ... 11 more
Change-Id: Ic2c1df60881ea06bd2cd3f6b68ea3ff7c1273153
Technically, this should be fixed device side, but random failure when
HAL side fails shouldn't crash the system either.
Fixes: https://gitlab.com/LineageOS/issues/android/-/issues/8391
Change-Id: Iedd869cbd74e4a5535655c977b8ead74e8d5868d
The existing Hardware Abstraction Layer (HAL) supports two distinct
control modes: TOGGLE and DEADLINE, each offering unique capabilities.
For instance, the TOGGLE mode allows for control over both charging
time and limit, while the DEADLINE mode only enables control over the
charging time. Managing these separate logic streams within a single
ChargingControlController class complicates the development process.
This commit separates the specific charging control logic — determining
what to send to the HAL—from the primary logic. The charging control
module now offers providers tailored to each HAL-supported charging
control mode, allowing for limit control, time control, or both. When
required, the ChargingControlController invokes these specific providers.
This commit also saparates other parts, like notifications, from the
main logic, to a saparate class.
This separation simplifies the codebase. Moreover, when introducing a new
mode in the HAL, developers only need to implement the corresponding
provider's logic based on the mode's capabilities. And minimal changes
are needed in the primary logic.
Change-Id: Ie40020c2df4141d4aa6385c8f5565821af942755
And a few language features (HashMap constructors, collapsing
catch blocks, method references)
plus two typos
Change-Id: I9ae2f7c006c5f2f9c7c99eab81059c08bece1202
* BluetoothAdapter.getDefaultAdapter() is deprecated since sdk 31
* Also fixes wrong naming for mBluetoothAdapter which was local
and thus didn't need the prefix "m"
Change-Id: I003fe06fbd8958cde0fdd71d61710272e32a2ca5
Currently if LineageHardwareManager couldn't get LineageHardwareService
on its first try, it stays disconnected and wouldn't retry in time.
Several one-time isSupported() checks during boot would then fail,
resulting in missing features e.g. HWC2-based LiveDisplay.
Change-Id: I85e6866543798ed4a805db5c99a28ef8a39335cc
Changing APEX modules behavior is as annoying as it can be.
Futhermore this target was used for a single setting entry that can be
easily replaced by using the AOSP settings provider, that is already
accessible in the module.
Change-Id: I0d2aa32dc4f3057d29bf59126c5a2dc3a4043c21