1 /*
2 * Copyright (c) 2024 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 #ifdef FEATURE_GNSS_SUPPORT
17 #include "gnss_common_event_subscriber.h"
18
19 #include "agnss_ni_manager.h"
20 #include "location_log.h"
21
22 namespace OHOS {
23 namespace Location {
OnReceiveEvent(const OHOS::EventFwk::CommonEventData & data)24 void GnssCommonEventSubscriber::OnReceiveEvent(const OHOS::EventFwk::CommonEventData &data)
25 {
26 LBSLOGI(GNSS, "OnReceiveEvent");
27 auto want = data.GetWant();
28 std::string action = want.GetAction();
29
30 auto agnssNiManager = AGnssNiManager::GetInstance();
31 if (agnssNiManager == nullptr) {
32 LBSLOGE(GNSS, "agnssNiManager nullptr");
33 return;
34 }
35 if (action == CommonEventSupport::COMMON_EVENT_SMS_RECEIVE_COMPLETED) {
36 LBSLOGI(GNSS, "[AGNSS NI]:receive sms msg");
37 agnssNiManager->CheckSmsSuplInit(want);
38 } else if (action == CommonEventSupport::COMMON_EVENT_SMS_WAPPUSH_RECEIVE_COMPLETED) {
39 LBSLOGI(GNSS, "[AGNSS NI]:receive wap push msg");
40 agnssNiManager->CheckWapSuplInit(want);
41 } else if (action == CommonEventSupport::COMMON_EVENT_CALL_STATE_CHANGED) {
42 LBSLOGI(GNSS, "[AGNSS NI]:receive call state msg");
43 agnssNiManager->OnCallStateChanged(want);
44 } else if (action == AGNSS_NI_ACCEPT_EVENT) {
45 LBSLOGI(GNSS, "[AGNSS NI]:receive user accept event");
46 agnssNiManager->SendUserResponse(GNSS_NI_RESPONSE_CMD_ACCEPT);
47 } else if (action == AGNSS_NI_REJECT_EVENT) {
48 LBSLOGI(GNSS, "[AGNSS NI]:receive user reject event");
49 agnssNiManager->SendUserResponse(GNSS_NI_RESPONSE_CMD_REJECT);
50 }
51 }
52 } // namespace Location
53 } // namespace OHOS
54 #endif // FEATURE_GNSS_SUPPORT
55