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

Commit 378ad24a authored by YK Hung's avatar YK Hung Committed by Android (Google) Code Review
Browse files

Merge "Recheck the scedule job when the device is full charged and add more logs" into udc-qpr-dev

parents 7e92664f 13695adf
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;
        }