summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java11
-rw-r--r--services/profcollect/src/com/android/server/profcollect/Utils.java3
2 files changed, 12 insertions, 2 deletions
diff --git a/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java b/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java
index c31594a4bf47..fc585c9e0f96 100644
--- a/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java
+++ b/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java
@@ -16,6 +16,8 @@
package com.android.server.profcollect;
+import static android.content.Intent.ACTION_BATTERY_LOW;
+import static android.content.Intent.ACTION_BATTERY_OKAY;
import static android.content.Intent.ACTION_SCREEN_OFF;
import static android.content.Intent.ACTION_SCREEN_ON;
@@ -77,6 +79,7 @@ public final class ProfcollectForwardingService extends SystemService {
static boolean sVerityEnforced;
static boolean sIsInteractive;
static boolean sAdbActive;
+ static boolean sIsBatteryLow;
private static IProfCollectd sIProfcollect;
private static ProfcollectForwardingService sSelfService;
@@ -91,7 +94,11 @@ public final class ProfcollectForwardingService extends SystemService {
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- if (ACTION_SCREEN_ON.equals(intent.getAction())) {
+ if (ACTION_BATTERY_LOW.equals(intent.getAction())) {
+ sIsBatteryLow = true;
+ } else if (ACTION_BATTERY_OKAY.equals(intent.getAction())) {
+ sIsBatteryLow = false;
+ } else if (ACTION_SCREEN_ON.equals(intent.getAction())) {
Log.d(LOG_TAG, "Received broadcast that the device became interactive, was "
+ sIsInteractive);
sIsInteractive = true;
@@ -141,6 +148,8 @@ public final class ProfcollectForwardingService extends SystemService {
context.getResources().getBoolean(R.bool.config_profcollectReportUploaderEnabled);
final IntentFilter filter = new IntentFilter();
+ filter.addAction(ACTION_BATTERY_LOW);
+ filter.addAction(ACTION_BATTERY_OKAY);
filter.addAction(ACTION_SCREEN_ON);
filter.addAction(ACTION_SCREEN_OFF);
filter.addAction(INTENT_UPLOAD_PROFILES);
diff --git a/services/profcollect/src/com/android/server/profcollect/Utils.java b/services/profcollect/src/com/android/server/profcollect/Utils.java
index b754ca1875b6..c109f5cf05b6 100644
--- a/services/profcollect/src/com/android/server/profcollect/Utils.java
+++ b/services/profcollect/src/com/android/server/profcollect/Utils.java
@@ -118,6 +118,7 @@ final class Utils {
}
return ProfcollectForwardingService.sVerityEnforced
&& !ProfcollectForwardingService.sAdbActive
- && ProfcollectForwardingService.sIsInteractive;
+ && ProfcollectForwardingService.sIsInteractive
+ && !ProfcollectForwardingService.sIsBatteryLow;
}
}