From 1eb8e2c9e77ad9fed9b1abba0ca6ecc032d83ea4 Mon Sep 17 00:00:00 2001 From: yuaqiang Date: Mon, 24 Jan 2022 03:12:02 +0000 Subject: [PATCH] Description:To request permission dynamically in context Sig:SIG_ApplicationFramework Feature or Bugfix:Feature Binary Source:No Signed-off-by: altay Change-Id: I2de9043672265113f24a4e99bb86254577d72e54 --- api/application/AbilityContext.d.ts | 12 ++++++ api/application/PermissionRequestResult.d.ts | 41 ++++++++++++++++++++ 2 files changed, 53 insertions(+) mode change 100644 => 100755 api/application/AbilityContext.d.ts create mode 100755 api/application/PermissionRequestResult.d.ts diff --git a/api/application/AbilityContext.d.ts b/api/application/AbilityContext.d.ts old mode 100644 new mode 100755 index 345363d17e..311aaae2f4 --- a/api/application/AbilityContext.d.ts +++ b/api/application/AbilityContext.d.ts @@ -21,6 +21,7 @@ import { HapModuleInfo } from "../bundle/hapModuleInfo"; import Context from "./Context"; import Want from "../@ohos.application.Want"; import StartOptions from "../@ohos.application.StartOptions"; +import PermissionRequestResult from "./PermissionRequestResult"; /** * The context of an ability. It allows access to ability-specific resources. @@ -121,4 +122,15 @@ export default class AbilityContext extends Context { */ disconnectAbility(connection: number, callback:AsyncCallback): void; disconnectAbility(connection: number): Promise; + + /** + * Requests certain permissions from the system. + * + * @devices phone, tablet, tv, wearable, car + * @since 8 + * @sysCap AAFwk + * @param permissions Indicates the list of permissions to be requested. This parameter cannot be null or empty. + */ + requestPermissionsFromUser(permissions: Array, requestCallback: AsyncCallback) : void; + requestPermissionsFromUser(permissions: Array) : Promise; } \ No newline at end of file diff --git a/api/application/PermissionRequestResult.d.ts b/api/application/PermissionRequestResult.d.ts new file mode 100755 index 0000000000..9bf51a133f --- /dev/null +++ b/api/application/PermissionRequestResult.d.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2022 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 result of requestPermissionsFromUser with asynchronous callback. + * + * @since 8 + * @sysCap AAFwk + * @devices phone, tablet, tv, wearable, car + * @permission N/A + */ +export default class PermissionRequestResult { + /** + * The permissions passed in by the user. + * + * @since 8 + * @sysCap AAFwk + */ + permissions: Array; + + /** + * The results for the corresponding request permissions. The value 0 indicates that a + * permission is granted, and the value -1 indicates not. + * + * @since 8 + * @sysCap AAFwk + */ + authResults: Array; +} \ No newline at end of file -- Gitee