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

Commit 13695adf authored by Zaiyue Xue's avatar Zaiyue Xue
Browse files

Recheck the scedule job when the device is full charged and add more logs

Bug: 298539147
Fix: 298539147
Test: manual
Change-Id: Id9fdba17b24cbc6558bc29576f8cd93782854ee4
parent f2735dec
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;
        }