Merge "Recheck the scedule job when the device is full charged and add more logs" into udc-qpr-dev
This commit is contained in:
@@ -120,6 +120,7 @@ public final class BatteryUsageBroadcastReceiver extends BroadcastReceiver {
|
|||||||
|
|
||||||
mFetchBatteryUsageData = true;
|
mFetchBatteryUsageData = true;
|
||||||
BatteryUsageDataLoader.enqueueWork(context, /*isFullChargeStart=*/ true);
|
BatteryUsageDataLoader.enqueueWork(context, /*isFullChargeStart=*/ true);
|
||||||
|
BootBroadcastReceiver.invokeJobRecheck(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendBatteryEventData(Context context, BatteryEventType batteryEventType) {
|
private void sendBatteryEventData(Context context, BatteryEventType batteryEventType) {
|
||||||
|
@@ -68,6 +68,8 @@ public final class PeriodicJobManager {
|
|||||||
/** Schedules the next alarm job if it is available. */
|
/** Schedules the next alarm job if it is available. */
|
||||||
public void refreshJob(final boolean fromBoot) {
|
public void refreshJob(final boolean fromBoot) {
|
||||||
if (mAlarmManager == null) {
|
if (mAlarmManager == null) {
|
||||||
|
BatteryUsageLogUtils.writeLog(mContext, Action.SCHEDULE_JOB,
|
||||||
|
"cannot schedule next alarm job due to AlarmManager is null");
|
||||||
Log.e(TAG, "cannot schedule next alarm job");
|
Log.e(TAG, "cannot schedule next alarm job");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -80,8 +82,8 @@ public final class PeriodicJobManager {
|
|||||||
AlarmManager.RTC_WAKEUP, triggerAtMillis, pendingIntent);
|
AlarmManager.RTC_WAKEUP, triggerAtMillis, pendingIntent);
|
||||||
|
|
||||||
final String utcToLocalTime = ConvertUtils.utcToLocalTimeForLogging(triggerAtMillis);
|
final String utcToLocalTime = ConvertUtils.utcToLocalTimeForLogging(triggerAtMillis);
|
||||||
BatteryUsageLogUtils.writeLog(
|
BatteryUsageLogUtils.writeLog(mContext, Action.SCHEDULE_JOB,
|
||||||
mContext, Action.SCHEDULE_JOB, "triggerTime=" + utcToLocalTime);
|
String.format("triggerTime=%s, fromBoot=%b", utcToLocalTime, fromBoot));
|
||||||
Log.d(TAG, "schedule next alarm job at " + utcToLocalTime);
|
Log.d(TAG, "schedule next alarm job at " + utcToLocalTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,12 +33,23 @@ public final class PeriodicJobReceiver extends BroadcastReceiver {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
try {
|
||||||
|
loadDataAndRefreshJob(context, intent);
|
||||||
|
} catch (Exception e) {
|
||||||
|
BatteryUsageLogUtils.writeLog(context, Action.SCHEDULE_JOB,
|
||||||
|
String.format("loadDataAndRefreshJob() failed: %s", e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void loadDataAndRefreshJob(Context context, Intent intent) {
|
||||||
final String action = intent == null ? "" : intent.getAction();
|
final String action = intent == null ? "" : intent.getAction();
|
||||||
if (!ACTION_PERIODIC_JOB_UPDATE.equals(action)) {
|
if (!ACTION_PERIODIC_JOB_UPDATE.equals(action)) {
|
||||||
Log.w(TAG, "receive unexpected action=" + action);
|
Log.w(TAG, "receive unexpected action=" + action);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (DatabaseUtils.isWorkProfile(context)) {
|
if (DatabaseUtils.isWorkProfile(context)) {
|
||||||
|
BatteryUsageLogUtils.writeLog(context, Action.SCHEDULE_JOB,
|
||||||
|
"do not refresh job for work profile");
|
||||||
Log.w(TAG, "do not refresh job for work profile action=" + action);
|
Log.w(TAG, "do not refresh job for work profile action=" + action);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user