Skip to content

Commit

Permalink
Rapong/release/18.1.2 (#2535)
Browse files Browse the repository at this point in the history
  • Loading branch information
rpdome authored Nov 12, 2024
1 parent 9fa8331 commit 14933d8
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 3 deletions.
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ codeCoverageReport {

// In dev, we want to keep the dependencies(common4j, broker4j, common) to 1.0.+ to be able to be consumed by daily dev pipeline.
// In release/*, we change these to specific versions being consumed.
def common4jVersion = "15.1.0"
def common4jVersion = "15.1.2"
if (project.hasProperty("distCommon4jVersion") && project.distCommon4jVersion != '') {
common4jVersion = project.distCommon4jVersion
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import android.os.Build;
import android.os.PowerManager;

import androidx.annotation.NonNull;

/**
* Wrapper class for PowerManager.
*/
Expand All @@ -35,6 +37,7 @@ public class PowerManagerWrapper {

private static PowerManagerWrapper sInstance;

private static final String UNKNOWN_STATUS = "Unknown";
/**
* Set instance of PowerManagerWrapper.
*
Expand Down Expand Up @@ -67,6 +70,60 @@ public boolean isDeviceIdleMode(final Context connectionContext) {
return ((PowerManager) connectionContext.getSystemService(Context.POWER_SERVICE)).isDeviceIdleMode();
}

/**
* Gets a string representing Device Idle status.
* Will return an empty string if the device is not in any idle mode.
* (Possible Values: "Idle", "LightIdle", "Unknown" , "")
*/
@NonNull
public String getDeviceIdleMode(@NonNull final Context context){
try {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return UNKNOWN_STATUS;
}

final PowerManager powerManager = ((PowerManager) context.getSystemService(Context.POWER_SERVICE));
if (powerManager.isDeviceIdleMode()) {
return "Idle";
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU &&
powerManager.isDeviceLightIdleMode()) {
return "LightIdle";
}
} catch (final Exception e){
// Swallow all exception!
return UNKNOWN_STATUS;
}

return "";
}

/**
* Gets a string representing Power Optimization settings of the calling app
* Will return an empty string if the app isn't opting out.
* (Possible Values: "OptOut", "Unknown" , "")
*/
@NonNull
public String getPowerOptimizationSettings(@NonNull final Context context){
try {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return UNKNOWN_STATUS;
}

final PowerManager powerManager = ((PowerManager) context.getSystemService(Context.POWER_SERVICE));
if (powerManager.isIgnoringBatteryOptimizations(context.getPackageName())){
return "OptOut";
} else {
return "";
}

} catch (final Exception e){
// Swallow all exception!
return UNKNOWN_STATUS;
}
}

/**
* Wrap the calling to method isIgnoringBatteryOptimizations() of final class PowerManager.
*
Expand Down
2 changes: 1 addition & 1 deletion common4j/versioning/version.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Wed May 12 20:08:39 UTC 2021
versionName=15.1.0
versionName=15.1.2
versionCode=1
latestPatchVersion=227
2 changes: 1 addition & 1 deletion versioning/version.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Tue Apr 06 22:55:08 UTC 2021
versionName=18.1.0
versionName=18.1.2
versionCode=1
latestPatchVersion=234

0 comments on commit 14933d8

Please sign in to comment.