mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-28 15:56:49 +00:00
Try and resolve the package name from the intent directly falling back to the resolved component name if it fails. (Bug 6452306)
Change-Id: Ifb2187fb845f807f30df966bf298ffde1b779b46
This commit is contained in:
@@ -102,6 +102,12 @@ class ApplicationInfo extends ItemInfo {
|
||||
firstInstallTime = info.firstInstallTime;
|
||||
}
|
||||
|
||||
/** Returns the package name that the shortcut's intent will resolve to, or an empty string if
|
||||
* none exists. */
|
||||
String getPackageName() {
|
||||
return super.getPackageName(intent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the application intent based on a component name and various launch flags.
|
||||
* Sets {@link #itemType} to {@link LauncherSettings.BaseLauncherColumns#ITEM_TYPE_APPLICATION}.
|
||||
|
||||
@@ -381,8 +381,8 @@ public class DragController {
|
||||
if (dragInfo != null &&
|
||||
dragInfo.intent != null &&
|
||||
info.intent != null) {
|
||||
boolean isSamePackage = info.intent.getComponent().getPackageName().equals(
|
||||
dragInfo.intent.getComponent().getPackageName());
|
||||
boolean isSamePackage = dragInfo.getPackageName().equals(
|
||||
info.getPackageName());
|
||||
if (isSamePackage) {
|
||||
cancelDrag();
|
||||
return;
|
||||
|
||||
@@ -16,13 +16,14 @@
|
||||
|
||||
package com.android.launcher2;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Represents an item in the launcher.
|
||||
*/
|
||||
@@ -109,6 +110,21 @@ class ItemInfo {
|
||||
container = info.container;
|
||||
}
|
||||
|
||||
/** Returns the package name that the intent will resolve to, or an empty string if
|
||||
* none exists. */
|
||||
static String getPackageName(Intent intent) {
|
||||
if (intent != null) {
|
||||
String packageName = intent.getPackage();
|
||||
if (packageName == null) {
|
||||
packageName = intent.getComponent().getPackageName();
|
||||
}
|
||||
if (packageName != null) {
|
||||
return packageName;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the fields of this item to the DB
|
||||
*
|
||||
|
||||
@@ -1684,7 +1684,7 @@ public class LauncherModel extends BroadcastReceiver {
|
||||
for (ItemInfo i : sWorkspaceItems) {
|
||||
if (i instanceof ShortcutInfo) {
|
||||
ShortcutInfo info = (ShortcutInfo) i;
|
||||
if (info.intent.getComponent().getPackageName().equals(packageName)) {
|
||||
if (packageName.equals(info.getPackageName())) {
|
||||
infos.add(info);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,6 +98,12 @@ class ShortcutInfo extends ItemInfo {
|
||||
return mIcon;
|
||||
}
|
||||
|
||||
/** Returns the package name that the shortcut's intent will resolve to, or an empty string if
|
||||
* none exists. */
|
||||
String getPackageName() {
|
||||
return super.getPackageName(intent);
|
||||
}
|
||||
|
||||
public void updateIcon(IconCache iconCache) {
|
||||
mIcon = iconCache.getIcon(intent);
|
||||
usingFallbackIcon = iconCache.isDefaultIcon(mIcon);
|
||||
|
||||
@@ -3622,7 +3622,8 @@ public class Workspace extends SmoothPagedView
|
||||
for (String intentStr : newApps) {
|
||||
try {
|
||||
Intent intent = Intent.parseUri(intentStr, 0);
|
||||
if (packageNames.contains(intent.getComponent().getPackageName())) {
|
||||
String pn = ItemInfo.getPackageName(intent);
|
||||
if (packageNames.contains(pn)) {
|
||||
newApps.remove(intentStr);
|
||||
}
|
||||
} catch (URISyntaxException e) {}
|
||||
|
||||
Reference in New Issue
Block a user