mirror of
https://gitee.com/openharmony/applications_dlp_manager
synced 2024-11-24 02:19:49 +00:00
abilityWant整改
Signed-off-by: li-li-wang <wangliliang5@huawei.com>
This commit is contained in:
parent
41565abe97
commit
89cc406251
@ -26,7 +26,7 @@ const TAG = 'Alert';
|
||||
export default class AlertAbility extends UIAbility {
|
||||
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
|
||||
HiLog.info(TAG, `onCreate`);
|
||||
GlobalContext.store('abilityWant', want);
|
||||
GlobalContext.store('alertWant', want);
|
||||
}
|
||||
|
||||
onDestroy(): void {
|
||||
@ -36,12 +36,15 @@ export default class AlertAbility extends UIAbility {
|
||||
onWindowStageCreate(windowStage: window.WindowStage): void {
|
||||
// Main window is created, set main page for this ability
|
||||
HiLog.info(TAG, `onWindowStageCreate`);
|
||||
windowStage.loadContent('pages/alert', (err: BusinessError) => {
|
||||
if (err && err.code !== 0) {
|
||||
HiLog.error(TAG, `setUIContent failed: ${JSON.stringify(err)}`);
|
||||
}
|
||||
});
|
||||
windowStage.disableWindowDecor();
|
||||
let storage: LocalStorage = new LocalStorage({
|
||||
'alertWant': GlobalContext.load('alertWant')
|
||||
} as Record<string, Want>);
|
||||
try {
|
||||
windowStage.loadContent('pages/alert', storage);
|
||||
windowStage.disableWindowDecor();
|
||||
} catch (exception) {
|
||||
HiLog.error(TAG, `Failed to set the background color. Cause: ${JSON.stringify(exception)}`);
|
||||
}
|
||||
let mainWindow: window.Window | undefined = undefined;
|
||||
|
||||
windowStage.getMainWindow((err, data) => {
|
||||
|
@ -150,8 +150,8 @@ export default class MainAbility extends UIExtensionAbility {
|
||||
}
|
||||
}
|
||||
|
||||
async checkValidWant(): Promise<boolean> {
|
||||
let parameters = (GlobalContext.load('abilityWant') as Want).parameters;
|
||||
async checkValidWant(want: Want): Promise<boolean> {
|
||||
let parameters = want.parameters;
|
||||
if (parameters === undefined) {
|
||||
HiLog.error(TAG, `need parameters in want`);
|
||||
return false;
|
||||
@ -164,7 +164,7 @@ export default class MainAbility extends UIExtensionAbility {
|
||||
HiLog.error(TAG, `need name in want.parameters.fileName`);
|
||||
return false;
|
||||
}
|
||||
if ((GlobalContext.load('abilityWant') as Want).uri === undefined) {
|
||||
if (want.uri === undefined) {
|
||||
HiLog.error(TAG, `need uri in want`);
|
||||
return false;
|
||||
}
|
||||
@ -175,7 +175,7 @@ export default class MainAbility extends UIExtensionAbility {
|
||||
return false;
|
||||
}
|
||||
AppStorage.setOrCreate('hiPkgName', callerBundleName);
|
||||
let uri = String((GlobalContext.load('abilityWant') as Want).uri);
|
||||
let uri = String(want.uri);
|
||||
if (!isValidPath(uri)) {
|
||||
HiLog.error(TAG, `invalid uri in want.uri`);
|
||||
return false;
|
||||
@ -216,9 +216,9 @@ export default class MainAbility extends UIExtensionAbility {
|
||||
})
|
||||
}
|
||||
|
||||
async checkValidWantAndAccount(session: UIExtensionContentSession): Promise<void> {
|
||||
async checkValidWantAndAccount(session: UIExtensionContentSession, want: Want): Promise<void> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
if (!this.checkValidWant()) {
|
||||
if (!this.checkValidWant(want)) {
|
||||
await GetAlertMessage.startAlertAbility(this.context,
|
||||
{ code: Constants.ERR_JS_APP_PARAM_ERROR } as BusinessError, session);
|
||||
reject();
|
||||
@ -243,7 +243,7 @@ export default class MainAbility extends UIExtensionAbility {
|
||||
async getNewWantPage(want: Want, session: UIExtensionContentSession): Promise<void> {
|
||||
HiLog.info(TAG, `getNewWantPage start`);
|
||||
try {
|
||||
await this.checkValidWantAndAccount(session)
|
||||
await this.checkValidWantAndAccount(session, want)
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
@ -258,21 +258,20 @@ export default class MainAbility extends UIExtensionAbility {
|
||||
GlobalContext.store('requestIsFromSandBox', requestIsFromSandBox);
|
||||
HiLog.info(TAG, `request is from sandbox: ${requestIsFromSandBox}`);
|
||||
if (requestIsFromSandBox) {
|
||||
this.requestIsFromSandBox(session);
|
||||
this.requestIsFromSandBox(session, want);
|
||||
} else {
|
||||
this.requestIsNotFromSandBox(session);
|
||||
this.requestIsNotFromSandBox(session, want);
|
||||
}
|
||||
}
|
||||
|
||||
requestIsFromSandBox(session: UIExtensionContentSession): void {
|
||||
let abilityWant: Want = GlobalContext.load('abilityWant') as Want;
|
||||
const linkFileName: string = (abilityWant.parameters?.linkFileName as Record<string, string>)?.name;
|
||||
requestIsFromSandBox(session: UIExtensionContentSession, want: Want): void {
|
||||
const linkFileName: string = (want.parameters?.linkFileName as Record<string, string>)?.name;
|
||||
this.homeFeature.sandBoxLinkFileHome(linkFileName, this.callerToken,
|
||||
(err: number, data: dlpPermission.DLPProperty, uri: string) => {
|
||||
if (err !== 0) {
|
||||
return;
|
||||
}
|
||||
let dlpFileName: string = (abilityWant.parameters?.fileName as Record<string, string>)?.name;
|
||||
let dlpFileName: string = (want.parameters?.fileName as Record<string, string>)?.name;
|
||||
GlobalContext.store('dlpFileName', dlpFileName);
|
||||
GlobalContext.store('linkFileName', linkFileName);
|
||||
GlobalContext.store('dlpProperty', data);
|
||||
@ -285,9 +284,8 @@ export default class MainAbility extends UIExtensionAbility {
|
||||
});
|
||||
}
|
||||
|
||||
async requestIsNotFromSandBox(session: UIExtensionContentSession): Promise<void> {
|
||||
let fileName: string =
|
||||
((GlobalContext.load('abilityWant') as Want).parameters?.fileName as Record<string, string>)?.name;
|
||||
async requestIsNotFromSandBox(session: UIExtensionContentSession, want: Want): Promise<void> {
|
||||
let fileName: string = (want.parameters?.fileName as Record<string, string>)?.name;
|
||||
let isDlpSuffix: boolean = false;
|
||||
try {
|
||||
isDlpSuffix = await FileUtils.isDLPFile(GlobalContext.load('uri'));
|
||||
@ -313,10 +311,10 @@ export default class MainAbility extends UIExtensionAbility {
|
||||
return;
|
||||
} else {
|
||||
try {
|
||||
let dlpFd = getFileFd(String((GlobalContext.load('abilityWant') as Want).uri));
|
||||
let dlpFd = getFileFd(String(want.uri));
|
||||
let accountType = await getAccountType(this.context, dlpFd);
|
||||
if (accountType === dlpPermission.AccountType.DOMAIN_ACCOUNT) {
|
||||
this.dlpFilesToEncrypt(session);
|
||||
this.dlpFilesToEncrypt(session, want);
|
||||
} else {
|
||||
await GetAlertMessage.startAlertAbility(this.context, {
|
||||
code: Constants.ERR_JS_APP_CANNOT_OPEN } as BusinessError);
|
||||
@ -327,15 +325,14 @@ export default class MainAbility extends UIExtensionAbility {
|
||||
}
|
||||
}
|
||||
|
||||
async dlpFilesToEncrypt(session: UIExtensionContentSession): Promise<void> {
|
||||
async dlpFilesToEncrypt(session: UIExtensionContentSession, want: Want): Promise<void> {
|
||||
let uri: string = GlobalContext.load('uri') as string;
|
||||
try {
|
||||
await this.findFileOpenHistoryHome(uri, session);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
let dlpFileName: string =
|
||||
((GlobalContext.load('abilityWant') as Want).parameters?.fileName as Record<string, string>)?.name;
|
||||
let dlpFileName: string = (want.parameters?.fileName as Record<string, string>)?.name;
|
||||
GlobalContext.store('dlpFileName', dlpFileName);
|
||||
let callerAppId: string;
|
||||
try {
|
||||
|
@ -319,7 +319,7 @@ export default class ViewAbility extends ServiceExtensionAbility {
|
||||
let callerAppId: string;
|
||||
try {
|
||||
callerAppId = await getAppId(this.callerBundleName);
|
||||
HiLog.info(TAG, `get AppId: ${callerAppId}`);
|
||||
HiLog.info(TAG, `get AppId success`);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
@ -14,14 +14,12 @@
|
||||
*/
|
||||
|
||||
export default class Constants {
|
||||
public static INDEX_BORDER_RADIUS = 24;
|
||||
public static FOOTER_HEIGHT = 40;
|
||||
public static FOOTER_BUTTON_HEIGHT = 40;
|
||||
public static FOOTER_ROW_WIDTH = '100%';
|
||||
public static FOOTER_ROW_MARGIN = 8;
|
||||
public static FOOTER_ROW_PAD_LEFT = 16;
|
||||
public static FOOTER_ROW_PAD_RIGHT = 16;
|
||||
public static HEADER_TEXT_FRONT_SIZE = 20;
|
||||
public static HEADER_TEXT_LINE_HEIGHT = 28;
|
||||
public static HEADER_TEXT_WIDTH = '100%';
|
||||
public static HEADER_COLUMN_WIDTH = '100%';
|
||||
@ -35,7 +33,6 @@ export default class Constants {
|
||||
public static ENCRYPTION_SUCCESS_CIRCLE = 64;
|
||||
public static ENCRYPTION_SUCCESS_ICON = 40;
|
||||
public static HEADER_COLUMN_MESSAGE_TIPS = 400;
|
||||
public static HEADER_COLUMN_MESSAGE_TIPS_CLOUD = 242;
|
||||
public static ENCRYPTION_SUCCESS_TRANSLATE = 180;
|
||||
public static ENCRYPTION_SUCCESS_TRANSLATE_WIDTH = 180;
|
||||
public static ENCRYPTION_SUCCESS_CHANGE_TOP = 32;
|
||||
@ -46,14 +43,10 @@ export default class Constants {
|
||||
public static HEADER_ROW_FONT_SIZE = 16;
|
||||
public static ENCRYPTION_STAFF_BORDER_RADIUS = 999;
|
||||
public static ENCRYPTION_STAFF_MAX_WIDTH = 82;
|
||||
public static ENCRYPTION_STAFF_WIDTH = 112;
|
||||
public static ENCRYPTION_STAFF_WIDTH_NAME = 82;
|
||||
public static ENCRYPTION_STAFF_PAD = 8;
|
||||
public static ENCRYPTION_PERMISSION_STATUS_WIDTH = '70%';
|
||||
public static ENCRYPTION_PERMISSION_STATUS_IMAGE = '90%';
|
||||
public static PP_TEXT_MAX_LINE = 1;
|
||||
public static MAIN_FLAG_MAX_NUMBER = 1;
|
||||
public static PP_TEXT_PAD_RIGHT = 4;
|
||||
public static PP_IMAGE_WIDTH = 24;
|
||||
public static PP_IMAGE_HEIGHT = 24;
|
||||
public static PP_IMAGE_PAD = 2;
|
||||
@ -66,28 +59,14 @@ export default class Constants {
|
||||
public static DU_WIDTH_FULL = '100%';
|
||||
public static DU_LINE_WIDTH = 0.5;
|
||||
public static DU_LINE_MARGIN_TOP2 = 8;
|
||||
public static DA_FONT_SIZE = 20;
|
||||
public static DA_ROW_HEIGHT = 56;
|
||||
public static DA_ROW_WIDTH = 288;
|
||||
public static DA_TEXT_LINE_HEIGHT = 28;
|
||||
public static DA_SCROLL_LINE_HEIGHT = 16;
|
||||
public static DA_SCROLL_FONT_SIZE = 14;
|
||||
public static DA_SCROLL_BAR_WIDTH = 5;
|
||||
public static DA_STRAIN_SIZE_MA_HEIGHT = 500;
|
||||
public static DA_MARGIN_TOP = 12;
|
||||
public static DA_SCROLL_WIDTH = 288;
|
||||
public static ROW_BUTTON_WIDTH = 304;
|
||||
public static ROW_BUTTON_HEIGHT = 40;
|
||||
public static ROW_FONT_SIZE = 16;
|
||||
public static ROW_MARGIN_TOP = 8;
|
||||
public static DA_COLOUM_WIDTH = 336;
|
||||
public static DA_COLOUM_RADIUS = 24;
|
||||
|
||||
public static FILE_OPEN_HISTORY_ZERO = 0;
|
||||
public static FILE_OPEN_HISTORY_ONE = 1;
|
||||
public static FILE_OPEN_HISTORY_TWO = 2;
|
||||
public static FILE_OPEN_HISTORY_THREE = 3;
|
||||
public static FILE_OPEN_HISTORY_FOUR = 4;
|
||||
public static ADD_STAFF_ITEM_MARGIN_RIGHT = 4;
|
||||
public static CHANGE_MAX_HEIGHT = '70%';
|
||||
public static ENCRYPTION_SUCCESS_MAX_HEIGHT = '70%';
|
||||
@ -104,18 +83,15 @@ export default class Constants {
|
||||
public static ENCRYPTION_STAFF_ITEM_MARGIN = 12;
|
||||
public static ENCRYPTION_STAFF_ITEM_MARGIN_BOTTOM = 12;
|
||||
public static ENCRYPTION_ADD_STAFF_HEIGHT = 28;
|
||||
public static ENCRYPTION_ADD_STAFF_PADDING_TOP = 10;
|
||||
public static ENCRYPTION_ADD_STAFF_BORDER = 1;
|
||||
public static ENCRYPTION_ADD_STAFF_BORDER2 = 2;
|
||||
public static ENCRYPTION_ADD_STAFF_BORDER_MARGIN_TOP = 8;
|
||||
public static ENCRYPTION_SUCCESS_TOGGLE_HEIGHT = 32;
|
||||
public static ENCRYPTION_PROTECTION_BUTTON_MARGIN = 8;
|
||||
public static ENCRYPTION_PROTECTION_TIME_MENU_HEIGHT = 50;
|
||||
public static ENCRYPTION_PROTECTION_TIME_MENU_PADDING_LEFT = 12;
|
||||
public static ENCRYPTION_PROTECTION_TIME_MENU_PADDING_RIGHT = 12;
|
||||
public static ENCRYPTION_PROTECTION_TIME_MENU_MARGIN_LEFT = 2;
|
||||
public static ENCRYPTION_PROTECTION_TIME_MENU_MARGIN_RIGHT = 2;
|
||||
public static ENCRYPTION_PROTECTION_TIME_MENU_DIVIDER_LENGTH = '76%';
|
||||
public static ENCRYPTION_PROTECTION_TIME_MENU_WIDTH = 32;
|
||||
public static ENCRYPTION_ADD_STAFF_FLEX_GROW = 1;
|
||||
public static ENCRYPTION_ADD_STAFF_MARGIN_RIGHT = 8;
|
||||
@ -129,22 +105,16 @@ export default class Constants {
|
||||
public static ENCRYPTION_STATUS_VALUE_COLOR = 0.6;
|
||||
public static ENCRYPTION_TYPE_SELECT_INDEX = 0;
|
||||
public static ENCRYPTION_TYPE_SELECT = 1;
|
||||
public static ENCRYPTION_ADD_STAFF_MENU_WIDTH = 100;
|
||||
public static ENCRYPTION_ADD_STAFF_MENU_HEIGHT = 50;
|
||||
public static ENCRYPTION_MESSAGE_DIALOG_TIPS = 400;
|
||||
public static ENCRYPTION_MESSAGE_DIALOG_BUTTON = 256;
|
||||
public static ENCRYPTION_MESSAGE_DIALOG_TIPS_PADDING = 72;
|
||||
public static ENCRYPTION_MESSAGE_ALERT_MESSAGE_TOP = 0;
|
||||
public static ENCRYPTION_MESSAGE_ALERT_MESSAGE_TOP1 = 24;
|
||||
public static ENCRYPTION_MESSAGE_ALERT_MESSAGE_PADDING_LEFT = 24;
|
||||
public static ENCRYPTION_MESSAGE_ALERT_MESSAGE_PADDING_TOP = 16;
|
||||
public static ENCRYPTION_PC_FIXING_WIDTH = 588;
|
||||
public static ENCRYPTION_PC_FIXING_STATUS_WIDTH = 400;
|
||||
public static ENCRYPTION_PC_FIXING_MINWIDTH = 0;
|
||||
|
||||
public static DLPRPC_SERVICE_PROXY_ERRCODE = 0;
|
||||
public static DLP_MANAGER_BUNDLE_NAME = 'com.ohos.dlpmanager';
|
||||
public static TRANSPARENT_GREY_BACKGROUND_COLOR = '#33182431';
|
||||
public static TRANSPARENT_BACKGROUND_COLOR = '#00000000';
|
||||
public static START_ABILITY_YNUMBER = 300;
|
||||
public static START_ABILITY_WINDOW_WIDTH = 492;
|
||||
@ -153,7 +123,6 @@ export default class Constants {
|
||||
public static START_ABILITY_HEIGHT_DEFAULT1 = 165;
|
||||
public static START_ABILITY_HEIGHT_DEFAULT = 154;
|
||||
public static START_ABILITY_HEIGHT_ONE_ROWS = 174;
|
||||
public static START_ABILITY_HEIGHT_TWO_ROWS = 194;
|
||||
public static START_ABILITY_HEIGHT_THREE_ROWS = 214;
|
||||
public static START_ABILITY_HEIGHT_FOUR_ROWS = 240;
|
||||
public static START_ABILITY_MESSAGE_HEIGHT = '20%';
|
||||
@ -161,7 +130,6 @@ export default class Constants {
|
||||
public static START_ABILITY_MESSAGE_HEIGHT_ONE = '24%';
|
||||
public static START_ABILITY_MESSAGE_HEIGHT_TWO = '32%';
|
||||
public static START_ABILITY_MESSAGE_HEIGHT_THREE = '45%';
|
||||
public static START_ABILITY_MESSAGE_HEIGHT_FOUR = '52%';
|
||||
|
||||
public static FOOTER_OPACITY_ONE = 1;
|
||||
public static FOOTER_OPACITY_SEPC = 0.6;
|
||||
@ -194,12 +162,10 @@ export default class Constants {
|
||||
public static ERR_JS_NETWORK_INVALID = 12300013;
|
||||
public static DLP_FILE_PARSE_ERROR = 103;
|
||||
public static DLP_INSTALL_SANDBOX_SUCCESS = 202;
|
||||
public static DLP_GET_PARAMETERS_FAILED = 100;
|
||||
public static DLP_START_SANDBOX_ERROR = 105;
|
||||
public static DLP_START_SANDBOX_SUCCESS = 203;
|
||||
public static DLP_INSTALL_SANDBOX_ERROR = 104;
|
||||
|
||||
public static GUTTER = 0;
|
||||
public static XS_COLUMNS = 2;
|
||||
public static XS_SPAN = 2;
|
||||
public static XS_OFFSET = 0;
|
||||
@ -210,12 +176,9 @@ export default class Constants {
|
||||
public static MD_SPAN = 8;
|
||||
public static MD_OFFSET = 0;
|
||||
public static LG_COLUMNS = 12;
|
||||
public static LG_SPAN = 8;
|
||||
public static LG_OFFSET = 2;
|
||||
|
||||
public static DIALOG_GUTTER = 24;
|
||||
public static DIALOG_MARGIN = 16;
|
||||
public static DIALOG_MARGIN_VERTICAL = 12;
|
||||
public static DIALOG_MD_SPAN = 6;
|
||||
public static DIALOG_MD_OFFSET = 1;
|
||||
public static DIALOG_LG_SPAN = 6;
|
||||
@ -235,7 +198,6 @@ export default class Constants {
|
||||
public static VALIDITY_IMAGE_PADDING_LEFT = 8;
|
||||
|
||||
public static TIPS_HEIGHT_ITEM = 20;
|
||||
public static TIPS_COLON_WIDTH = 9;
|
||||
public static TIPS_STAFF_WIDTH = 82;
|
||||
public static TIPS_STAFF_MAX_WIDTH = 50;
|
||||
public static TIPS_SPACE_ZERO = '\u200B';
|
||||
@ -281,4 +243,9 @@ export default class Constants {
|
||||
public static SHARE_PAGES_COLUMN_WIDTH = '100%';
|
||||
public static SHARE_PAGES_COLUMN_HEIGHT = '100%';
|
||||
public static SHARE_SET_TIMEOUT = 1500;
|
||||
|
||||
public static readonly ERR_CODE_NETWORK_ERROR: number = -4;
|
||||
public static readonly ERR_CODE_CONNECTION_FAIL: number = -301;
|
||||
public static readonly ERR_CODE_CONNECTION_TIME_OUT: number = -310;
|
||||
public static readonly ERR_CODE_SUCCESS: number = 0;
|
||||
}
|
||||
|
@ -54,7 +54,6 @@ struct AddStaff {
|
||||
@State isInputInvalidFlag: boolean = false;
|
||||
private controller: RichEditorController = new RichEditorController();
|
||||
private options: RichEditorOptions = { controller: this.controller };
|
||||
@State domainAccount: boolean = true;
|
||||
|
||||
@Builder
|
||||
StaffItemBuilder(authAccount: string, textContent: string, index: number) {
|
||||
@ -99,11 +98,7 @@ struct AddStaff {
|
||||
this.errInput = [];
|
||||
break;
|
||||
}
|
||||
if (this.domainAccount) {
|
||||
await this.createStaffByDomain(i, startOffset, endOffset);
|
||||
} else {
|
||||
this.createStaffByCloud(i, startOffset, endOffset);
|
||||
}
|
||||
await this.createStaffByDomain(i, startOffset, endOffset);
|
||||
}
|
||||
this.isAccountCheckSuccess = true;
|
||||
if (this.staffArray.length < Constants.ENCRYPTION_ADD_STAFF_LENGTH_MAX) {
|
||||
@ -114,20 +109,6 @@ struct AddStaff {
|
||||
}
|
||||
}
|
||||
|
||||
private createStaffByCloud(i: number, startOffset: number[], endOffset: number[]) {
|
||||
let o2: Staff = {
|
||||
authAccount: this.inputArray[i],
|
||||
textContent: this.inputArray[i]
|
||||
};
|
||||
this.staffArray.push(o2);
|
||||
if (this.inputArray.length === Constants.RICH_EDITOR_FIRST) {
|
||||
this.deleteBuildSpan(startOffset, endOffset);
|
||||
}
|
||||
this.succ = AppStorage.get('hiAccountVerifySucc') as number + 1;
|
||||
AppStorage.setOrCreate('hiAccountVerifySucc', this.succ);
|
||||
this.addBuildSpan(i, this.inputArray[i]);
|
||||
}
|
||||
|
||||
private createStaffByDomain(i: number, startOffset: number[], endOffset: number[]) {
|
||||
return new Promise<void>(async (resolve, reject) => {
|
||||
try {
|
||||
@ -202,10 +183,8 @@ struct AddStaff {
|
||||
}
|
||||
|
||||
async aboutToAppear() {
|
||||
if (this.domainAccount) {
|
||||
await AccountTipsConfig.getConfigTips();
|
||||
this.textContent = AccountTipsConfig.showContentKey;
|
||||
}
|
||||
await AccountTipsConfig.getConfigTips();
|
||||
this.textContent = AccountTipsConfig.showContentKey;
|
||||
if (this.staffArray.length) {
|
||||
setTimeout(() => {
|
||||
this.onDataChange();
|
||||
|
@ -59,31 +59,21 @@ struct staffItem {
|
||||
@Prop textContent: string = '';
|
||||
@State accountTipsArray: AccountTips[] = [];
|
||||
@State isHover: boolean = false;
|
||||
@State domainAccount: boolean = true;
|
||||
dlpAlertDialog?: CustomDialogController;
|
||||
|
||||
@Builder popupBuilderTips() {
|
||||
Column() {
|
||||
if (this.domainAccount) {
|
||||
ForEach(this.accountTipsArray, (item: AccountTips) => {
|
||||
if (item.isShow) {
|
||||
Row() {
|
||||
if (AccountTipsConfig.isSysLanguage()) {
|
||||
Text(item.description?.replace('%s', item.value)).tipsTextStyle()
|
||||
} else {
|
||||
Text(item.descriptionEn?.replace('%s', item.value)).tipsTextStyle()
|
||||
}
|
||||
}.height(Constants.TIPS_HEIGHT_ITEM)
|
||||
}
|
||||
}, (item: AccountTips) => item.key)
|
||||
} else {
|
||||
Row() {
|
||||
Text($r('app.string.encrypt_employee_id', this.accountNameTips))
|
||||
.wordBreak(WordBreak.BREAK_ALL)
|
||||
.tipsTextStyle()
|
||||
ForEach(this.accountTipsArray, (item: AccountTips) => {
|
||||
if (item.isShow) {
|
||||
Row() {
|
||||
if (AccountTipsConfig.isSysLanguage()) {
|
||||
Text(item.description?.replace('%s', item.value)).tipsTextStyle()
|
||||
} else {
|
||||
Text(item.descriptionEn?.replace('%s', item.value)).tipsTextStyle()
|
||||
}
|
||||
}.height(Constants.TIPS_HEIGHT_ITEM)
|
||||
}
|
||||
.width(Constants.HEADER_COLUMN_MESSAGE_TIPS_CLOUD)
|
||||
}
|
||||
}, (item: AccountTips) => item.key)
|
||||
}
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.padding({
|
||||
@ -116,9 +106,6 @@ struct staffItem {
|
||||
}
|
||||
|
||||
private splitContent() {
|
||||
if (!this.domainAccount) {
|
||||
return this.textContent;
|
||||
}
|
||||
if (this.textContent) {
|
||||
if (this.textContent.length > Constants.TIPS_NAME_LENGTH) {
|
||||
return this.textContent.split('').join(Constants.TIPS_SPACE_ZERO)
|
||||
@ -141,11 +128,7 @@ struct staffItem {
|
||||
}
|
||||
}
|
||||
|
||||
async aboutToAppear() {
|
||||
if (!this.domainAccount) {
|
||||
this.textContent = this.authAccount;
|
||||
}
|
||||
}
|
||||
async aboutToAppear() {}
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
@ -180,28 +163,23 @@ struct staffItem {
|
||||
.height(Constants.HEADER_ROW_FONT_SIZE);
|
||||
}
|
||||
.onClick(() => {
|
||||
if (this.domainAccount) {
|
||||
try {
|
||||
AccountTipsConfig.getAccountInfo(this.authAccount)
|
||||
.then(async (result: account_osAccount.DomainAccountInfo) => {
|
||||
this.accountTipsArray = await AccountTipsConfig.getConfigTips();
|
||||
this.handlePopupTips = !this.handlePopupTips;
|
||||
this.accountTipsArray?.forEach((item: AccountTips) => {
|
||||
let value: string = result[item.key];
|
||||
item.value = value;
|
||||
})
|
||||
try {
|
||||
AccountTipsConfig.getAccountInfo(this.authAccount)
|
||||
.then(async (result: account_osAccount.DomainAccountInfo) => {
|
||||
this.accountTipsArray = await AccountTipsConfig.getConfigTips();
|
||||
this.handlePopupTips = !this.handlePopupTips;
|
||||
this.accountTipsArray?.forEach((item: AccountTips) => {
|
||||
let value: string = result[item.key];
|
||||
item.value = value;
|
||||
})
|
||||
.catch((err: BusinessError) => {
|
||||
HiLog.error(TAG, `getAccountInfo error: ${JSON.stringify(err)}`);
|
||||
let errInfo = GetAlertMessage.getAlertMessage(err);
|
||||
this.showErrorDialog(errInfo.title, errInfo.msg);
|
||||
})
|
||||
} catch (err) {
|
||||
HiLog.error(TAG, `getAccountInfo exception: ${JSON.stringify(err)}`);
|
||||
}
|
||||
} else {
|
||||
this.handlePopupTips = !this.handlePopupTips;
|
||||
this.accountNameTips = this.authAccount;
|
||||
})
|
||||
.catch((err: BusinessError) => {
|
||||
HiLog.error(TAG, `getAccountInfo error: ${JSON.stringify(err)}`);
|
||||
let errInfo = GetAlertMessage.getAlertMessage(err);
|
||||
this.showErrorDialog(errInfo.title, errInfo.msg);
|
||||
})
|
||||
} catch (err) {
|
||||
HiLog.error(TAG, `getAccountInfo exception: ${JSON.stringify(err)}`);
|
||||
}
|
||||
})
|
||||
.hitTestBehavior(HitTestMode.Block)
|
||||
|
@ -22,7 +22,7 @@ const TAG = 'CredCallbackStub';
|
||||
export default class CredCallbackStub extends rpc.RemoteObject {
|
||||
private connectService: ConnectService = new ConnectService(getContext(this));
|
||||
private static readonly DESCRIPTOR: string = 'OHOS.HapDlpCredAbilityServiceStub';
|
||||
private static readonly COMMAND_ON_RESULT = 1;
|
||||
private static readonly COMMAND_SEARCH_USER_INFO = 1;
|
||||
|
||||
constructor(des: string) {
|
||||
super(des);
|
||||
@ -39,7 +39,7 @@ export default class CredCallbackStub extends rpc.RemoteObject {
|
||||
return false;
|
||||
}
|
||||
switch (code) {
|
||||
case CredCallbackStub.COMMAND_ON_RESULT: {
|
||||
case CredCallbackStub.COMMAND_SEARCH_USER_INFO: {
|
||||
let resultVar = data.readString();
|
||||
HiLog.info(TAG, `onRemoteMessageRequest data: ${JSON.stringify(resultVar)}`);
|
||||
AppStorage.setOrCreate('isInputInvalid', resultVar);
|
||||
|
@ -235,30 +235,6 @@ async function showErrorDialogAndExit(windowStage: window.WindowStage, error: Bu
|
||||
});
|
||||
}
|
||||
|
||||
async function goToAlertMessagePage(
|
||||
session: UIExtensionContentSession,
|
||||
title?: Resource,
|
||||
message?: Resource,
|
||||
messageName?: Object,
|
||||
cancel?: Resource,
|
||||
ok?: Resource
|
||||
) {
|
||||
let storage: LocalStorage = new LocalStorage({
|
||||
'session': session,
|
||||
'title': title,
|
||||
'message': message,
|
||||
'messageName': messageName,
|
||||
'cancel': cancel,
|
||||
'ok': ok
|
||||
} as Record<string, UIExtensionContentSession | Object | Resource>);
|
||||
try {
|
||||
session.loadContent('pages/alertMessage', storage);
|
||||
session.setWindowBackgroundColor(Constants.TRANSPARENT_BACKGROUND_COLOR);
|
||||
} catch (exception) {
|
||||
HiLog.error(TAG, `Failed to set the background color. Cause: ${JSON.stringify(exception)}`);
|
||||
}
|
||||
}
|
||||
|
||||
function getAppId(bundleName: string) {
|
||||
return new Promise<string>(async resolve => {
|
||||
let bundleFlags: number = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
|
||||
@ -522,7 +498,6 @@ export {
|
||||
toggleShow,
|
||||
directionStatus,
|
||||
showErrorDialogAndExit,
|
||||
goToAlertMessagePage,
|
||||
getAppId,
|
||||
getTime,
|
||||
getFileSizeByUri,
|
||||
|
@ -19,7 +19,6 @@ import common from '@ohos.app.ability.common';
|
||||
import Want from '@ohos.app.ability.Want';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import Constants from '../common/constant';
|
||||
import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession';
|
||||
import ability from '@ohos.ability.ability';
|
||||
import account_osAccount from '@ohos.account.osAccount';
|
||||
import dlpPermission from '@ohos.dlpPermission';
|
||||
@ -37,7 +36,7 @@ let storage = LocalStorage.getShared();
|
||||
@Entry(storage)
|
||||
@Component
|
||||
struct Index {
|
||||
@State session: UIExtensionContentSession | undefined = storage === undefined ? undefined : storage.get<UIExtensionContentSession>('session');
|
||||
@State alertWant: Want | undefined = storage.get<Want>('alertWant');
|
||||
@State title: string | Resource = '';
|
||||
@State message: string | Resource = '';
|
||||
@State cancel: string | Resource = '';
|
||||
@ -57,23 +56,14 @@ struct Index {
|
||||
value: this.cancel ? this.cancel : $r('app.string.da_button'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
if (this.session !== undefined) {
|
||||
this.session.terminateSelfWithResult({
|
||||
'resultCode': 0,
|
||||
'want': {
|
||||
'bundleName': Constants.DLP_MANAGER_BUNDLE_NAME,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
abilityResult.resultCode = 0;
|
||||
(getContext(this) as common.UIAbilityContext).terminateSelfWithResult(abilityResult);
|
||||
}
|
||||
abilityResult.resultCode = 0;
|
||||
(getContext(this) as common.UIAbilityContext).terminateSelfWithResult(abilityResult);
|
||||
}
|
||||
}, {
|
||||
value: this.ok,
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
let error = (GlobalContext.load('abilityWant') as Want).parameters?.error as BusinessError;
|
||||
let error = this.alertWant?.parameters?.error as BusinessError;
|
||||
if (error && error.code === Constants.ERR_JS_OFFLINE) {
|
||||
let want: Want = {
|
||||
action: 'action.system.home',
|
||||
@ -93,17 +83,8 @@ struct Index {
|
||||
value: this.cancel ? this.cancel : $r('app.string.da_button'),
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
if (this.session !== undefined) {
|
||||
this.session.terminateSelfWithResult({
|
||||
'resultCode': 0,
|
||||
'want': {
|
||||
'bundleName': Constants.DLP_MANAGER_BUNDLE_NAME,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
abilityResult.resultCode = 0;
|
||||
(getContext(this) as common.UIAbilityContext).terminateSelfWithResult(abilityResult);
|
||||
}
|
||||
abilityResult.resultCode = 0;
|
||||
(getContext(this) as common.UIAbilityContext).terminateSelfWithResult(abilityResult);
|
||||
}
|
||||
}
|
||||
],
|
||||
@ -183,9 +164,9 @@ struct Index {
|
||||
async aboutToAppear() {
|
||||
HiLog.info(TAG, `alert aboutToAppear start`);
|
||||
try {
|
||||
let messageCode = ((GlobalContext.load('abilityWant') as Want).parameters?.error as BusinessError).code;
|
||||
let errorMsg = (GlobalContext.load('abilityWant') as Want).parameters?.error as BusinessError;
|
||||
let accountType = (GlobalContext.load('abilityWant') as Want).parameters?.accountType as number;
|
||||
let messageCode = (this.alertWant?.parameters?.error as BusinessError).code;
|
||||
let errorMsg = this.alertWant?.parameters?.error as BusinessError;
|
||||
let accountType = this.alertWant?.parameters?.accountType as number;
|
||||
let errInfo: Record<string, Resource> = {};
|
||||
this.accountType = accountType;
|
||||
if ([
|
||||
@ -206,7 +187,7 @@ struct Index {
|
||||
} else {
|
||||
errInfo = GetAlertMessage.getAlertMessage(errorMsg);
|
||||
}
|
||||
this.windowHeight = (GlobalContext.load('abilityWant') as Want).parameters?.windowHeight as number;
|
||||
this.windowHeight = this.alertWant?.parameters?.windowHeight as number;
|
||||
this.windowHeight = Number(this.windowHeight) - Constants.START_ABILITY_MSG_HEIGHT_ROWS;
|
||||
this.title = errInfo.title;
|
||||
this.message = errInfo.msg;
|
||||
@ -301,17 +282,8 @@ struct Index {
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary_activated'))
|
||||
.height(Constants.FOOTER_HEIGHT)
|
||||
.onClick(async (event) => {
|
||||
if (this.session !== undefined) {
|
||||
this.session.terminateSelfWithResult({
|
||||
'resultCode': 0,
|
||||
'want': {
|
||||
'bundleName': Constants.DLP_MANAGER_BUNDLE_NAME,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
abilityResult.resultCode = 0;
|
||||
(getContext(this) as common.UIAbilityContext).terminateSelfWithResult(abilityResult);
|
||||
}
|
||||
abilityResult.resultCode = 0;
|
||||
(getContext(this) as common.UIAbilityContext).terminateSelfWithResult(abilityResult);
|
||||
})
|
||||
.margin({ right: Constants.ENCRYPTION_PROTECTION_BUTTON_MARGIN })
|
||||
if (this.ok) {
|
||||
@ -321,7 +293,7 @@ struct Index {
|
||||
.backgroundColor($r('sys.color.ohos_id_color_text_primary_activated'))
|
||||
.height(Constants.FOOTER_BUTTON_HEIGHT)
|
||||
.onClick(async (event) => {
|
||||
let error = (GlobalContext.load('abilityWant') as Want).parameters?.error as BusinessError;
|
||||
let error = this.alertWant?.parameters?.error as BusinessError;
|
||||
if (error && error.code === Constants.ERR_JS_OFFLINE) {
|
||||
let want: Want = {
|
||||
action: 'action.system.home',
|
||||
|
@ -92,7 +92,6 @@ struct changeEncryption {
|
||||
@State staffDataArrayReadOnly: AuthAccount[] = [];
|
||||
@State staffDataArrayEdit: AuthAccount[] = [];
|
||||
private routerData: Record<string, AuthAccount[]> = {};
|
||||
@State domainAccount: boolean = true;
|
||||
@State permissionDict: PermissionValue[] = [
|
||||
{
|
||||
value: $r('app.string.PERMISSION_TYPE_SELECT_TARGET') as Resource, data: 'target', index: 0
|
||||
|
@ -223,13 +223,22 @@ struct encryptedSharing {
|
||||
return false;
|
||||
};
|
||||
let credentialCallBack = JSON.parse(this.isInputInvalid) as Record<string, string>;
|
||||
if (!credentialCallBack.status) {
|
||||
if (!credentialCallBack.status && Number(credentialCallBack.errorCode) === Constants.ERR_CODE_SUCCESS) {
|
||||
HiLog.info(TAG, `credentialCallBack: ${credentialCallBack.msg}`);
|
||||
this.credentialCallBackMsg = credentialCallBack.msg;
|
||||
this.phoneFormatTips = true;
|
||||
AppStorage.setOrCreate('isInputInvalid', '');
|
||||
return false;
|
||||
}
|
||||
if (!credentialCallBack.status && Number(credentialCallBack.errorCode) !== Constants.ERR_CODE_SUCCESS) {
|
||||
promptAction.showToast({
|
||||
message: $r('app.string.network_invalid'),
|
||||
duration: Constants.SHARE_SET_TIMEOUT
|
||||
});
|
||||
this.phoneFormatTips = true;
|
||||
AppStorage.setOrCreate('isInputInvalid', '');
|
||||
return false;
|
||||
}
|
||||
let authUserList: AuthUserList[] = [
|
||||
{
|
||||
'authAccount': credentialCallBack.userIdCipher,
|
||||
|
@ -98,7 +98,6 @@ struct DlpDialog {
|
||||
@State prepareData: boolean = false;
|
||||
@State validity: Date = AppStorage.get('validity') || new Date();
|
||||
@State selectedIndex: number = AppStorage.get('permanent') === false ? 1 : 0;
|
||||
@State domainOrCloudAccount: number = dlpPermission.AccountType.DOMAIN_ACCOUNT
|
||||
@State permissionDict: PermissionType[] = [
|
||||
{
|
||||
value: $r('app.string.PERMISSION_TYPE_SELECT_TARGET'), data: 'target', index: 0
|
||||
@ -504,7 +503,7 @@ struct DlpDialog {
|
||||
authAccount: item.authAccount,
|
||||
dlpFileAccess: dlpPermission.DLPFileAccess.READ_ONLY,
|
||||
permExpiryTime: Date.UTC(9999, 1, 1),
|
||||
authAccountType: this.domainOrCloudAccount,
|
||||
authAccountType: dlpPermission.AccountType.DOMAIN_ACCOUNT,
|
||||
})
|
||||
})
|
||||
this.staffDataArrayEdit && this.staffDataArrayEdit.forEach(item => {
|
||||
@ -512,7 +511,7 @@ struct DlpDialog {
|
||||
authAccount: item.authAccount,
|
||||
dlpFileAccess: dlpPermission.DLPFileAccess.CONTENT_EDIT,
|
||||
permExpiryTime: Date.UTC(9999, 1, 1),
|
||||
authAccountType: this.domainOrCloudAccount,
|
||||
authAccountType: dlpPermission.AccountType.DOMAIN_ACCOUNT,
|
||||
})
|
||||
})
|
||||
}
|
||||
@ -526,7 +525,7 @@ struct DlpDialog {
|
||||
authAccount: this.dlpProperty.ownerAccount,
|
||||
dlpFileAccess: dlpPermission.DLPFileAccess.FULL_CONTROL,
|
||||
permExpiryTime: Date.UTC(9999, 1, 1),
|
||||
authAccountType: this.domainOrCloudAccount,
|
||||
authAccountType: dlpPermission.AccountType.DOMAIN_ACCOUNT,
|
||||
}
|
||||
this.dlpProperty.authUserList?.push(ownerAccount)
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user