зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1392224 - Make Fennec the default handler for Leanplum Push Notification. r=maliu
MozReview-Commit-ID: GiXHPvcPhgp --HG-- extra : rebase_source : f0ca0874c693bccd98b23f0dc83567309d9dfcc1
This commit is contained in:
Родитель
7210bd7226
Коммит
a873a62c28
|
@ -475,13 +475,21 @@ public class LeanplumPushService {
|
|||
* 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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче