• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { AsyncCallback , Callback} from './basic';
17import { WantAgent } from "./@ohos.wantAgent";
18import Context from './application/BaseContext';
19
20/**
21 * Manages background tasks.
22 *
23 * @since 7
24 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
25 * @deprecated since 9
26 * @useinstead @ohos.resourceschedule.backgroundTaskManager
27 */
28declare namespace backgroundTaskManager {
29    /**
30     * The info of delay suspend.
31     *
32     * @name DelaySuspendInfo
33     * @since 7
34     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
35     * @deprecated since 9
36     * @useinstead @ohos.resourceschedule.backgroundTaskManager.DelaySuspendInfo
37     */
38    interface DelaySuspendInfo {
39        /**
40         * The unique identifier of the delay request.
41         */
42        requestId: number;
43        /**
44         * The actual delay duration (ms).
45         */
46        actualDelayTime: number;
47    }
48
49    /**
50     * Cancels delayed transition to the suspended state.
51     *
52     * @since 7
53     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
54     * @param requestId Indicates the identifier of the delay request.
55     * @deprecated since 9
56     * @useinstead @ohos.resourceschedule.backgroundTaskManager.cancelSuspendDelay
57     */
58    function cancelSuspendDelay(requestId: number): void;
59
60    /**
61     * Obtains the remaining time before an application enters the suspended state.
62     *
63     * @since 7
64     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
65     * @param requestId Indicates the identifier of the delay request.
66     * @return The remaining delay time
67     * @deprecated since 9
68     * @useinstead @ohos.resourceschedule.backgroundTaskManager.getRemainingDelayTime
69     */
70    function getRemainingDelayTime(requestId: number, callback: AsyncCallback<number>): void;
71    function getRemainingDelayTime(requestId: number): Promise<number>;
72
73    /**
74     * Requests delayed transition to the suspended state.
75     *
76     * @since 7
77     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
78     * @param reason Indicates the reason for delayed transition to the suspended state.
79     * @param callback The callback delay time expired.
80     * @return Info of delay request
81     * @deprecated since 9
82     * @useinstead @ohos.resourceschedule.backgroundTaskManager.requestSuspendDelay
83     */
84    function requestSuspendDelay(reason: string, callback: Callback<void>): DelaySuspendInfo;
85
86    /**
87     * Service ability uses this method to request start running in background.
88     * system will publish a notification related to the this service.
89     *
90     * @since 8
91     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
92     * @permission ohos.permission.KEEP_BACKGROUND_RUNNING
93     * @param context app running context.
94     * @param bgMode Indicates which background mode to request.
95     * @param wantAgent Indicates which ability to start when user click the notification bar.
96     * @deprecated since 9
97     * @useinstead @ohos.resourceschedule.backgroundTaskManager.startBackgroundRunning
98     */
99    function startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent, callback: AsyncCallback<void>): void;
100    function startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent): Promise<void>;
101
102    /**
103     * Service ability uses this method to request stop running in background.
104     *
105     * @since 8
106     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
107     * @param context app running context.
108     * @deprecated since 9
109     * @useinstead @ohos.resourceschedule.backgroundTaskManager.stopBackgroundRunning
110     */
111    function stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): void;
112    function stopBackgroundRunning(context: Context): Promise<void>;
113
114    /**
115     * supported background mode.
116     *
117     * @since 8
118     * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
119     * @deprecated since 9
120     * @useinstead @ohos.resourceschedule.backgroundTaskManager.BackgroundMode
121     */
122    export enum BackgroundMode {
123        /**
124         * data transfer mode
125         *
126         * @since 8
127         * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
128         */
129        DATA_TRANSFER = 1,
130
131        /**
132         * audio playback mode
133         *
134         * @since 8
135         * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
136         */
137        AUDIO_PLAYBACK = 2,
138
139        /**
140         * audio recording mode
141         *
142         * @since 8
143         * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
144         */
145        AUDIO_RECORDING = 3,
146
147        /**
148         * location mode
149         *
150         * @since 8
151         * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
152         */
153        LOCATION = 4,
154
155        /**
156         * bluetooth interaction mode
157         *
158         * @since 8
159         * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
160         */
161        BLUETOOTH_INTERACTION = 5,
162
163        /**
164         * multi-device connection mode
165         *
166         * @since 8
167         * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
168         */
169        MULTI_DEVICE_CONNECTION = 6,
170
171        /**
172         * wifi interaction mode
173         *
174         * @since 8
175         * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
176         * @systemapi Hide this for inner system use.
177         */
178        WIFI_INTERACTION = 7,
179
180        /**
181         * Voice over Internet Phone mode
182         *
183         * @since 8
184         * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
185         * @systemapi Hide this for inner system use.
186         */
187        VOIP = 8,
188
189        /**
190         * background continuous calculate mode, for example 3D render.
191         * only supported in particular device
192         *
193         * @since 8
194         * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
195         */
196        TASK_KEEPING = 9,
197    }
198}
199
200export default backgroundTaskManager;
201