1eace7efcSopenharmony_ci/* 2eace7efcSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 3eace7efcSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4eace7efcSopenharmony_ci * you may not use this file except in compliance with the License. 5eace7efcSopenharmony_ci * You may obtain a copy of the License at 6eace7efcSopenharmony_ci * 7eace7efcSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8eace7efcSopenharmony_ci * 9eace7efcSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10eace7efcSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11eace7efcSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12eace7efcSopenharmony_ci * See the License for the specific language governing permissions and 13eace7efcSopenharmony_ci * limitations under the License. 14eace7efcSopenharmony_ci */ 15eace7efcSopenharmony_ci 16eace7efcSopenharmony_ci#ifndef OHOS_ABILITY_RUNTIME_START_ABILITY_HANDLER_H 17eace7efcSopenharmony_ci#define OHOS_ABILITY_RUNTIME_START_ABILITY_HANDLER_H 18eace7efcSopenharmony_ci#include <memory> 19eace7efcSopenharmony_ci#include <optional> 20eace7efcSopenharmony_ci 21eace7efcSopenharmony_ci#include "ability_record.h" 22eace7efcSopenharmony_ci#include "event_report.h" 23eace7efcSopenharmony_ci#include "want.h" 24eace7efcSopenharmony_ci#include "refbase.h" 25eace7efcSopenharmony_ci 26eace7efcSopenharmony_cinamespace OHOS { 27eace7efcSopenharmony_ciclass IRemoteObject; 28eace7efcSopenharmony_cinamespace AAFwk { 29eace7efcSopenharmony_cistruct StartAbilityParams { 30eace7efcSopenharmony_ci StartAbilityParams(Want &reqWant) : want(reqWant) {} 31eace7efcSopenharmony_ci Want &want; 32eace7efcSopenharmony_ci sptr<IRemoteObject> callerToken; 33eace7efcSopenharmony_ci sptr<IRemoteObject> asCallerSourceToken; 34eace7efcSopenharmony_ci int32_t userId = -1; 35eace7efcSopenharmony_ci int requestCode = 0; 36eace7efcSopenharmony_ci bool isStartAsCaller = false; 37eace7efcSopenharmony_ci const StartOptions* startOptions = nullptr; 38eace7efcSopenharmony_ci 39eace7efcSopenharmony_ci int32_t GetValidUserId() 40eace7efcSopenharmony_ci { 41eace7efcSopenharmony_ci return validUserId; 42eace7efcSopenharmony_ci } 43eace7efcSopenharmony_ci void SetValidUserId(int32_t value) 44eace7efcSopenharmony_ci { 45eace7efcSopenharmony_ci validUserId = value; 46eace7efcSopenharmony_ci } 47eace7efcSopenharmony_ci bool IsCallerSandboxApp(); 48eace7efcSopenharmony_ci 49eace7efcSopenharmony_ci#ifdef WITH_DLP 50eace7efcSopenharmony_ci bool OtherAppsAccessDlp(); 51eace7efcSopenharmony_ci bool DlpAccessOtherApps(); 52eace7efcSopenharmony_ci bool SandboxExternalAuth(); 53eace7efcSopenharmony_ci#endif // WITH_DLP 54eace7efcSopenharmony_ci bool IsCallerSysApp(); 55eace7efcSopenharmony_ci std::shared_ptr<AbilityRecord> GetCallerRecord(); 56eace7efcSopenharmony_ci int32_t GetCallerAppIndex(); 57eace7efcSopenharmony_ci 58eace7efcSopenharmony_ci EventInfo BuildEventInfo(); 59eace7efcSopenharmony_ciprivate: 60eace7efcSopenharmony_ci int32_t validUserId = 0; 61eace7efcSopenharmony_ci#ifdef WITH_DLP 62eace7efcSopenharmony_ci std::optional<bool> otherAppsAccessDlp; 63eace7efcSopenharmony_ci std::optional<bool> dlpAccessOtherApps; 64eace7efcSopenharmony_ci#endif // WITH_DLP 65eace7efcSopenharmony_ci std::optional<bool> sandboxExternalAuth; 66eace7efcSopenharmony_ci std::optional<bool> isCallerSysApp; 67eace7efcSopenharmony_ci std::optional<std::shared_ptr<AbilityRecord>> callerRecord; 68eace7efcSopenharmony_ci std::optional<int32_t> callerAppIndex; 69eace7efcSopenharmony_ci}; 70eace7efcSopenharmony_ci 71eace7efcSopenharmony_ciclass StartAbilityHandler { 72eace7efcSopenharmony_cipublic: 73eace7efcSopenharmony_ci StartAbilityHandler() = default; 74eace7efcSopenharmony_ci StartAbilityHandler(StartAbilityHandler &) = delete; 75eace7efcSopenharmony_ci void operator=(StartAbilityHandler &) = delete; 76eace7efcSopenharmony_ci virtual ~StartAbilityHandler() = default; 77eace7efcSopenharmony_ci virtual bool MatchStartRequest(StartAbilityParams ¶ms); 78eace7efcSopenharmony_ci virtual int HandleStartRequest(StartAbilityParams ¶ms); 79eace7efcSopenharmony_ci virtual int GetPriority() 80eace7efcSopenharmony_ci { 81eace7efcSopenharmony_ci return 0; 82eace7efcSopenharmony_ci } 83eace7efcSopenharmony_ci virtual std::string GetHandlerName() 84eace7efcSopenharmony_ci { 85eace7efcSopenharmony_ci return ""; 86eace7efcSopenharmony_ci } 87eace7efcSopenharmony_ci}; 88eace7efcSopenharmony_ci} // namespace AAFwk 89eace7efcSopenharmony_ci} // namespace OHOS 90eace7efcSopenharmony_ci#endif // OHOS_ABILITY_RUNTIME_START_ABILITY_HANDLER_H