diff --git a/display/AppScope/app.json b/display/AppScope/app.json index e48d02ec5bb39d1ce182c2f691a46d6a130a9225..aae3daefc31d8471a570b6283bb5ae07dfaf9db0 100644 --- a/display/AppScope/app.json +++ b/display/AppScope/app.json @@ -2,8 +2,8 @@ "app": { "bundleName": "com.ohos.devicemanagerui", "vendor": "example", - "versionCode": 1000048, - "versionName": "1.0.48", + "versionCode": 1000049, + "versionName": "1.0.49", "icon": "$media:app_icon", "label": "$string:app_name", "minAPIVersion": 10, diff --git a/display/entry/src/main/ets/UIExtAbility/ConfirmUIExtAbility.ets b/display/entry/src/main/ets/UIExtAbility/ConfirmUIExtAbility.ets index fee7f67dd8f877536dee28acc101b6104d10b624..62cbaabff70c9e39a45fd27d8b3a7e61f43fdf2c 100644 --- a/display/entry/src/main/ets/UIExtAbility/ConfirmUIExtAbility.ets +++ b/display/entry/src/main/ets/UIExtAbility/ConfirmUIExtAbility.ets @@ -49,6 +49,9 @@ export default class ConfirmUIExtAbility extends UIExtensionAbility { if (want.parameters.title) { AppStorage.setOrCreate('title', want.parameters.title); } + if (want.parameters.metaType != undefined) { + AppStorage.setOrCreate('metaType', want.parameters.metaType); + } let param: Record = { 'session': session diff --git a/display/entry/src/main/ets/UIExtAbility/InputUIExtAbility.ets b/display/entry/src/main/ets/UIExtAbility/InputUIExtAbility.ets index 15a8081dcf0b8c1adbb458e2a8726e667d88682a..db1c7998747fdeb7a030e0e4eaa795b9e8ba9b70 100644 --- a/display/entry/src/main/ets/UIExtAbility/InputUIExtAbility.ets +++ b/display/entry/src/main/ets/UIExtAbility/InputUIExtAbility.ets @@ -27,6 +27,9 @@ export default class InputUIExtAbility extends UIExtensionAbility { if (want.parameters && want.parameters.model) { AppStorage.setOrCreate('model', want.parameters.model); } + if (want.parameters.metaType != undefined) { + AppStorage.setOrCreate('metaType', want.parameters.metaType); + } let param: Record = { 'session': session diff --git a/display/entry/src/main/ets/UIExtAbility/PincodeUIExtAbility.ets b/display/entry/src/main/ets/UIExtAbility/PincodeUIExtAbility.ets index 125515e18d3708fe09f0840c81faa5e203d91d5b..857364cd531e31840c0809245aa617e1180d8b25 100644 --- a/display/entry/src/main/ets/UIExtAbility/PincodeUIExtAbility.ets +++ b/display/entry/src/main/ets/UIExtAbility/PincodeUIExtAbility.ets @@ -24,6 +24,9 @@ export default class InputUIExtAbility extends UIExtensionAbility { if (want.parameters && want.parameters.pinCode) { AppStorage.setOrCreate('pinCode', want.parameters.pinCode); } + if (want.parameters.metaType != undefined) { + AppStorage.setOrCreate('metaType', want.parameters.metaType); + } let param: Record = { 'session': session diff --git a/display/entry/src/main/ets/pages/ConfirmDialog.ets b/display/entry/src/main/ets/pages/ConfirmDialog.ets index 19f1a102c8b717da714abaa05a5d2742e93d2221..e6e5dd350949cfcaac48eaa445f167da05aff0b0 100644 --- a/display/entry/src/main/ets/pages/ConfirmDialog.ets +++ b/display/entry/src/main/ets/pages/ConfirmDialog.ets @@ -25,6 +25,7 @@ import window from '@ohos.window'; let dmClass: deviceManager.DeviceManager | null; let TAG = '[DeviceManagerUI:ConfirmDialog]==>'; +let metaType: number = 11; const ACTION_ALLOW_AUTH_ONCE: number = 0; const ACTION_CANCEL_AUTH: number = 1; const ACTION_AUTH_CONFIRM_TIMEOUT: number = 2; @@ -126,6 +127,10 @@ struct ConfirmCustomDialog { this.onCancel; } + if (AppStorage.get('metaType') != null) { + metaType = AppStorage.get('metaType') as number; + } + if (AppStorage.get('title') != null) { this.title = AppStorage.get('title') as string; console.log('title is ' + this.title); @@ -187,7 +192,11 @@ struct ConfirmCustomDialog { if (this.secondsNum === 0) { clearInterval(this.times); this.times = 0; - this.setUserOperation(ACTION_AUTH_CONFIRM_TIMEOUT); + const param = { + 'META_TYPE': metaType + }; + const jsonStr = JSON.stringify(param); + this.setUserOperation(ACTION_AUTH_CONFIRM_TIMEOUT, jsonStr); this.destruction(); console.info('click cancel times run out'); } @@ -230,12 +239,13 @@ struct ConfirmCustomDialog { return } const param = { - 'appUserData': this.selectedAppDataList + 'appUserData': this.selectedAppDataList, + 'META_TYPE': metaType }; const jsonStr = JSON.stringify(param); console.log('allow once' + ACTION_ALLOW_AUTH_ONCE) console.log('param:' + jsonStr) - this.setUserAuthorization(ACTION_ALLOW_AUTH_ONCE, jsonStr) + this.setUserOperation(ACTION_ALLOW_AUTH_ONCE, jsonStr) this.destruction() } @@ -246,12 +256,13 @@ struct ConfirmCustomDialog { return } const param = { - 'appUserData': this.selectedAppDataList + 'appUserData': this.selectedAppDataList, + 'META_TYPE': metaType }; const jsonStr = JSON.stringify(param); console.log('allow always' + ACTION_ALLOW_AUTH_ALWAYS) console.log('param:' + jsonStr) - this.setUserAuthorization(ACTION_ALLOW_AUTH_ALWAYS, jsonStr) + this.setUserOperation(ACTION_ALLOW_AUTH_ALWAYS, jsonStr) this.destruction() } @@ -263,7 +274,11 @@ struct ConfirmCustomDialog { } console.log('cancel' + ACTION_CANCEL_AUTH) - this.setUserOperation(ACTION_CANCEL_AUTH) + const param = { + 'META_TYPE': metaType + }; + const jsonStr = JSON.stringify(param); + this.setUserOperation(ACTION_CANCEL_AUTH, jsonStr) this.destruction() } @@ -309,27 +324,14 @@ struct ConfirmCustomDialog { } } - setUserAuthorization(operation: number, param: string) { - console.log(TAG + 'setUserAuthorization: ' + operation) - if (dmClass == null) { - console.log(TAG + 'setUserAuthorization: ' + 'dmClass null') - return; - } - try { - dmClass.setUserOperation(operation, param); - } catch (err) { - console.log(TAG + 'dmClass setUserOperation failed') - } - } - - setUserOperation(operation: number) { + setUserOperation(operation: number, param: string) { console.log(TAG + 'setUserOperation: ' + operation) if (dmClass == null) { console.log(TAG + 'setUserOperation: ' + 'dmClass null') return; } try { - dmClass.setUserOperation(operation, 'extra'); + dmClass.setUserOperation(operation, param); } catch (err) { console.log(TAG + 'dmClass setUserOperation failed') } @@ -1761,18 +1763,22 @@ struct dialogPlusPage { onWillDismiss() { console.log(TAG + 'onWillDismiss: ' + ACTION_CANCEL_AUTH) - this.setUserOperation(ACTION_CANCEL_AUTH); + const param = { + 'META_TYPE': metaType + }; + const jsonStr = JSON.stringify(param); + this.setUserOperation(ACTION_CANCEL_AUTH, jsonStr); this.destruction(); } - setUserOperation(operation: number) { + setUserOperation(operation: number, param: string) { console.log(TAG + 'setUserOperation: ' + operation) if (dmClass == null) { console.log(TAG + 'setUserOperation: ' + 'dmClass null') return; } try { - dmClass.setUserOperation(operation, 'extra'); + dmClass.setUserOperation(operation, param); } catch (err) { console.log(TAG + 'dmClass setUserOperation failed') } diff --git a/display/entry/src/main/ets/pages/ConfirmDialogTv.ets b/display/entry/src/main/ets/pages/ConfirmDialogTv.ets index 49f3ce1e40e23585ac551311794d6886cc2ff004..165a2b203cf60960683c7eb3311d1b36109353d4 100644 --- a/display/entry/src/main/ets/pages/ConfirmDialogTv.ets +++ b/display/entry/src/main/ets/pages/ConfirmDialogTv.ets @@ -23,6 +23,7 @@ import { KeyCode } from '@ohos.multimodalInput.keyCode'; let dmClass: deviceManager.DeviceManager | null; let TAG = '[DeviceManagerUI:ConfirmDialog]==>'; +let metaType: number = 11; const ACTION_ALLOW_AUTH_ONCE: number = 0; const ACTION_CANCEL_AUTH: number = 1; const ACTION_AUTH_CONFIRM_TIMEOUT: number = 2; @@ -86,6 +87,10 @@ struct ConfirmCustomDialog { this.peerCustomDescription = context.resourceManager.getStringSync($r('app.string.dm_confirm_intention').id); } + if (AppStorage.get('metaType') != null) { + metaType = AppStorage.get('metaType') as number; + } + if (AppStorage.get('deviceType') != null) { this.peerDeviceType = AppStorage.get('deviceType') as number; console.log('peerDeviceType is ' + this.peerDeviceType); @@ -97,7 +102,11 @@ struct ConfirmCustomDialog { if (this.secondsNum === 0) { clearInterval(this.times); this.times = 0; - this.setUserOperation(ACTION_AUTH_CONFIRM_TIMEOUT); + const param = { + 'META_TYPE': metaType + }; + const jsonStr = JSON.stringify(param); + this.setUserOperation(ACTION_AUTH_CONFIRM_TIMEOUT, jsonStr); this.destruction(); console.info('click cancel times run out'); } @@ -114,7 +123,11 @@ struct ConfirmCustomDialog { } console.log('allow once' + ACTION_ALLOW_AUTH_ONCE) - this.setUserOperation(ACTION_ALLOW_AUTH_ONCE) + const param = { + 'META_TYPE': metaType + }; + const jsonStr = JSON.stringify(param); + this.setUserOperation(ACTION_ALLOW_AUTH_ONCE, jsonStr) this.destruction() } @@ -126,7 +139,11 @@ struct ConfirmCustomDialog { } console.log('allow always' + ACTION_ALLOW_AUTH_ALWAYS) - this.setUserOperation(ACTION_ALLOW_AUTH_ALWAYS) + const param = { + 'META_TYPE': metaType + }; + const jsonStr = JSON.stringify(param); + this.setUserOperation(ACTION_ALLOW_AUTH_ALWAYS, jsonStr) this.destruction() } @@ -138,18 +155,22 @@ struct ConfirmCustomDialog { } console.log('cancel' + ACTION_CANCEL_AUTH) - this.setUserOperation(ACTION_CANCEL_AUTH) + const param = { + 'META_TYPE': metaType + }; + const jsonStr = JSON.stringify(param); + this.setUserOperation(ACTION_CANCEL_AUTH, jsonStr) this.destruction() } - setUserOperation(operation: number) { + setUserOperation(operation: number, param: string) { console.log(TAG + 'setUserOperation: ' + operation) if (dmClass == null) { console.log(TAG + 'setUserOperation: ' + 'dmClass null') return; } try { - dmClass.setUserOperation(operation, 'extra'); + dmClass.setUserOperation(operation, param); } catch (error) { console.log(TAG + 'dmClass setUserOperation failed') } @@ -457,18 +478,22 @@ struct dialogPlusPage { onWillDismiss() { console.log(TAG + 'onWillDismiss: ' + ACTION_CANCEL_AUTH) - this.setUserOperation(ACTION_CANCEL_AUTH); + const param = { + 'META_TYPE': metaType + }; + const jsonStr = JSON.stringify(param); + this.setUserOperation(ACTION_CANCEL_AUTH, jsonStr); this.destruction(); } - setUserOperation(operation: number) { + setUserOperation(operation: number, param: string) { console.log(TAG + 'setUserOperation: ' + operation) if (dmClass == null) { console.log(TAG + 'setUserOperation: ' + 'dmClass null') return; } try { - dmClass.setUserOperation(operation, 'extra'); + dmClass.setUserOperation(operation, param); } catch (error) { console.log(TAG + 'dmClass setUserOperation failed') } diff --git a/display/entry/src/main/ets/pages/ConfirmDialogWearable.ets b/display/entry/src/main/ets/pages/ConfirmDialogWearable.ets index 8509bc09a097238390e51d87f4226dd506a70899..e63fa6385de2afe4fc47b83cb0446a995f1c376c 100644 --- a/display/entry/src/main/ets/pages/ConfirmDialogWearable.ets +++ b/display/entry/src/main/ets/pages/ConfirmDialogWearable.ets @@ -18,6 +18,7 @@ import common from '@ohos.app.ability.common'; let dmClass: deviceManager.DeviceManager | null; let TAG = '[DeviceManagerUI:ConfirmDialog]==>'; +let metaType: number = 11; const ACTION_ALLOW_AUTH_ONCE: number = 0; const ACTION_CANCEL_AUTH: number = 1; const ACTION_AUTH_CONFIRM_TIMEOUT: number = 2; @@ -125,7 +126,7 @@ struct Index { } } - setUserOperation(operation: number) { + setUserOperation(operation: number, param: string) { console.log(TAG + 'setUserOperation: ' + operation); if (dmClass === null) { console.log(TAG + 'setUserOperation: ' + 'dmClass null'); @@ -133,7 +134,7 @@ struct Index { } try { this.isUserOperate = true; - dmClass.setUserOperation(operation, 'extra'); + dmClass.setUserOperation(operation, param); } catch (error) { console.log(TAG + 'dmClass setUserOperation failed'); } @@ -146,6 +147,9 @@ struct Index { if (AppStorage.get('deviceName') != null) { this.peerDeviceName = AppStorage.get('deviceName') as string; } + if (AppStorage.get('metaType') != null) { + metaType = AppStorage.get('metaType') as number; + } let hostPkgLabel: string = AppStorage.get('hostPkgLabel') as string; if (hostPkgLabel === CAST_PKG_NAME) { this.title = @@ -173,7 +177,11 @@ struct Index { if (this.secondsNum === 0) { clearInterval(this.times); this.times = 0; - this.setUserOperation(ACTION_AUTH_CONFIRM_TIMEOUT); + const param = { + 'META_TYPE': metaType + }; + const jsonStr = JSON.stringify(param); + this.setUserOperation(ACTION_AUTH_CONFIRM_TIMEOUT, jsonStr); this.destruction(); console.info('click cancel times run out'); } @@ -188,7 +196,11 @@ struct Index { } console.log('allow once' + ACTION_ALLOW_AUTH_ONCE); - this.setUserOperation(ACTION_ALLOW_AUTH_ONCE); + const param = { + 'META_TYPE': metaType + }; + const jsonStr = JSON.stringify(param); + this.setUserOperation(ACTION_ALLOW_AUTH_ONCE, jsonStr); this.destruction(); } @@ -200,7 +212,11 @@ struct Index { } console.log('allow always' + ACTION_ALLOW_AUTH_ALWAYS); - this.setUserOperation(ACTION_ALLOW_AUTH_ALWAYS); + const param = { + 'META_TYPE': metaType + }; + const jsonStr = JSON.stringify(param); + this.setUserOperation(ACTION_ALLOW_AUTH_ALWAYS, jsonStr); this.destruction(); } @@ -212,7 +228,11 @@ struct Index { } console.log('cancel' + ACTION_CANCEL_AUTH); - this.setUserOperation(ACTION_CANCEL_AUTH); + const param = { + 'META_TYPE': metaType + }; + const jsonStr = JSON.stringify(param); + this.setUserOperation(ACTION_CANCEL_AUTH, jsonStr); this.destruction(); } diff --git a/display/entry/src/main/ets/pages/InputPinDialog.ets b/display/entry/src/main/ets/pages/InputPinDialog.ets index 1c6949c5708927f330bb2f05903c660a324a9857..ec93a9482acc27d194cbfa15e45a32827b9d62e9 100644 --- a/display/entry/src/main/ets/pages/InputPinDialog.ets +++ b/display/entry/src/main/ets/pages/InputPinDialog.ets @@ -25,6 +25,7 @@ import i18n from '@ohos.i18n'; let dmClass: deviceManager.DeviceManager | null; let TAG = '[DeviceManagerUI:InputPinDialog]==>' +let metaType: number = 11; const ACTION_CANCEL_PINCODE_INPUT: number = 4 const ACTION_DONE_PINCODE_INPUT: number = 5 const MSG_PIN_CODE_ERROR: number = 0 @@ -133,6 +134,9 @@ struct InputCustomDialog { this.model = AppStorage.get('model') as string; console.log('model is ' + this.model); } + if (AppStorage.get('metaType') != null) { + metaType = AppStorage.get('metaType') as number; + } deviceManager.createDeviceManager('com.ohos.devicemanagerui.input', (err: Error, dm: deviceManager.DeviceManager) => { if (err) { @@ -206,7 +210,11 @@ struct InputCustomDialog { return; } console.log('cancle' + ACTION_CANCEL_PINCODE_INPUT); - this.setUserOperation(ACTION_CANCEL_PINCODE_INPUT, 'extra'); + const param = { + 'META_TYPE': metaType + }; + const jsonStr = JSON.stringify(param); + this.setUserOperation(ACTION_CANCEL_PINCODE_INPUT, jsonStr); this.destruction(); } @@ -222,7 +230,12 @@ struct InputCustomDialog { return; } console.log('confirm' + JSON.stringify(ACTION_DONE_PINCODE_INPUT)); - this.setUserOperation(ACTION_DONE_PINCODE_INPUT, this.password); + const param = { + 'pinCode': this.password, + 'META_TYPE': metaType + }; + const jsonStr = JSON.stringify(param); + this.setUserOperation(ACTION_DONE_PINCODE_INPUT, jsonStr); } setUserOperation(operation: number, extra: string) { diff --git a/display/entry/src/main/ets/pages/InputPinDialogWearable.ets b/display/entry/src/main/ets/pages/InputPinDialogWearable.ets index f7a91899fced845d0264d63f96b5b0bcf346e8c0..99917ddb21f72a55d17f7f426d20ded420d79b9f 100644 --- a/display/entry/src/main/ets/pages/InputPinDialogWearable.ets +++ b/display/entry/src/main/ets/pages/InputPinDialogWearable.ets @@ -17,6 +17,7 @@ import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSessi let dmClass: deviceManager.DeviceManager | null; let TAG = '[DeviceManagerUI:InputPinDialog]==>'; +let metaType: number = 11; const ACTION_CANCEL_PINCODE_INPUT: number = 4; const ACTION_DONE_PINCODE_INPUT: number = 5; const MSG_PIN_CODE_ERROR: number = 0; @@ -55,6 +56,9 @@ struct Index { console.log(TAG + 'deviceManager exist'); return; } + if (AppStorage.get('metaType') != null) { + metaType = AppStorage.get('metaType') as number; + } deviceManager.createDeviceManager('com.ohos.devicemanagerui.input', (err: Error, dm: deviceManager.DeviceManager) => { if (err) { @@ -147,7 +151,11 @@ struct Index { return; } console.log('cancle' + ACTION_CANCEL_PINCODE_INPUT); - this.setUserOperation(ACTION_CANCEL_PINCODE_INPUT, 'extra'); + const param = { + 'META_TYPE': metaType + }; + const jsonStr = JSON.stringify(param); + this.setUserOperation(ACTION_CANCEL_PINCODE_INPUT, jsonStr); this.destruction(); } @@ -163,7 +171,12 @@ struct Index { return; } console.log('confirm' + JSON.stringify(ACTION_DONE_PINCODE_INPUT)); - this.setUserOperation(ACTION_DONE_PINCODE_INPUT, this.input); + const param = { + 'pinCode': this.input, + 'META_TYPE': metaType + }; + const jsonStr = JSON.stringify(param); + this.setUserOperation(ACTION_DONE_PINCODE_INPUT, jsonStr); } build() { @@ -288,7 +301,12 @@ struct Index { } if (length === MAX_PINCODE_LENGTH) { setTimeout(() => { - this.setUserOperation(ACTION_DONE_PINCODE_INPUT, this.input); + const param = { + 'pinCode': this.input, + 'META_TYPE': metaType + }; + const jsonStr = JSON.stringify(param); + this.setUserOperation(ACTION_DONE_PINCODE_INPUT, jsonStr); }, 50); } this.isUserInput = true; diff --git a/display/entry/src/main/ets/pages/PinDialog.ets b/display/entry/src/main/ets/pages/PinDialog.ets index b629e0de760972b7155bd588a391248b3a1e265b..11af03290e6fc0fb1bc17578fe4e607aa0504474 100644 --- a/display/entry/src/main/ets/pages/PinDialog.ets +++ b/display/entry/src/main/ets/pages/PinDialog.ets @@ -22,6 +22,7 @@ import { KeyCode } from '@ohos.multimodalInput.keyCode'; let dmClass: deviceManager.DeviceManager | null; let TAG = '[DeviceManagerUI:PinDialog]==>'; +let metaType: number = 11; const ACTION_CANCEL_PINCODE_DISPLAY: number = 3; const MSG_CANCEL_PIN_CODE_SHOW: number = 2; @@ -48,20 +49,23 @@ struct PinCustomDialog { aboutToAppear() { console.log(TAG + 'aboutToAppear execute PinCustomDialog'); + if (AppStorage.get('metaType') != null) { + metaType = AppStorage.get('metaType') as number; + } this.isPC = Constant.isPC(); // 获取pinCode this.pinCode = AppStorage.get('pinCode') as string; this.pinCodeArr = this.pinCode.split(''); } - setUserOperation(operation: number) { + setUserOperation(operation: number, param: string) { console.log(TAG + 'setUserOperation: ' + operation); if (dmClass == null) { console.log(TAG + 'setUserOperation: ' + 'dmClass null'); return; } try { - dmClass.setUserOperation(operation, 'extra'); + dmClass.setUserOperation(operation, param); } catch (error) { console.log(TAG + 'dmClass setUserOperation failed'); } @@ -133,7 +137,11 @@ struct PinCustomDialog { this.controller.close(); } this.cancel(); - this.setUserOperation(ACTION_CANCEL_PINCODE_DISPLAY); + const param = { + 'META_TYPE': metaType + }; + const jsonStr = JSON.stringify(param); + this.setUserOperation(ACTION_CANCEL_PINCODE_DISPLAY, jsonStr); } }) .onClick(() => { @@ -141,7 +149,11 @@ struct PinCustomDialog { this.controller.close(); } this.cancel(); - this.setUserOperation(ACTION_CANCEL_PINCODE_DISPLAY); + const param = { + 'META_TYPE': metaType + }; + const jsonStr = JSON.stringify(param); + this.setUserOperation(ACTION_CANCEL_PINCODE_DISPLAY, jsonStr); }) .onHover((isHover?: boolean, event?: HoverEvent): void => { if (isHover) { @@ -194,7 +206,11 @@ struct dialogPlusPage { onWillDismiss() { console.log(TAG + 'onWillDismiss: ' + ACTION_CANCEL_PINCODE_DISPLAY) - this.setUserOperation(ACTION_CANCEL_PINCODE_DISPLAY); + const param = { + 'META_TYPE': metaType + }; + const jsonStr = JSON.stringify(param); + this.setUserOperation(ACTION_CANCEL_PINCODE_DISPLAY, jsonStr); this.destruction(); } @@ -244,14 +260,14 @@ struct dialogPlusPage { }); } - setUserOperation(operation: number) { + setUserOperation(operation: number, param: string) { console.log(TAG + 'setUserOperation: ' + operation) if (dmClass == null) { console.log(TAG + 'setUserOperation: ' + 'dmClass null') return; } try { - dmClass.setUserOperation(operation, 'extra'); + dmClass.setUserOperation(operation, param); } catch (error) { console.log(TAG + 'dmClass setUserOperation failed') } diff --git a/display/entry/src/main/ets/pages/PinDialogTv.ets b/display/entry/src/main/ets/pages/PinDialogTv.ets index 4d93d460bea2fc4bb7eff82769839dfc0df9291e..59864ef96b9054c19bf70b58da4e5107a0ef79a5 100644 --- a/display/entry/src/main/ets/pages/PinDialogTv.ets +++ b/display/entry/src/main/ets/pages/PinDialogTv.ets @@ -23,6 +23,7 @@ import { KeyCode } from '@ohos.multimodalInput.keyCode'; let dmClass: deviceManager.DeviceManager | null; let TAG = '[DeviceManagerUI:PinDialog]==>'; +let metaType: number = 11; const ACTION_CANCEL_PINCODE_DISPLAY: number = 3; const MSG_CANCEL_PIN_CODE_SHOW: number = 2; @@ -59,19 +60,22 @@ struct PinCustomDialog { console.error('Failed to get display width:', err); this.mLocalWidth = 0; } + if (AppStorage.get('metaType') != null) { + metaType = AppStorage.get('metaType') as number; + } this.isPC = Constant.isPC(); this.pinCode = AppStorage.get('pinCode') as string; this.pinCodeArr = this.pinCode.split(''); } - setUserOperation(operation: number) { + setUserOperation(operation: number, param: string) { console.log(TAG + 'setUserOperation: ' + operation); if (dmClass == null) { console.log(TAG + 'setUserOperation: ' + 'dmClass null'); return; } try { - dmClass.setUserOperation(operation, 'extra'); + dmClass.setUserOperation(operation, param); } catch (error) { console.log(TAG + 'dmClass setUserOperation failed'); } @@ -148,7 +152,11 @@ struct PinCustomDialog { this.controller.close(); } this.cancel(); - this.setUserOperation(ACTION_CANCEL_PINCODE_DISPLAY); + const param = { + 'META_TYPE': metaType + }; + const jsonStr = JSON.stringify(param); + this.setUserOperation(ACTION_CANCEL_PINCODE_DISPLAY, jsonStr); } }) .onClick(() => { @@ -156,7 +164,11 @@ struct PinCustomDialog { this.controller.close(); } this.cancel(); - this.setUserOperation(ACTION_CANCEL_PINCODE_DISPLAY); + const param = { + 'META_TYPE': metaType + }; + const jsonStr = JSON.stringify(param); + this.setUserOperation(ACTION_CANCEL_PINCODE_DISPLAY, jsonStr); }) .onHover((isHover?: boolean, event?: HoverEvent): void => { if (isHover) { @@ -222,7 +234,11 @@ struct dialogPlusPage { onWillDismiss() { console.log(TAG + 'onWillDismiss: ' + ACTION_CANCEL_PINCODE_DISPLAY) - this.setUserOperation(ACTION_CANCEL_PINCODE_DISPLAY); + const param = { + 'META_TYPE': metaType + }; + const jsonStr = JSON.stringify(param); + this.setUserOperation(ACTION_CANCEL_PINCODE_DISPLAY, jsonStr); this.destruction(); } @@ -272,14 +288,14 @@ struct dialogPlusPage { }); } - setUserOperation(operation: number) { + setUserOperation(operation: number, param: string) { console.log(TAG + 'setUserOperation: ' + operation) if (dmClass == null) { console.log(TAG + 'setUserOperation: ' + 'dmClass null') return; } try { - dmClass.setUserOperation(operation, 'extra'); + dmClass.setUserOperation(operation, param); } catch (error) { console.log(TAG + 'dmClass setUserOperation failed') } diff --git a/display/entry/src/main/ets/pages/PinDialogWearable.ets b/display/entry/src/main/ets/pages/PinDialogWearable.ets index bb286179c48d1c3b4c32f2f450d8ae3899d3fdb5..1945dfc7319bde21c376f1bda62ec368191b4dcf 100644 --- a/display/entry/src/main/ets/pages/PinDialogWearable.ets +++ b/display/entry/src/main/ets/pages/PinDialogWearable.ets @@ -18,6 +18,7 @@ import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSessi let dmClass: deviceManager.DeviceManager | null; let TAG = '[DeviceManagerUI:PinDialog]==>'; +let metaType: number = 11; const ACTION_CANCEL_PINCODE_DISPLAY: number = 3; const MSG_CANCEL_PIN_CODE_SHOW: number = 2; @@ -31,6 +32,9 @@ struct PinDialog { aboutToAppear() { console.log(TAG + 'aboutToAppear execute PinCustomDialog'); + if (AppStorage.get('metaType') != null) { + metaType = AppStorage.get('metaType') as number; + } // 获取pinCode this.pinCode = AppStorage.get('pinCode') as string; this.pinCodeArr = this.pinCode.split(''); @@ -100,7 +104,7 @@ struct PinDialog { }); } - setUserOperation(operation: number) { + setUserOperation(operation: number, param: string) { console.log(TAG + 'setUserOperation: ' + operation); if (dmClass === null) { console.log(TAG + 'setUserOperation: ' + 'dmClass null'); @@ -108,7 +112,7 @@ struct PinDialog { } try { this.isUserOperate = true; - dmClass.setUserOperation(operation, 'extra'); + dmClass.setUserOperation(operation, param); } catch (error) { console.log(TAG + 'dmClass setUserOperation failed'); } @@ -176,7 +180,11 @@ struct PinDialog { .fontColor('#FFFFFF') .backgroundColor(Color.Transparent) .onClick(() => { - this.setUserOperation(ACTION_CANCEL_PINCODE_DISPLAY); + const param = { + 'META_TYPE': metaType + }; + const jsonStr = JSON.stringify(param); + this.setUserOperation(ACTION_CANCEL_PINCODE_DISPLAY, jsonStr); this.destruction(); }) .offset({ y: -5 }) diff --git a/services/implementation/src/ability/standard/dm_dialog_manager.cpp b/services/implementation/src/ability/standard/dm_dialog_manager.cpp index 156d95b885f03fb87cee74eed45afebabacaf55b..b90375a9a5775476d21ea3a6c6b1a69742b9c715 100644 --- a/services/implementation/src/ability/standard/dm_dialog_manager.cpp +++ b/services/implementation/src/ability/standard/dm_dialog_manager.cpp @@ -37,6 +37,7 @@ constexpr int32_t INVALID_USERID = -1; constexpr int32_t MESSAGE_PARCEL_KEY_SIZE = 3; constexpr int32_t WINDOW_LEVEL_UPPER = 2; constexpr int32_t WINDOW_LEVEL_DEFAULT = 1; +constexpr int32_t PROXY_DEFAULT = 11; constexpr const char* CONNECT_PIN_DIALOG = "pinDialog"; constexpr const char* DM_UI_BUNDLE_NAME = "com.ohos.devicemanagerui"; constexpr const char* CONFIRM_ABILITY_NAME = "com.ohos.devicemanagerui.ConfirmUIExtAbility"; @@ -249,6 +250,7 @@ void DmDialogManager::SendMsgRequest(const sptr& remoteObject) param[TAG_TARGET_DEVICE_NAME] = targetDeviceName_; param[TAG_HOST_PKGLABEL] = hostPkgLabel_; param["disableUpGesture"] = 1; + param["metaType"] = PROXY_DEFAULT; std::string paramStr = param.Dump(); data.WriteString16(Str8ToStr16(paramStr)); LOGI("show dm dialog is begin"); diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index e237a3678578b0d7485252b70826ec244ceb0fa1..cba2d2c4f2073ba62d94d1c775c19be49fc987e6 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -1947,6 +1947,9 @@ int32_t DmAuthManager::OnUserOperation(int32_t action, const std::string ¶ms .stageRes = static_cast(StageRes::STAGE_CANCEL), .bizState = static_cast(BizState::BIZ_STATE_END), }; + JsonObject paramJson; + paramJson.Parse(params); + std::string pinCode; switch (action) { case USER_OPERATION_TYPE_ALLOW_AUTH: case USER_OPERATION_TYPE_CANCEL_AUTH: @@ -1966,7 +1969,12 @@ int32_t DmAuthManager::OnUserOperation(int32_t action, const std::string ¶ms info.errCode = DmRadarHelper::GetInstance().GetErrCode(ERR_DM_BIND_USER_CANCEL_ERROR); break; case USER_OPERATION_TYPE_DONE_PINCODE_INPUT: - ProcessPincode(params); + if (paramJson.IsDiscarded() || !IsString(paramJson, PIN_CODE_KEY)) { + LOGE("DmAuthManager OnUserOperation pinCode not found"); + return ERR_DM_INPUT_PARA_INVALID; + } + pinCode = paramJson[PIN_CODE_KEY].Get(); + ProcessPincode(pinCode); info.stageRes = static_cast(StageRes::STAGE_SUCC); break; default: diff --git a/services/implementation/src/authentication_v2/auth_manager.cpp b/services/implementation/src/authentication_v2/auth_manager.cpp index b38dc56227044113042fabda12f6346b33bb7ee3..82da45bda40a499f9a056046484f01197186934b 100644 --- a/services/implementation/src/authentication_v2/auth_manager.cpp +++ b/services/implementation/src/authentication_v2/auth_manager.cpp @@ -858,6 +858,9 @@ int32_t AuthSrcManager::OnUserOperation(int32_t action, const std::string ¶m return ERR_DM_AUTH_NOT_START; } + JsonObject paramJson; + paramJson.Parse(params); + std::string pinCode; switch (action) { case USER_OPERATION_TYPE_CANCEL_PINCODE_INPUT: LOGE("AuthSrcManager OnUserOperation user cancel"); @@ -868,12 +871,17 @@ int32_t AuthSrcManager::OnUserOperation(int32_t action, const std::string ¶m case USER_OPERATION_TYPE_DONE_PINCODE_INPUT: LOGE("AuthSrcManager OnUserOperation user input done"); context_->pinInputResult = USER_OPERATION_TYPE_DONE_PINCODE_INPUT; + if (paramJson.IsDiscarded() || !IsString(paramJson, PIN_CODE_KEY)) { + LOGE("AuthSrcManager OnUserOperation pinCode not found"); + return ERR_DM_INPUT_PARA_INVALID; + } + pinCode = paramJson[PIN_CODE_KEY].Get(); { - if (!IsNumberString(params)) { + if (!IsNumberString(pinCode)) { LOGE("OnUserOperation jsonStr error"); return ERR_DM_INPUT_PARA_INVALID; } - context_->pinCode = params; + context_->pinCode = pinCode; } context_->authStateMachine->NotifyEventFinish(DmEventType::ON_USER_OPERATION); break; diff --git a/services/service/include/discovery/discovery_manager.h b/services/service/include/discovery/discovery_manager.h index a4c6ebc4cc789ee2bdadd7bbf07035a0989df96f..16c944f8e83e9d60fd1b7d9c608184f998ea9a91 100644 --- a/services/service/include/discovery/discovery_manager.h +++ b/services/service/include/discovery/discovery_manager.h @@ -52,6 +52,7 @@ typedef enum { PROXY_WINPC = 8, PROXY_COLLABORATION_FWK = 9, PROXY_DMSDP = 10, + PROXY_DEFAULT = 11, CUSTOM_UNKNOWN, } MetaNodeType; diff --git a/services/service/src/device_manager_service.cpp b/services/service/src/device_manager_service.cpp index 45925abffa3eadb13348f4b1052ef81e64597065..49436cea9481ed209b06ec270d33ba994a653431 100644 --- a/services/service/src/device_manager_service.cpp +++ b/services/service/src/device_manager_service.cpp @@ -1114,10 +1114,18 @@ int32_t DeviceManagerService::SetUserOperation(std::string &pkgName, int32_t act LOGE("DeviceManagerService::SetUserOperation error: Invalid parameter, pkgName: %{public}s", pkgName.c_str()); return ERR_DM_INPUT_PARA_INVALID; } - if (IsDMServiceAdapterSoLoaded()) { + JsonObject paramJson; + paramJson.Parse(params); + if (paramJson.IsDiscarded() || !IsInt32(paramJson, PARAM_KEY_META_TYPE)) { + LOGE("meta type not found"); + return ERR_DM_INPUT_PARA_INVALID; + } + int32_t metaType = paramJson[PARAM_KEY_META_TYPE].Get(); + if (metaType != PROXY_DEFAULT && IsDMServiceAdapterSoLoaded()) { + LOGE("SetUserOperation metaType: %{public}d", metaType); dmServiceImplExtResident_->ReplyUiAction(pkgName, action, params); } - if (!IsDMServiceImplReady()) { + if (metaType != PROXY_DEFAULT || !IsDMServiceImplReady()) { LOGE("SetUserOperation failed, instance not init or init failed."); return ERR_DM_NOT_INIT; } diff --git a/test/commonunittest/UTTest_dm_auth_manager_first.cpp b/test/commonunittest/UTTest_dm_auth_manager_first.cpp index deb4543468eb529cb7906f86ccfcfe44a4497f54..fe638b6fb2214bd807ae8b3ce7531bb051eba368 100644 --- a/test/commonunittest/UTTest_dm_auth_manager_first.cpp +++ b/test/commonunittest/UTTest_dm_auth_manager_first.cpp @@ -736,8 +736,10 @@ HWTEST_F(DmAuthManagerTest, OnUserOperation_005, testing::ext::TestSize.Level1) HWTEST_F(DmAuthManagerTest, OnUserOperation_006, testing::ext::TestSize.Level1) { int32_t action = 5; - std::string params = "5"; - int32_t ret = authManager_->OnUserOperation(action, params); + JsonObject param; + param[PIN_CODE_KEY] = "5"; + std::string paramStr = param.Dump(); + int32_t ret = authManager_->OnUserOperation(action, paramStr); ASSERT_EQ(ret, DM_OK); }