diff options
| author | Dianne Hackborn <hackbod@google.com> | 2010-03-04 00:58:29 -0800 |
|---|---|---|
| committer | Dianne Hackborn <hackbod@google.com> | 2010-03-04 11:52:14 -0800 |
| commit | 20cb56e26e91df91bd64d4251222e0d421cdbe47 (patch) | |
| tree | 17f4e6b033d060bd4745fd6a2ac38ada2e35897f /core/java/android | |
| parent | 89d6d00a8b015e97f6bf8ca9fa9203402c15aa00 (diff) | |
Fix some bugs.
Bug #2376231: Apps lose window focus (and back key causes ANR) if the
lock screen is dismissed while the phone is in landscape mode
This is another case where we weren't recomputing the focused window
after changing the visibility policy.
bug #2479958: Investigate source of "Resources don't contain package
for resource number 0x7f0a0000"
Um, okay, so it turns out there were bugs all over the place where
we would load an XML resource from a another application, but not
use the Resources for that application to retrieve its resources...!
I think the only reason any of this stuff was working at all was
because it typically only cared about retrieving the resource
identifiers of the items (it would look up the values later).
Bug #2401082: Passion ERE26 monkey crash - InputMethodManagerService
Add some null checks.
Diffstat (limited to 'core/java/android')
6 files changed, 41 insertions, 9 deletions
diff --git a/core/java/android/accounts/AccountAuthenticatorCache.java b/core/java/android/accounts/AccountAuthenticatorCache.java index d6c76a2a5d75..d2b3bc77e9c5 100644 --- a/core/java/android/accounts/AccountAuthenticatorCache.java +++ b/core/java/android/accounts/AccountAuthenticatorCache.java @@ -19,6 +19,7 @@ package android.accounts; import android.content.pm.PackageManager; import android.content.pm.RegisteredServicesCache; import android.content.pm.XmlSerializerAndParser; +import android.content.res.Resources; import android.content.res.TypedArray; import android.content.Context; import android.util.AttributeSet; @@ -47,8 +48,9 @@ import java.io.IOException; AccountManager.AUTHENTICATOR_ATTRIBUTES_NAME, sSerializer); } - public AuthenticatorDescription parseServiceAttributes(String packageName, AttributeSet attrs) { - TypedArray sa = mContext.getResources().obtainAttributes(attrs, + public AuthenticatorDescription parseServiceAttributes(Resources res, + String packageName, AttributeSet attrs) { + TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AccountAuthenticator); try { final String accountType = diff --git a/core/java/android/app/WallpaperInfo.java b/core/java/android/app/WallpaperInfo.java index 5ca3fb54e2fc..7db9fa8fed65 100644 --- a/core/java/android/app/WallpaperInfo.java +++ b/core/java/android/app/WallpaperInfo.java @@ -25,7 +25,9 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; +import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources.NotFoundException; +import android.content.res.Resources; import android.content.res.TypedArray; import android.content.res.XmlResourceParser; import android.graphics.drawable.Drawable; @@ -96,6 +98,8 @@ public final class WallpaperInfo implements Parcelable { + WallpaperService.SERVICE_META_DATA + " meta-data"); } + Resources res = pm.getResourcesForApplication(si.applicationInfo); + AttributeSet attrs = Xml.asAttributeSet(parser); int type; @@ -109,7 +113,7 @@ public final class WallpaperInfo implements Parcelable { "Meta-data does not start with wallpaper tag"); } - TypedArray sa = context.getResources().obtainAttributes(attrs, + TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.Wallpaper); settingsActivityComponent = sa.getString( com.android.internal.R.styleable.Wallpaper_settingsActivity); @@ -125,6 +129,9 @@ public final class WallpaperInfo implements Parcelable { -1); sa.recycle(); + } catch (NameNotFoundException e) { + throw new XmlPullParserException( + "Unable to create context for: " + si.packageName); } finally { if (parser != null) parser.close(); } diff --git a/core/java/android/app/admin/DeviceAdminInfo.java b/core/java/android/app/admin/DeviceAdminInfo.java index c4de812d4ce0..0bcd65cd48fe 100644 --- a/core/java/android/app/admin/DeviceAdminInfo.java +++ b/core/java/android/app/admin/DeviceAdminInfo.java @@ -26,6 +26,8 @@ import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; +import android.content.pm.PackageManager.NameNotFoundException; +import android.content.res.Resources; import android.content.res.TypedArray; import android.content.res.XmlResourceParser; import android.content.res.Resources.NotFoundException; @@ -181,6 +183,8 @@ public final class DeviceAdminInfo implements Parcelable { + DeviceAdminReceiver.DEVICE_ADMIN_META_DATA + " meta-data"); } + Resources res = pm.getResourcesForApplication(ai.applicationInfo); + AttributeSet attrs = Xml.asAttributeSet(parser); int type; @@ -194,7 +198,7 @@ public final class DeviceAdminInfo implements Parcelable { "Meta-data does not start with device-admin tag"); } - TypedArray sa = context.getResources().obtainAttributes(attrs, + TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.DeviceAdmin); mVisible = sa.getBoolean( @@ -227,6 +231,9 @@ public final class DeviceAdminInfo implements Parcelable { } } } + } catch (NameNotFoundException e) { + throw new XmlPullParserException( + "Unable to create context for: " + ai.packageName); } finally { if (parser != null) parser.close(); } diff --git a/core/java/android/content/SyncAdaptersCache.java b/core/java/android/content/SyncAdaptersCache.java index 6ade83781470..98a25953c3eb 100644 --- a/core/java/android/content/SyncAdaptersCache.java +++ b/core/java/android/content/SyncAdaptersCache.java @@ -18,6 +18,7 @@ package android.content; import android.content.pm.RegisteredServicesCache; import android.content.pm.XmlSerializerAndParser; +import android.content.res.Resources; import android.content.res.TypedArray; import android.util.AttributeSet; import org.xmlpull.v1.XmlPullParser; @@ -42,8 +43,9 @@ import java.io.IOException; super(context, SERVICE_INTERFACE, SERVICE_META_DATA, ATTRIBUTES_NAME, sSerializer); } - public SyncAdapterType parseServiceAttributes(String packageName, AttributeSet attrs) { - TypedArray sa = mContext.getResources().obtainAttributes(attrs, + public SyncAdapterType parseServiceAttributes(Resources res, + String packageName, AttributeSet attrs) { + TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.SyncAdapter); try { final String authority = diff --git a/core/java/android/content/pm/RegisteredServicesCache.java b/core/java/android/content/pm/RegisteredServicesCache.java index b74c073f5b47..dce3963ea98c 100644 --- a/core/java/android/content/pm/RegisteredServicesCache.java +++ b/core/java/android/content/pm/RegisteredServicesCache.java @@ -21,6 +21,8 @@ import android.content.BroadcastReceiver; import android.content.Intent; import android.content.IntentFilter; import android.content.ComponentName; +import android.content.pm.PackageManager.NameNotFoundException; +import android.content.res.Resources; import android.content.res.XmlResourceParser; import android.os.Environment; import android.os.Handler; @@ -402,7 +404,8 @@ public abstract class RegisteredServicesCache<V> { "Meta-data does not start with " + mAttributesName + " tag"); } - V v = parseServiceAttributes(si.packageName, attrs); + V v = parseServiceAttributes(pm.getResourcesForApplication(si.applicationInfo), + si.packageName, attrs); if (v == null) { return null; } @@ -410,6 +413,9 @@ public abstract class RegisteredServicesCache<V> { final ApplicationInfo applicationInfo = serviceInfo.applicationInfo; final int uid = applicationInfo.uid; return new ServiceInfo<V>(v, componentName, uid); + } catch (NameNotFoundException e) { + throw new XmlPullParserException( + "Unable to load resources for pacakge " + si.packageName); } finally { if (parser != null) parser.close(); } @@ -499,5 +505,6 @@ public abstract class RegisteredServicesCache<V> { } } - public abstract V parseServiceAttributes(String packageName, AttributeSet attrs); + public abstract V parseServiceAttributes(Resources res, + String packageName, AttributeSet attrs); } diff --git a/core/java/android/view/inputmethod/InputMethodInfo.java b/core/java/android/view/inputmethod/InputMethodInfo.java index 316bcd614c46..357cb5feea1a 100644 --- a/core/java/android/view/inputmethod/InputMethodInfo.java +++ b/core/java/android/view/inputmethod/InputMethodInfo.java @@ -25,6 +25,8 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; +import android.content.pm.PackageManager.NameNotFoundException; +import android.content.res.Resources; import android.content.res.TypedArray; import android.content.res.XmlResourceParser; import android.graphics.drawable.Drawable; @@ -92,6 +94,8 @@ public final class InputMethodInfo implements Parcelable { + InputMethod.SERVICE_META_DATA + " meta-data"); } + Resources res = pm.getResourcesForApplication(si.applicationInfo); + AttributeSet attrs = Xml.asAttributeSet(parser); int type; @@ -105,13 +109,16 @@ public final class InputMethodInfo implements Parcelable { "Meta-data does not start with input-method tag"); } - TypedArray sa = context.getResources().obtainAttributes(attrs, + TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.InputMethod); settingsActivityComponent = sa.getString( com.android.internal.R.styleable.InputMethod_settingsActivity); isDefaultResId = sa.getResourceId( com.android.internal.R.styleable.InputMethod_isDefault, 0); sa.recycle(); + } catch (NameNotFoundException e) { + throw new XmlPullParserException( + "Unable to create context for: " + si.packageName); } finally { if (parser != null) parser.close(); } |
