提交 6d53d9ea 编写于 作者: lizhongyi_'s avatar lizhongyi_

Merge branch 'dev1' into dev

...@@ -88,7 +88,7 @@ class ScreenFileObserver extends FileObserver { ...@@ -88,7 +88,7 @@ class ScreenFileObserver extends FileObserver {
* 开启截图监听 * 开启截图监听
*/ */
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
export const onUserCaptureScreen : OnUserCaptureScreen = function (callback: (res:UTSJSONObject) => void) { export const onUserCaptureScreen : OnUserCaptureScreen = function (callback : UTSCallback) {
// 检查相关权限是否已经具备 // 检查相关权限是否已经具备
if (ActivityCompat.checkSelfPermission(UTSAndroid.getUniActivity()!, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { if (ActivityCompat.checkSelfPermission(UTSAndroid.getUniActivity()!, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
...@@ -135,7 +135,7 @@ export const onUserCaptureScreen : OnUserCaptureScreen = function (callback: (re ...@@ -135,7 +135,7 @@ export const onUserCaptureScreen : OnUserCaptureScreen = function (callback: (re
/** /**
* 关闭截屏监听 * 关闭截屏监听
*/ */
export const offUserCaptureScreen : OffUserCaptureScreen = function (success: (res: any) => void) { export const offUserCaptureScreen : OffUserCaptureScreen = function (callback : UTSCallback) {
// android 10以上,关闭监听通过移除文件监听器实现 // android 10以上,关闭监听通过移除文件监听器实现
if (screenOB != null) { if (screenOB != null) {
...@@ -144,7 +144,7 @@ export const offUserCaptureScreen : OffUserCaptureScreen = function (success: (r ...@@ -144,7 +144,7 @@ export const offUserCaptureScreen : OffUserCaptureScreen = function (success: (r
} }
lastFileObserverTime = 0; lastFileObserverTime = 0;
success({}); callback({});
} }
/** /**
...@@ -152,7 +152,7 @@ export const offUserCaptureScreen : OffUserCaptureScreen = function (success: (r ...@@ -152,7 +152,7 @@ export const offUserCaptureScreen : OffUserCaptureScreen = function (success: (r
*/ */
export const setUserCaptureScreen : SetUserCaptureScreen = function (option: SetUserCaptureScreenOption) { export const setUserCaptureScreen : SetUserCaptureScreen = function (option: SetUserCaptureScreenOption) {
// 切换到UI线程 // 切换到UI线程
UTSAndroid.getUniActivity()?.runOnUiThread(new SetUserCaptureScreenRunnable(option.open)); UTSAndroid.getUniActivity()?.runOnUiThread(new SetUserCaptureScreenRunnable(option.enable));
const res = new UserCaptureScreenResult(); const res = new UserCaptureScreenResult();
res.errCode = 0; res.errCode = 0;
res.errMsg = "setUserCaptureScreen:ok"; res.errMsg = "setUserCaptureScreen:ok";
...@@ -164,21 +164,21 @@ export const setUserCaptureScreen : SetUserCaptureScreen = function (option: Set ...@@ -164,21 +164,21 @@ export const setUserCaptureScreen : SetUserCaptureScreen = function (option: Set
class SetUserCaptureScreenRunnable extends Runnable { class SetUserCaptureScreenRunnable extends Runnable {
/** /**
* true 表示禁止截屏 * ture: 允许用户截屏
* false 表示允许截屏 * false: 不允许用户截屏,防止用户截屏到应用页面内容
*/ */
private open: boolean = false; private enable: boolean;
constructor(open: boolean) { constructor(enable: boolean) {
super(); super();
this.open = open; this.enable = enable;
} }
override run(): void { override run(): void {
if (this.open) { if (this.enable) {
UTSAndroid.getUniActivity()?.getWindow()?.addFlags(WindowManager.LayoutParams.FLAG_SECURE);
} else {
UTSAndroid.getUniActivity()?.getWindow()?.clearFlags(WindowManager.LayoutParams.FLAG_SECURE); UTSAndroid.getUniActivity()?.getWindow()?.clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
} else {
UTSAndroid.getUniActivity()?.getWindow()?.addFlags(WindowManager.LayoutParams.FLAG_SECURE);
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册