1// 2// Copyright (C) 2013 The Android Open Source Project 3// 4// Licensed under the Apache License, Version 2.0 (the "License"); 5// you may not use this file except in compliance with the License. 6// You may obtain a copy of the License at 7// 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// See the License for the specific language governing permissions and 14// limitations under the License. 15// 16 17#include "shill/cellular/subscription_state_out_of_credits_detector.h" 18 19#include <string> 20 21#include "ModemManager/ModemManager.h" 22 23#include "shill/cellular/cellular_service.h" 24#include "shill/logging.h" 25 26using std::string; 27 28namespace shill { 29 30namespace Logging { 31static auto kModuleLogScope = ScopeLogger::kCellular; 32static string ObjectID(CellularService* c) { return c->GetRpcIdentifier(); } 33} 34 35SubscriptionStateOutOfCreditsDetector::SubscriptionStateOutOfCreditsDetector( 36 EventDispatcher* dispatcher, 37 Manager* manager, 38 Metrics* metrics, 39 CellularService* service) 40 : OutOfCreditsDetector(dispatcher, manager, metrics, service) { 41} 42 43SubscriptionStateOutOfCreditsDetector:: 44 ~SubscriptionStateOutOfCreditsDetector() { 45} 46 47void SubscriptionStateOutOfCreditsDetector::NotifySubscriptionStateChanged( 48 uint32_t subscription_state) { 49 bool ooc = (static_cast<MMModem3gppSubscriptionState>(subscription_state) == 50 MM_MODEM_3GPP_SUBSCRIPTION_STATE_OUT_OF_DATA); 51 if (ooc != out_of_credits()) { 52 if (ooc) 53 SLOG(service(), 2) << "Marking service out-of-credits"; 54 else 55 SLOG(service(), 2) << "Marking service as not out-of-credits"; 56 } 57 ReportOutOfCredits(ooc); 58} 59 60} // namespace shill 61