Merge change 7421 into donut

* changes:
  Clamp app widget updates from updatePeriodMillis to a minimum of 30 minutes.
This commit is contained in:
Android (Google) Code Review
2009-07-15 12:37:08 -07:00
2 changed files with 9 additions and 2 deletions

View File

@ -57,6 +57,9 @@ public class AppWidgetProviderInfo implements Parcelable {
*
* <p>This field corresponds to the <code>android:updatePeriodMillis</code> attribute in
* 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;

View File

@ -68,6 +68,7 @@ class AppWidgetService extends IAppWidgetService.Stub
private static final String SETTINGS_FILENAME = "appwidgets.xml";
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.
@ -629,9 +630,12 @@ class AppWidgetService extends IAppWidgetService.Stub
Binder.restoreCallingIdentity(token);
}
if (!alreadyRegistered) {
long period = p.info.updatePeriodMillis;
if (period < MIN_UPDATE_PERIOD) {
period = MIN_UPDATE_PERIOD;
}
mAlarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime() + p.info.updatePeriodMillis,
p.info.updatePeriodMillis, p.broadcast);
SystemClock.elapsedRealtime() + period, period, p.broadcast);
}
}
}