• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 
16 #ifndef OHOS_ABILITY_RUNTIME_MEDIA_CONTROL_EXTENSION_CONTEXT_H
17 #define OHOS_ABILITY_RUNTIME_MEDIA_CONTROL_EXTENSION_CONTEXT_H
18 
19 #include "extension_context.h"
20 
21 #include "start_options.h"
22 #include "want.h"
23 
24 namespace OHOS {
25 namespace AbilityRuntime {
26 /**
27  * @brief context supply for MediaControlExtension
28  *
29  */
30 class MediaControlExtensionContext : public ExtensionContext {
31 public:
32     MediaControlExtensionContext() = default;
33     virtual ~MediaControlExtensionContext() = default;
34 
35     /**
36      * @brief Starts a new ability.
37      * An ability using the AbilityInfo.AbilityType.EXTENSION or
38      * AbilityInfo.AbilityType.PAGE template uses this method
39      * to start a specific ability. The system locates the target ability
40      * from installed abilities based on the value
41      * of the want parameter and then starts it.
42      * You can specify the ability to start using the want parameter.
43      *
44      * @param want Indicates the Want containing information about the target ability to start.
45      *
46      * @return errCode ERR_OK on success, others on failure.
47      */
48     virtual ErrCode StartAbility(const AAFwk::Want &want) const;
49     virtual ErrCode StartAbility(const AAFwk::Want &want, const AAFwk::StartOptions &startOptions) const;
50 
51     /**
52      * @brief Destroys the current ui extension ability.
53      *
54      * @return errCode ERR_OK on success, others on failure.
55      */
56     virtual ErrCode TerminateSelf();
57 
58     using SelfType = MediaControlExtensionContext;
59     static const size_t CONTEXT_TYPE_ID;
60 
61 private:
62     static int ILLEGAL_REQUEST_CODE;
63 
64     /**
65      * @brief Get Current Ability Type
66      *
67      * @return Current Ability Type
68      */
69     OHOS::AppExecFwk::AbilityType GetAbilityInfoType() const;
70 };
71 }  // namespace AbilityRuntime
72 }  // namespace OHOS
73 #endif  // OHOS_ABILITY_RUNTIME_MEDIA_CONTROL_EXTENSION_CONTEXT_H
74