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 Want & want,const StartOptions & options)27 bool HiddenStartUtils::IsHiddenStart(const Want &want, const StartOptions &options)
28 {
29 if (!PermissionVerification::GetInstance()->VerifyStartUIAbilityToHiddenPermission()) {
30 return false;
31 }
32
33 if (options.processOptions == nullptr) {
34 return false;
35 }
36
37 if (options.processOptions->startupVisibility != OHOS::AAFwk::StartupVisibility::STARTUP_HIDE) {
38 return false;
39 }
40
41 return true;
42 }
43
CheckHiddenStartSupported(const Want & want,const StartOptions & options)44 int32_t HiddenStartUtils::CheckHiddenStartSupported(const Want &want, const StartOptions &options)
45 {
46 if (!AppUtils::GetInstance().IsStartOptionsWithAnimation()) {
47 TAG_LOGE(AAFwkTag::ABILITYMGR, "start ability silently is not supported in this device");
48 return ERR_NOT_SUPPORTED_PRODUCT_TYPE;
49 }
50
51 if (options.processOptions == nullptr ||
52 (!ProcessOptions::IsNewHiddenProcessMode(options.processOptions->processMode) &&
53 !ProcessOptions::IsNoAttachmentMode(options.processOptions->processMode))) {
54 TAG_LOGE(AAFwkTag::ABILITYMGR, "this processMode is not supported in hidden start");
55 return ERR_INVALID_VALUE;
56 }
57
58 return ERR_OK;
59 }
60 }
61 }