1 /* 2 * Copyright (c) 2021 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 #ifndef OHOS_ABILITY_RUNTIME_ABILITY_PROCESS_H 17 #define OHOS_ABILITY_RUNTIME_ABILITY_PROCESS_H 18 19 #include <mutex> 20 #include "feature_ability_common.h" 21 #include "napi_context.h" 22 23 namespace OHOS { 24 namespace AppExecFwk { 25 /** 26 * @class AbilityProcess 27 * Provides the feature ability function. 28 */ 29 class AbilityProcess { 30 public: 31 AbilityProcess(); 32 virtual ~AbilityProcess(); 33 static std::shared_ptr<AbilityProcess> GetInstance(); 34 35 ErrCode StartAbility(Ability *ability, CallAbilityParam param, CallbackInfo callback); 36 void OnAbilityResult(Ability *ability, int requestCode, int resultCode, const Want &resultData); 37 void AddAbilityResultCallback(Ability *ability, CallAbilityParam ¶m, int32_t errCode, CallbackInfo &callback); 38 39 void RequestPermissionsFromUser(Ability *ability, CallAbilityPermissionParam ¶m, CallbackInfo callbackInfo); 40 41 private: 42 bool CaullFunc(int requestCode, const std::vector<std::string> &permissions, 43 const std::vector<int> &permissionsState, CallbackInfo &callbackInfo); 44 45 private: 46 static std::mutex mutex_; 47 static std::shared_ptr<AbilityProcess> instance_; 48 static std::map<Ability *, std::map<int, CallbackInfo>> abilityResultMap_; 49 }; 50 } // namespace AppExecFwk 51 } // namespace OHOS 52 #endif // OHOS_ABILITY_RUNTIME_ABILITY_PROCESS_H 53