92 lines
3.4 KiB
Java
92 lines
3.4 KiB
Java
package c.a.h;
|
|
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.pm.PackageManager;
|
|
import android.content.pm.ResolveInfo;
|
|
import android.net.Uri;
|
|
import d0.t.u;
|
|
import d0.z.d.m;
|
|
import java.util.ArrayList;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
/* compiled from: CustomTabsPackages.kt */
|
|
public final class a {
|
|
public static final String a(Context context) {
|
|
Object obj;
|
|
Object obj2;
|
|
Object obj3;
|
|
m.checkNotNullParameter(context, "$this$getCustomTabsDefaultPackage");
|
|
PackageManager packageManager = context.getPackageManager();
|
|
Object obj4 = null;
|
|
Intent data = new Intent().setAction("android.intent.action.VIEW").addCategory("android.intent.category.BROWSABLE").setData(Uri.fromParts("http", "", null));
|
|
m.checkNotNullExpressionValue(data, "Intent()\n .setA…mParts(\"http\", \"\", null))");
|
|
List<ResolveInfo> queryIntentActivities = packageManager.queryIntentActivities(data, 0);
|
|
m.checkNotNullExpressionValue(queryIntentActivities, "packageManager.queryInte…ltViewIntentHandler(), 0)");
|
|
ArrayList arrayList = new ArrayList();
|
|
for (ResolveInfo resolveInfo : queryIntentActivities) {
|
|
Intent intent = new Intent().setAction("android.support.customtabs.action.CustomTabsService").setPackage(resolveInfo.activityInfo.packageName);
|
|
m.checkNotNullExpressionValue(intent, "Intent()\n .se…activityInfo.packageName)");
|
|
String str = context.getPackageManager().resolveService(intent, 0) != null ? resolveInfo.activityInfo.packageName : null;
|
|
if (str != null) {
|
|
arrayList.add(str);
|
|
}
|
|
}
|
|
Iterator it = arrayList.iterator();
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
obj = null;
|
|
break;
|
|
}
|
|
obj = it.next();
|
|
if (m.areEqual((String) obj, "com.android.chrome")) {
|
|
break;
|
|
}
|
|
}
|
|
String str2 = (String) obj;
|
|
if (str2 == null) {
|
|
Iterator it2 = arrayList.iterator();
|
|
while (true) {
|
|
if (!it2.hasNext()) {
|
|
obj3 = null;
|
|
break;
|
|
}
|
|
obj3 = it2.next();
|
|
if (m.areEqual((String) obj3, "com.chrome.beta")) {
|
|
break;
|
|
}
|
|
}
|
|
str2 = (String) obj3;
|
|
}
|
|
if (str2 == null) {
|
|
Iterator it3 = arrayList.iterator();
|
|
while (true) {
|
|
if (!it3.hasNext()) {
|
|
obj2 = null;
|
|
break;
|
|
}
|
|
obj2 = it3.next();
|
|
if (m.areEqual((String) obj2, "com.chrome.dev")) {
|
|
break;
|
|
}
|
|
}
|
|
str2 = (String) obj2;
|
|
}
|
|
if (str2 == null) {
|
|
Iterator it4 = arrayList.iterator();
|
|
while (true) {
|
|
if (!it4.hasNext()) {
|
|
break;
|
|
}
|
|
Object next = it4.next();
|
|
if (m.areEqual((String) next, "com.google.android.apps.chrome")) {
|
|
obj4 = next;
|
|
break;
|
|
}
|
|
}
|
|
str2 = (String) obj4;
|
|
}
|
|
return str2 != null ? str2 : (String) u.firstOrNull((List<? extends Object>) arrayList);
|
|
}
|
|
}
|