update:2020.09.22
fix:修复强制安装应用为空时缓存了上次的管控信息
add:
This commit is contained in:
2020-09-22 15:18:32 +08:00
parent 63ed572385
commit 48eaf5794e
19 changed files with 619 additions and 166 deletions

View File

@@ -600,6 +600,7 @@ public class ApkUtils {
this.add("com.android.dreams.basic");
this.add("com.android.musicfx");
this.add("com.android.email");
this.add("com.jiaoguanyi.sysc");
}};
public static List<String> show_canremove_systemapp = new ArrayList<String>() {{

View File

@@ -209,5 +209,5 @@ public class Configure {
public static final String SEND_SCREENSHOT = HTTP_TAG_HEAD_NEW + "Screenshot/addImg";
//上传截图
public static final String UPDATE_DEVICEINFO = HTTP_TAG_HEAD_NEW + "Mac/getInfo";
//上传设备信息
//上传我的设备
}

View File

@@ -64,6 +64,7 @@ import com.mjsheng.myappstore.comm.CommonDatas;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
@@ -71,6 +72,7 @@ import java.io.LineNumberReader;
import java.io.Reader;
import java.lang.reflect.Method;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.DecimalFormat;
@@ -84,6 +86,15 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Pattern;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
public class Utils {
@@ -1049,20 +1060,55 @@ public class Utils {
* 屏幕截图
* 适用于lanucher版
*/
public void shotScreen() {
public static void shotScreen(final Context context) {
//adb截图方法
new Thread(new Runnable() {
Observable.create(new ObservableOnSubscribe<Integer>() {
@Override
public void run() {
Log.e("whh0914", "开始屏幕截图...");
String filepath = "/sdcard/screenShot.png";
try {
CmdUtil.execute("screencap -p " + filepath);
} catch (Exception e) {
Log.e("whh0914", "屏幕截图出现异常:" + e.toString());
}
public void subscribe(ObservableEmitter<Integer> e) throws Exception {
String filepath = context.getCacheDir().getAbsolutePath();
long time = System.currentTimeMillis();
int n = CmdUtil.execute("screencap -p " + filepath + File.separator + time + ".db").code;
e.onNext(n);
}
}).start();
}).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<Integer>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Integer integer) {
if (integer == 0) {
Log.e("doss", "成功");
} else {
Log.e("doss", "失败");
}
}
@Override
public void onError(Throwable e) {
Log.e("doss", "Throwable=" + e.getMessage());
}
@Override
public void onComplete() {
}
});
// new Thread(new Runnable() {
// @Override
// public void run() {
// Log.e("whh0914", "开始屏幕截图...");
// String filepath = context.getFileStreamPath("screenshot").getAbsolutePath();
// try {
// CmdUtil.execute("screencap -p " + filepath);
// } catch (Exception e) {
// Log.e("whh0914", "屏幕截图出现异常:" + e.toString());
// }
// }
// }).start();
}
@@ -1131,31 +1177,65 @@ public class Utils {
Log.e("h_bl", "屏幕密度dpi120 / 160 / 240" + densityDpi);
Log.e("h_bl", "屏幕宽度dp" + screenWidth);
Log.e("h_bl", "屏幕高度dp" + screenHeight);
return screenWidth + "×" + screenHeight;
return width + "×" + height;
}
public static String getMacAddress() {
List<NetworkInterface> interfaces = null;
try {
interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
for (NetworkInterface networkInterface : interfaces) {
if (networkInterface != null && TextUtils.isEmpty(networkInterface.getName()) == false) {
if ("wlan0".equalsIgnoreCase(networkInterface.getName())) {
byte[] macBytes = networkInterface.getHardwareAddress();
if (macBytes != null && macBytes.length > 0) {
StringBuilder str = new StringBuilder();
for (byte b : macBytes) {
str.append(String.format("%02X:", b));
}
if (str.length() > 0) {
str.deleteCharAt(str.length() - 1);
}
return str.toString();
}
}
}
}
} catch (SocketException e) {
e.printStackTrace();
}
return "unknown";
}
public static String getIMEI(Context context) {
String IMEI = "unknow";
String IMEI1, IMEI2, IMEI3;
//获取手机设备号
TelephonyManager TelephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
//8.0及以后版本获取
// if (android.os.Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) {
// IMEI1 = TelephonyMgr.getDeviceId();
// } else
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// try {
// Method method = TelephonyMgr.getClass().getMethod("getImei");
// IMEI2 = (String) method.invoke(TelephonyMgr);
// } catch (Exception e) {
// e.printStackTrace();
// Log.e("getIMEI", e.getMessage());
// }
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
IMEI = TelephonyMgr.getDeviceId();
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// try {
// Method method = TelephonyMgr.getClass().getMethod("getImei");
// IMEI = (String) method.invoke(TelephonyMgr);
// } catch (Exception e) {
// e.printStackTrace();
// Log.e("getIMEI", e.getMessage());
// }
// IMEI = TelephonyMgr.getDeviceId();
// } else {//9.0到10.0获取
IMEI = Settings.System.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
}
Log.e("IMEI:", "IMEI: " + IMEI);
return IMEI.toUpperCase();
if (null == IMEI) {
return "-";
} else {
return IMEI.toUpperCase();
}
}
public static String getMachine(Context context) {
@@ -1175,16 +1255,48 @@ public class Utils {
return jsonObject.toJSONString();
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public static String getHardware(Context context) {
JSONObject jsonObject = new JSONObject();
String electric = getBattery(context) + "%";
String charging = String.valueOf(getIsCharging(context));
int electric = getBattery(context);
int charging = getIsCharging(context);
String memory = Formatter.formatFileSize(context, getAvailMemory(context)) + "\t 已用" + "/" + "" + Formatter.formatFileSize(context, getTotalMemory(context));
String storage = getRemnantSize(context) + "/" + getDataTotalSize(context);
// String CPU = ;
int CPU = getNumCores();
JSONObject jsonObject = new JSONObject();
jsonObject.put("electric", electric);
jsonObject.put("charging", charging);
jsonObject.put("memory", memory);
jsonObject.put("storage", storage);
jsonObject.put("CPU", CPU + "");
return jsonObject.toJSONString();
}
private static int getNumCores() {
// Private Class to display only CPU devices in the directory listing
class CpuFilter implements FileFilter {
@Override
public boolean accept(File pathname) {
// Check if filename is "cpu", followed by a single digit number
if (Pattern.matches("cpu[0-9]", pathname.getName())) {
return true;
}
return false;
}
}
try {
// Get directory containing CPU info
File dir = new File("/sys/devices/system/cpu/");
// Filter to only list the devices we care about
File[] files = dir.listFiles(new CpuFilter());
// Return the number of cores (virtual CPU devices)
return files.length;
} catch (Exception e) {
// Default to return 1 core
return 1;
}
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public static int getBattery(Context context) {
try {