diff --git a/android/gradle.properties b/android/gradle.properties index 69ce1fc1ca..3011d73030 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -2,8 +2,8 @@ propMinSdkVersion=21 propTargetSdkVersion=29 propCompileSdkVersion=29 propBuildToolsVersion=27.0.3 -propVersionCode=1049 -propVersionName=10.4.9 +propVersionCode=1050 +propVersionName=10.5.0 propDebugNdkFlags=V=1 NDK_DEBUG=1 DEBUG=1 propReleaseNdkFlags=V=1 NDK_DEBUG=0 PRODUCTION=1 propMultiDexVersion=2.0.1 diff --git a/android/jni/com/mapswithme/platform/Platform.cpp b/android/jni/com/mapswithme/platform/Platform.cpp index af2ebd288c..f36bf641b4 100644 --- a/android/jni/com/mapswithme/platform/Platform.cpp +++ b/android/jni/com/mapswithme/platform/Platform.cpp @@ -127,9 +127,10 @@ Platform::ChargingStatus Platform::GetChargingStatus() ASSERT(clazzBatteryState, ()); static jmethodID const getChargingMethodId = - jni::GetStaticMethodID(env, clazzBatteryState, "getChargingStatus", "()I"); + jni::GetStaticMethodID(env, clazzBatteryState, "getChargingStatus", "(Landroid/content/Context;)I"); + jobject context = android::Platform::Instance().GetContext(); return static_cast( - env->CallStaticIntMethod(clazzBatteryState, getChargingMethodId)); + env->CallStaticIntMethod(clazzBatteryState, getChargingMethodId, context)); } uint8_t Platform::GetBatteryLevel() @@ -143,9 +144,9 @@ uint8_t Platform::GetBatteryLevel() ASSERT(clazzBatteryState, ()); static auto const getLevelMethodId = - jni::GetStaticMethodID(env, clazzBatteryState, "getLevel", "()I"); - - return static_cast(env->CallStaticIntMethod(clazzBatteryState, getLevelMethodId)); + jni::GetStaticMethodID(env, clazzBatteryState, "getLevel", "(Landroid/content/Context;)I"); + jobject context = android::Platform::Instance().GetContext(); + return static_cast(env->CallStaticIntMethod(clazzBatteryState, getLevelMethodId, context)); } namespace platform diff --git a/android/src/com/mapswithme/util/BatteryState.java b/android/src/com/mapswithme/util/BatteryState.java index ca39ebc50e..9dbbe64931 100644 --- a/android/src/com/mapswithme/util/BatteryState.java +++ b/android/src/com/mapswithme/util/BatteryState.java @@ -50,6 +50,12 @@ public final class BatteryState return batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, 0); } + @ChargingStatus + public static int getChargingStatus(@NonNull Context context) + { + return getState(context).getChargingStatus(); + } + @ChargingStatus private static int getChargingStatus(@NonNull Intent batteryStatus) {