歌尔基办 v2.7.0版本的 MD5 值为:921fd7c85ec097e8cab7f049269b36e4
以下内容为反编译后的 CustomTabsHelper.java 源代码,内容仅作参考
package im.ovithmjoec.messenger.support.customtabsclient.shared;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import im.ovithmjoec.messenger.ApplicationLoader;
import java.util.ArrayList;
import java.util.List;
public class CustomTabsHelper {
private static final String ACTION_CUSTOM_TABS_CONNECTION = "android.support.customtabs.action.CustomTabsService";
static final String BETA_PACKAGE = "com.chrome.beta";
static final String DEV_PACKAGE = "com.chrome.dev";
private static final String EXTRA_CUSTOM_TABS_KEEP_ALIVE = "android.support.customtabs.extra.KEEP_ALIVE";
static final String LOCAL_PACKAGE = "com.google.android.apps.chrome";
static final String STABLE_PACKAGE = "com.android.chrome";
private static final String TAG = "CustomTabsHelper";
private static String sPackageNameToUse;
private CustomTabsHelper() {
}
public static void addKeepAliveExtra(Context context, Intent intent) {
intent.putExtra(EXTRA_CUSTOM_TABS_KEEP_ALIVE, new Intent().setClassName(context.getPackageName(), KeepAliveService.class.getCanonicalName()));
}
public static String getPackageNameToUse(Context context) {
PackageManager packageManager;
ApplicationInfo applicationInfo;
String str = sPackageNameToUse;
if (str != null) {
return str;
}
PackageManager packageManager2 = context.getPackageManager();
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("http://www.example.com"));
ResolveInfo resolveActivity = packageManager2.resolveActivity(intent, 0);
String str2 = resolveActivity != null ? resolveActivity.activityInfo.packageName : null;
List<ResolveInfo> queryIntentActivities = packageManager2.queryIntentActivities(intent, 0);
ArrayList arrayList = new ArrayList();
for (ResolveInfo resolveInfo : queryIntentActivities) {
Intent intent2 = new Intent();
intent2.setAction("android.support.customtabs.action.CustomTabsService");
intent2.setPackage(resolveInfo.activityInfo.packageName);
if (packageManager2.resolveService(intent2, 0) != null) {
arrayList.add(resolveInfo.activityInfo.packageName);
}
}
if (arrayList.isEmpty()) {
sPackageNameToUse = null;
} else if (arrayList.size() == 1) {
sPackageNameToUse = (String) arrayList.get(0);
} else if (!TextUtils.isEmpty(str2) && !hasSpecializedHandlerIntents(context, intent) && arrayList.contains(str2)) {
sPackageNameToUse = str2;
} else if (arrayList.contains(STABLE_PACKAGE)) {
sPackageNameToUse = STABLE_PACKAGE;
} else if (arrayList.contains(BETA_PACKAGE)) {
sPackageNameToUse = BETA_PACKAGE;
} else if (arrayList.contains(DEV_PACKAGE)) {
sPackageNameToUse = DEV_PACKAGE;
} else if (arrayList.contains(LOCAL_PACKAGE)) {
sPackageNameToUse = LOCAL_PACKAGE;
}
try {
if ("com.sec.android.app.sbrowser".equalsIgnoreCase(sPackageNameToUse) && (applicationInfo = (packageManager = ApplicationLoader.applicationContext.getPackageManager()).getApplicationInfo(STABLE_PACKAGE, 0)) != null && applicationInfo.enabled) {
packageManager.getPackageInfo(STABLE_PACKAGE, 1);
sPackageNameToUse = STABLE_PACKAGE;
}
} catch (Throwable unused) {
}
return sPackageNameToUse;
}
private static boolean hasSpecializedHandlerIntents(Context context, Intent intent) {
List<ResolveInfo> queryIntentActivities;
try {
queryIntentActivities = context.getPackageManager().queryIntentActivities(intent, 64);
} catch (RuntimeException unused) {
Log.e(TAG, "Runtime exception while getting specialized handlers");
}
if (queryIntentActivities != null && queryIntentActivities.size() != 0) {
for (ResolveInfo resolveInfo : queryIntentActivities) {
IntentFilter intentFilter = resolveInfo.filter;
if (intentFilter != null && intentFilter.countDataAuthorities() != 0 && intentFilter.countDataPaths() != 0 && resolveInfo.activityInfo != null) {
return true;
}
}
return false;
}
return false;
}
public static String[] getPackages() {
return new String[]{"", STABLE_PACKAGE, BETA_PACKAGE, DEV_PACKAGE, LOCAL_PACKAGE};
}
}