• 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 
16 #include "wukong_app_manager.h"
17 #include "element_name.h"
18 #include "ability_manager_client.h"
19 #include "app_log_wrapper.h"
20 
21 namespace OHOS {
22     namespace AppExecFwk {
StartAbilityByBundleInfo(std::string AbilityNameArgs,std::string BundleNameArgs)23         ErrCode WuKongAppManager::StartAbilityByBundleInfo(std::string AbilityNameArgs, std::string BundleNameArgs)
24         {
25             Want want;
26             int result;
27 
28             if (AbilityNameArgs.size() == 0 || BundleNameArgs.size() == 0) {
29                 if (AbilityNameArgs.size() == 0) {
30                     resultReceiver_.append(HELP_MSG_NO_ABILITY_NAME_OPTION + "\n");
31                 }
32                 if (BundleNameArgs.size() == 0) {
33                     resultReceiver_.append(HELP_MSG_NO_BUNDLE_NAME_OPTION + "\n");
34                 }
35                 result = OHOS::ERR_INVALID_VALUE;
36             } else {
37                 ElementName element("", BundleNameArgs, AbilityNameArgs);
38                 want.SetElement(element);
39                 result = OHOS::AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want);
40                 if (result == OHOS::ERR_OK) {
41                     resultReceiver_ = STRING_START_ABILITY_OK + "\n";
42                 } else {
43                     resultReceiver_ = STRING_START_ABILITY_NG + "\n";
44                 }
45             }
46             return result;
47         }
48     }
49 }