Make DateTimeView more robust to weird contexts.

In particular, some clients (*ahem* SystemUI) have been
known to inflate RemoteViews with unusual derived contexts
that may not have valid application contexts. DateTimeView
can now resist this.

Bug: 22852700
Change-Id: I5e91ae0e66859f5f5efd7b19c0ae6dfbc26bcc54
This commit is contained in:
Dan Sandler
2015-07-30 22:33:12 -04:00
parent 706274f7ff
commit 4b67713709

View File

@@ -16,6 +16,7 @@
package android.widget;
import android.app.ActivityThread;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -259,7 +260,7 @@ public class DateTimeView extends TextView {
static final Context getApplicationContextIfAvailable(Context context) {
final Context ac = context.getApplicationContext();
return ac != null ? ac : context;
return ac != null ? ac : ActivityThread.currentApplication().getApplicationContext();
}
void register(Context context) {