Bug 1392224 - Make Fennec the default handler for Leanplum Push Notification. r?maliu
MozReview-Commit-ID: GiXHPvcPhgp
--- a/mobile/android/thirdparty/com/leanplum/LeanplumPushService.java
+++ b/mobile/android/thirdparty/com/leanplum/LeanplumPushService.java
@@ -470,23 +470,31 @@ public class LeanplumPushService {
}
return null;
}
/**
* Checks if there is some activity that can handle intent.
*/
private static Boolean activityHasIntent(Context context, Intent deepLinkIntent) {
+ final int flag;
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
+ flag = PackageManager.MATCH_ALL;
+ } else {
+ flag = 0;
+ }
List<ResolveInfo> resolveInfoList =
- context.getPackageManager().queryIntentActivities(deepLinkIntent, 0);
+ context.getPackageManager().queryIntentActivities(deepLinkIntent, flag);
if (resolveInfoList != null && !resolveInfoList.isEmpty()) {
for (ResolveInfo resolveInfo : resolveInfoList) {
if (resolveInfo != null && resolveInfo.activityInfo != null &&
resolveInfo.activityInfo.name != null) {
- if (resolveInfo.activityInfo.name.contains(context.getPackageName())) {
+ // In local build, Fennec's activityInfo.packagename is org.mozilla.fennec_<device_name>
+ // But activityInfo.name is org.mozilla.Gecko.App. Thus we should use packagename here.
+ if (resolveInfo.activityInfo.packageName.equals(context.getPackageName())) {
// If url can be handled by current app - set package name to intent, so url will be
// open by current app. Skip chooser dialog.
deepLinkIntent.setPackage(resolveInfo.activityInfo.packageName);
return true;
}
}
}
}