360手机助手 v5.2.50版本的 MD5 值为:087c008db9e518cd556c792742e6830c
以下内容为反编译后的 AccountService.java 源代码,内容仅作参考
package com.qihoo.accountcenter.service;
import android.app.Service;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.Process;
import android.text.TextUtils;
import android.util.Base64;
import com.android.volleypro.toolbox.VolleyHttpClient;
import com.qihoo.accountcenter.g;
import com.qihoo.appstore.utils.ApplicationConfig;
import com.qihoo.utils.al;
import com.qihoo.utils.be;
import com.qihoo.utils.bn;
import com.qihoo360.accounts.QihooAccount;
import com.qihoo360.accounts.a.x;
import com.qihoo360.accounts.o;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class AccountService extends Service {
private static final String[] d = {"360zhushou", "open_ms", "360yxhezi"};
private static final String[] e = {"j8a7i2u6", "2a9u8q4y", "u72g3fds"};
public com.qihoo360.accounts.b.a a = null;
Handler b = new a(this, Looper.getMainLooper());
private final com.qihoo.accountcenter.a.b c = new b(this);
public static int b(Context context, String str, String str2, String str3, String[] strArr, boolean z) {
String[] strArr2;
?? r1;
Exception exc;
if (strArr == null || strArr.length < 2) {
return 99101;
}
strArr[0] = context.getString(o.unknown_error_logout);
if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str3)) {
strArr[0] = context.getString(o.fail_wrong_parameter);
return 4001;
}
SQLiteDatabase writableDatabase = new com.qihoo.accountcenter.a(context).getWritableDatabase();
strArr2 = c.b;
Cursor query = writableDatabase.query("account", strArr2, "account=?", new String[]{str2}, null, null, null);
try {
try {
} finally {
if (query != null) {
query.close();
}
}
} catch (Exception e2) {
r1 = strArr2;
exc = e2;
}
if (query != null) {
try {
} catch (Exception e3) {
exc = e3;
r1 = 5099;
exc.printStackTrace();
if (query != null) {
query.close();
}
writableDatabase.close();
bn.b("AccountService", "logout(), pkgName = " + str + ", account = " + str2 + ", result = " + Arrays.toString(strArr));
return r1;
}
if (query.getCount() > 0) {
if (z) {
int b = b(context, Binder.getCallingUid(), str, str3, strArr);
if (b == 0) {
strArr[0] = context.getString(o.succeed_del_num, Integer.valueOf(writableDatabase.delete("account", "account=?", new String[]{str2})));
}
r1 = b;
} else {
strArr[0] = context.getString(o.succeed_del_num, Integer.valueOf(writableDatabase.delete("account", "account=?", new String[]{str2})));
r1 = 0;
}
writableDatabase.close();
bn.b("AccountService", "logout(), pkgName = " + str + ", account = " + str2 + ", result = " + Arrays.toString(strArr));
return r1;
}
}
strArr[0] = context.getString(o.succeed_del_num, 0);
r1 = 0;
writableDatabase.close();
bn.b("AccountService", "logout(), pkgName = " + str + ", account = " + str2 + ", result = " + Arrays.toString(strArr));
return r1;
}
public static void a(Context context, String str, String str2) {
SQLiteDatabase writableDatabase = new com.qihoo.accountcenter.a(context).getWritableDatabase();
try {
String encodeToString = Base64.encodeToString(com.qihoo.utils.d.b.a(str2.getBytes()), 0);
ContentValues contentValues = new ContentValues();
contentValues.put("qt", encodeToString);
writableDatabase.update("account", contentValues, "qid=?", new String[]{str});
} catch (Exception e2) {
bn.b("AccountService", "modifyPwd failed.", e2);
} finally {
writableDatabase.close();
}
}
@Override
public void onCreate() {
bn.b("AccountService", "onCreate called");
super.onCreate();
if (be.a) {
bn.b("KillSelfHelper", "AccountService.onCreate = " + Process.myPid());
}
}
@Override
public IBinder onBind(Intent intent) {
bn.b("AccountService", "onBind() called");
if (be.a) {
bn.b("KillSelfHelper", "AccountService.onBind = " + Process.myPid() + ", intent = " + bn.a(intent));
}
return this.c;
}
protected String a(String str, String str2) {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("account=").append(str).append("&token=").append(str2).append("&method=CommonAccount.mobileLoginByToken").append("&v=").append(al.h(this)).append("&from=mpc_zhushou").append("&mid=").append(com.qihoo.productdatainfo.b.b.a(2)).append("&format=json").append("&vt_guid=").append(String.valueOf(Math.abs(new Random().nextInt())));
String stringBuffer2 = stringBuffer.toString();
return "https://login.360.cn/intf.php?" + stringBuffer2 + "&sig=" + g.a(stringBuffer2);
}
public static int b(Context context, int i, String str, String str2, String[] strArr) {
int i2;
String[] strArr2;
bn.b("AccountService", "checkPermission() called");
strArr[0] = "unauthorized";
String[] a = a(context, i, str);
int length = a.length;
SQLiteDatabase writableDatabase = new com.qihoo.accountcenter.a(context).getWritableDatabase();
int i3 = 0;
while (true) {
if (i3 >= length) {
i2 = 99102;
break;
}
if (!TextUtils.isEmpty(a[i3])) {
strArr2 = d.a;
Cursor query = writableDatabase.query("verify", strArr2, "pkg_name=? AND app_key=? AND public_key=?", new String[]{str, str2, a[i3]}, null, null, null);
if (query != null) {
try {
try {
if (query.moveToFirst()) {
long j = query.getLong(0);
if (System.currentTimeMillis() - j <= 86400000 && System.currentTimeMillis() - j >= 0) {
i2 = 0;
if (query != null) {
query.close();
}
}
}
} catch (Exception e2) {
e2.printStackTrace();
if (query != null) {
query.close();
}
}
} catch (Throwable th) {
if (query != null) {
query.close();
}
throw th;
}
}
if (query != null) {
query.close();
}
}
i3++;
}
bn.b("AccountService", "checkPermission query TABLE_VERIFY, resultCode = " + i2);
if (i2 != 0) {
writableDatabase.delete("verify", "pkg_name=? AND app_key=?", new String[]{str, str2});
int i4 = 0;
while (true) {
if (i4 >= length) {
break;
}
if (!TextUtils.isEmpty(a[i4])) {
InputStream inputStream = null;
com.qihoo.accountcenter.b bVar = null;
try {
try {
bVar = com.qihoo.accountcenter.b.a((String) null);
HttpPost httpPost = new HttpPost("http://openapi.360.cn/internal/verify_mobile_app.json");
httpPost.setHeader(VolleyHttpClient.HEADER_CONTENT_TYPE, VolleyHttpClient.HEADER_CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENCODED);
httpPost.setHeader("Charset", "UTF8");
ArrayList arrayList = new ArrayList();
arrayList.add(new BasicNameValuePair("app_name", str2));
arrayList.add(new BasicNameValuePair("public_key", a[i4]));
httpPost.setEntity(new UrlEncodedFormEntity(arrayList, "UTF8"));
HttpResponse execute = bVar.execute(httpPost);
int statusCode = execute.getStatusLine().getStatusCode();
bn.b("AccountService", "checkPermission try to insert TABLE_VERIFY, stCode = " + statusCode);
if (statusCode == 200) {
inputStream = execute.getEntity().getContent();
if ("verified".equalsIgnoreCase(new JSONObject(new String(a(inputStream), "UTF8")).optString("ret"))) {
i2 = 0;
ContentValues contentValues = new ContentValues();
contentValues.put("pkg_name", str);
contentValues.put("app_key", str2);
contentValues.put("public_key", a[i4]);
contentValues.put("verify_time", Long.valueOf(System.currentTimeMillis()));
writableDatabase.insert("verify", null, contentValues);
bn.b("AccountService", "checkPermission insert TABLE_VERIFY");
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e3) {
e3.printStackTrace();
}
}
if (bVar != null) {
bVar.a();
}
}
}
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e4) {
e4.printStackTrace();
}
}
if (bVar != null) {
bVar.a();
}
} catch (Exception e5) {
e5.printStackTrace();
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e6) {
e6.printStackTrace();
}
}
if (bVar != null) {
bVar.a();
}
}
} catch (Throwable th2) {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e7) {
e7.printStackTrace();
}
}
if (bVar != null) {
bVar.a();
}
throw th2;
}
}
i4++;
}
}
writableDatabase.close();
bn.b("AccountService", "checkPermission return " + i2 + ", result = " + Arrays.toString(strArr));
return i2;
}
public int a(String str, String[] strArr) {
InputStream inputStream = null;
bn.b("AccountService", "checkQT() called");
int i = 5099;
strArr[0] = getString(o.unknown_error_check_qt);
if (!TextUtils.isEmpty(str)) {
com.qihoo.accountcenter.b a = com.qihoo.accountcenter.b.a((String) null);
HttpGet httpGet = new HttpGet("http://openapi.360.cn/internal/verify_q_t.json");
httpGet.setHeader(VolleyHttpClient.HEADER_CONTENT_TYPE, VolleyHttpClient.HEADER_CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENCODED);
httpGet.setHeader("Charset", "UTF8");
httpGet.setHeader("Cookie", str);
try {
try {
HttpResponse execute = a.execute(httpGet);
if (execute.getStatusLine().getStatusCode() == 200) {
inputStream = execute.getEntity().getContent();
String optString = new JSONObject(new String(a(inputStream), "UTF8")).optString("ret");
if ("verified".equalsIgnoreCase(optString)) {
i = 0;
} else {
try {
strArr[0] = optString;
i = 4010207;
} catch (Exception e2) {
i = 4010207;
e = e2;
bn.c("AccountService", "getQT failed.", e);
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e3) {
e3.printStackTrace();
}
}
if (a != null) {
a.a();
}
bn.c("AccountService", "checkQT() return " + i + ", result = " + Arrays.toString(strArr));
return i;
}
}
}
} finally {
if (0 != 0) {
try {
inputStream.close();
} catch (IOException e4) {
e4.printStackTrace();
}
}
if (a != null) {
a.a();
}
}
} catch (Exception e5) {
e = e5;
}
}
bn.c("AccountService", "checkQT() return " + i + ", result = " + Arrays.toString(strArr));
return i;
}
public int b(String str, String str2, String[] strArr, JSONObject jSONObject) {
int i;
bn.b("AccountService", "getAuthCode() called");
int i2 = 5099;
strArr[0] = getString(o.unknown_error_get_auth_code);
com.qihoo.accountcenter.b a = com.qihoo.accountcenter.b.a((String) null);
HttpPost httpPost = new HttpPost(str);
httpPost.setHeader(VolleyHttpClient.HEADER_CONTENT_TYPE, VolleyHttpClient.HEADER_CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENCODED);
httpPost.setHeader("Charset", "UTF8");
httpPost.setHeader("Cookie", str2);
ArrayList arrayList = new ArrayList();
arrayList.add(new BasicNameValuePair("authorize", "sdk_by_cookie"));
try {
try {
httpPost.setEntity(new UrlEncodedFormEntity(arrayList, "UTF8"));
HttpResponse execute = a.execute(httpPost);
if (execute.getStatusLine().getStatusCode() == 302) {
String value = execute.getFirstHeader("Location").getValue();
Matcher matcher = Pattern.compile("[?&]code=([0-9a-zA-Z]*)").matcher(value);
Matcher matcher2 = Pattern.compile("[?&]state=([0-9a-zA-Z_]*)").matcher(value);
if (matcher.find()) {
jSONObject.put("auth_code", matcher.group(1));
i2 = 0;
}
if (matcher2.find()) {
jSONObject.put("state", matcher2.group(1));
}
i = i2;
} else {
strArr[0] = getString(o.fail_invalid_qt);
i = 4010207;
}
} catch (Exception e2) {
i = 5099;
bn.c("AccountService", "getQT failed.", e2);
if (a != null) {
a.a();
}
}
bn.b("AccountService", "getAuthCode finished, resultCode = " + i + ", result = " + Arrays.toString(strArr) + ", resultData = " + jSONObject);
return i;
} finally {
if (a != null) {
a.a();
}
}
}
public static byte[] a(InputStream inputStream) {
byte[] bArr = new byte[1024];
try {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
while (true) {
int read = inputStream.read(bArr);
if (read != -1) {
byteArrayOutputStream.write(bArr, 0, read);
} else {
byteArrayOutputStream.close();
inputStream.close();
return byteArrayOutputStream.toByteArray();
}
}
} catch (Exception e2) {
e2.printStackTrace();
return new byte[1024];
} catch (OutOfMemoryError e3) {
System.gc();
e3.printStackTrace();
return new byte[1024];
}
}
public int a(String str, String[] strArr, String str2, JSONObject jSONObject) {
Exception exc;
int i;
InputStream inputStream;
HttpResponse execute;
InputStream inputStream2 = null;
bn.b("AccountService", "modifyPsw() called");
strArr[0] = "用户中心修改密码未知错误";
com.qihoo.accountcenter.b a = com.qihoo.accountcenter.b.a((String) null);
HttpGet httpGet = new HttpGet(str);
httpGet.setHeader(VolleyHttpClient.HEADER_CONTENT_TYPE, VolleyHttpClient.HEADER_CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENCODED);
httpGet.setHeader("Charset", "UTF8");
try {
try {
execute = a.execute(httpGet);
} catch (Throwable th) {
th = th;
if (inputStream2 != null) {
try {
inputStream2.close();
} catch (IOException e2) {
e2.printStackTrace();
}
}
if (a != null) {
a.a();
}
throw th;
}
} catch (Exception e3) {
exc = e3;
i = 5099;
inputStream = null;
}
if (execute.getStatusLine().getStatusCode() == 200) {
inputStream2 = execute.getEntity().getContent();
try {
JSONObject jSONObject2 = new JSONObject(a(new String(a(inputStream2), "UTF8"), execute));
int i2 = jSONObject2.getInt("errno");
if (i2 == 0) {
String str3 = "";
Header[] headers = execute.getHeaders("set-cookie");
for (Header header : headers) {
String value = header.getValue();
int indexOf = value.indexOf("Q=");
if (indexOf < 0) {
indexOf = value.indexOf("T=");
}
if (indexOf >= 0) {
str3 = str3.concat(value.substring(indexOf, value.indexOf(ApplicationConfig.LIST_TO_STRING_SEPARATOR, indexOf) + 1));
}
}
if (!TextUtils.isEmpty(str3)) {
try {
jSONObject.put("qt", str3.substring(0, str3.length() - 1));
jSONObject.put("qid", str2);
i = 0;
} catch (Exception e4) {
inputStream = inputStream2;
i = 0;
exc = e4;
try {
bn.c("AccountService", "getQT failed.", exc);
if (inputStream != null) {
}
if (a != null) {
}
return i;
} catch (Throwable th2) {
th = th2;
inputStream2 = inputStream;
if (inputStream2 != null) {
}
if (a != null) {
}
throw th;
}
}
}
} else {
try {
strArr[0] = jSONObject2.optString("errmsg");
if (TextUtils.isEmpty(strArr[0])) {
strArr[0] = "密码修改失败";
}
i = i2;
} catch (Exception e5) {
exc = e5;
inputStream = inputStream2;
i = i2;
bn.c("AccountService", "getQT failed.", exc);
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e6) {
e6.printStackTrace();
}
}
if (a != null) {
a.a();
}
return i;
}
}
if (inputStream2 != null) {
try {
inputStream2.close();
} catch (IOException e7) {
e7.printStackTrace();
}
}
if (a != null) {
a.a();
}
} catch (Exception e8) {
exc = e8;
i = 5099;
inputStream = inputStream2;
}
return i;
}
i = 5099;
if (inputStream2 != null) {
}
if (a != null) {
}
return i;
}
public int b(String str, String[] strArr, JSONObject jSONObject) {
Exception exc;
int i;
InputStream inputStream;
HttpResponse execute;
InputStream inputStream2 = null;
bn.b("AccountService", "getQT() called");
strArr[0] = getString(o.unknown_error_get_qt);
com.qihoo.accountcenter.b a = com.qihoo.accountcenter.b.a((String) null);
HttpGet httpGet = new HttpGet(str);
httpGet.setHeader(VolleyHttpClient.HEADER_CONTENT_TYPE, VolleyHttpClient.HEADER_CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENCODED);
httpGet.setHeader("Charset", "UTF8");
try {
try {
execute = a.execute(httpGet);
} catch (Throwable th) {
th = th;
if (inputStream2 != null) {
try {
inputStream2.close();
} catch (IOException e2) {
e2.printStackTrace();
}
}
if (a != null) {
a.a();
}
throw th;
}
} catch (Exception e3) {
exc = e3;
i = 5099;
inputStream = null;
}
if (execute.getStatusLine().getStatusCode() == 200) {
inputStream2 = execute.getEntity().getContent();
try {
JSONObject jSONObject2 = new JSONObject(a(new String(a(inputStream2), "UTF8"), execute));
int i2 = jSONObject2.getInt("errno");
if (i2 == 0) {
String str2 = "";
Header[] headers = execute.getHeaders("set-cookie");
for (Header header : headers) {
String value = header.getValue();
int indexOf = value.indexOf("Q=");
if (indexOf < 0) {
indexOf = value.indexOf("T=");
}
if (indexOf >= 0) {
str2 = str2.concat(value.substring(indexOf, value.indexOf(ApplicationConfig.LIST_TO_STRING_SEPARATOR, indexOf) + 1));
}
}
JSONObject optJSONObject = jSONObject2.optJSONObject("user");
if (optJSONObject != null) {
jSONObject.put("fields", optJSONObject);
jSONObject.put("qid", optJSONObject.optLong("qid"));
}
if (!TextUtils.isEmpty(str2)) {
try {
jSONObject.put("qt", str2.substring(0, str2.length() - 1));
i = 0;
} catch (Exception e4) {
inputStream = inputStream2;
i = 0;
exc = e4;
try {
bn.c("AccountService", "getQT failed.", exc);
if (inputStream != null) {
}
if (a != null) {
}
bn.b("AccountService", "getQT() returns " + i + ", result = " + Arrays.toString(strArr) + ", resultData = " + jSONObject);
return i;
} catch (Throwable th2) {
th = th2;
inputStream2 = inputStream;
if (inputStream2 != null) {
}
if (a != null) {
}
throw th;
}
}
}
} else {
try {
strArr[0] = jSONObject2.optString("errmsg");
if (TextUtils.isEmpty(strArr[0])) {
strArr[0] = getString(o.fail_invalid_username_or_pwd);
}
i = i2;
} catch (Exception e5) {
exc = e5;
inputStream = inputStream2;
i = i2;
bn.c("AccountService", "getQT failed.", exc);
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e6) {
e6.printStackTrace();
}
}
if (a != null) {
a.a();
}
bn.b("AccountService", "getQT() returns " + i + ", result = " + Arrays.toString(strArr) + ", resultData = " + jSONObject);
return i;
}
}
if (inputStream2 != null) {
try {
inputStream2.close();
} catch (IOException e7) {
e7.printStackTrace();
}
}
if (a != null) {
a.a();
}
} catch (Exception e8) {
exc = e8;
i = 5099;
inputStream = inputStream2;
}
bn.b("AccountService", "getQT() returns " + i + ", result = " + Arrays.toString(strArr) + ", resultData = " + jSONObject);
return i;
}
i = 5099;
if (inputStream2 != null) {
}
if (a != null) {
}
bn.b("AccountService", "getQT() returns " + i + ", result = " + Arrays.toString(strArr) + ", resultData = " + jSONObject);
return i;
}
public static int a(String str, JSONObject jSONObject) {
InputStream inputStream = null;
bn.b("AccountService", "getUserInfo() called");
int i = 5099;
com.qihoo.accountcenter.b a = com.qihoo.accountcenter.b.a((String) null);
HttpGet httpGet = new HttpGet(g.a());
httpGet.setHeader(VolleyHttpClient.HEADER_CONTENT_TYPE, VolleyHttpClient.HEADER_CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENCODED);
httpGet.setHeader("Charset", "UTF8");
httpGet.setHeader("Cookie", str);
try {
try {
HttpResponse execute = a.execute(httpGet);
if (execute.getStatusLine().getStatusCode() == 200) {
inputStream = execute.getEntity().getContent();
JSONObject jSONObject2 = new JSONObject(a(new String(a(inputStream), "UTF8"), execute));
int i2 = jSONObject2.getInt("errno");
if (i2 == 0) {
JSONObject optJSONObject = jSONObject2.optJSONObject("data");
if (optJSONObject != null) {
i = 0;
jSONObject.put("details", optJSONObject);
}
} else {
i = i2;
}
}
} catch (Exception e2) {
bn.c("AccountService", "getUserInfo failed.", e2);
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e3) {
e3.printStackTrace();
}
}
if (a != null) {
a.a();
}
}
bn.b("AccountService", "getUserInfo() returns " + i + ", resultData = " + jSONObject);
return i;
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e4) {
e4.printStackTrace();
}
}
if (a != null) {
a.a();
}
}
}
public int a(String str, String[] strArr, JSONObject jSONObject) {
Exception exc;
int i;
HttpResponse execute;
bn.b("AccountService", "registerByNameOrEmail() called");
strArr[0] = getString(o.unknown_error_name_or_email);
com.qihoo.accountcenter.b a = com.qihoo.accountcenter.b.a((String) null);
HttpGet httpGet = new HttpGet(str);
httpGet.setHeader(VolleyHttpClient.HEADER_CONTENT_TYPE, VolleyHttpClient.HEADER_CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENCODED);
httpGet.setHeader("Charset", "UTF8");
try {
try {
execute = a.execute(httpGet);
} finally {
if (a != null) {
a.a();
}
}
} catch (Exception e2) {
exc = e2;
i = 5099;
}
if (execute.getStatusLine().getStatusCode() == 200) {
JSONObject jSONObject2 = new JSONObject(a(new String(a(execute.getEntity().getContent()), "UTF8"), execute));
int i2 = jSONObject2.getInt("errno");
if (i2 == 0) {
String str2 = "";
Header[] headers = execute.getHeaders("set-cookie");
for (Header header : headers) {
String value = header.getValue();
int indexOf = value.indexOf("Q=");
if (indexOf < 0) {
indexOf = value.indexOf("T=");
}
if (indexOf >= 0) {
str2 = str2.concat(value.substring(indexOf, value.indexOf(ApplicationConfig.LIST_TO_STRING_SEPARATOR, indexOf) + 1));
}
}
JSONObject optJSONObject = jSONObject2.optJSONObject("data");
if (optJSONObject != null) {
jSONObject.put("fields", optJSONObject);
jSONObject.put("qid", optJSONObject.optLong("qid"));
}
if (!TextUtils.isEmpty(str2)) {
try {
jSONObject.put("qt", str2.substring(0, str2.length() - 1));
i = 0;
} catch (Exception e3) {
i = 0;
exc = e3;
bn.c("AccountService", "getQT failed.", exc);
if (a != null) {
a.a();
}
return i;
}
}
} else {
try {
strArr[0] = jSONObject2.optString("errmsg");
if (TextUtils.isEmpty(strArr[0])) {
strArr[0] = getString(o.fail_name_or_email_reg_fial);
}
i = i2;
} catch (Exception e4) {
exc = e4;
i = i2;
bn.c("AccountService", "getQT failed.", exc);
if (a != null) {
}
return i;
}
}
return i;
}
i = 5099;
return i;
}
public int b(String str, int i, String[] strArr, JSONObject jSONObject) {
HttpResponse execute;
bn.b("AccountService", "registerBySMSNoPwd() called");
int i2 = 5099;
strArr[0] = getString(o.unknown_error_mobile);
HttpGet httpGet = new HttpGet(str);
httpGet.setHeader(VolleyHttpClient.HEADER_CONTENT_TYPE, VolleyHttpClient.HEADER_CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENCODED);
httpGet.setHeader("Charset", "UTF8");
long currentTimeMillis = System.currentTimeMillis();
long j = currentTimeMillis;
while (true) {
if (j - currentTimeMillis >= 60000) {
break;
}
com.qihoo.accountcenter.b bVar = null;
InputStream inputStream = null;
try {
try {
bVar = com.qihoo.accountcenter.b.a((String) null);
execute = bVar.execute(httpGet);
} catch (Throwable th) {
th = th;
}
if (execute.getStatusLine().getStatusCode() != 200) {
if (0 != 0) {
try {
inputStream.close();
} catch (IOException e2) {
e2.printStackTrace();
}
}
if (bVar != null) {
bVar.a();
}
} else {
inputStream = execute.getEntity().getContent();
String a = a(new String(a(inputStream), "UTF8"), execute);
if (!TextUtils.isEmpty(a)) {
JSONObject jSONObject2 = new JSONObject(a);
bn.b("AccountService", "registerBySMS loop check result, responedStr = " + a);
i2 = jSONObject2.optInt("errno", 5099);
if (i2 != 0) {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e3) {
e3.printStackTrace();
}
}
if (bVar != null) {
bVar.a();
}
} else {
JSONObject optJSONObject = jSONObject2.optJSONObject("data");
i2 = optJSONObject.optInt("errno", 5099);
String optString = optJSONObject.optString("isregsucc");
if (i2 == 0 && "yes".equals(optString)) {
jSONObject.put("account", optJSONObject.optString("mobile"));
jSONObject.put("qid", optJSONObject.optLong("qid"));
String concat = "Q=".concat(URLEncoder.encode(optJSONObject.optString("q"), "UTF8")).concat(ApplicationConfig.LIST_TO_STRING_SEPARATOR).concat("T=").concat(URLEncoder.encode(optJSONObject.optString("t"), "UTF8"));
jSONObject.put("qt", concat);
i2 = a(concat, jSONObject);
if (i2 == 0) {
jSONObject.put("randpwd", optJSONObject.optString("randpwd"));
jSONObject.put("tmptoken", optJSONObject.optString("tmptoken"));
jSONObject.put("randcode", optJSONObject.optString("randcode"));
jSONObject.put("mobile", optJSONObject.optString("mobile"));
jSONObject.put("REG_ACCOUNT_ALREADY_EXIST", false);
}
jSONObject.put("fields", jSONObject2);
strArr[0] = getString(o.succeed_register);
bn.a("AccountService", "registerBySmsNoPwd 注册成功 将详细数据返回");
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e4) {
e4.printStackTrace();
}
}
if (bVar != null) {
bVar.a();
}
} else if (i2 == 1037 && "no".equals(optString)) {
String optString2 = optJSONObject.optString("mobile");
String optString3 = optJSONObject.optString("tmptoken");
Object optString4 = optJSONObject.optString("randcode");
String a2 = a(optString2, optString3);
bn.a("AccountService", "resultCode == RESULT_CODE_ACCOUNT_ALREADY_EXIST, genLoginByTempToken url = " + a2);
int b = b(a2, new String[2], jSONObject);
try {
i2 = a(jSONObject.optString("qt"), jSONObject);
if (i2 == 0) {
strArr[0] = getString(o.succeed_login);
}
jSONObject.put("mobile", optString2);
jSONObject.put("account", optString2);
jSONObject.put("tmptoken", optString3);
jSONObject.put("randcode", optString4);
jSONObject.put("REG_ACCOUNT_ALREADY_EXIST", true);
if (TextUtils.isEmpty(jSONObject.optString("fields"))) {
jSONObject.put("fields", jSONObject2);
}
bn.a("AccountService", "registerBySmsNoPwd 注册用户已存在 将详细数据返回");
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e5) {
e5.printStackTrace();
}
}
if (bVar != null) {
bVar.a();
}
} catch (Throwable th2) {
i2 = b;
th = th2;
bn.c("AccountService", "failed in registerBySmsNoPwd", th);
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e6) {
e6.printStackTrace();
}
}
if (bVar != null) {
bVar.a();
}
synchronized (this) {
}
}
} else if (i2 != 1020302) {
strArr[0] = jSONObject2.optString("errmsg");
bn.a("AccountService", "registerBySmsNoPwd 内层errno不是ongoing 停止轮询");
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e7) {
e7.printStackTrace();
}
}
if (bVar != null) {
bVar.a();
}
} else {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e8) {
e8.printStackTrace();
}
}
if (bVar != null) {
bVar.a();
}
synchronized (this) {
try {
wait(5000L);
} catch (Exception e9) {
e9.printStackTrace();
}
}
j = System.currentTimeMillis();
}
}
}
}
} finally {
if (0 != 0) {
try {
inputStream.close();
} catch (IOException e10) {
e10.printStackTrace();
}
}
if (0 != 0) {
bVar.a();
}
}
}
bn.b("AccountService", "registerBySMSNoPwd() resultCode = " + i2 + ", result = " + Arrays.toString(strArr) + ", resultData = " + jSONObject);
return i2;
}
public int a(String str, int i, String[] strArr, JSONObject jSONObject) {
bn.b("AccountService", "registerBySMS() called");
int i2 = 5099;
strArr[0] = getString(o.unknown_error_mobile);
HttpGet httpGet = new HttpGet(str);
httpGet.setHeader(VolleyHttpClient.HEADER_CONTENT_TYPE, VolleyHttpClient.HEADER_CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENCODED);
httpGet.setHeader("Charset", "UTF8");
long currentTimeMillis = System.currentTimeMillis();
long j = currentTimeMillis;
while (true) {
if (j - currentTimeMillis >= 60000) {
break;
}
com.qihoo.accountcenter.b bVar = null;
InputStream inputStream = null;
try {
try {
com.qihoo.accountcenter.b a = com.qihoo.accountcenter.b.a((String) null);
HttpResponse execute = a.execute(httpGet);
if (execute.getStatusLine().getStatusCode() == 200) {
inputStream = execute.getEntity().getContent();
String a2 = a(new String(a(inputStream), "UTF8"), execute);
JSONObject jSONObject2 = new JSONObject(a2);
bn.b("AccountService", "registerBySMS loop check result, responedStr = " + a2);
if (jSONObject2.has("errno")) {
i2 = jSONObject2.optInt("errno", 5099);
if (i2 == 0) {
JSONObject jSONObject3 = jSONObject2.getJSONObject("data");
i2 = jSONObject3.optInt("errno", 5099);
if (i2 == 0) {
jSONObject.put("account", jSONObject3.optString("mobile"));
jSONObject.put("qid", jSONObject3.optLong("qid"));
jSONObject.put("qt", "Q=".concat(URLEncoder.encode(jSONObject3.optString("q"), "UTF8")).concat(ApplicationConfig.LIST_TO_STRING_SEPARATOR).concat("T=").concat(URLEncoder.encode(jSONObject3.optString("t"), "UTF8")));
jSONObject.put("fields", jSONObject3);
bn.a("AccountService", "registerBySMS 将详细数据返回");
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e2) {
e2.printStackTrace();
}
}
if (a != null) {
a.a();
}
} else if (i2 != 1020302) {
strArr[0] = jSONObject3.optString("errmsg");
bn.a("AccountService", "registerBySMS 内层失败原因,直接返回");
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e3) {
e3.printStackTrace();
}
}
if (a != null) {
a.a();
}
}
} else {
strArr[0] = jSONObject2.optString("errmsg");
bn.a("AccountService", "registerBySMS 外层失败原因,直接返回");
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e4) {
e4.printStackTrace();
}
}
if (a != null) {
a.a();
}
}
} else {
JSONObject jSONObject4 = jSONObject2.getJSONObject("ret");
i2 = jSONObject4.optInt("regist_errno", 5099);
if (i2 == 0) {
jSONObject.put("account", jSONObject4.optString("mobile_phone_number"));
jSONObject.put("qid", jSONObject4.optLong("qid"));
jSONObject.put("qt", "Q=".concat(URLEncoder.encode(jSONObject4.optString("q"), "UTF8")).concat(ApplicationConfig.LIST_TO_STRING_SEPARATOR).concat("T=").concat(URLEncoder.encode(jSONObject4.optString("t"), "UTF8")));
bn.a("AccountService", "registerBySMS 开放平台老接口, resultCode == RESULT_CODE_SUCCEED");
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e5) {
e5.printStackTrace();
}
}
if (a != null) {
a.a();
}
} else if (i2 != 9999) {
if (jSONObject4.optString("mobile_phone_number") != null) {
jSONObject.put("account", jSONObject4.optString("mobile_phone_number"));
}
strArr[0] = getString(o.fail_sms_reg_fail);
bn.a("AccountService", "registerBySMS 开放平台老接口, 注册失败");
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e6) {
e6.printStackTrace();
}
}
if (a != null) {
a.a();
}
}
}
}
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e7) {
e7.printStackTrace();
}
}
if (a != null) {
a.a();
}
} catch (Exception e8) {
bn.c("AccountService", "getQT failed.", e8);
if (0 != 0) {
try {
inputStream.close();
} catch (IOException e9) {
e9.printStackTrace();
}
}
if (0 != 0) {
bVar.a();
}
}
synchronized (this) {
try {
wait(5000L);
} catch (Exception e10) {
e10.printStackTrace();
}
}
j = System.currentTimeMillis();
} catch (Throwable th) {
if (0 != 0) {
try {
inputStream.close();
} catch (IOException e11) {
e11.printStackTrace();
}
}
if (0 != 0) {
bVar.a();
}
throw th;
}
}
bn.b("AccountService", "registerBySMS() resultCode = " + i2 + ", result = " + Arrays.toString(strArr) + ", resultData = " + jSONObject);
return i2;
}
public int a(String str, String str2, String[] strArr, JSONObject jSONObject) {
int i;
Exception exc;
String str3 = null;
bn.b("AccountService", "registerByTry() called");
int i2 = 5099;
strArr[0] = getString(o.unknown_error_try);
com.qihoo.accountcenter.b a = com.qihoo.accountcenter.b.a((String) null);
HttpGet httpGet = new HttpGet(str2);
httpGet.setHeader(VolleyHttpClient.HEADER_CONTENT_TYPE, VolleyHttpClient.HEADER_CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENCODED);
httpGet.setHeader("Charset", "UTF8");
if (!TextUtils.isEmpty(str)) {
httpGet.setHeader("Cookie", str);
}
try {
try {
HttpResponse execute = a.execute(httpGet);
if (execute.getStatusLine().getStatusCode() == 200) {
JSONObject jSONObject2 = new JSONObject(a(new String(a(execute.getEntity().getContent()), "UTF8"), execute));
jSONObject.put("account", jSONObject2.optString("name"));
jSONObject.put("qid", jSONObject2.optLong("id"));
jSONObject.put("is_register", jSONObject2.optString("is_register"));
Header[] headers = execute.getHeaders("set-cookie");
int i3 = 0;
while (true) {
if (i3 >= headers.length) {
break;
}
String value = headers[i3].getValue();
int indexOf = value.indexOf("try_id=");
if (indexOf < 0) {
i3++;
} else {
str3 = value.substring(indexOf, value.indexOf(ApplicationConfig.LIST_TO_STRING_SEPARATOR, indexOf));
break;
}
}
if (!TextUtils.isEmpty(str3)) {
try {
jSONObject.put("qt", str3);
i2 = 0;
} catch (Exception e2) {
exc = e2;
i = 0;
bn.c("AccountService", "getQT failed.", exc);
if (a != null) {
a.a();
}
return i;
}
}
JSONObject jSONObject3 = new JSONObject();
jSONObject3.put("head_pic", jSONObject2.optString("avatar"));
jSONObject.put("fields", jSONObject3);
i = i2;
} else {
strArr[0] = getString(o.fail_try_reg_fail);
i = 99110;
}
} catch (Exception e3) {
i = 5099;
exc = e3;
}
return i;
} finally {
if (a != null) {
a.a();
}
}
}
private static String[] a(Context context, int i, String str) {
String[] strArr = null;
bn.b("AccountService", "getPublicKey() called");
PackageManager packageManager = context.getPackageManager();
String[] packagesForUid = packageManager.getPackagesForUid(i);
int length = packagesForUid.length;
int i2 = 0;
while (true) {
if (i2 >= length) {
str = null;
break;
}
if (str.equalsIgnoreCase(packagesForUid[i2])) {
break;
}
i2++;
}
if (TextUtils.isEmpty(str)) {
return null;
}
try {
PackageInfo packageInfo = packageManager.getPackageInfo(str, 64);
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
int length2 = packageInfo.signatures.length;
String[] strArr2 = new String[length2];
for (int i3 = 0; i3 < length2; i3++) {
try {
strArr2[i3] = a(((X509Certificate) certificateFactory.generateCertificate(new ByteArrayInputStream(packageInfo.signatures[i3].toByteArray()))).getPublicKey().getEncoded());
} catch (PackageManager.NameNotFoundException e2) {
strArr = strArr2;
e = e2;
e.printStackTrace();
return strArr;
} catch (CertificateException e3) {
strArr = strArr2;
e = e3;
e.printStackTrace();
return strArr;
}
}
return strArr2;
} catch (PackageManager.NameNotFoundException e4) {
e = e4;
} catch (CertificateException e5) {
e = e5;
}
}
private static String a(byte[] bArr) {
try {
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
messageDigest.update(bArr);
return b(messageDigest.digest());
} catch (NoSuchAlgorithmException e2) {
e2.printStackTrace();
return null;
}
}
private static String b(byte[] bArr) {
char[] cArr = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
StringBuilder sb = new StringBuilder(bArr.length * 2);
for (int i = 0; i < bArr.length; i++) {
sb.append(cArr[(bArr[i] & 240) >>> 4]);
sb.append(cArr[bArr[i] & 15]);
}
return sb.toString();
}
public static com.qihoo360.accounts.b.a a(Context context) {
AccountService accountService;
com.qihoo360.accounts.b.a aVar;
com.qihoo360.accounts.b.a b = x.a().b();
if (b == null) {
if (context == null || !(context instanceof AccountService)) {
accountService = null;
} else {
accountService = (AccountService) context;
if (accountService.a != null) {
return accountService.a;
}
}
if (Looper.myLooper() == Looper.getMainLooper()) {
aVar = new com.qihoo360.accounts.b.a(context);
} else {
if (accountService == null) {
return null;
}
try {
CountDownLatch countDownLatch = new CountDownLatch(1);
Message.obtain(accountService.b, 4562, countDownLatch).sendToTarget();
if (countDownLatch.await(3000L, TimeUnit.MILLISECONDS)) {
aVar = accountService.a;
if (aVar != null) {
int i = 0;
while (i < 10) {
try {
int a = aVar.a();
if (a == 2 || a == 3) {
break;
}
int i2 = i + 1;
try {
Thread.currentThread();
Thread.sleep(100L);
} catch (InterruptedException e2) {
e2.printStackTrace();
}
i = i2;
} catch (Exception e3) {
}
}
}
} else {
aVar = b;
}
} catch (Exception e4) {
aVar = b;
}
}
return aVar;
}
return b;
}
public static boolean a(Context context, List list) {
com.qihoo360.accounts.b.a a;
if (list == null) {
return false;
}
try {
a = a(context);
} catch (Exception e2) {
e2.printStackTrace();
}
if (a == null) {
return false;
}
QihooAccount[] b = a.b();
QihooAccount[] a2 = b != null ? com.qihoo360.accounts.sso.cli.c.a(b) : b;
if (a2 != null) {
int i = 0;
for (QihooAccount qihooAccount : a2) {
i++;
list.add(qihooAccount.a());
}
}
return true;
}
public static JSONObject a(Context context, int i) {
SQLiteDatabase sQLiteDatabase;
String[] strArr;
String str;
String str2;
Cursor cursor = null;
JSONObject jSONObject = new JSONObject();
String valueOf = i > 0 ? String.valueOf(i) : null;
String str3 = new String();
HashSet hashSet = new HashSet();
try {
SQLiteDatabase writableDatabase = new com.qihoo.accountcenter.a(context).getWritableDatabase();
try {
strArr = c.d;
cursor = writableDatabase.query("account", strArr, "account_type!=0", null, null, null, "login_time DESC, qid DESC", valueOf);
if (cursor == null || !cursor.moveToFirst()) {
str = str3;
} else {
String string = cursor.getString(0);
hashSet.add(string);
while (cursor.moveToNext()) {
String string2 = cursor.getString(0);
if (!hashSet.contains(string2)) {
hashSet.add(string2);
string = string.concat(ApplicationConfig.LIST_TO_STRING_SEPARATOR + string2);
}
}
str = string;
}
ArrayList<String> arrayList = new ArrayList();
if (a(context, arrayList)) {
for (String str4 : arrayList) {
if (hashSet.contains(str4)) {
str2 = str;
} else {
hashSet.add(str4);
str2 = TextUtils.isEmpty(str) ? str.concat(str4) : str.concat(ApplicationConfig.LIST_TO_STRING_SEPARATOR + str4);
}
str = str2;
}
}
jSONObject.put("account", str);
if (cursor != null) {
try {
cursor.close();
} catch (Exception e2) {
}
}
if (writableDatabase != null) {
try {
writableDatabase.close();
} catch (Exception e3) {
}
}
} catch (Exception e4) {
sQLiteDatabase = writableDatabase;
e = e4;
try {
bn.b("AccountService", "queryUserList failed.", e);
if (cursor != null) {
try {
cursor.close();
} catch (Exception e5) {
}
}
if (sQLiteDatabase != null) {
try {
sQLiteDatabase.close();
} catch (Exception e6) {
}
}
return jSONObject;
} catch (Throwable th) {
th = th;
if (cursor != null) {
try {
cursor.close();
} catch (Exception e7) {
}
}
if (sQLiteDatabase != null) {
throw th;
}
try {
sQLiteDatabase.close();
throw th;
} catch (Exception e8) {
throw th;
}
}
} catch (Throwable th2) {
sQLiteDatabase = writableDatabase;
th = th2;
if (cursor != null) {
}
if (sQLiteDatabase != null) {
}
}
} catch (Exception e9) {
e = e9;
sQLiteDatabase = null;
} catch (Throwable th3) {
th = th3;
sQLiteDatabase = null;
}
return jSONObject;
}
public static JSONArray b(Context context) {
Cursor cursor;
Cursor cursor2;
SQLiteDatabase sQLiteDatabase;
SQLiteDatabase sQLiteDatabase2 = null;
try {
JSONArray jSONArray = new JSONArray();
SQLiteDatabase writableDatabase = new com.qihoo.accountcenter.a(context).getWritableDatabase();
try {
cursor = writableDatabase.query("account", c.a, "account_type!=0", null, null, null, "login_time DESC, qid DESC");
if (cursor == null) {
if (cursor != null) {
try {
cursor.close();
} catch (Exception e2) {
}
}
if (writableDatabase != null) {
try {
writableDatabase.close();
} catch (Exception e3) {
}
}
return null;
}
try {
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
String string = cursor.getString(0);
String string2 = cursor.getString(2);
if (!TextUtils.isEmpty(string) && !TextUtils.isEmpty(string2)) {
String str = new String(com.qihoo.utils.d.b.b(Base64.decode(string2, 0)));
JSONObject jSONObject = new JSONObject();
jSONObject.put("account", string);
jSONObject.put("qt", str);
jSONArray.put(jSONObject);
}
cursor.moveToNext();
}
if (cursor != null) {
try {
cursor.close();
} catch (Exception e4) {
}
}
if (writableDatabase != null) {
try {
writableDatabase.close();
} catch (Exception e5) {
}
}
return jSONArray;
} catch (Exception e6) {
sQLiteDatabase = writableDatabase;
cursor2 = cursor;
if (cursor2 != null) {
try {
cursor2.close();
} catch (Exception e7) {
}
}
if (sQLiteDatabase != null) {
try {
sQLiteDatabase.close();
} catch (Exception e8) {
}
}
return null;
} catch (Throwable th) {
sQLiteDatabase2 = writableDatabase;
th = th;
if (cursor != null) {
try {
cursor.close();
} catch (Exception e9) {
}
}
if (sQLiteDatabase2 == null) {
throw th;
}
try {
sQLiteDatabase2.close();
throw th;
} catch (Exception e10) {
throw th;
}
}
} catch (Exception e11) {
sQLiteDatabase = writableDatabase;
cursor2 = null;
} catch (Throwable th2) {
cursor = null;
sQLiteDatabase2 = writableDatabase;
th = th2;
}
} catch (Exception e12) {
cursor2 = null;
sQLiteDatabase = null;
} catch (Throwable th3) {
th = th3;
cursor = null;
}
}
private static String a(String str, HttpResponse httpResponse) {
try {
new JSONObject(str);
return str;
} catch (JSONException e2) {
Header firstHeader = httpResponse.getFirstHeader("From");
if (firstHeader != null) {
String value = firstHeader.getValue();
bn.b("AccountService", "preDes header from=" + value);
for (int i = 0; i < d.length; i++) {
if (value.equals(d[i])) {
return g.d(str, e[i]);
}
}
return str;
}
return str;
}
}
public static void a(Context context, int i, String str, String str2, String str3) {
String[] strArr;
bn.b("AccountService", "saveAccountToDb logintype:" + i + ",account:" + str + ",qid:" + str2 + ",qt:" + str3);
try {
SQLiteDatabase writableDatabase = new com.qihoo.accountcenter.a(context).getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put("pkg_name", context.getPackageName());
String b = com.qihoo360.accounts.b.a.b(str3);
contentValues.put("qt", b);
bn.b("AccountService", "saveAccountToDb encryptQt:" + b);
contentValues.put("login_time", Long.valueOf(System.currentTimeMillis()));
Cursor query = writableDatabase.query("account", c.a, null, null, null, null, "login_time DESC, qid DESC");
try {
try {
if (query.getCount() > 0) {
writableDatabase.delete("account", "account=? AND account_type!=0", new String[]{str});
}
} finally {
if (query != null) {
query.close();
}
}
} catch (Exception e2) {
e2.printStackTrace();
if (query != null) {
query.close();
}
}
contentValues.put("account", str);
int i2 = 4;
if (i == 1) {
i2 = 1;
} else if (i == 2) {
i2 = 2;
}
contentValues.put("account_type", Integer.valueOf(i2));
strArr = c.c;
Cursor query2 = writableDatabase.query("account", strArr, "qid=?", new String[]{str2}, null, null, null);
if (query2 != null) {
try {
try {
if (query2.getCount() > 0) {
writableDatabase.update("account", contentValues, "qid=?", new String[]{str2});
if (query2 != null) {
query2.close();
}
writableDatabase.close();
}
} catch (Exception e3) {
e3.printStackTrace();
if (query2 != null) {
query2.close();
}
writableDatabase.close();
return;
}
} catch (Throwable th) {
if (query2 != null) {
query2.close();
}
writableDatabase.close();
throw th;
}
}
contentValues.put("qid", str2);
writableDatabase.insert("account", null, contentValues);
if (query2 != null) {
}
writableDatabase.close();
} catch (Exception e4) {
}
}
public static int a(Context context, String str) {
return b(context, context.getPackageName(), str, "appKey", new String[2], false);
}
}