!456 外部入参初始化

Merge pull request !456 from fanchenxuan/master+
This commit is contained in:
openharmony_ci
2025-07-21 06:41:37 +00:00
committed by Gitee
3 changed files with 13 additions and 12 deletions
@@ -33,13 +33,14 @@ export default class GlobalExtensionAbility extends extension {
if (!want.parameters) {
return;
}
let resource: string = want.parameters['ohos.sensitive.resource'] as string ?? '';
if (!globalDialogModel.permissionCheck()) {
this.context?.terminateSelf();
return;
}
if (!globalDialogModel.statusCheck(this.context, want.parameters['ohos.sensitive.resource'] as string)) {
if (!globalDialogModel.statusCheck(this.context, resource)) {
this.context?.terminateSelf();
return;
}
@@ -53,7 +54,7 @@ export default class GlobalExtensionAbility extends extension {
height: dis.height
};
Log.info('want: ' + JSON.stringify(want));
let property: Record<string, Object> = { 'globalState': want.parameters['ohos.sensitive.resource'] };
let property: Record<string, Object> = { 'globalState': resource };
let storage: LocalStorage = new LocalStorage(property);
globalDialogModel.createWindow(this.context, navigationBarRect, storage).then(window => {
globalWindow = window;
@@ -21,13 +21,14 @@ import { abilityAccessCtrl, bundleManager } from '@kit.AbilityKit';
const TAG = 'PermissionManager_Log:';
const USER_ID = 100;
let callerBundleName: string;
export default class MainAbility extends UIAbility {
onCreate(want, launchParam): void {
console.log(TAG + 'MainAbility onCreate, ability name is ' + want.abilityName + '.');
globalThis.bundleName = want.parameters.bundleName;
GlobalContext.store('bundleName', want.parameters.bundleName);
callerBundleName = want.parameters?.bundleName as string ?? '';
GlobalContext.store('bundleName', callerBundleName);
}
onWindowStageCreate(windowStage): void {
@@ -41,9 +42,9 @@ export default class MainAbility extends UIAbility {
return;
}
if (globalThis.bundleName) {
globalThis.currentApp = globalThis.bundleName;
this.getSperifiedApplication(globalThis.bundleName);
if (callerBundleName) {
globalThis.currentApp = callerBundleName;
this.getSperifiedApplication(callerBundleName);
} else {
globalThis.currentApp = 'all';
this.getAllApplications();
@@ -79,9 +80,8 @@ export default class MainAbility extends UIAbility {
onNewWant(want): void {
console.log(TAG + 'MainAbility onNewWant. want: ' + JSON.stringify(want));
console.log(TAG + 'MainAbility onNewWant. bundleName: ' + JSON.stringify(want.parameters.bundleName));
let bundleName = want.parameters.bundleName ? want.parameters.bundleName : 'all';
let bundleName = want.parameters?.bundleName ? want.parameters.bundleName : 'all';
if (globalThis.currentApp === 'all') {
if (globalThis.currentApp !== bundleName) {
console.log(TAG + 'MainAbility onNewWant. all -> app');
@@ -55,11 +55,11 @@ export function ReportDialogResult(wantPermissions: Permissions[]) {
}
export function getCallerBundleInfo(want: WantInfo): CallerBundleInfo {
let bundleName: string = want.parameters['ohos.aafwk.param.callerBundleName'];
let bundleName: string = want.parameters['ohos.aafwk.param.callerBundleName'] ?? '';
let uId: number = want.parameters['ohos.aafwk.param.callerUid'] ?? 0;
let token: number = want.parameters['ohos.aafwk.param.callerToken'] ?? 0;
let permissions: Permissions[] = want.parameters['ohos.user.setting.permission'];
let globSwitch: number = want.parameters['ohos.user.setting.global_switch'];
let permissions: Permissions[] = want.parameters['ohos.user.setting.permission'] ?? [];
let globSwitch: number = want.parameters['ohos.user.setting.global_switch'] ?? -1;
const callerBundle: CallerBundleInfo = {
bundleName: bundleName,