Driving Zone: Germany v1.22.4版本的 MD5 值为:2b6e2d8e8733a3104dcc306c5770286c
以下内容为反编译后的 AdViewAbroad.java 源代码,内容仅作参考
package com.bz.simplesdk.adviewabroad;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import android.util.Base64;
import android.util.TypedValue;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Toast;
import androidx.browser.trusted.sharing.ShareTarget;
import com.appsflyer.AppsFlyerProperties;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import org.json.JSONObject;
public class AdViewAbroad extends RelativeLayout {
private String adv_type;
private String binding_url;
private Bitmap bitmap;
private String channel;
private int closeImageSize;
private Dialog dialog;
private Handler handler;
private String httpAddress;
private String ipAddress;
private String ll_toast;
private Activity mActivity;
private String openadvurl;
private WindowManager.LayoutParams params;
private WindowManager wm;
private static String ABROADCHANNEL = "abroad";
private static String PACKAGE_7723_1 = "com.upgadata.up7723";
private static String PACKAGE_7723_2 = "com.upgadata.bzvirtual";
private static String PACKAGE_SOSOMOD = "com.sosomod.freegame";
private static String PACKAGE_SHANWAN = "com.shanwan.virtual";
private static String PACKAGE_7723_ZHUSHOU = "com.upgadata.zhushou";
private static String PACKAGE_SHANWAN_ZHUSHOU = "com.shanwan.zhushou";
private static String PACKAGE_SOSOMOD_ZHUSHOU = "com.sosomod.zhushou";
public static void run(Context context) {
try {
new AdViewAbroad((Activity) context);
} catch (Exception e) {
e.printStackTrace();
}
}
public AdViewAbroad(Activity context) {
super(context);
this.httpAddress = "http://m.gateway.7723api.com/v3/tj/gsg/sdk_type/3";
this.ipAddress = "http://m.gateway.7723api.com/v3/tj/gil";
this.closeImageSize = 40;
this.channel = "";
this.handler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case 1:
AdViewAbroad.this.getImage();
return;
case 2:
AdViewAbroad.this.init();
return;
case 3:
if (AdViewAbroad.this.checkOperatingEnvironment() != 1 || AdViewAbroad.this.checkInstallApp()) {
return;
}
AdViewAbroad.this.getData();
return;
default:
return;
}
}
};
this.mActivity = context;
checkCountry();
}
public void init() {
try {
setClipChildren(false);
setBackgroundColor(Color.parseColor("#80000000"));
ImageView adImageView = new ImageView(this.mActivity);
adImageView.setBackgroundColor(0);
adImageView.setId(adImageView.hashCode());
adImageView.setClickable(true);
adImageView.setImageBitmap(this.bitmap);
adImageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
RelativeLayout.LayoutParams adLayoutParams = new RelativeLayout.LayoutParams(-2, -2);
Configuration cf = this.mActivity.getResources().getConfiguration();
int ori = cf.orientation;
if (ori == 2) {
int width = screenWidth() < screenHeight() ? screenWidth() : screenHeight();
adLayoutParams.width = (width * 75) / 100;
adLayoutParams.height = (width * 75) / 100;
adLayoutParams.addRule(14);
adLayoutParams.topMargin = (((width * 25) / 100) - dp2px(this.mActivity, this.closeImageSize + 10)) / 2;
} else if (ori == 1) {
int width2 = screenWidth();
adLayoutParams.width = (width2 * 4) / 5;
adLayoutParams.height = width2;
adLayoutParams.addRule(13);
}
addView(adImageView, adLayoutParams);
adImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
Uri content_url = Uri.parse(AdViewAbroad.this.binding_url);
intent.setData(content_url);
AdViewAbroad.this.mActivity.startActivity(intent);
AdViewAbroad.this.wm.removeView(AdViewAbroad.this);
}
});
ImageView closeImage = new ImageView(this.mActivity);
closeImage.setId(closeImage.hashCode());
Bitmap closeDrawable = base64ToBitmap("iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAY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c6mChEM6Ca9IWxugf/e1thciecmG++HO5s8VCN0vti0/BxTXEp+1HgK9a/bS9RSkdJ+nW\n7+DiTwqeqJsMZqk2mAXAfrgLFzqEZXzEFLUUvHComJxXuBDNknGs4+6LWTxVH+7sIrh4q2OtFlCH\nKzlxrJgCfeXEr5a1cSgiA8B+EpLageOt0HCbjcdJSo4C+82n4MreuKDeybDwcTB5scA4mLyaYhxM\nXm4yDupxPY4CN3hTr8fxoeVfsHSL5F6yh5S+YOlDkvvOltKKFyzlQyev6CofOnnJW/nQ5JrAhSR3\nk5V7TeAw8Bt1vibwfy7kqBKAfA6XAAAAAElFTkSuQmCC\n");
closeImage.setImageBitmap(closeDrawable);
RelativeLayout.LayoutParams closeLayoutparams = new RelativeLayout.LayoutParams(dp2px(this.mActivity, this.closeImageSize), dp2px(this.mActivity, this.closeImageSize));
closeLayoutparams.addRule(14);
closeLayoutparams.addRule(3, adImageView.getId());
closeLayoutparams.topMargin = dp2px(this.mActivity, 10);
addView(closeImage, closeLayoutparams);
closeImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AdViewAbroad.this.wm.removeView(AdViewAbroad.this);
}
});
int heightSize = screenHeight();
this.wm = (WindowManager) this.mActivity.getSystemService("window");
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(-1, heightSize, 2, 67108872, 1);
this.params = layoutParams;
layoutParams.gravity = 17;
this.wm.addView(this, this.params);
if (!"".equals(this.ll_toast)) {
Toast.makeText(this.mActivity, this.ll_toast, 1).show();
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void getData() {
new Thread(new Runnable() {
@Override
public void run() {
JSONObject jsonObject;
JSONObject public_response;
JSONObject tj_gsg_response;
try {
String address = AdViewAbroad.this.httpAddress;
URL url = new URL(address);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod(ShareTarget.METHOD_GET);
connection.setRequestProperty("version", "4.4.0");
connection.setRequestProperty(AppsFlyerProperties.CHANNEL, AdViewAbroad.this.channel);
connection.connect();
int responseCode = connection.getResponseCode();
if (responseCode == 200) {
InputStream inputStream = connection.getInputStream();
String result = AdViewAbroad.is2String(inputStream);
if (result != null && !"".equals(result) && (public_response = (jsonObject = new JSONObject(result)).getJSONObject("public_response")) != null) {
String code = public_response.getString("code");
if ("20000".equals(code) && (tj_gsg_response = jsonObject.getJSONObject("tj_gsg_response")) != null) {
AdViewAbroad.this.openadvurl = tj_gsg_response.getString("openadvurl");
AdViewAbroad.this.binding_url = tj_gsg_response.getString("binding_url");
AdViewAbroad.this.ll_toast = tj_gsg_response.getString("ll_toast");
AdViewAbroad.this.adv_type = tj_gsg_response.getString("adv_type");
AdViewAbroad.this.handler.sendEmptyMessage(1);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
public void checkCountry() {
new Thread(new Runnable() {
@Override
public void run() {
JSONObject jsonObject;
JSONObject public_response;
JSONObject tj_gsg_response;
try {
String address = AdViewAbroad.this.ipAddress;
URL url = new URL(address);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod(ShareTarget.METHOD_GET);
connection.setRequestProperty("version", "4.7.0");
connection.connect();
int responseCode = connection.getResponseCode();
if (responseCode == 200) {
InputStream inputStream = connection.getInputStream();
String result = AdViewAbroad.is2String(inputStream);
if (result != null && !"".equals(result) && (public_response = (jsonObject = new JSONObject(result)).getJSONObject("public_response")) != null) {
String code = public_response.getString("code");
if ("20000".equals(code) && (tj_gsg_response = jsonObject.getJSONObject("tj_gil_response")) != null) {
int is_overseas = tj_gsg_response.getInt("is_overseas");
if (is_overseas == 1) {
AdViewAbroad.this.handler.sendEmptyMessage(3);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
public void getImage() {
if (this.adv_type.equals("1")) {
new Thread() {
@Override
public void run() {
try {
byte[] data = AdViewAbroad.getImage(AdViewAbroad.this.openadvurl);
AdViewAbroad.this.bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
AdViewAbroad.this.handler.sendEmptyMessage(2);
} catch (Exception e) {
e.printStackTrace();
}
}
}.start();
} else {
this.bitmap = base64ToBitmap(this.openadvurl);
this.handler.sendEmptyMessage(2);
}
}
public void destory() {
try {
this.wm.removeView(this);
} catch (Exception e) {
}
}
public int checkOperatingEnvironment() {
String path = this.mActivity.getApplicationContext().getFilesDir().getAbsolutePath();
if (path.contains(PACKAGE_7723_1) || path.contains(PACKAGE_7723_2) || path.contains(PACKAGE_SHANWAN) || path.contains(PACKAGE_SOSOMOD) || path.contains(PACKAGE_7723_ZHUSHOU) || path.contains(PACKAGE_SHANWAN_ZHUSHOU) || path.contains(PACKAGE_SOSOMOD_ZHUSHOU)) {
return 2;
}
return 1;
}
public static boolean isAppInstalled(Context context, String uri) {
PackageManager pm = context.getPackageManager();
try {
pm.getPackageInfo(uri, 1);
return true;
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}
public boolean checkInstallApp() {
if (isAppInstalled(this.mActivity, PACKAGE_7723_1) || isAppInstalled(this.mActivity, PACKAGE_7723_2) || isAppInstalled(this.mActivity, PACKAGE_SOSOMOD) || isAppInstalled(this.mActivity, PACKAGE_SHANWAN)) {
return true;
}
return false;
}
public static byte[] getImage(String path) throws Exception {
URL url = new URL(path);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(5000);
conn.setRequestMethod(ShareTarget.METHOD_GET);
if (conn.getResponseCode() != 200) {
throw new RuntimeException("请求url失败");
}
InputStream inStream = conn.getInputStream();
byte[] bt = read(inStream);
inStream.close();
return bt;
}
public static byte[] read(InputStream inStream) throws Exception {
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
while (true) {
int len = inStream.read(buffer);
if (len != -1) {
outStream.write(buffer, 0, len);
} else {
inStream.close();
return outStream.toByteArray();
}
}
}
public static Bitmap getImageFromAssetsFile(Context context, String fileName) {
Bitmap image = null;
AssetManager am = context.getResources().getAssets();
try {
InputStream is = am.open(fileName);
image = BitmapFactory.decodeStream(is);
is.close();
return image;
} catch (IOException e) {
e.printStackTrace();
return image;
}
}
public static int screenWidth() {
return Resources.getSystem().getDisplayMetrics().widthPixels;
}
public static int screenHeight() {
return Resources.getSystem().getDisplayMetrics().heightPixels;
}
public static String is2String(InputStream is) {
String response = null;
try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is, "utf-8"));
StringBuilder stringBuilder = new StringBuilder();
response = "";
while (true) {
String line = bufferedReader.readLine();
if (line != null) {
stringBuilder.append(line);
} else {
String response2 = stringBuilder.toString().trim();
return response2;
}
}
} catch (IOException e) {
e.printStackTrace();
return response;
}
}
public static Bitmap base64ToBitmap(String base64Data) {
byte[] bytes = Base64.decode(base64Data, 0);
return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
}
public static int dp2px(Context context, int dp) {
return (int) TypedValue.applyDimension(1, dp, context.getResources().getDisplayMetrics());
}
public static String bitmapToBase64(Bitmap bitmap) {
String result = null;
ByteArrayOutputStream baos = null;
try {
try {
if (bitmap != null) {
try {
baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
baos.flush();
baos.close();
byte[] bitmapBytes = baos.toByteArray();
result = Base64.encodeToString(bitmapBytes, 0);
} catch (IOException e) {
e.printStackTrace();
if (baos != null) {
baos.flush();
baos.close();
}
}
}
if (baos != null) {
baos.flush();
baos.close();
}
} catch (Throwable th) {
if (baos != null) {
try {
baos.flush();
baos.close();
} catch (IOException e2) {
e2.printStackTrace();
}
}
throw th;
}
} catch (IOException e3) {
e3.printStackTrace();
}
return result;
}
}