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

Commit be96b3a2 authored by Joe Onorato's avatar Joe Onorato
Browse files

Clamp app widget updates from updatePeriodMillis to a minimum of 30 minutes.

parent 37b939a6
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -57,6 +57,9 @@ public class AppWidgetProviderInfo implements Parcelable {
     *
     *
     * <p>This field corresponds to the <code>android:updatePeriodMillis</code> attribute in
     * <p>This field corresponds to the <code>android:updatePeriodMillis</code> attribute in
     * the AppWidget meta-data file.
     * the AppWidget meta-data file.
     *
     * <p class="note"><b>Note:</b> Updates requested with <code>updatePeriodMillis</code>
     * will not be delivered more than once every 30 minutes.</p>
     */
     */
    public int updatePeriodMillis;
    public int updatePeriodMillis;


+6 −2
Original line number Original line Diff line number Diff line
@@ -68,6 +68,7 @@ class AppWidgetService extends IAppWidgetService.Stub


    private static final String SETTINGS_FILENAME = "appwidgets.xml";
    private static final String SETTINGS_FILENAME = "appwidgets.xml";
    private static final String SETTINGS_TMP_FILENAME = SETTINGS_FILENAME + ".tmp";
    private static final String SETTINGS_TMP_FILENAME = SETTINGS_FILENAME + ".tmp";
    private static final int MIN_UPDATE_PERIOD = 30 * 60 * 1000; // 30 minutes


    /*
    /*
     * When identifying a Host or Provider based on the calling process, use the uid field.
     * When identifying a Host or Provider based on the calling process, use the uid field.
@@ -629,9 +630,12 @@ class AppWidgetService extends IAppWidgetService.Stub
                Binder.restoreCallingIdentity(token);
                Binder.restoreCallingIdentity(token);
            }
            }
            if (!alreadyRegistered) {
            if (!alreadyRegistered) {
                long period = p.info.updatePeriodMillis;
                if (period < MIN_UPDATE_PERIOD) {
                    period = MIN_UPDATE_PERIOD;
                }
                mAlarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                mAlarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                        SystemClock.elapsedRealtime() + p.info.updatePeriodMillis,
                        SystemClock.elapsedRealtime() + period, period, p.broadcast);
                        p.info.updatePeriodMillis, p.broadcast);
            }
            }
        }
        }
    }
    }