Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit abc3ed4c authored by YK Hung's avatar YK Hung Committed by Automerger Merge Worker
Browse files

Merge "Recheck the scedule job when the device is full charged and add more...

Merge "Recheck the scedule job when the device is full charged and add more logs" into udc-qpr-dev am: 378ad24a am: 348b3b91

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/24673967



Change-Id: I6d29fc6eec107000986ad154bb8bc3bf81722b1c
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 3de16033 348b3b91
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ public final class BatteryUsageBroadcastReceiver extends BroadcastReceiver {

        mFetchBatteryUsageData = true;
        BatteryUsageDataLoader.enqueueWork(context, /*isFullChargeStart=*/ true);
        BootBroadcastReceiver.invokeJobRecheck(context);
    }

    private void sendBatteryEventData(Context context, BatteryEventType batteryEventType) {
+4 −2
Original line number Diff line number Diff line
@@ -68,6 +68,8 @@ public final class PeriodicJobManager {
    /** Schedules the next alarm job if it is available. */
    public void refreshJob(final boolean fromBoot) {
        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");
            return;
        }
@@ -80,8 +82,8 @@ public final class PeriodicJobManager {
                AlarmManager.RTC_WAKEUP, triggerAtMillis, pendingIntent);

        final String utcToLocalTime = ConvertUtils.utcToLocalTimeForLogging(triggerAtMillis);
        BatteryUsageLogUtils.writeLog(
                mContext, Action.SCHEDULE_JOB, "triggerTime=" + utcToLocalTime);
        BatteryUsageLogUtils.writeLog(mContext, Action.SCHEDULE_JOB,
                String.format("triggerTime=%s, fromBoot=%b", utcToLocalTime, fromBoot));
        Log.d(TAG, "schedule next alarm job at " + utcToLocalTime);
    }

+11 −0
Original line number Diff line number Diff line
@@ -33,12 +33,23 @@ public final class PeriodicJobReceiver extends BroadcastReceiver {

    @Override
    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();
        if (!ACTION_PERIODIC_JOB_UPDATE.equals(action)) {
            Log.w(TAG, "receive unexpected action=" + action);
            return;
        }
        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);
            return;
        }