() {{
+ this.add("com.uiui.sn");
+ this.add("com.uiui.appstore");
+ this.add("com.uiui.browser");
+ this.add("com.uiui.videoplayer");
+ }};
+}
diff --git a/app/src/main/java/com/xwad/os/utils/LenovoCsdkUtil.java b/app/src/main/java/com/xwad/os/utils/LenovoCsdkUtil.java
deleted file mode 100644
index 2b9a141..0000000
--- a/app/src/main/java/com/xwad/os/utils/LenovoCsdkUtil.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package com.xwad.os.utils;
-
-import android.annotation.SuppressLint;
-import android.app.csdk.CSDKManager;
-import android.content.Context;
-import android.util.Log;
-
-import com.tencent.mmkv.MMKV;
-import com.xwad.os.BuildConfig;
-import com.xwad.os.config.CommonConfig;
-
-public class LenovoCsdkUtil {
- private static final String TAG = "LenovoCsdkUtil";
-
- @SuppressLint("StaticFieldLeak")
- private static LenovoCsdkUtil sInstance;
- private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
- private Context mContext;
- private CSDKManager mCSDKManager;
-
-
- private LenovoCsdkUtil(Context context) {
- if (context == null) {
- throw new RuntimeException("Context is NULL");
- }
- this.mContext = context;
- try {
- this.mCSDKManager = new CSDKManager(context);
- if (mCSDKManager.isLicenseKeyEnabled(BuildConfig.APPLICATION_ID)) {
- Log.e(TAG, "LenovoCsdkUtil: devices activated");
- } else {
- Log.e(TAG, "LenovoCsdkUtil: devices not activated");
- }
- } catch (Exception e) {
- Log.e(TAG, "LenovoCsdkUtil: " + e.getMessage());
- }
-
- }
-
- public static void init(Context context) {
- if (sInstance == null) {
- Log.e(TAG, "init: ");
- sInstance = new LenovoCsdkUtil(context);
- }
- }
-
- public static LenovoCsdkUtil getInstance() {
- if (sInstance == null) {
- throw new IllegalStateException("You must be init LenovoCsdkUtil first");
- }
- return sInstance;
- }
-
- /**
- * int: 1 MAC
- * int: 2 SN
- * int: 3 Model
- * int: 4 IMEI
- */
- public String getDeviceMac() {
- String mac = mCSDKManager.getDeviceInfo(1);
- return mac;
- }
-
-// public String getSerial() {
-// if (BuildConfig.DEBUG) {
-// return "T811MN128GB23529041363";
-// }
-// String sn = mCSDKManager.getDeviceInfo(2);
-// return sn;
-// }
-
- public String getDeviceModel() {
- String model = mCSDKManager.getDeviceInfo(3);
- return model;
- }
-
- public String getDeviceIMEI() {
- String imei = mCSDKManager.getDeviceInfo(4);
- return imei;
- }
-
-}
diff --git a/app/src/main/java/com/xwad/os/utils/Utils.java b/app/src/main/java/com/xwad/os/utils/Utils.java
index 2835af7..6c26aad 100644
--- a/app/src/main/java/com/xwad/os/utils/Utils.java
+++ b/app/src/main/java/com/xwad/os/utils/Utils.java
@@ -1,5 +1,6 @@
package com.xwad.os.utils;
+import android.Manifest;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
@@ -13,14 +14,18 @@ import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
+import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
import android.os.BatteryManager;
import android.os.Build;
import android.os.Environment;
import android.os.PowerManager;
+import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.WindowManager;
+import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import com.google.zxing.BarcodeFormat;
@@ -33,8 +38,10 @@ import com.xwad.os.BuildConfig;
import com.xwad.os.R;
import com.xwad.os.manager.RemoteManager;
+import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
+import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.Reader;
@@ -43,11 +50,58 @@ import java.net.NetworkInterface;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
public class Utils {
private static final String TAG = "Utils";
+ /**
+ * 判断MagicOS 版本
+ * https://developer.honor.com/cn/docs/adaptation_guide/guides/general_adaptation_guide
+ *
+ * @return
+ */
+ public static int getMagicOsVersion() {
+ if (!isHonorDevice()) {
+ // 非荣耀设备,暂不支持
+ return -1;
+ }
+ // Android S及以上版本取用MAGIC_SDK_INT值
+ if (Build.VERSION.SDK_INT >= 31) {
+ return com.hihonor.android.os.Build.VERSION.MAGIC_SDK_INT;
+ }
+ // Android R版本对应MagicUI 5.0
+ if (Build.VERSION.SDK_INT == 30) {
+ return 31;
+ }
+ // Android Q版本对应MagicUI 4.0
+ if (Build.VERSION.SDK_INT == 29) {
+ return 26;
+ }
+ // Android Q以下版本返回-1
+ return -1;
+ }
+
+ /**
+ * @return 判定荣耀折叠屏设备
+ */
+ public static boolean isHonorFoldableDevice(Context context) {
+ if (Build.MANUFACTURER.equalsIgnoreCase("HONOR")
+ && context.getPackageManager() != null
+ && context.getPackageManager().hasSystemFeature("com.hihonor.hardware.sensor.posture")) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @return 判定荣耀设备
+ */
+ public static boolean isHonorDevice() {
+ return "HONOR".equalsIgnoreCase(Build.MANUFACTURER);
+ }
+
/**
* 获取设备序列号
*
@@ -76,6 +130,8 @@ public class Utils {
// }
// return serial;
// }
+
+
public static String getAndroiodScreenProperty(Context context) {
Log.e("getAndroiodScreenProperty", "heightPixels:" + context.getResources().getDisplayMetrics().heightPixels);
Log.e("getAndroiodScreenProperty", "widthPixels:" + context.getResources().getDisplayMetrics().widthPixels);
@@ -102,16 +158,179 @@ public class Utils {
return width + "×" + height;
}
- public static String getDeviceSN() {
- String serial = null;
+ /**
+ * @return 序列号
+ */
+ public static String getSerial(Context context) {
+ String serialNumber = "unknow";
try {
- Class> c = Class.forName("android.os.SystemProperties");
- Method get = c.getMethod("get", String.class);
- serial = (String) get.invoke(c, "persist.sys.hrSerial");
+ if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {//9.0+
+ serialNumber = Build.getSerial();
+ } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N) {//8.0+
+ serialNumber = Build.SERIAL;
+ } else {//8.0-
+ Class> c = Class.forName("android.os.SystemProperties");
+ Method get = c.getMethod("get", String.class);
+ serialNumber = (String) get.invoke(c, "ro.serialno");
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ Log.e("getSerial", "读取设备序列号异常:" + e.toString());
+ }
+ return serialNumber;
+ }
+
+ public static String getSerial() {
+ String serialNumber = "unknow";
+ try {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {//9.0+
+ serialNumber = Build.getSerial();
+ } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N) {//8.0+
+ serialNumber = Build.SERIAL;
+ } else {//8.0-
+ Class> c = Class.forName("android.os.SystemProperties");
+ Method get = c.getMethod("get", String.class);
+ serialNumber = (String) get.invoke(c, "ro.serialno");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ Log.e("getSerial", "读取设备序列号异常:" + e.toString());
+ }
+ return serialNumber;
+ }
+
+ /**
+ * @param context 获取真实的MAC地址
+ * @return
+ */
+ public static String getAndroid10MAC(Context context) {
+// if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1) {
+// return getMacAddress(context);
+// } else {
+// return getAndroid7MAC();
+// }
+ return getAllMacAddress(context);
+ }
+
+ /**
+ * 获取MAC地址
+ *
+ * @param context
+ * @return
+ */
+ public static String getAllMacAddress(Context context) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
+ return getMacDefault(context);
+ } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
+ return getMacAddressM();
+ } else {
+ return getMacFromHardware();
+ }
+ }
+
+ /**
+ * Android 6.0 之前(不包括6.0)
+ *
+ * @param context
+ * @return
+ */
+ private static String getMacDefault(Context context) {
+ String mac = "未获取到设备Mac地址";
+ if (context == null) {
+ return mac;
+ }
+ WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+ WifiInfo info = null;
+ try {
+ info = wifi.getConnectionInfo();
} catch (Exception e) {
e.printStackTrace();
}
- return serial;
+ if (info == null) {
+ return mac;
+ }
+ mac = info.getMacAddress();
+ if (!TextUtils.isEmpty(mac)) {
+ mac = mac.toUpperCase(Locale.ENGLISH);
+ }
+
+ return mac;
+ }
+
+ /**
+ * Android 6.0(包括) - Android 7.0(不包括)
+ *
+ * @return
+ */
+ private static String getMacAddressM() {
+ String mac = "未获取到设备Mac地址";
+
+ try {
+ mac = new BufferedReader(new FileReader("/sys/class/net/wlan0/address")).readLine();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return mac;
+ }
+
+ /**
+ * 兼容7.0获取不到的问题
+ *
+ * @return
+ */
+ public static String getAndroid7MAC() {
+ try {
+ List all = Collections.list(NetworkInterface.getNetworkInterfaces());
+ for (NetworkInterface nif : all) {
+ if (!nif.getName().equalsIgnoreCase("wlan0"))
+ continue;
+ byte[] macBytes = nif.getHardwareAddress();
+ if (macBytes == null) {
+ return "";
+ }
+ StringBuilder res1 = new StringBuilder();
+ for (byte b : macBytes) {
+ res1.append(String.format("%02X:", b));
+ }
+ if (res1.length() > 0) {
+ res1.deleteCharAt(res1.length() - 1);
+ }
+ return res1.toString();
+ }
+ } catch (Exception ex) {
+ }
+ return "";
+ }
+
+ /**
+ * 遍历循环所有的网络接口,找到接口是 wlan0
+ *
+ * @return
+ */
+ private static String getMacFromHardware() {
+ try {
+ List all = Collections.list(NetworkInterface.getNetworkInterfaces());
+
+ for (NetworkInterface nif : all) {
+ if (!nif.getName().equalsIgnoreCase("wlan0")) {
+ continue;
+ }
+ byte[] macBytes = nif.getHardwareAddress();
+ StringBuilder res1 = new StringBuilder();
+ for (byte b : macBytes) {
+ res1.append(String.format("%02X:", b));
+ }
+ if (res1 != null) {
+ res1.deleteCharAt(res1.length() - 1);
+ }
+ return res1.toString();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return "未获取到设备Mac地址";
}
/**
@@ -352,36 +571,6 @@ public class Utils {
return macSerial;
}
- /**
- * 兼容7.0获取不到的问题
- *
- * @return
- */
- public static String getAndroid7MAC() {
- try {
- List all = Collections.list(NetworkInterface.getNetworkInterfaces());
- for (NetworkInterface nif : all) {
- if (!"wlan0".equalsIgnoreCase(nif.getName()))
- continue;
- byte[] macBytes = nif.getHardwareAddress();
- if (macBytes == null) {
- return "";
- }
- StringBuilder res1 = new StringBuilder();
- for (byte b : macBytes) {
- res1.append(String.format("%02X:", b));
- }
- if (res1.length() > 0) {
- res1.deleteCharAt(res1.length() - 1);
- }
- return res1.toString();
- }
- } catch (Exception ex) {
- Log.e(TAG, "getAndroid7MAC: " + ex.getMessage());
- }
- return "";
- }
-
public static String loadFileAsString(String fileName) throws Exception {
FileReader reader = new FileReader(fileName);
String text = loadReaderAsString(reader);
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 4479411..4e0a2f4 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -25,4 +25,46 @@
许可证验证成功,本账户已可长期使用,\n点击开启学习之旅!
有效期:%d年
二维码过期时间%s
+
+
+ "当前状态:"
+ "当前状态:"
+ "当前状态:"
+ 已禁用
+ 未禁用
+ 已保活
+ 未保活
+ 禁用WiFi
+ 启用WiFi
+ 将该应用保活
+ 取消该应用保活
+ 启用截屏
+ 禁用截屏
+ 启用数据连接
+ 该应用未激活
+ 无操作权限
+ 本应用只支持MAGIC4及以上的版本
+ 取消激活后将导致本软件的部分功能无法正常工作,您确定要取消激活么?
+ 同意
+ 退出
+ 已阅读
+ 不再提示
+ 免责声明与软件许可协议
+ 权限使用声明
+ 若您点击同意并开始使用本软件,代表您已阅读并接受《免责声明与软件许可协议》。
+ 请选择以下模式中的一种进行设备管理器的激活。
+ 用户确认激活模式即普通的激活方式,激活后用户可随时解除激活。
+ 强制激活模式只在企业定制版本(通过荣耀商城企业定制服务进行定制的终端版本)上生效,用户只能点击激活,激活成功后无法手动解除激活。
+ 延时解除激活模式请先输入延迟时间(范围在1~72的数字),激活成功后用户在设定的延迟时间(单位:小时)过后才能解除激活设备管理器。
+ 用户确认激活模式
+ 强制激活模式
+ 延时解除激活模式
+ 请输入延迟时间,范围:1~72
+ 解除激活设备管理器
+ setForcedActiveDeviceAdmin error
+ setDelayDeactiveDeviceAdmin error
+
+ 为关怀系统提供管控功能,请激活后使用
+ 开启我吧
+
diff --git a/app/src/main/res/xml/device_admin_sample.xml b/app/src/main/res/xml/device_admin_sample.xml
new file mode 100644
index 0000000..5e82553
--- /dev/null
+++ b/app/src/main/res/xml/device_admin_sample.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
index cf2eaba..2835143 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,2 +1,2 @@
include ':app', ':niceimageview', ':FlycoTabLayoutZ_Lib', ':verification-view', ':PhotoPreview'
-rootProject.name='九学王6_5桌面Lenovo'
\ No newline at end of file
+rootProject.name='学王365荣耀'
\ No newline at end of file