正在查看: Aptoide v9.22.5.3 应用的 CustomTabNativeReceiver.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Aptoide v9.22.5.3 应用的 CustomTabNativeReceiver.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package cm.aptoide.pt.link;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Bundle;
import android.widget.Toast;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
public class CustomTabNativeReceiver extends BroadcastReceiver {
private static final String MOCKUP_URL = "http://www.example.com";
private static final String REFERER_ATTRIBUTE = "Referer";
private static final String REFERER_VALUE = "http://m.aptoide.com";
private Set<String> extractPackagenames(List<ResolveInfo> list) {
HashSet hashSet = new HashSet();
Iterator<ResolveInfo> it = list.iterator();
while (it.hasNext()) {
hashSet.add(it.next().activityInfo.packageName);
}
return hashSet;
}
private Set<String> getNativeAppPackage(Context context, Uri uri) {
PackageManager packageManager = context.getPackageManager();
Set<String> extractPackagenames = extractPackagenames(packageManager.queryIntentActivities(new Intent("android.intent.action.VIEW", Uri.parse(MOCKUP_URL)), 0));
Set<String> extractPackagenames2 = extractPackagenames(packageManager.queryIntentActivities(new Intent("android.intent.action.VIEW", uri), 0));
extractPackagenames2.removeAll(extractPackagenames);
return extractPackagenames2;
}
@Override
public void onReceive(Context context, Intent intent) {
String dataString = intent.getDataString();
if (dataString != null) {
Set<String> nativeAppPackage = getNativeAppPackage(context, Uri.parse(dataString));
if ((nativeAppPackage.iterator().hasNext() ? nativeAppPackage.iterator().next() : null) == null) {
Toast.makeText(context, "No application to open.", 0).show();
return;
}
Intent intent2 = new Intent("android.intent.action.VIEW", Uri.parse(dataString));
Bundle bundle = new Bundle();
bundle.putString(REFERER_ATTRIBUTE, REFERER_VALUE);
intent2.putExtra("com.android.browser.headers", bundle);
intent2.setFlags(268435456);
context.startActivity(intent2);
}
}
}