Skip to content

Commit 4cce397

Browse files
Winson ChungAndroid (Google) Code Review
authored andcommitted
Merge "Letting partial update fall through if the widget has not received a full update yet. (Bug 7214731)" into jb-mr1-dev
2 parents 2e21bdb + 6611988 commit 4cce397

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

core/java/android/appwidget/AppWidgetManager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,10 @@ public void updateAppWidget(int appWidgetId, RemoteViews views) {
448448
* and outside of the handler.
449449
* This method will only work when called from the uid that owns the AppWidget provider.
450450
*
451+
* <p>
452+
* This method will be ignored if a widget has not received a full update via
453+
* {@link #updateAppWidget(int[], RemoteViews)}.
454+
*
451455
* @param appWidgetIds The AppWidget instances for which to set the RemoteViews.
452456
* @param views The RemoteViews object containing the incremental update / command.
453457
*/
@@ -476,6 +480,10 @@ public void partiallyUpdateAppWidget(int[] appWidgetIds, RemoteViews views) {
476480
* and outside of the handler.
477481
* This method will only work when called from the uid that owns the AppWidget provider.
478482
*
483+
* <p>
484+
* This method will be ignored if a widget has not received a full update via
485+
* {@link #updateAppWidget(int[], RemoteViews)}.
486+
*
479487
* @param appWidgetId The AppWidget instance for which to set the RemoteViews.
480488
* @param views The RemoteViews object containing the incremental update / command.
481489
*/

services/java/com/android/server/AppWidgetServiceImpl.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,10 @@ public void partiallyUpdateAppWidgetIds(int[] appWidgetIds, RemoteViews views) {
943943
ensureStateLoadedLocked();
944944
for (int i = 0; i < N; i++) {
945945
AppWidgetId id = lookupAppWidgetIdLocked(appWidgetIds[i]);
946-
updateAppWidgetInstanceLocked(id, views, true);
946+
if (id.views != null) {
947+
// Only trigger a partial update for a widget if it has received a full update
948+
updateAppWidgetInstanceLocked(id, views, true);
949+
}
947950
}
948951
}
949952
}
@@ -996,7 +999,7 @@ void updateAppWidgetInstanceLocked(AppWidgetId id, RemoteViews views, boolean is
996999
// drop unbound appWidgetIds (shouldn't be possible under normal circumstances)
9971000
if (id != null && id.provider != null && !id.provider.zombie && !id.host.zombie) {
9981001

999-
if (!isPartialUpdate || id.views == null) {
1002+
if (!isPartialUpdate) {
10001003
// For a full update we replace the RemoteViews completely.
10011004
id.views = views;
10021005
} else {

0 commit comments

Comments
 (0)