• 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 #include "media_control_extension.h"
17 
18 #include "hilog_wrapper.h"
19 #include "js_media_control_extension.h"
20 #include "runtime.h"
21 #include "media_control_extension_context.h"
22 
23 namespace OHOS {
24 namespace AbilityRuntime {
25 using namespace OHOS::AppExecFwk;
Create(const std::unique_ptr<Runtime> & runtime)26 MediaControlExtension* MediaControlExtension::Create(const std::unique_ptr<Runtime>& runtime)
27 {
28     if (!runtime) {
29         return new MediaControlExtension();
30     }
31     HILOG_DEBUG("MediaControlExtension Create runtime");
32     switch (runtime->GetLanguage()) {
33         case Runtime::Language::JS:
34             return JsMediaControlExtension::Create(runtime);
35 
36         default:
37             return new MediaControlExtension();
38     }
39 }
40 
Init(const std::shared_ptr<AbilityLocalRecord> & record,const std::shared_ptr<OHOSApplication> & application,std::shared_ptr<AbilityHandler> & handler,const sptr<IRemoteObject> & token)41 void MediaControlExtension::Init(const std::shared_ptr<AbilityLocalRecord> &record,
42     const std::shared_ptr<OHOSApplication> &application,
43     std::shared_ptr<AbilityHandler> &handler,
44     const sptr<IRemoteObject> &token)
45 {
46     HILOG_DEBUG("MediaControlExtension begin init");
47     ExtensionBase<MediaControlExtensionContext>::Init(record, application, handler, token);
48 }
49 
CreateAndInitContext(const std::shared_ptr<AbilityLocalRecord> & record,const std::shared_ptr<OHOSApplication> & application,std::shared_ptr<AbilityHandler> & handler,const sptr<IRemoteObject> & token)50 std::shared_ptr<MediaControlExtensionContext> MediaControlExtension::CreateAndInitContext(
51     const std::shared_ptr<AbilityLocalRecord> &record,
52     const std::shared_ptr<OHOSApplication> &application,
53     std::shared_ptr<AbilityHandler> &handler,
54     const sptr<IRemoteObject> &token)
55 {
56     std::shared_ptr<MediaControlExtensionContext> context =
57         ExtensionBase<MediaControlExtensionContext>::CreateAndInitContext(record, application, handler, token);
58     if (context == nullptr) {
59         HILOG_ERROR("MediaControlExtension CreateAndInitContext context is nullptr");
60         return context;
61     }
62     return context;
63 }
64 }
65 }
66