1 /* 2 * Copyright (c) 2020 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_AMS_INTERFACE_H 17 #define OHOS_AMS_INTERFACE_H 18 19 #include "feature.h" 20 #ifndef __LITEOS_M__ 21 #include "iproxy_server.h" 22 #else 23 #include "iunknown.h" 24 #endif 25 #include "want.h" 26 27 #ifdef __cplusplus 28 #if __cplusplus 29 extern "C" { 30 #endif 31 #endif /* __cplusplus */ 32 33 const char AMS_SERVICE[] = "abilityms"; 34 const char AMS_FEATURE[] = "AmsFeature"; 35 const char AMS_SLITE_FEATURE[] = "AmsSliteFeature"; 36 const char AMS_INNER_FEATURE[] = "AmsInnerFeature"; 37 38 #ifdef __LITEOS_M__ 39 constexpr uint32_t TRANSACTION_MSG_TOKEN_MASK = 0xFFFF; 40 constexpr uint32_t TRANSACTION_MSG_STATE_MASK = 0xFFFF; 41 constexpr uint32_t TRANSACTION_MSG_STATE_OFFSET = 16; 42 #endif 43 44 enum AmsCommand { 45 START_ABILITY = 0, 46 TERMINATE_ABILITY, 47 ATTACH_BUNDLE, 48 CONNECT_ABILITY, 49 CONNECT_ABILITY_DONE, 50 DISCONNECT_ABILITY, 51 DISCONNECT_ABILITY_DONE, 52 ABILITY_TRANSACTION_DONE, 53 TERMINATE_SERVICE, 54 START_ABILITY_WITH_CB, 55 INNER_BEGIN, 56 TERMINATE_APP = INNER_BEGIN, 57 DUMP_ABILITY, 58 TERMINATE_APP_BY_BUNDLENAME, 59 ADD_ABILITY_RECORD_OBSERVER, 60 REMOVE_ABILITY_RECORD_OBSERVER, 61 TERMINATE_MISSION, 62 TERMINATE_ALL, 63 COMMAND_END, 64 }; 65 66 #ifndef __LITEOS_M__ 67 /** 68 * Expose to start or terminate ability. 69 */ 70 struct AmsInterface { 71 INHERIT_SERVER_IPROXY; 72 int32 (*StartAbility)(const Want *want); 73 int32 (*TerminateAbility)(uint64_t token); 74 int32 (*ConnectAbility)(const Want *want, SvcIdentity *svc, uint64_t token); 75 int32 (*DisconnectAbility)(SvcIdentity *svc, uint64_t token); 76 int32 (*StopAbility)(const Want *want); 77 }; 78 79 struct AmsInnerInterface { 80 INHERIT_SERVER_IPROXY; 81 int32 (*StartKeepAliveApps)(); 82 int32 (*TerminateApp)(const char *bundleName); 83 }; 84 #else 85 struct AmsSliteInterface { 86 INHERIT_IUNKNOWN; 87 int32_t (*StartAbility)(const Want *want); 88 int32_t (*TerminateAbility)(uint64_t token); 89 int32_t (*SchedulerLifecycleDone)(uint64_t token, int state); 90 int32_t (*ForceStopBundle)(uint64_t token); 91 ElementName *(*GetTopAbility)(); 92 void *(*GetMissionInfos)(uint32_t maxNum); 93 }; 94 #endif 95 #ifdef __cplusplus 96 #if __cplusplus 97 } 98 #endif 99 #endif /* __cplusplus */ 100 #endif // OHOS_AMS_INTERFACE_H 101