百度手机卫士 v8.8.0版本的 MD5 值为:a85894a6923c8a39f0c3a3a686ad7443
以下内容为反编译后的 AppMarketPluginUtils.java 源代码,内容仅作参考
package com.dianxinos.optimizer.utils;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.os.Build;
import cn.opda.a.phonoalbumshoushou.R;
import com.baidu.android.gporter.api.TargetActivator;
import com.baidu.android.gporter.pm.GPTPackageInfo;
import com.baidu.android.gporter.pm.GPTPackageManager;
import com.dianxinos.optimizer.module.recommend.data.RelationalRecommendConstants;
import com.google.protobuf.micro.CodedOutputStreamMicro;
import com.quickbird.sdk.internal.HttpsClient;
import com.quickbird.sdk.internal.KeepAliveTimerTask;
import dxoptimizer.ajo;
import dxoptimizer.ajq;
import dxoptimizer.ajw;
import dxoptimizer.azp;
import dxoptimizer.bhr;
import dxoptimizer.hti;
import dxoptimizer.hwt;
import dxoptimizer.hwu;
import dxoptimizer.hwv;
import dxoptimizer.hww;
import dxoptimizer.hwx;
import dxoptimizer.hwy;
import dxoptimizer.hxa;
import dxoptimizer.hyw;
import dxoptimizer.hzh;
import dxoptimizer.hzt;
import dxoptimizer.ibb;
import dxoptimizer.ibc;
import dxoptimizer.icn;
import dxoptimizer.icu;
import dxoptimizer.icv;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.zip.GZIPInputStream;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class AppMarketPluginUtils {
private static String a;
private static String b;
private static String c;
private static BroadcastReceiver d;
private static BroadcastReceiver e;
private static ArrayList<PluginInfo> f;
private static HashMap<String, String[]> g;
static {
Context a2 = hxa.a();
g = new HashMap<>();
a = a2.getDir("plug_a", 0).getAbsolutePath();
b = new File(a, ".plugin_info_cache").getAbsolutePath();
c = new File(a, ".plugin_install_cache").getAbsolutePath();
}
private static String g() {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("pluginlist_v", "16785355");
} catch (JSONException e2) {
}
return jSONObject.toString();
}
private static String h() {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("channel", 11);
jSONObject.put("force", "1");
} catch (JSONException e2) {
}
return jSONObject.toString();
}
private static String c(String str) {
String[] split = str.split("://");
StringBuilder sb = new StringBuilder(split[0] + "://");
String[] split2 = split[1].split("/");
for (String str2 : split2) {
sb.append(URLEncoder.encode(str2, HttpsClient.HTTP_CHARSET) + "/");
}
return sb.substring(0, sb.length() - 1);
}
private static void a(GPTPackageManager gPTPackageManager, HashMap<String, PluginInfo> hashMap, String str) {
GPTPackageInfo packageInfo;
try {
JSONObject jSONObject = new JSONObject(str);
if (jSONObject.getInt("errno") <= 0) {
JSONArray jSONArray = jSONObject.getJSONObject("data").getJSONObject("api").getJSONObject("pluginlist").getJSONObject("dataset").getJSONArray("items");
int length = jSONArray.length();
for (int i = 0; i < length; i++) {
JSONObject jSONObject2 = jSONArray.getJSONObject(i);
if (jSONObject2.getInt("disable") == 0 && ((packageInfo = gPTPackageManager.getPackageInfo(jSONObject2.getString("pkg"))) == null || jSONObject2.getInt("version") > packageInfo.versionCode)) {
String string = jSONObject2.getString("pkg");
int i2 = jSONObject2.getInt("version");
PluginInfo pluginInfo = hashMap.get(string);
if (pluginInfo == null || i2 > pluginInfo.versionCode) {
PluginInfo pluginInfo2 = new PluginInfo(null);
pluginInfo2.downloadUrl = c(jSONObject2.getString("download_url"));
pluginInfo2.pkg = string;
pluginInfo2.iconUrl = c(jSONObject2.getString("icon_normal"));
pluginInfo2.signature = jSONObject2.getString("signature");
pluginInfo2.name = jSONObject2.getString("name");
pluginInfo2.versionCode = i2;
hashMap.put(string, pluginInfo2);
}
}
}
}
} catch (UnsupportedEncodingException e2) {
} catch (JSONException e3) {
}
}
private static void a(GPTPackageManager gPTPackageManager, HashMap<String, PluginInfo> hashMap, byte[] bArr) {
try {
GZIPInputStream gZIPInputStream = new GZIPInputStream(new ByteArrayInputStream(bArr));
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(CodedOutputStreamMicro.DEFAULT_BUFFER_SIZE);
byte[] bArr2 = new byte[CodedOutputStreamMicro.DEFAULT_BUFFER_SIZE];
while (true) {
int read = gZIPInputStream.read(bArr2);
if (read != -1) {
byteArrayOutputStream.write(bArr2, 0, read);
} else {
a(gPTPackageManager, hashMap, new String(byteArrayOutputStream.toByteArray(), HttpsClient.HTTP_CHARSET));
return;
}
}
} catch (IOException e2) {
}
}
public static ArrayList<PluginInfo> b(GPTPackageManager gPTPackageManager, boolean[] zArr) {
HttpURLConnection httpURLConnection;
HttpURLConnection httpURLConnection2;
HttpURLConnection httpURLConnection3 = null;
HashMap hashMap = new HashMap();
try {
try {
httpURLConnection = (HttpURLConnection) new URL("http://m.baidu.com/appsrv?native_api=1&action=pluginlist").openConnection();
try {
httpURLConnection.addRequestProperty("Accept-Encoding", "gzip");
httpURLConnection.setUseCaches(false);
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
httpURLConnection.setReadTimeout(KeepAliveTimerTask.VPN_DAEMON_INTERVAL);
StringBuilder sb = new StringBuilder();
sb.append("platform_version_id=" + Build.VERSION.SDK_INT + "&");
sb.append("ver=99999999&");
sb.append("version=" + g() + "&");
sb.append("data=" + h());
try {
OutputStream outputStream = httpURLConnection.getOutputStream();
outputStream.write(sb.toString().getBytes());
outputStream.flush();
if (200 == httpURLConnection.getResponseCode()) {
InputStream inputStream = httpURLConnection.getInputStream();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] bArr = new byte[CodedOutputStreamMicro.DEFAULT_BUFFER_SIZE];
while (true) {
int read = inputStream.read(bArr);
if (read == -1) {
break;
}
byteArrayOutputStream.write(bArr, 0, read);
}
byteArrayOutputStream.flush();
a(gPTPackageManager, (HashMap<String, PluginInfo>) hashMap, byteArrayOutputStream.toByteArray());
zArr[0] = true;
}
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
} catch (RuntimeException e2) {
ArrayList<PluginInfo> arrayList = new ArrayList<>();
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return arrayList;
}
} catch (MalformedURLException e3) {
zArr[0] = true;
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return new ArrayList<>(hashMap.values());
} catch (IOException e4) {
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return new ArrayList<>(hashMap.values());
}
} catch (Throwable th) {
httpURLConnection3 = httpURLConnection2;
th = th;
if (httpURLConnection3 != null) {
httpURLConnection3.disconnect();
}
throw th;
}
} catch (MalformedURLException e5) {
httpURLConnection = null;
} catch (IOException e6) {
httpURLConnection = null;
} catch (Throwable th2) {
th = th2;
if (httpURLConnection3 != null) {
}
throw th;
}
return new ArrayList<>(hashMap.values());
}
public static <T extends Serializable> void b(T t, String str) {
ObjectOutputStream objectOutputStream;
Throwable th;
synchronized (t) {
try {
try {
ibc a2 = ibb.a(new File(str));
ObjectOutputStream a3 = a2.a();
try {
a3.writeObject(t);
a2.b();
if (a3 != null) {
hyw.a(a3);
}
} catch (Throwable th2) {
objectOutputStream = a3;
th = th2;
if (objectOutputStream == null) {
throw th;
}
hyw.a(objectOutputStream);
throw th;
}
} catch (Throwable th3) {
objectOutputStream = null;
th = th3;
}
} catch (IOException e2) {
if (0 != 0) {
hyw.a((Closeable) null);
}
}
}
}
public static <T extends Serializable> T d(String str) {
ObjectInputStream objectInputStream;
ObjectInputStream objectInputStream2;
File file = new File(str);
if (file.exists()) {
try {
objectInputStream = ibb.b(file);
try {
T t = (T) objectInputStream.readObject();
if (objectInputStream == null) {
return t;
}
hyw.a((Closeable) objectInputStream);
return t;
} catch (IOException e2) {
objectInputStream2 = objectInputStream;
if (objectInputStream2 != null) {
hyw.a((Closeable) objectInputStream2);
return null;
}
return null;
} catch (ClassNotFoundException e3) {
if (objectInputStream != null) {
hyw.a((Closeable) objectInputStream);
return null;
}
return null;
} catch (Throwable th) {
th = th;
if (objectInputStream != null) {
hyw.a((Closeable) objectInputStream);
}
throw th;
}
} catch (IOException e4) {
objectInputStream2 = null;
} catch (ClassNotFoundException e5) {
objectInputStream = null;
} catch (Throwable th2) {
th = th2;
objectInputStream = null;
}
}
return null;
}
public static synchronized void g(Context context) {
synchronized (AppMarketPluginUtils.class) {
BroadcastReceiver broadcastReceiver = d;
if (broadcastReceiver != null) {
try {
context.unregisterReceiver(broadcastReceiver);
} catch (IllegalArgumentException e2) {
}
d = null;
}
}
}
public static synchronized void h(Context context) {
synchronized (AppMarketPluginUtils.class) {
BroadcastReceiver broadcastReceiver = e;
if (broadcastReceiver != null) {
context.unregisterReceiver(broadcastReceiver);
e = null;
}
}
}
public static BroadcastReceiver i() {
return new hwt();
}
private static ajw a(Context context, PluginInfo pluginInfo) {
return new hwu(pluginInfo, context);
}
private static ajo a(PluginInfo pluginInfo) {
ajo ajoVar = new ajo();
ajoVar.g = pluginInfo.downloadUrl;
ajoVar.b = pluginInfo.pkg;
ajoVar.c = pluginInfo.name;
ajoVar.h = pluginInfo.iconUrl;
ajoVar.a = "plugin_app_market";
ajoVar.j = a;
return ajoVar;
}
public static void b(Context context, ArrayList<PluginInfo> arrayList) {
ajq a2 = azp.a(context);
Iterator<PluginInfo> it = arrayList.iterator();
while (it.hasNext()) {
PluginInfo next = it.next();
azp.b(a2, a(next), a(context, next));
icu.a(context);
icu.a("am_ctg", "am_pds", (Number) 1);
}
}
public static void b(Context context, boolean z) {
Calendar calendar = Calendar.getInstance();
if (z || calendar.get(11) > 6) {
calendar.add(6, 1);
calendar.set(11, 0);
} else {
calendar.set(11, 6);
}
calendar.set(12, 0);
calendar.set(13, 0);
calendar.set(14, 0);
bhr.a("com.dianxinos.optimizer.action.ALARM_EVENT_APP_MARKET_PLUGIN_PLUGIN", calendar.getTimeInMillis());
}
public static void i(Context context) {
if (d == null) {
hwv hwvVar = new hwv(context);
icn.a(context, hwvVar, new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"));
d = hwvVar;
}
}
private static void c(Context context, int i) {
hzt.a(context, i);
hti.a().b(new hww(context));
}
public static String a(String str) {
HashMap hashMap = (HashMap) d(c);
if (hashMap == null) {
return null;
}
String[] strArr = (String[]) hashMap.get(str);
return strArr == null ? null : strArr[1];
}
public static void a(Context context) {
int i = Calendar.getInstance().get(6);
if (i != hzt.m(context)) {
c(context, i);
} else {
b(context, true);
}
}
private static void j() {
hti.a().b(new hwx());
}
public static void b(Context context) {
j();
int i = Calendar.getInstance().get(6);
if (i != hzt.m(context)) {
c(context, i);
} else if (!bhr.b("com.dianxinos.optimizer.action.ALARM_EVENT_APP_MARKET_PLUGIN_PLUGIN")) {
b(context, true);
}
}
private static Intent a(int i, String str, Context context) {
switch (i) {
case 1:
Intent intent = new Intent("com.baidu.appsearch.extinvoker.LAUNCH");
intent.addFlags(32);
intent.putExtra(RelationalRecommendConstants.RECOM_ELEMENT_ID, context.getPackageName());
intent.putExtra("backop", "0");
intent.putExtra("func", "1");
intent.putExtra("actionvalue", "homepage");
intent.setComponent(new ComponentName(str, "com.baidu.appsearch.AppSearchInvokerActivity"));
return intent;
case 2:
Intent intent2 = new Intent("com.baidu.appsearch.extinvoker.LAUNCH");
intent2.addFlags(32);
intent2.putExtra(RelationalRecommendConstants.RECOM_ELEMENT_ID, context.getPackageName());
intent2.putExtra("backop", "0");
intent2.putExtra("func", "22");
intent2.setComponent(new ComponentName(str, "com.baidu.appsearch.AppSearchInvokerActivity"));
return intent2;
case 3:
Intent intent3 = new Intent("com.baidu.appsearch.extinvoker.LAUNCH");
intent3.addFlags(32);
intent3.putExtra(RelationalRecommendConstants.RECOM_ELEMENT_ID, context.getPackageName());
intent3.putExtra("backop", "0");
intent3.putExtra("func", "2");
intent3.setComponent(new ComponentName(str, "com.baidu.appsearch.AppSearchInvokerActivity"));
return intent3;
default:
return null;
}
}
private static String a(int i) {
if (i < 16) {
return "com.baidu.appsearch.gpt.lite";
}
return null;
}
private static String d(Context context, int i) {
List installedApps;
GPTPackageInfo gPTPackageInfo;
Context applicationContext = context.getApplicationContext();
String a2 = a(i);
if (a2 == null || (installedApps = GPTPackageManager.getInstance(applicationContext).getInstalledApps()) == null || installedApps.isEmpty()) {
return null;
}
Iterator it = installedApps.iterator();
while (true) {
if (!it.hasNext()) {
gPTPackageInfo = null;
break;
}
gPTPackageInfo = (GPTPackageInfo) it.next();
if (a2.equals(gPTPackageInfo.packageName)) {
break;
}
}
return gPTPackageInfo == null ? null : a2;
}
public static boolean a(Context context, int i) {
return d(context, i) != null;
}
public static void c(Context context) {
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("http://mobile.baidu.com/"));
if (!hzh.a(context, intent)) {
icv.b(context, R.string.jadx_deobf_0x000029eb, 0);
return;
}
intent.setPackage("com.baidu.searchbox");
if (!hzh.a(context, intent)) {
intent.setPackage(null);
}
intent.addFlags(268435456);
context.startActivity(intent);
}
public static boolean b(Context context, int i) {
String d2;
Intent a2;
if (!hzt.n(context) || (d2 = d(context, i)) == null || (a2 = a(i, d2, context)) == null) {
return false;
}
TargetActivator.loadTargetAndRun(context, a2, new hwy());
return true;
}
public class PluginInfo implements Serializable {
private static final long serialVersionUID = 3001635540624760198L;
String downloadUrl;
String iconUrl;
String name;
public String pkg;
public String signature;
int versionCode;
private PluginInfo() {
}
PluginInfo(hwt hwtVar) {
this();
}
public String toString() {
return "PluginInfo{name='" + this.name + "', pkg='" + this.pkg + "', downloadUrl='" + this.downloadUrl + "', signature='" + this.signature + "', iconUrl='" + this.iconUrl + "', versionCode=" + this.versionCode + '}';
}
}
}