From 570081c4b22bfa46c8a6c75ad07cfef1d5142a5d Mon Sep 17 00:00:00 2001 From: shiyu_huang Date: Wed, 19 Jan 2022 17:09:01 +0800 Subject: [PATCH] Add appliction.BaseContext as base class for app.Context and application.Context Change-Id: Ia8b040cc6169ab7ba9e724d0530abc87ab0046f0 Signed-off-by: shiyu_huang --- api/app/context.d.ts | 3 ++- api/application/BaseContext.d.ts | 33 ++++++++++++++++++++++++++++++++ api/application/Context.d.ts | 3 ++- 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 api/application/BaseContext.d.ts diff --git a/api/app/context.d.ts b/api/app/context.d.ts index cb0b24f6e9..e4babaa2bd 100644 --- a/api/app/context.d.ts +++ b/api/app/context.d.ts @@ -17,6 +17,7 @@ import { AsyncCallback } from '../basic'; import { ApplicationInfo } from '../bundle/applicationInfo'; import { ProcessInfo } from './processInfo'; import { ElementName } from '../bundle/elementName'; +import BaseContext from '../application/BaseContext'; /** * The context of an ability or an application. It allows access to @@ -29,7 +30,7 @@ import { ElementName } from '../bundle/elementName'; * @import import abilityManager from 'app/context' * @permission N/A */ -export interface Context { +export interface Context extends BaseContext { /** * Get the local root dir of an app. If it is the first call, the dir diff --git a/api/application/BaseContext.d.ts b/api/application/BaseContext.d.ts new file mode 100644 index 0000000000..9461fdde36 --- /dev/null +++ b/api/application/BaseContext.d.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * The base context of 'app.Context' for FA Mode or + * 'application.Context' for Stage Mode. + * + * @since 8 + * @sysCap AAFwk + * @devices phone, tablet, tv, wearable, car + * @permission N/A + */ +export default interface BaseContext { + /** + * Indicates the context is FA Mode or Stage Mode. + * + * @since 8 + * @sysCap AAFwk + */ + stageMode: boolean; +} \ No newline at end of file diff --git a/api/application/Context.d.ts b/api/application/Context.d.ts index db1912de81..ce5fb3d345 100644 --- a/api/application/Context.d.ts +++ b/api/application/Context.d.ts @@ -15,6 +15,7 @@ import { ApplicationInfo } from "../bundle/applicationInfo"; import resmgr from "../@ohos.resourceManager"; +import BaseContext from "./BaseContext"; /** * The base context of an ability or an application. It allows access to @@ -25,7 +26,7 @@ import resmgr from "../@ohos.resourceManager"; * @devices phone, tablet, tv, wearable, car * @permission N/A */ -export default class Context { +export default class Context extends BaseContext { /** * Indicates the capability of accessing application resources. * -- Gitee