• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 "hidden_start_utils.h"
17 
18 #include "ability_manager_errors.h"
19 #include "app_mgr_util.h"
20 #include "app_utils.h"
21 #include "process_options.h"
22 #include "permission_verification.h"
23 #include "hilog_tag_wrapper.h"
24 
25 namespace OHOS {
26 namespace AAFwk {
IsHiddenStart(const StartOptions & options)27 bool HiddenStartUtils::IsHiddenStart(const StartOptions &options)
28 {
29     if (!PermissionVerification::GetInstance()->VerifyStartUIAbilityToHiddenPermission() &&
30         !PermissionVerification::GetInstance()->VerifyPreloadApplicationPermission()) {
31         return false;
32     }
33 
34     if (options.processOptions == nullptr) {
35         return false;
36     }
37 
38     if (options.processOptions->startupVisibility != OHOS::AAFwk::StartupVisibility::STARTUP_HIDE) {
39         return false;
40     }
41 
42     return true;
43 }
44 
CheckHiddenStartSupported(const StartOptions & options)45 int32_t HiddenStartUtils::CheckHiddenStartSupported(const StartOptions &options)
46 {
47     if (!AppUtils::GetInstance().IsStartOptionsWithAnimation() &&
48         !AppUtils::GetInstance().IsPreloadApplicationEnabled()) {
49         TAG_LOGE(AAFwkTag::ABILITYMGR, "start ability silently is not supported in this device");
50         return ERR_NOT_SUPPORTED_PRODUCT_TYPE;
51     }
52 
53     if (options.processOptions == nullptr ||
54         (!ProcessOptions::IsNewHiddenProcessMode(options.processOptions->processMode) &&
55         !ProcessOptions::IsNoAttachmentMode(options.processOptions->processMode) &&
56         !options.processOptions->isPreloadStart)) {
57         TAG_LOGE(AAFwkTag::ABILITYMGR, "this processMode is not supported in hidden start");
58         return ERR_INVALID_VALUE;
59     }
60 
61     return ERR_OK;
62 }
63 }
64 }