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

Commit 45f7d870 authored by jorgetm's avatar jorgetm Committed by Jorge De la Torre
Browse files

AlarmManager: Store time offset system property

For TILB (time in low battery mode) we need to store the time zone
offset as a system property. Updating AlarmManagerService so it matches
kr3-dev and stores this offset when the time zone is updated through
connectivity or when it is updated manually in the settings.

Bug: 311191984
Test: Update time zone manually and check the system property
Change-Id: I426941c01408bb83821573f83e757c05aec4dd5c
parent aaf96093
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -115,6 +115,7 @@ import android.os.ServiceManager;
import android.os.ShellCallback;
import android.os.ShellCommand;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.ThreadLocalWorkSource;
import android.os.Trace;
import android.os.UserHandle;
@@ -229,6 +230,9 @@ public class AlarmManagerService extends SystemService {

    private static final long TEMPORARY_QUOTA_DURATION = INTERVAL_DAY;

    // System property read on some device configurations to initialize time properly.
    private static final String TIMEOFFSET_PROPERTY = "persist.sys.time.offset";

    private final Intent mBackgroundIntent
            = new Intent().addFlags(Intent.FLAG_FROM_BACKGROUND);

@@ -2142,6 +2146,9 @@ public class AlarmManagerService extends SystemService {
            // "GMT" if the ID is unrecognized). The parameter ID is used here rather than
            // newZone.getId(). It will be rejected if it is invalid.
            timeZoneWasChanged = SystemTimeZone.setTimeZoneId(tzId, confidence, logInfo);

            final int gmtOffset = newZone.getOffset(mInjector.getCurrentTimeMillis());
            SystemProperties.set(TIMEOFFSET_PROPERTY, String.valueOf(gmtOffset));
        }

        // Clear the default time zone in the system server process. This forces the next call