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_CONTROLLER_STUB_H 17 #define OHOS_ABILITY_RUNTIME_ABILITY_CONTROLLER_STUB_H 18 19 #include <map> 20 21 #include "iremote_stub.h" 22 #include "iability_controller.h" 23 #include "nocopyable.h" 24 #include "string_ex.h" 25 26 namespace OHOS { 27 namespace AppExecFwk { 28 /** 29 * @brief Testing interface to monitor what is happening in ability manager while tests are running. 30 */ 31 class AbilityControllerStub : public IRemoteStub<IAbilityController> { 32 public: 33 AbilityControllerStub(); 34 virtual ~AbilityControllerStub(); 35 36 virtual int OnRemoteRequest( 37 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 38 39 /** 40 * The system is trying to start an ability. 41 * 42 * @param want The want of ability to start. 43 * @param bundleName The bundleName of ability to start. 44 * @return Return true to allow ability to start, or false to reject. 45 */ 46 virtual bool AllowAbilityStart(const Want &want, const std::string &bundleName) override; 47 48 /** 49 * The system is scheduling Ability to background. 50 * 51 * @param bundleName The bundleName of ability to return. 52 * @return Return true to allow ability to background, or false to reject. 53 */ 54 virtual bool AllowAbilityBackground(const std::string &bundleName) override; 55 56 private: 57 int32_t HandleAllowAbilityStart(MessageParcel &data, MessageParcel &reply); 58 59 int32_t HandleAllowAbilityBackground(MessageParcel &data, MessageParcel &reply); 60 61 DISALLOW_COPY_AND_MOVE(AbilityControllerStub); 62 }; 63 } // namespace AppExecFwk 64 } // namespace OHOS 65 #endif // OHOS_ABILITY_RUNTIME_ABILITY_CONTROLLER_STUB_H 66