summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJose Lima <joselima@google.com>2014-04-11 19:01:21 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-04-11 19:01:21 +0000
commit68b9d97593d2ec79892813ab06f1b89c41de64b0 (patch)
tree90d86ee22188e6d44850508eecd1f6fdd940f9ba
parentae3f7cca5235b9c3da080e7f8210a21ecf48285b (diff)
parent9e99cab7d9a0ec2315140c21bb1958eb7ff76a09 (diff)
downloadframeworks_base-68b9d97593d2ec79892813ab06f1b89c41de64b0.zip
frameworks_base-68b9d97593d2ec79892813ab06f1b89c41de64b0.tar.gz
frameworks_base-68b9d97593d2ec79892813ab06f1b89c41de64b0.tar.bz2
am 9e99cab7: am 970417c7: Added getLeanbackLaunchIntentForPackage()
* commit '9e99cab7d9a0ec2315140c21bb1958eb7ff76a09': Added getLeanbackLaunchIntentForPackage()
-rw-r--r--api/current.txt2
-rw-r--r--core/java/android/app/ApplicationPackageManager.java18
-rw-r--r--core/java/android/content/pm/PackageManager.java38
-rw-r--r--test-runner/src/android/test/mock/MockPackageManager.java6
4 files changed, 54 insertions, 10 deletions
diff --git a/api/current.txt b/api/current.txt
index 9f078d0..005d095 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -7784,6 +7784,7 @@ package android.content.pm {
method public abstract java.lang.String getInstallerPackageName(java.lang.String);
method public abstract android.content.pm.InstrumentationInfo getInstrumentationInfo(android.content.ComponentName, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public abstract android.content.Intent getLaunchIntentForPackage(java.lang.String);
+ method public abstract android.content.Intent getLeanbackLaunchIntentForPackage(java.lang.String);
method public abstract java.lang.String getNameForUid(int);
method public android.content.pm.PackageInfo getPackageArchiveInfo(java.lang.String, int);
method public abstract int[] getPackageGids(java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
@@ -26005,6 +26006,7 @@ package android.test.mock {
method public java.lang.String getInstallerPackageName(java.lang.String);
method public android.content.pm.InstrumentationInfo getInstrumentationInfo(android.content.ComponentName, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public android.content.Intent getLaunchIntentForPackage(java.lang.String);
+ method public android.content.Intent getLeanbackLaunchIntentForPackage(java.lang.String);
method public java.lang.String getNameForUid(int);
method public int[] getPackageGids(java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
method public android.content.pm.PackageInfo getPackageInfo(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java
index 6ca5244..ab62427 100644
--- a/core/java/android/app/ApplicationPackageManager.java
+++ b/core/java/android/app/ApplicationPackageManager.java
@@ -128,6 +128,24 @@ final class ApplicationPackageManager extends PackageManager {
}
@Override
+ public Intent getLeanbackLaunchIntentForPackage(String packageName) {
+ // Try to find a main leanback_launcher activity.
+ Intent intentToResolve = new Intent(Intent.ACTION_MAIN);
+ intentToResolve.addCategory(Intent.CATEGORY_LEANBACK_LAUNCHER);
+ intentToResolve.setPackage(packageName);
+ List<ResolveInfo> ris = queryIntentActivities(intentToResolve, 0);
+
+ if (ris == null || ris.size() <= 0) {
+ return null;
+ }
+ Intent intent = new Intent(intentToResolve);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.setClassName(ris.get(0).activityInfo.packageName,
+ ris.get(0).activityInfo.name);
+ return intent;
+ }
+
+ @Override
public int[] getPackageGids(String packageName)
throws NameNotFoundException {
try {
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index d24a472..d981cc1 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -1012,6 +1012,7 @@ public abstract class PackageManager {
* @hide
* @deprecated
*/
+ @Deprecated
@SdkConstant(SdkConstantType.FEATURE)
public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce";
@@ -1308,6 +1309,7 @@ public abstract class PackageManager {
* something like a DPAD, not through touch or mouse.
* @deprecated use {@link #FEATURE_LEANBACK} instead.
*/
+ @Deprecated
@SdkConstant(SdkConstantType.FEATURE)
public static final String FEATURE_TELEVISION = "android.hardware.type.television";
@@ -1522,17 +1524,33 @@ public abstract class PackageManager {
public abstract Intent getLaunchIntentForPackage(String packageName);
/**
- * Return an array of all of the secondary group-ids that have been
- * assigned to a package.
- *
- * <p>Throws {@link NameNotFoundException} if a package with the given
- * name cannot be found on the system.
- *
+ * Return a "good" intent to launch a front-door Leanback activity in a
+ * package, for use for example to implement an "open" button when browsing
+ * through packages. The current implementation will look for a main
+ * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or
+ * return null if no main leanback activities are found.
+ * <p>
+ * Throws {@link NameNotFoundException} if a package with the given name
+ * cannot be found on the system.
+ *
+ * @param packageName The name of the package to inspect.
+ * @return Returns either a fully-qualified Intent that can be used to launch
+ * the main Leanback activity in the package, or null if the package
+ * does not contain such an activity.
+ */
+ public abstract Intent getLeanbackLaunchIntentForPackage(String packageName);
+
+ /**
+ * Return an array of all of the secondary group-ids that have been assigned
+ * to a package.
+ * <p>
+ * Throws {@link NameNotFoundException} if a package with the given name
+ * cannot be found on the system.
+ *
* @param packageName The full name (i.e. com.google.apps.contacts) of the
- * desired package.
- *
- * @return Returns an int array of the assigned gids, or null if there
- * are none.
+ * desired package.
+ * @return Returns an int array of the assigned gids, or null if there are
+ * none.
*/
public abstract int[] getPackageGids(String packageName)
throws NameNotFoundException;
diff --git a/test-runner/src/android/test/mock/MockPackageManager.java b/test-runner/src/android/test/mock/MockPackageManager.java
index daef37a..992ef4b 100644
--- a/test-runner/src/android/test/mock/MockPackageManager.java
+++ b/test-runner/src/android/test/mock/MockPackageManager.java
@@ -78,6 +78,12 @@ public class MockPackageManager extends PackageManager {
}
@Override
+ public Intent getLeanbackLaunchIntentForPackage(String packageName) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+
public int[] getPackageGids(String packageName) throws NameNotFoundException {
throw new UnsupportedOperationException();
}