From 9a0fe3bea68f0bc457fd02b24b926960c3a689e6 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Tue, 13 Jun 2023 14:24:16 +0200 Subject: [PATCH] sdk: Add static isChargingControlSupported(ctx) method This will let us use it without bothering to handle RuntimeException from HealthInterface contructor. Change-Id: I768c250d1e527b6fd8e49a40452b98404062cc18 --- .../java/lineageos/health/HealthInterface.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sdk/src/java/lineageos/health/HealthInterface.java b/sdk/src/java/lineageos/health/HealthInterface.java index 7cb41543..d5d76e32 100644 --- a/sdk/src/java/lineageos/health/HealthInterface.java +++ b/sdk/src/java/lineageos/health/HealthInterface.java @@ -119,6 +119,21 @@ public class HealthInterface { return false; } + /** + * Returns whether charging control is supported + * + * @return true if charging control is supported + */ + public static boolean isChargingControlSupported(Context context) { + try { + return getInstance(context).isChargingControlSupported(); + } catch (RuntimeException e) { + Log.e(TAG, e.getLocalizedMessage(), e); + } + + return false; + } + /** * Returns the charging control enabled status *