summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorJose Lima <joselima@google.com>2014-04-10 10:42:19 -0700
committerJose Lima <joselima@google.com>2014-04-11 10:54:39 -0700
commit970417c7d3e33ccbd6918e28d9bc5da24651f5b3 (patch)
tree749f3b107192ceec97ac39d534138f4298303928 /core/java
parent3d9a3b589af661f980a7c03f208915b54521639f (diff)
downloadframeworks_base-970417c7d3e33ccbd6918e28d9bc5da24651f5b3.zip
frameworks_base-970417c7d3e33ccbd6918e28d9bc5da24651f5b3.tar.gz
frameworks_base-970417c7d3e33ccbd6918e28d9bc5da24651f5b3.tar.bz2
Added getLeanbackLaunchIntentForPackage()
Change-Id: I23be3bfa59be812a915adc37e08fdf59be8ad90f
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/ApplicationPackageManager.java18
-rw-r--r--core/java/android/content/pm/PackageManager.java40
2 files changed, 47 insertions, 11 deletions
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java
index 6f53df4..010988e 100644
--- a/core/java/android/app/ApplicationPackageManager.java
+++ b/core/java/android/app/ApplicationPackageManager.java
@@ -129,6 +129,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 34a6f1d..e3a0362 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -970,6 +970,7 @@ public abstract class PackageManager {
* @hide
* @deprecated
*/
+ @Deprecated
@SdkConstant(SdkConstantType.FEATURE)
public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce";
@@ -1266,6 +1267,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";
@@ -1455,17 +1457,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;
@@ -2449,7 +2467,7 @@ public abstract class PackageManager {
/**
* Return the generic icon for an activity that is used when no specific
* icon is defined.
- *
+ *
* @return Drawable Image of the icon.
*/
public abstract Drawable getDefaultActivityIcon();