360手机助手 v5.2.50版本的 MD5 值为:087c008db9e518cd556c792742e6830c
以下内容为反编译后的 b.java 源代码,内容仅作参考
package com.qihoo360.mobilesafe.pcdaemon.b;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import com.qihoo.utils.cb;
import com.qihoo360.mobilesafe.pcdaemon.data.ACSIITextPdu;
import com.qihoo360.mobilesafe.pcdaemon.data.PduBase;
import com.qihoo360.mobilesafe.util.DaemonException;
import java.util.List;
public class b extends a {
protected static final boolean d = com.qihoo.appstore.h.a.a;
PackageManager e;
Context f;
private com.qihoo360.mobilesafe.opti.a.a.a g;
private Handler h;
private final ServiceConnection i;
public b(Context context) {
super(context);
this.g = null;
this.e = null;
this.f = null;
this.i = new c(this);
this.f = context;
this.e = context.getPackageManager();
}
public PduBase a(PduBase pduBase, com.qihoo360.mobilesafe.pcdaemon.conn.a aVar) throws Exception {
PduBase b;
PduBase i;
PduBase f;
PduBase j;
PduBase g;
PduBase e;
PduBase d2;
PduBase h;
PduBase c;
String e2 = pduBase.e();
if ("CMD_BATTERY_GET_MODES_STATIC".equalsIgnoreCase(e2)) {
synchronized ("CMD_BATTERY_GET_MODES_STATIC") {
c = c(pduBase, aVar);
}
return c;
}
if ("CMD_BATTERY_GET_REMAIN_TIME_STATIC".equalsIgnoreCase(e2)) {
synchronized ("CMD_BATTERY_GET_REMAIN_TIME_STATIC") {
h = h(pduBase, aVar);
}
return h;
}
if ("CMD_BATTERY_GET_MODES_DYNAMIC".equalsIgnoreCase(e2)) {
synchronized ("RET_BATTERY_GET_MODES_DYNAMIC:") {
d2 = d(pduBase, aVar);
}
return d2;
}
if ("CMD_BATTERY_GET_REMAIN_TIME_BY_MODE_DATA".equalsIgnoreCase(e2)) {
synchronized ("CMD_BATTERY_GET_REMAIN_TIME_BY_MODE_DATA") {
e = e(pduBase, aVar);
}
return e;
}
if ("CMD_BATTERY_GET_CURRENT_MODE".equalsIgnoreCase(e2)) {
synchronized ("CMD_BATTERY_GET_CURRENT_MODE") {
g = g(pduBase, aVar);
}
return g;
}
if ("CMD_CLEAR_BATTERYE_UNBIND".equalsIgnoreCase(e2)) {
synchronized ("CMD_CLEAR_BATTERYE_UNBIND") {
j = j(pduBase, aVar);
}
return j;
}
if ("CMD_BATTERY_APPLY_MODE_BY_KEY".equalsIgnoreCase(e2)) {
synchronized ("CMD_BATTERY_APPLY_MODE_BY_KEY") {
f = f(pduBase, aVar);
}
return f;
}
if ("CMD_BATTERY_GET_BASE_REMAIN_TIME".equalsIgnoreCase(e2)) {
synchronized ("CMD_BATTERY_GET_BASE_REMAIN_TIME") {
i = i(pduBase, aVar);
}
return i;
}
if ("CMD_BATTERY_GET_MODE_ENABLED".equalsIgnoreCase(e2)) {
synchronized ("CMD_BATTERY_GET_MODE_ENABLED") {
b = b(pduBase, aVar);
}
return b;
}
return null;
}
public boolean a(String str) {
return "CMD_BATTERY_GET_MODES_STATIC".equalsIgnoreCase(str) || "CMD_BATTERY_GET_MODES_DYNAMIC".equalsIgnoreCase(str) || "CMD_BATTERY_GET_REMAIN_TIME_BY_MODE_DATA".equalsIgnoreCase(str) || "CMD_BATTERY_GET_CURRENT_MODE".equalsIgnoreCase(str) || "CMD_BATTERY_GET_REMAIN_TIME_STATIC".equalsIgnoreCase(str) || "CMD_BATTERY_GET_BASE_REMAIN_TIME".equalsIgnoreCase(str) || "CMD_BATTERY_APPLY_MODE_BY_KEY".equalsIgnoreCase(str) || "CMD_BATTERY_GET_MODE_ENABLED".equalsIgnoreCase(str) || "CMD_CLEAR_BATTERYE_UNBIND".equalsIgnoreCase(str);
}
private void a() throws DaemonException {
String str = Build.VERSION.SDK;
if (TextUtils.isEmpty(str)) {
throw new DaemonException("PACKAGE_VERSION_TOO_LOW:");
}
if (Integer.valueOf(str).intValue() < 7) {
throw new DaemonException("PACKAGE_VERSION_TOO_LOW:");
}
}
private void b() throws DaemonException {
try {
PackageInfo packageInfo = this.e.getPackageInfo("com.qihoo360.mobilesafe.opti.powerctl", 0);
if (packageInfo == null) {
throw new DaemonException("PACKAGE_NOT_FOUND:");
}
if (packageInfo.versionCode < 17) {
throw new DaemonException("PACKAGE_VERSION_TOO_LOW:" + packageInfo.versionCode + ":17");
}
} catch (PackageManager.NameNotFoundException e) {
throw new DaemonException("PACKAGE_NOT_FOUND:");
}
}
private PduBase b(PduBase pduBase, com.qihoo360.mobilesafe.pcdaemon.conn.a aVar) {
try {
b();
c();
return ACSIITextPdu.a("RET_BATTERY_GET_MODE_ENABLED:OK:" + String.valueOf(this.g.c()));
} catch (Throwable th) {
if (d) {
Log.e("BatteryCmdHandle", th.toString());
}
return ACSIITextPdu.a("RET_BATTERY_GET_MODE_ENABLED:ERR_FAILED:" + th.getMessage());
}
}
private PduBase c(PduBase pduBase, com.qihoo360.mobilesafe.pcdaemon.conn.a aVar) {
try {
a();
return ACSIITextPdu.a("RET_BATTERY_GET_MODES_STATIC:OK:-1;;60;;1;;false;;false;;true;;false;;false;;BEST;;mode.best.exp|-1;;30;;2;;false;;false;;false;;false;;false;;LONG;;mode.ext.long|15;;15;;2;;false;;false;;false;;false;;false;;EXTRE;;mode.extre");
} catch (Throwable th) {
if (d) {
Log.e("BatteryCmdHandle", th.toString());
}
return ACSIITextPdu.a("RET_BATTERY_GET_MODES_STATIC:ERR_FAILED:" + th.getMessage());
}
}
private PduBase d(PduBase pduBase, com.qihoo360.mobilesafe.pcdaemon.conn.a aVar) {
try {
b();
c();
List a = this.g.a();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < a.size(); i++) {
String str = (String) a.get(i);
if (d) {
Log.d("BatteryCmdHandle", "RET_BATTERY_GET_MODES_DYNAMIC:" + str);
}
sb.append(str);
if (i != a.size() - 1) {
sb.append("|");
}
}
return ACSIITextPdu.a("RET_BATTERY_GET_MODES_DYNAMIC:OK:" + sb.toString());
} catch (Throwable th) {
if (d) {
Log.e("BatteryCmdHandle", th.toString());
}
return ACSIITextPdu.a("RET_BATTERY_GET_MODES_DYNAMIC:ERR_FAILED:" + th.getMessage());
}
}
private PduBase e(PduBase pduBase, com.qihoo360.mobilesafe.pcdaemon.conn.a aVar) {
try {
b();
String str = null;
String[] d2 = pduBase.d();
if (d2 != null && d2.length > 0) {
str = d2[0];
}
if (TextUtils.isEmpty(str)) {
return ACSIITextPdu.a("RET_BATTERY_GET_REMAIN_TIME_BY_MODE_DATA:ERR_FAILED:PARAMETER ERROR");
}
c();
return ACSIITextPdu.a("RET_BATTERY_GET_REMAIN_TIME_BY_MODE_DATA:OK:" + this.g.a(str));
} catch (Throwable th) {
th.printStackTrace();
if (d) {
Log.e("BatteryCmdHandle", "RET_BATTERY_GET_MODE_BY_KEY" + th.toString());
}
return ACSIITextPdu.a("RET_BATTERY_GET_REMAIN_TIME_BY_MODE_DATA:ERR_FAILED:" + th.getMessage());
}
}
private PduBase f(PduBase pduBase, com.qihoo360.mobilesafe.pcdaemon.conn.a aVar) {
try {
b();
String str = null;
String[] d2 = pduBase.d();
if (d2 != null && d2.length > 0) {
str = d2[0];
}
if (TextUtils.isEmpty(str)) {
return ACSIITextPdu.a("RET_BATTERY_APPLY_MODE_BY_KEY:ERR_FAILED:PARAMETER ERROR");
}
c();
boolean b = this.g.b(str);
if (b) {
return ACSIITextPdu.a("RET_BATTERY_APPLY_MODE_BY_KEY:OK:" + b);
}
return ACSIITextPdu.a("RET_BATTERY_APPLY_MODE_BY_KEY:ERR_FAILED:" + b);
} catch (Throwable th) {
if (d) {
Log.e("BatteryCmdHandle", "RET_BATTERY_GET_MODE_BY_KEY" + th.toString());
}
return ACSIITextPdu.a("RET_BATTERY_APPLY_MODE_BY_KEY:ERR_FAILED:" + th.getMessage());
}
}
private PduBase g(PduBase pduBase, com.qihoo360.mobilesafe.pcdaemon.conn.a aVar) {
try {
b();
c();
return ACSIITextPdu.a("RET_BATTERY_GET_CURRENT_MODE:OK:" + this.g.b());
} catch (Throwable th) {
if (d) {
Log.e("BatteryCmdHandle", "RET_BATTERY_GET_CURRENT_MODE" + th.toString());
}
return ACSIITextPdu.a("RET_BATTERY_GET_CURRENT_MODE:ERR_FAILED:" + th.getMessage());
}
}
private PduBase h(PduBase pduBase, com.qihoo360.mobilesafe.pcdaemon.conn.a aVar) {
ACSIITextPdu a;
try {
a();
com.qihoo360.mobilesafe.lib.a.c a2 = com.qihoo360.mobilesafe.lib.a.c.a(this.f);
com.qihoo360.mobilesafe.lib.a.b a3 = com.qihoo360.mobilesafe.lib.a.b.a("-1;;60;;1;;false;;false;;true;;false;;false;;BEST;;mode.best.exp");
com.qihoo360.mobilesafe.lib.a.b a4 = com.qihoo360.mobilesafe.lib.a.b.a("-1;;30;;2;;false;;false;;false;;false;;false;;LONG;;mode.ext.long");
com.qihoo360.mobilesafe.lib.a.b a5 = com.qihoo360.mobilesafe.lib.a.b.a("15;;15;;2;;false;;false;;false;;false;;false;;EXTRE;;mode.extre");
com.qihoo360.mobilesafe.businesscard.summary.f.a(this.c);
int a6 = cb.a();
Object obj = new Object();
d dVar = new d(this, a6, obj, a2, a3, a4, a5);
synchronized (obj) {
try {
if (this.h == null) {
this.h = new Handler(Looper.getMainLooper());
}
this.h.post(dVar);
obj.wait();
a = ACSIITextPdu.a("RET_BATTERY_GET_REMAIN_TIME_STATIC:OK:" + dVar.a());
} catch (InterruptedException e) {
throw e;
}
}
return a;
} catch (Throwable th) {
if (d) {
Log.e("BatteryCmdHandle", th.toString(), th);
}
return ACSIITextPdu.a("RET_BATTERY_GET_REMAIN_TIME_STATIC:ERR_FAILED:" + th.getMessage());
}
}
private PduBase i(PduBase pduBase, com.qihoo360.mobilesafe.pcdaemon.conn.a aVar) {
ACSIITextPdu a;
try {
a();
com.qihoo360.mobilesafe.lib.a.e eVar = new com.qihoo360.mobilesafe.lib.a.e(this.f);
com.qihoo360.mobilesafe.businesscard.summary.f.a(this.c);
int a2 = cb.a();
Object obj = new Object();
e eVar2 = new e(this, a2, obj, eVar);
synchronized (obj) {
try {
if (this.h == null) {
this.h = new Handler(Looper.getMainLooper());
}
this.h.post(eVar2);
obj.wait();
if (eVar2.b() != null) {
throw eVar2.b();
}
a = ACSIITextPdu.a("RET_BATTERY_GET_BASE_REMAIN_TIME:OK:mode.def.baseAvailTime;;" + eVar2.a());
} catch (Exception e) {
throw e;
}
}
return a;
} catch (Throwable th) {
if (d) {
Log.e("BatteryCmdHandle", th.toString());
}
return ACSIITextPdu.a("RET_BATTERY_GET_BASE_REMAIN_TIME:ERR_FAILED:" + th.getMessage());
}
}
private synchronized void c() {
int i = 1;
synchronized (this) {
while (this.g == null && i <= 3) {
if (!this.c.bindService(new Intent("com.qihoo360.mobilesafe.opti.SERVICE"), this.i, 1)) {
throw new DaemonException("BIND_SERVICE_FAIL:");
}
i++;
try {
Thread.sleep(2000L);
} catch (Exception e) {
}
}
}
}
private PduBase j(PduBase pduBase, com.qihoo360.mobilesafe.pcdaemon.conn.a aVar) {
try {
this.c.unbindService(this.i);
this.g = null;
return ACSIITextPdu.a("RET_CLEAR_BATTERY_UNBIND:OK:");
} catch (Throwable th) {
if (d) {
Log.d("BatteryCmdHandle", th.getClass().getSimpleName() + ":" + th.getMessage());
}
return ACSIITextPdu.a("RET_CLEAR_BATTERY_UNBIND:ERR_FAILED:" + th.getMessage());
}
}
}