summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2014-10-07 19:51:16 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-10-07 19:51:17 +0000
commit1a98dd5cc7ea89793208b51983198bfbeade5ccc (patch)
tree03546d9a5684721b0442cf94582518de90fd4427
parent733bcc7fbe8f03c92f20c57dd25cbc3b011cef9e (diff)
parentd00bb5edcfc8ee5c2026f66785b703b388314b22 (diff)
downloadframeworks_base-1a98dd5cc7ea89793208b51983198bfbeade5ccc.zip
frameworks_base-1a98dd5cc7ea89793208b51983198bfbeade5ccc.tar.gz
frameworks_base-1a98dd5cc7ea89793208b51983198bfbeade5ccc.tar.bz2
Merge "Load shared library dependencies for AppWidgets" into lmp-dev
-rw-r--r--core/java/android/app/ApplicationPackageManager.java30
-rw-r--r--services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java8
-rw-r--r--tests/SharedLibrary/client/AndroidManifest.xml8
-rw-r--r--tests/SharedLibrary/client/res/layout/dependent_appwidget.xml18
-rw-r--r--tests/SharedLibrary/client/res/xml/dependent_appwidget_info.xml22
-rw-r--r--tests/SharedLibrary/client/src/com/google/android/test/lib_client/DependentAppwidgetProvider.java29
-rw-r--r--tests/SharedLibrary/lib/res/values/public.xml2
7 files changed, 103 insertions, 14 deletions
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java
index 6860683..1e1a613 100644
--- a/core/java/android/app/ApplicationPackageManager.java
+++ b/core/java/android/app/ApplicationPackageManager.java
@@ -80,6 +80,9 @@ final class ApplicationPackageManager extends PackageManager {
private final static boolean DEBUG = 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();
@GuardedBy("mLock")
@@ -730,7 +733,7 @@ final class ApplicationPackageManager extends PackageManager {
}
if (appInfo == null) {
try {
- appInfo = getApplicationInfo(packageName, 0);
+ appInfo = getApplicationInfo(packageName, sDefaultFlags);
} catch (NameNotFoundException e) {
return null;
}
@@ -770,7 +773,7 @@ final class ApplicationPackageManager extends PackageManager {
@Override public Drawable getActivityIcon(ComponentName activityName)
throws NameNotFoundException {
- return getActivityInfo(activityName, 0).loadIcon(this);
+ return getActivityInfo(activityName, sDefaultFlags).loadIcon(this);
}
@Override public Drawable getActivityIcon(Intent intent)
@@ -799,13 +802,13 @@ final class ApplicationPackageManager extends PackageManager {
@Override public Drawable getApplicationIcon(String packageName)
throws NameNotFoundException {
- return getApplicationIcon(getApplicationInfo(packageName, 0));
+ return getApplicationIcon(getApplicationInfo(packageName, sDefaultFlags));
}
@Override
public Drawable getActivityBanner(ComponentName activityName)
throws NameNotFoundException {
- return getActivityInfo(activityName, 0).loadBanner(this);
+ return getActivityInfo(activityName, sDefaultFlags).loadBanner(this);
}
@Override
@@ -832,13 +835,13 @@ final class ApplicationPackageManager extends PackageManager {
@Override
public Drawable getApplicationBanner(String packageName)
throws NameNotFoundException {
- return getApplicationBanner(getApplicationInfo(packageName, 0));
+ return getApplicationBanner(getApplicationInfo(packageName, sDefaultFlags));
}
@Override
public Drawable getActivityLogo(ComponentName activityName)
throws NameNotFoundException {
- return getActivityInfo(activityName, 0).loadLogo(this);
+ return getActivityInfo(activityName, sDefaultFlags).loadLogo(this);
}
@Override
@@ -865,7 +868,7 @@ final class ApplicationPackageManager extends PackageManager {
@Override
public Drawable getApplicationLogo(String packageName)
throws NameNotFoundException {
- return getApplicationLogo(getApplicationInfo(packageName, 0));
+ return getApplicationLogo(getApplicationInfo(packageName, sDefaultFlags));
}
@Override
@@ -914,7 +917,7 @@ final class ApplicationPackageManager extends PackageManager {
@Override public Resources getResourcesForActivity(
ComponentName activityName) throws NameNotFoundException {
return getResourcesForApplication(
- getActivityInfo(activityName, 0).applicationInfo);
+ getActivityInfo(activityName, sDefaultFlags).applicationInfo);
}
@Override public Resources getResourcesForApplication(
@@ -926,7 +929,8 @@ final class ApplicationPackageManager extends PackageManager {
Resources r = mContext.mMainThread.getTopLevelResources(
sameUid ? app.sourceDir : app.publicSourceDir,
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) {
return r;
}
@@ -936,7 +940,7 @@ final class ApplicationPackageManager extends PackageManager {
@Override public Resources getResourcesForApplication(
String appPackageName) throws NameNotFoundException {
return getResourcesForApplication(
- getApplicationInfo(appPackageName, 0));
+ getApplicationInfo(appPackageName, sDefaultFlags));
}
/** @hide */
@@ -951,7 +955,7 @@ final class ApplicationPackageManager extends PackageManager {
return mContext.mMainThread.getSystemContext().getResources();
}
try {
- ApplicationInfo ai = mPM.getApplicationInfo(appPackageName, 0, userId);
+ ApplicationInfo ai = mPM.getApplicationInfo(appPackageName, sDefaultFlags, userId);
if (ai != null) {
return getResourcesForApplication(ai);
}
@@ -1136,7 +1140,7 @@ final class ApplicationPackageManager extends PackageManager {
}
if (appInfo == null) {
try {
- appInfo = getApplicationInfo(packageName, 0);
+ appInfo = getApplicationInfo(packageName, sDefaultFlags);
} catch (NameNotFoundException e) {
return null;
}
@@ -1164,7 +1168,7 @@ final class ApplicationPackageManager extends PackageManager {
ApplicationInfo appInfo) {
if (appInfo == null) {
try {
- appInfo = getApplicationInfo(packageName, 0);
+ appInfo = getApplicationInfo(packageName, sDefaultFlags);
} catch (NameNotFoundException e) {
return null;
}
diff --git a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java
index 86cfdb9..fca13f8 100644
--- a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java
+++ b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java
@@ -2207,9 +2207,15 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
private List<ResolveInfo> queryIntentReceivers(Intent intent, int userId) {
final long identity = Binder.clearCallingIdentity();
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,
intent.resolveTypeIfNeeded(mContext.getContentResolver()),
- PackageManager.GET_META_DATA, userId);
+ flags, userId);
} catch (RemoteException re) {
return Collections.emptyList();
} finally {
diff --git a/tests/SharedLibrary/client/AndroidManifest.xml b/tests/SharedLibrary/client/AndroidManifest.xml
index a39c754..d1167fa 100644
--- a/tests/SharedLibrary/client/AndroidManifest.xml
+++ b/tests/SharedLibrary/client/AndroidManifest.xml
@@ -25,5 +25,13 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</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>
</manifest>
diff --git a/tests/SharedLibrary/client/res/layout/dependent_appwidget.xml b/tests/SharedLibrary/client/res/layout/dependent_appwidget.xml
new file mode 100644
index 0000000..13beafa
--- /dev/null
+++ b/tests/SharedLibrary/client/res/layout/dependent_appwidget.xml
@@ -0,0 +1,18 @@
+<?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>
diff --git a/tests/SharedLibrary/client/res/xml/dependent_appwidget_info.xml b/tests/SharedLibrary/client/res/xml/dependent_appwidget_info.xml
new file mode 100644
index 0000000..452e010
--- /dev/null
+++ b/tests/SharedLibrary/client/res/xml/dependent_appwidget_info.xml
@@ -0,0 +1,22 @@
+<?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" />
diff --git a/tests/SharedLibrary/client/src/com/google/android/test/lib_client/DependentAppwidgetProvider.java b/tests/SharedLibrary/client/src/com/google/android/test/lib_client/DependentAppwidgetProvider.java
new file mode 100644
index 0000000..4e9b26b
--- /dev/null
+++ b/tests/SharedLibrary/client/src/com/google/android/test/lib_client/DependentAppwidgetProvider.java
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+package com.google.android.test.lib_client;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+public class DependentAppwidgetProvider extends BroadcastReceiver {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+
+ }
+}
diff --git a/tests/SharedLibrary/lib/res/values/public.xml b/tests/SharedLibrary/lib/res/values/public.xml
index 37b1ec9..23d307e 100644
--- a/tests/SharedLibrary/lib/res/values/public.xml
+++ b/tests/SharedLibrary/lib/res/values/public.xml
@@ -13,5 +13,7 @@
<public type="attr" name="zip" id="0x00010005" />
<public type="attr" name="country" id="0x00010006" />
+ <public type="drawable" name="size_48x48" id="0x00030000" />
+
<public type="array" name="animals" id="0x02050000" />
</resources>