From 180cfd5feb4fe415d04494bf00f2013896f93b77 Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Sun, 4 Nov 2012 12:03:12 -0800 Subject: [PATCH] If a default keyguard layout isn't specified, fallback to the default layout -> Also fixing a typo in AppWidgetProvider clone() -- this was the cause of the "couldn't load widget". It wasn't getting expressed before for various reasons. Change-Id: Ib7114565a414d66facd8b4baeb97d5a71e96b5e9 --- core/java/android/appwidget/AppWidgetHostView.java | 5 ++++- core/java/android/appwidget/AppWidgetProviderInfo.java | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/java/android/appwidget/AppWidgetHostView.java b/core/java/android/appwidget/AppWidgetHostView.java index be6a770e6f33b..52771eebecbb9 100644 --- a/core/java/android/appwidget/AppWidgetHostView.java +++ b/core/java/android/appwidget/AppWidgetHostView.java @@ -553,7 +553,10 @@ public class AppWidgetHostView extends FrameLayout { if (options.containsKey(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY)) { int category = options.getInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY); if (category == AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD) { - layoutId = mInfo.initialKeyguardLayout; + int kgLayoutId = mInfo.initialKeyguardLayout; + // If a default keyguard layout is not specified, use the standard + // default layout. + layoutId = kgLayoutId == 0 ? layoutId : kgLayoutId; } } defaultView = inflater.inflate(layoutId, this, false); diff --git a/core/java/android/appwidget/AppWidgetProviderInfo.java b/core/java/android/appwidget/AppWidgetProviderInfo.java index 6bf12e681bad0..7b8b286ab643a 100644 --- a/core/java/android/appwidget/AppWidgetProviderInfo.java +++ b/core/java/android/appwidget/AppWidgetProviderInfo.java @@ -260,7 +260,7 @@ public class AppWidgetProviderInfo implements Parcelable { that.minResizeWidth = this.minResizeHeight; that.minResizeHeight = this.minResizeHeight; that.updatePeriodMillis = this.updatePeriodMillis; - that.initialLayout = that.initialLayout; + that.initialLayout = this.initialLayout; that.initialKeyguardLayout = this.initialKeyguardLayout; that.configure = this.configure == null ? null : this.configure.clone(); that.label = this.label == null ? null : this.label.substring(0);