1 /* 2 * Copyright (c) 2022 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_ABILITYRUNTIME_ICONNECTION_OBSERVER_H 17 #define OHOS_ABILITYRUNTIME_ICONNECTION_OBSERVER_H 18 19 #include "connection_data.h" 20 21 #ifdef WITH_DLP 22 #include "dlp_state_data.h" 23 #endif // WITH_DLP 24 25 #include "iremote_broker.h" 26 27 namespace OHOS { 28 namespace AbilityRuntime { 29 /** 30 * @class IConnectionObserver 31 * IConnectionObserver is used to notify connection relationship of extension component. 32 */ 33 class IConnectionObserver : public OHOS::IRemoteBroker { 34 public: 35 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.abilityruntime.connectionobserver"); 36 37 /** 38 * called when extension was connected. 39 * 40 * @param data connection relationship data. 41 */ 42 virtual void OnExtensionConnected(const ConnectionData &data) = 0; 43 44 /** 45 * called when extension was disconnected. 46 * 47 * @param data connection relationship data. 48 */ 49 virtual void OnExtensionDisconnected(const ConnectionData &data) = 0; 50 51 /** 52 * called when extension was suspended. 53 * 54 * @param data connection relationship data. 55 */ 56 virtual void OnExtensionSuspended(const ConnectionData &data) = 0; 57 58 /** 59 * called when extension was resumed. 60 * 61 * @param data connection relationship data. 62 */ 63 virtual void OnExtensionResumed(const ConnectionData &data) = 0; 64 65 #ifdef WITH_DLP 66 /** 67 * called when dlp ability was started. 68 * 69 * @param data dlp state data. 70 */ 71 virtual void OnDlpAbilityOpened(const DlpStateData &data) = 0; 72 73 /** 74 * called when dlp ability was terminated. 75 * 76 * @param data dlp state data. 77 */ 78 virtual void OnDlpAbilityClosed(const DlpStateData &data) = 0; 79 #endif // WITH_DLP 80 81 enum ConnectionObserverCmd { 82 // ipc id for OnExtensionConnected 83 ON_EXTENSION_CONNECTED = 0, 84 85 // ipc id for OnExtensionDisconnected 86 ON_EXTENSION_DISCONNECTED, 87 88 #ifdef WITH_DLP 89 // ipc id for OnDlpAbilityOpened 90 ON_DLP_ABILITY_OPENED, 91 92 // ipc id for OnExtensionDisconnected 93 ON_DLP_ABILITY_CLOSED, 94 #endif // WITH_DLP 95 96 // ipc id for OnExtensionSuspended 97 ON_EXTENSION_SUSPENDED, 98 99 // ipc id for OnExtensionResumed 100 ON_EXTENSION_RESUMED, 101 102 // maximum of enum 103 CMD_MAX 104 }; 105 }; 106 } // namespace AbilityRuntime 107 } // namespace OHOS 108 #endif // OHOS_ABILITYRUNTIME_ICONNECTION_OBSERVER_H 109