Loading core/java/android/app/ApplicationPackageManager.java +17 −13 Original line number Original line Diff line number Diff line Loading @@ -80,6 +80,9 @@ final class ApplicationPackageManager extends PackageManager { private final static boolean DEBUG = false; private final static boolean DEBUG = false; private final static boolean DEBUG_ICONS = false; private final static boolean DEBUG_ICONS = false; // Default flags to use with PackageManager when no flags are given. private final static int sDefaultFlags = PackageManager.GET_SHARED_LIBRARY_FILES; private final Object mLock = new Object(); private final Object mLock = new Object(); @GuardedBy("mLock") @GuardedBy("mLock") Loading Loading @@ -730,7 +733,7 @@ final class ApplicationPackageManager extends PackageManager { } } if (appInfo == null) { if (appInfo == null) { try { try { appInfo = getApplicationInfo(packageName, 0); appInfo = getApplicationInfo(packageName, sDefaultFlags); } catch (NameNotFoundException e) { } catch (NameNotFoundException e) { return null; return null; } } Loading Loading @@ -770,7 +773,7 @@ final class ApplicationPackageManager extends PackageManager { @Override public Drawable getActivityIcon(ComponentName activityName) @Override public Drawable getActivityIcon(ComponentName activityName) throws NameNotFoundException { throws NameNotFoundException { return getActivityInfo(activityName, 0).loadIcon(this); return getActivityInfo(activityName, sDefaultFlags).loadIcon(this); } } @Override public Drawable getActivityIcon(Intent intent) @Override public Drawable getActivityIcon(Intent intent) Loading Loading @@ -799,13 +802,13 @@ final class ApplicationPackageManager extends PackageManager { @Override public Drawable getApplicationIcon(String packageName) @Override public Drawable getApplicationIcon(String packageName) throws NameNotFoundException { throws NameNotFoundException { return getApplicationIcon(getApplicationInfo(packageName, 0)); return getApplicationIcon(getApplicationInfo(packageName, sDefaultFlags)); } } @Override @Override public Drawable getActivityBanner(ComponentName activityName) public Drawable getActivityBanner(ComponentName activityName) throws NameNotFoundException { throws NameNotFoundException { return getActivityInfo(activityName, 0).loadBanner(this); return getActivityInfo(activityName, sDefaultFlags).loadBanner(this); } } @Override @Override Loading @@ -832,13 +835,13 @@ final class ApplicationPackageManager extends PackageManager { @Override @Override public Drawable getApplicationBanner(String packageName) public Drawable getApplicationBanner(String packageName) throws NameNotFoundException { throws NameNotFoundException { return getApplicationBanner(getApplicationInfo(packageName, 0)); return getApplicationBanner(getApplicationInfo(packageName, sDefaultFlags)); } } @Override @Override public Drawable getActivityLogo(ComponentName activityName) public Drawable getActivityLogo(ComponentName activityName) throws NameNotFoundException { throws NameNotFoundException { return getActivityInfo(activityName, 0).loadLogo(this); return getActivityInfo(activityName, sDefaultFlags).loadLogo(this); } } @Override @Override Loading @@ -865,7 +868,7 @@ final class ApplicationPackageManager extends PackageManager { @Override @Override public Drawable getApplicationLogo(String packageName) public Drawable getApplicationLogo(String packageName) throws NameNotFoundException { throws NameNotFoundException { return getApplicationLogo(getApplicationInfo(packageName, 0)); return getApplicationLogo(getApplicationInfo(packageName, sDefaultFlags)); } } @Override @Override Loading Loading @@ -914,7 +917,7 @@ final class ApplicationPackageManager extends PackageManager { @Override public Resources getResourcesForActivity( @Override public Resources getResourcesForActivity( ComponentName activityName) throws NameNotFoundException { ComponentName activityName) throws NameNotFoundException { return getResourcesForApplication( return getResourcesForApplication( getActivityInfo(activityName, 0).applicationInfo); getActivityInfo(activityName, sDefaultFlags).applicationInfo); } } @Override public Resources getResourcesForApplication( @Override public Resources getResourcesForApplication( Loading @@ -926,7 +929,8 @@ final class ApplicationPackageManager extends PackageManager { Resources r = mContext.mMainThread.getTopLevelResources( Resources r = mContext.mMainThread.getTopLevelResources( sameUid ? app.sourceDir : app.publicSourceDir, sameUid ? app.sourceDir : app.publicSourceDir, sameUid ? app.splitSourceDirs : app.splitPublicSourceDirs, sameUid ? app.splitSourceDirs : app.splitPublicSourceDirs, app.resourceDirs, null, Display.DEFAULT_DISPLAY, null, mContext.mPackageInfo); app.resourceDirs, app.sharedLibraryFiles, Display.DEFAULT_DISPLAY, null, mContext.mPackageInfo); if (r != null) { if (r != null) { return r; return r; } } Loading @@ -936,7 +940,7 @@ final class ApplicationPackageManager extends PackageManager { @Override public Resources getResourcesForApplication( @Override public Resources getResourcesForApplication( String appPackageName) throws NameNotFoundException { String appPackageName) throws NameNotFoundException { return getResourcesForApplication( return getResourcesForApplication( getApplicationInfo(appPackageName, 0)); getApplicationInfo(appPackageName, sDefaultFlags)); } } /** @hide */ /** @hide */ Loading @@ -951,7 +955,7 @@ final class ApplicationPackageManager extends PackageManager { return mContext.mMainThread.getSystemContext().getResources(); return mContext.mMainThread.getSystemContext().getResources(); } } try { try { ApplicationInfo ai = mPM.getApplicationInfo(appPackageName, 0, userId); ApplicationInfo ai = mPM.getApplicationInfo(appPackageName, sDefaultFlags, userId); if (ai != null) { if (ai != null) { return getResourcesForApplication(ai); return getResourcesForApplication(ai); } } Loading Loading @@ -1136,7 +1140,7 @@ final class ApplicationPackageManager extends PackageManager { } } if (appInfo == null) { if (appInfo == null) { try { try { appInfo = getApplicationInfo(packageName, 0); appInfo = getApplicationInfo(packageName, sDefaultFlags); } catch (NameNotFoundException e) { } catch (NameNotFoundException e) { return null; return null; } } Loading Loading @@ -1164,7 +1168,7 @@ final class ApplicationPackageManager extends PackageManager { ApplicationInfo appInfo) { ApplicationInfo appInfo) { if (appInfo == null) { if (appInfo == null) { try { try { appInfo = getApplicationInfo(packageName, 0); appInfo = getApplicationInfo(packageName, sDefaultFlags); } catch (NameNotFoundException e) { } catch (NameNotFoundException e) { return null; return null; } } Loading services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java +7 −1 Original line number Original line Diff line number Diff line Loading @@ -2207,9 +2207,15 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku private List<ResolveInfo> queryIntentReceivers(Intent intent, int userId) { private List<ResolveInfo> queryIntentReceivers(Intent intent, int userId) { final long identity = Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity(); try { try { int flags = PackageManager.GET_META_DATA; // Widgets referencing shared libraries need to have their // dependencies loaded. flags |= PackageManager.GET_SHARED_LIBRARY_FILES; return mPackageManager.queryIntentReceivers(intent, return mPackageManager.queryIntentReceivers(intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), intent.resolveTypeIfNeeded(mContext.getContentResolver()), PackageManager.GET_META_DATA, userId); flags, userId); } catch (RemoteException re) { } catch (RemoteException re) { return Collections.emptyList(); return Collections.emptyList(); } finally { } finally { Loading tests/SharedLibrary/client/AndroidManifest.xml +8 −0 Original line number Original line Diff line number Diff line Loading @@ -25,5 +25,13 @@ <category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </intent-filter> </activity> </activity> <receiver android:name="DependentAppwidgetProvider"> <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> </intent-filter> <meta-data android:name="android.appwidget.provider" android:resource="@xml/dependent_appwidget_info" /> </receiver> </application> </application> </manifest> </manifest> tests/SharedLibrary/client/res/layout/dependent_appwidget.xml 0 → 100644 +18 −0 Original line number Original line Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/label" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@com.google.android.test.shared_library:string/shared_string" style="@com.google.android.test.shared_library:style/CodeFont"/> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@com.google.android.test.shared_library:drawable/size_48x48"/> </LinearLayout> tests/SharedLibrary/client/res/xml/dependent_appwidget_info.xml 0 → 100644 +22 −0 Original line number Original line Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2013 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" android:minWidth="40dp" android:minHeight="40dp" android:updatePeriodMillis="0" android:initialLayout="@layout/dependent_appwidget" android:resizeMode="horizontal|vertical" /> Loading
core/java/android/app/ApplicationPackageManager.java +17 −13 Original line number Original line Diff line number Diff line Loading @@ -80,6 +80,9 @@ final class ApplicationPackageManager extends PackageManager { private final static boolean DEBUG = false; private final static boolean DEBUG = false; private final static boolean DEBUG_ICONS = false; private final static boolean DEBUG_ICONS = false; // Default flags to use with PackageManager when no flags are given. private final static int sDefaultFlags = PackageManager.GET_SHARED_LIBRARY_FILES; private final Object mLock = new Object(); private final Object mLock = new Object(); @GuardedBy("mLock") @GuardedBy("mLock") Loading Loading @@ -730,7 +733,7 @@ final class ApplicationPackageManager extends PackageManager { } } if (appInfo == null) { if (appInfo == null) { try { try { appInfo = getApplicationInfo(packageName, 0); appInfo = getApplicationInfo(packageName, sDefaultFlags); } catch (NameNotFoundException e) { } catch (NameNotFoundException e) { return null; return null; } } Loading Loading @@ -770,7 +773,7 @@ final class ApplicationPackageManager extends PackageManager { @Override public Drawable getActivityIcon(ComponentName activityName) @Override public Drawable getActivityIcon(ComponentName activityName) throws NameNotFoundException { throws NameNotFoundException { return getActivityInfo(activityName, 0).loadIcon(this); return getActivityInfo(activityName, sDefaultFlags).loadIcon(this); } } @Override public Drawable getActivityIcon(Intent intent) @Override public Drawable getActivityIcon(Intent intent) Loading Loading @@ -799,13 +802,13 @@ final class ApplicationPackageManager extends PackageManager { @Override public Drawable getApplicationIcon(String packageName) @Override public Drawable getApplicationIcon(String packageName) throws NameNotFoundException { throws NameNotFoundException { return getApplicationIcon(getApplicationInfo(packageName, 0)); return getApplicationIcon(getApplicationInfo(packageName, sDefaultFlags)); } } @Override @Override public Drawable getActivityBanner(ComponentName activityName) public Drawable getActivityBanner(ComponentName activityName) throws NameNotFoundException { throws NameNotFoundException { return getActivityInfo(activityName, 0).loadBanner(this); return getActivityInfo(activityName, sDefaultFlags).loadBanner(this); } } @Override @Override Loading @@ -832,13 +835,13 @@ final class ApplicationPackageManager extends PackageManager { @Override @Override public Drawable getApplicationBanner(String packageName) public Drawable getApplicationBanner(String packageName) throws NameNotFoundException { throws NameNotFoundException { return getApplicationBanner(getApplicationInfo(packageName, 0)); return getApplicationBanner(getApplicationInfo(packageName, sDefaultFlags)); } } @Override @Override public Drawable getActivityLogo(ComponentName activityName) public Drawable getActivityLogo(ComponentName activityName) throws NameNotFoundException { throws NameNotFoundException { return getActivityInfo(activityName, 0).loadLogo(this); return getActivityInfo(activityName, sDefaultFlags).loadLogo(this); } } @Override @Override Loading @@ -865,7 +868,7 @@ final class ApplicationPackageManager extends PackageManager { @Override @Override public Drawable getApplicationLogo(String packageName) public Drawable getApplicationLogo(String packageName) throws NameNotFoundException { throws NameNotFoundException { return getApplicationLogo(getApplicationInfo(packageName, 0)); return getApplicationLogo(getApplicationInfo(packageName, sDefaultFlags)); } } @Override @Override Loading Loading @@ -914,7 +917,7 @@ final class ApplicationPackageManager extends PackageManager { @Override public Resources getResourcesForActivity( @Override public Resources getResourcesForActivity( ComponentName activityName) throws NameNotFoundException { ComponentName activityName) throws NameNotFoundException { return getResourcesForApplication( return getResourcesForApplication( getActivityInfo(activityName, 0).applicationInfo); getActivityInfo(activityName, sDefaultFlags).applicationInfo); } } @Override public Resources getResourcesForApplication( @Override public Resources getResourcesForApplication( Loading @@ -926,7 +929,8 @@ final class ApplicationPackageManager extends PackageManager { Resources r = mContext.mMainThread.getTopLevelResources( Resources r = mContext.mMainThread.getTopLevelResources( sameUid ? app.sourceDir : app.publicSourceDir, sameUid ? app.sourceDir : app.publicSourceDir, sameUid ? app.splitSourceDirs : app.splitPublicSourceDirs, sameUid ? app.splitSourceDirs : app.splitPublicSourceDirs, app.resourceDirs, null, Display.DEFAULT_DISPLAY, null, mContext.mPackageInfo); app.resourceDirs, app.sharedLibraryFiles, Display.DEFAULT_DISPLAY, null, mContext.mPackageInfo); if (r != null) { if (r != null) { return r; return r; } } Loading @@ -936,7 +940,7 @@ final class ApplicationPackageManager extends PackageManager { @Override public Resources getResourcesForApplication( @Override public Resources getResourcesForApplication( String appPackageName) throws NameNotFoundException { String appPackageName) throws NameNotFoundException { return getResourcesForApplication( return getResourcesForApplication( getApplicationInfo(appPackageName, 0)); getApplicationInfo(appPackageName, sDefaultFlags)); } } /** @hide */ /** @hide */ Loading @@ -951,7 +955,7 @@ final class ApplicationPackageManager extends PackageManager { return mContext.mMainThread.getSystemContext().getResources(); return mContext.mMainThread.getSystemContext().getResources(); } } try { try { ApplicationInfo ai = mPM.getApplicationInfo(appPackageName, 0, userId); ApplicationInfo ai = mPM.getApplicationInfo(appPackageName, sDefaultFlags, userId); if (ai != null) { if (ai != null) { return getResourcesForApplication(ai); return getResourcesForApplication(ai); } } Loading Loading @@ -1136,7 +1140,7 @@ final class ApplicationPackageManager extends PackageManager { } } if (appInfo == null) { if (appInfo == null) { try { try { appInfo = getApplicationInfo(packageName, 0); appInfo = getApplicationInfo(packageName, sDefaultFlags); } catch (NameNotFoundException e) { } catch (NameNotFoundException e) { return null; return null; } } Loading Loading @@ -1164,7 +1168,7 @@ final class ApplicationPackageManager extends PackageManager { ApplicationInfo appInfo) { ApplicationInfo appInfo) { if (appInfo == null) { if (appInfo == null) { try { try { appInfo = getApplicationInfo(packageName, 0); appInfo = getApplicationInfo(packageName, sDefaultFlags); } catch (NameNotFoundException e) { } catch (NameNotFoundException e) { return null; return null; } } Loading
services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java +7 −1 Original line number Original line Diff line number Diff line Loading @@ -2207,9 +2207,15 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku private List<ResolveInfo> queryIntentReceivers(Intent intent, int userId) { private List<ResolveInfo> queryIntentReceivers(Intent intent, int userId) { final long identity = Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity(); try { try { int flags = PackageManager.GET_META_DATA; // Widgets referencing shared libraries need to have their // dependencies loaded. flags |= PackageManager.GET_SHARED_LIBRARY_FILES; return mPackageManager.queryIntentReceivers(intent, return mPackageManager.queryIntentReceivers(intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), intent.resolveTypeIfNeeded(mContext.getContentResolver()), PackageManager.GET_META_DATA, userId); flags, userId); } catch (RemoteException re) { } catch (RemoteException re) { return Collections.emptyList(); return Collections.emptyList(); } finally { } finally { Loading
tests/SharedLibrary/client/AndroidManifest.xml +8 −0 Original line number Original line Diff line number Diff line Loading @@ -25,5 +25,13 @@ <category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </intent-filter> </activity> </activity> <receiver android:name="DependentAppwidgetProvider"> <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> </intent-filter> <meta-data android:name="android.appwidget.provider" android:resource="@xml/dependent_appwidget_info" /> </receiver> </application> </application> </manifest> </manifest>
tests/SharedLibrary/client/res/layout/dependent_appwidget.xml 0 → 100644 +18 −0 Original line number Original line Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/label" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@com.google.android.test.shared_library:string/shared_string" style="@com.google.android.test.shared_library:style/CodeFont"/> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@com.google.android.test.shared_library:drawable/size_48x48"/> </LinearLayout>
tests/SharedLibrary/client/res/xml/dependent_appwidget_info.xml 0 → 100644 +22 −0 Original line number Original line Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2013 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" android:minWidth="40dp" android:minHeight="40dp" android:updatePeriodMillis="0" android:initialLayout="@layout/dependent_appwidget" android:resizeMode="horizontal|vertical" />