Restore the creation of the remote context in sync inflation.
This was mistakenly removed in Android S (in ag/13732454) and could cause issues if the top-level layout parameters are defined using resources defined in the AppWidget's package. Also add some safeguard to avoid crashing if the AppWidgetProviderInfo doesn't contain a ProviderInfo (which can happen if it's not created by the system). Fix: 201744899 Test: Existing CTS tests Change-Id: Ibb4f2c26a6258ec2c68a7fd1fafe3e5fe3551109
This commit is contained in:
@@ -552,6 +552,10 @@ public class AppWidgetHostView extends FrameLayout {
|
||||
inflateAsync(rvToApply);
|
||||
return;
|
||||
}
|
||||
// Prepare a local reference to the remote Context so we're ready to
|
||||
// inflate any requested LayoutParams.
|
||||
mRemoteContext = getRemoteContext();
|
||||
|
||||
int layoutId = rvToApply.getLayoutId();
|
||||
if (rvToApply.canRecycleView(mView)) {
|
||||
try {
|
||||
@@ -727,6 +731,9 @@ public class AppWidgetHostView extends FrameLayout {
|
||||
} catch (NameNotFoundException e) {
|
||||
Log.e(TAG, "Package name " + mInfo.providerInfo.packageName + " not found");
|
||||
return mContext;
|
||||
} catch (NullPointerException e) {
|
||||
Log.e(TAG, "Error trying to create the remote context.", e);
|
||||
return mContext;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user