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

Commit 53eaf674 authored by Jonathan Klee's avatar Jonathan Klee
Browse files

Add logs

parent 242020d4
Loading
Loading
Loading
Loading
+7 −10
Original line number Diff line number Diff line
@@ -55,8 +55,6 @@ public class WeatherUpdater {
        long refreshPeriod = Preferences.weatherRefreshIntervalInMs(context);
        long elapsedTime = Math.abs(SystemClock.elapsedRealtime() - Preferences.lastWeatherUpdateTimestamp(context));

        Log.i(TAG, "elapsedTime=" + elapsedTime + " vs refreshPeriod=" + refreshPeriod);

        boolean isPeriodicRequestAllowed = refreshPeriod != 0 && elapsedTime >= refreshPeriod;
        if (isPeriodicRequestAllowed) {
            forceWeatherRequest();
@@ -72,14 +70,13 @@ public class WeatherUpdater {

    private boolean canForceWeatherRequest() {
        Context context = mWeakContext.get();

        long elapsedTime = Math.abs(SystemClock.elapsedRealtime() - Preferences.getForceRequestLastTry(context));
        boolean isRequestAllowed = elapsedTime >= mForceRequestPeriodInMs
                || mForceRequestPeriodInMs == Preferences.weatherRefreshIntervalInMs(context);

        boolean isRequestAllowed = elapsedTime >= mForceRequestPeriodInMs;

        if (isRequestAllowed) {
            Preferences.setForceRequestLastTry(context, SystemClock.elapsedRealtime());
        } else {
            Log.w(TAG, "Cannot force weather update too frequently. Period is " + mForceRequestPeriodInMs + "ms.");
        }

        return isRequestAllowed;
@@ -98,10 +95,9 @@ public class WeatherUpdater {

    private void increaseForceRequestPeriod() {
        mForceRequestPeriodInMs = mForceRequestPeriodInMs * 2;
        long requestPeriod = Preferences.weatherRefreshIntervalInMs(mWeakContext.get());

        if (mForceRequestPeriodInMs > requestPeriod) {
            mForceRequestPeriodInMs = requestPeriod;
        if (mForceRequestPeriodInMs > Preferences.weatherRefreshIntervalInMs(mWeakContext.get())) {
            mForceRequestPeriodInMs = DEFAULT_FORCE_REQUEST_PERIOD_IN_MS;
        }
    }

@@ -144,6 +140,7 @@ public class WeatherUpdater {

    private synchronized void onNewLocationFetched(@Nullable Location location) {
        if (location == null) {
            Log.w(TAG, "Could not fetch any location");
            return;
        }

@@ -158,7 +155,7 @@ public class WeatherUpdater {
        requestWeatherUpdate(getMostRecentLocation());
    }

    protected void notifyUi(@NonNull Context context, @Nullable WeatherInfo weatherInfo, int status) {
    private void notifyUi(@NonNull Context context, @Nullable WeatherInfo weatherInfo, int status) {

        if (weatherInfo == null) {
            Log.i(TAG, "WeatherInfo is null. Status reported: " + status);