feat(base): 集成 MQTT 并添加屏幕状态监听
- 初始化 HiveMQ MQTT 客户端并连接 Broker,订阅命令主题 - 添加屏幕亮灭广播监听,支持上报设备亮屏/熄屏状态 - 新增 MQTT 配置(地址、主题等)及 SystemUtils 屏幕状态查询方法 - 添加 HiveMQ 依赖并配置 ProGuard 混淆规则与打包排除项
This commit is contained in:
@@ -23,6 +23,7 @@ import android.net.wifi.WifiManager;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.os.IBinder;
|
||||
import android.os.PowerManager;
|
||||
import android.os.Process;
|
||||
import android.os.RemoteException;
|
||||
import android.os.UserHandle;
|
||||
@@ -1078,7 +1079,7 @@ public class SystemUtils {
|
||||
|
||||
// 这是一个针对 Android 9/10 的简化逻辑参考:
|
||||
Bitmap bitmap = (Bitmap) surfaceControlClass.getDeclaredMethod("screenshot",
|
||||
Rect.class, Integer.TYPE, Integer.TYPE, Integer.TYPE)
|
||||
Rect.class, Integer.TYPE, Integer.TYPE, Integer.TYPE)
|
||||
.invoke(null, new Rect(), screenWidth, screenHeight, 0);
|
||||
|
||||
return bitmap;
|
||||
@@ -1244,4 +1245,16 @@ public class SystemUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询设备当前屏幕是否亮屏。
|
||||
*/
|
||||
public static boolean isScreenOn(Context context) {
|
||||
try {
|
||||
PowerManager powerManager =
|
||||
(PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
return powerManager != null && powerManager.isInteractive();
|
||||
} catch (Throwable e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user