add fenceExtension

Signed-off-by: 李文龙 <liwenlong22@huawei.com>
This commit is contained in:
李文龙 2024-10-10 16:09:24 +08:00
parent c27d604c0b
commit ad10f1b834
3 changed files with 127 additions and 0 deletions

View File

@ -0,0 +1,57 @@
/*
* Copyright (c) 2024 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.
*/
/**
* @file
* @kit LocationKit
*/
import type FenceExtensionContext from './@ohos.app.ability.FenceExtensionContext';
import geoLocationManager from './@ohos.geoLocationManager';
/**
* Class of fence extension ability.
*
* @syscap SystemCapability.Location.Location.Geofence
* @since 5.0.0(12)
*/
export default class FenceExtensionAbility {
/**
* Indicates fence extension context.
*
* @type { FenceExtensionContext }
* @syscap SystemCapability.Location.Location.Geofence
* @since 12
*/
context: FenceExtensionContext;
/**
* Called back when geofence status is change.
*
* @param { geoLocationManager.GeofenceTransition } transition - Geofence transition status
* @param { Record<string, string> } additions - Indicates additional information
* @syscap SystemCapability.Location.Location.Geofence
* @since 12
*/
onFenceStatusChange(transition: geoLocationManager.GeofenceTransition, additions: Record<string, string>): void;
/**
* Called back before a fence extension is destroyed.
*
* @syscap SystemCapability.Location.Location.Geofence
* @since 12
*/
onDestroy(): void;
}

View File

@ -0,0 +1,62 @@
/*
* Copyright (c) 2024 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.
*/
/**
* @file
* @kit LocationKit
*/
import ExtensionContext from './application/ExtensionContext';
import type Want from './@ohos.app.ability.Want';
/**
* class of static subscriber extension context.
*
* @extends ExtensionContext
* @syscap SystemCapability.Location.Location.Geofence
* @since 12
*/
export default class FenceExtensionContext extends ExtensionContext {
/**
* Starts a new service extension ability.
* If the target service extension ability is visible, you can start the target service extension ability;
* If the target service extension ability is invisible,
* you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible service extension ability.
* If the target service extension ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC.
*
* @param { Want } want - Indicates the want info to start.
* @returns { Promise<void> } The promise returned by the function.
* @throws { BusinessError } 201 - The application does not have permission to call the interface.
* @throws { BusinessError } 202 - The application is not system-app, can not use system-api.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
* @throws { BusinessError } 16000001 - The specified ability does not exist.
* @throws { BusinessError } 16000002 - Incorrect ability type.
* @throws { BusinessError } 16000004 - Can not start invisible component.
* @throws { BusinessError } 16000005 - The specified process does not have the permission.
* @throws { BusinessError } 16000006 - Cross-user operations are not allowed.
* @throws { BusinessError } 16000008 - The crowdtesting application expires.
* @throws { BusinessError } 16000011 - The context does not exist.
* @throws { BusinessError } 16000012 - The application is controlled.
* @throws { BusinessError } 16000013 - The application is controlled by EDM.
* @throws { BusinessError } 16000019 - Can not match any component.
* @throws { BusinessError } 16000050 - Internal error.
* @throws { BusinessError } 16200001 - The caller has been released.
* @syscap SystemCapability.Location.Location.Geofence
* @systemapi
* @stagemodelonly
* @since 12
*/
startAbility(want: Want): Promise<void>;
}

View File

@ -662,6 +662,14 @@ declare namespace bundleManager {
*/
INSIGHT_INTENT_UI = 22,
/**
* Indicates extension info with type of fence
*
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @since 12
*/
FENCE = 24,
/**
* Indicates extension info with type of unspecified
*