blob: 1b022b650a38c5c9bbbe602bca7f95292ea47bce [file] [log] [blame]
Darin Petkovac635a82012-01-10 16:51:58 +01001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Darin Petkovdaf43862011-10-27 11:37:28 +02002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef SHILL_CELLULAR_CAPABILITY_CDMA_
6#define SHILL_CELLULAR_CAPABILITY_CDMA_
7
Darin Petkov184c54e2011-11-15 12:44:39 +01008#include <base/memory/scoped_ptr.h>
Eric Shienbrood3e20a232012-02-16 11:35:56 -05009#include <base/memory/weak_ptr.h>
Jason Glasgow9f09aef2012-05-08 16:26:55 -040010#include <chromeos/dbus/service_constants.h>
Darin Petkovae0c64e2011-11-15 15:50:27 +010011#include <gtest/gtest_prod.h> // for FRIEND_TEST
Darin Petkova3d3be52011-11-14 21:34:16 +010012
Jason Glasgow82f9ab32012-04-04 14:27:19 -040013#include <string>
Jason Glasgow4c0724a2012-04-17 15:47:40 -040014#include <vector>
Jason Glasgow82f9ab32012-04-04 14:27:19 -040015
Darin Petkovdaf43862011-10-27 11:37:28 +020016#include "shill/cellular_capability.h"
Jason Glasgow82f9ab32012-04-04 14:27:19 -040017#include "shill/cellular_capability_classic.h"
Darin Petkov381928f2012-02-02 23:00:12 +010018#include "shill/cellular_service.h"
Darin Petkov184c54e2011-11-15 12:44:39 +010019#include "shill/modem_cdma_proxy_interface.h"
Darin Petkovdaf43862011-10-27 11:37:28 +020020
21namespace shill {
22
Jason Glasgow82f9ab32012-04-04 14:27:19 -040023class CellularCapabilityCDMA : public CellularCapabilityClassic {
Darin Petkovdaf43862011-10-27 11:37:28 +020024 public:
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050025 CellularCapabilityCDMA(Cellular *cellular, ProxyFactory *proxy_factory);
Darin Petkovdaf43862011-10-27 11:37:28 +020026
Darin Petkovb05315f2011-11-07 10:14:25 +010027 // Inherited from CellularCapability.
Eric Shienbrood9a245532012-03-07 14:20:39 -050028 virtual void StartModem(Error *error, const ResultCallback &callback);
Darin Petkov5f316f62011-11-18 12:10:26 +010029 virtual void OnServiceCreated();
Darin Petkovae0c64e2011-11-15 15:50:27 +010030 virtual void SetupConnectProperties(DBusPropertiesMap *properties);
Eric Shienbrood9a245532012-03-07 14:20:39 -050031 virtual void Activate(const std::string &carrier, Error *error,
32 const ResultCallback &callback);
Darin Petkovb72cf402011-11-22 14:51:39 +010033 virtual bool IsRegistered();
Eric Shienbrood7fce52c2012-04-13 19:11:02 -040034 virtual void SetUnregistered(bool searching);
Darin Petkovac635a82012-01-10 16:51:58 +010035 virtual std::string CreateFriendlyServiceName();
Darin Petkov20c13ec2011-11-09 15:07:15 +010036 virtual std::string GetNetworkTechnologyString() const;
37 virtual std::string GetRoamingStateString() const;
Darin Petkov3e509242011-11-10 14:46:44 +010038 virtual void GetSignalQuality();
Jason Glasgow9f09aef2012-05-08 16:26:55 -040039 virtual std::string GetTypeString() const {
40 return flimflam::kTechnologyFamilyCdma;
41 }
Jason Glasgow4c0724a2012-04-17 15:47:40 -040042 virtual bool AllowRoaming();
Eric Shienbrood9a245532012-03-07 14:20:39 -050043 virtual void GetRegistrationState();
44 virtual void GetProperties(const ResultCallback &callback);
Eric Shienbrood9a245532012-03-07 14:20:39 -050045 virtual void GetMEID(const ResultCallback &callback);
Darin Petkovcb547732011-11-09 13:55:26 +010046
Darin Petkovae0c64e2011-11-15 15:50:27 +010047 uint32 activation_state() const { return activation_state_; }
Darin Petkov184c54e2011-11-15 12:44:39 +010048 uint32 registration_state_evdo() const { return registration_state_evdo_; }
49 uint32 registration_state_1x() const { return registration_state_1x_; }
50
Eric Shienbrood9a245532012-03-07 14:20:39 -050051 protected:
52 virtual void InitProxies();
53 virtual void ReleaseProxies();
Jason Glasgow4380f0d2012-05-03 18:05:04 -040054 virtual void UpdateStatus(const DBusPropertiesMap &properties);
Eric Shienbrood9a245532012-03-07 14:20:39 -050055
Darin Petkovdaf43862011-10-27 11:37:28 +020056 private:
Darin Petkov184c54e2011-11-15 12:44:39 +010057 friend class CellularCapabilityCDMATest;
Eric Shienbrood9a245532012-03-07 14:20:39 -050058 friend class CellularTest;
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050059 FRIEND_TEST(CellularCapabilityCDMATest, Activate);
60 FRIEND_TEST(CellularCapabilityCDMATest, ActivateError);
Darin Petkovac635a82012-01-10 16:51:58 +010061 FRIEND_TEST(CellularCapabilityCDMATest, CreateFriendlyServiceName);
Darin Petkovae0c64e2011-11-15 15:50:27 +010062 FRIEND_TEST(CellularCapabilityCDMATest, GetActivationStateString);
63 FRIEND_TEST(CellularCapabilityCDMATest, GetActivationErrorString);
64 FRIEND_TEST(CellularTest, CreateService);
65
66 static const char kPhoneNumber[];
Darin Petkov184c54e2011-11-15 12:44:39 +010067
Darin Petkovae0c64e2011-11-15 15:50:27 +010068 void HandleNewActivationState(uint32 error);
69
70 // Updates the serving operator on the active service.
71 void UpdateServingOperator();
72
73 static std::string GetActivationStateString(uint32 state);
74 static std::string GetActivationErrorString(uint32 error);
75
Eric Shienbrood9a245532012-03-07 14:20:39 -050076 // Signal callbacks from the Modem.CDMA interface
Nathan Williams3022be52012-04-19 17:40:49 -040077 void OnActivationStateChangedSignal(
Darin Petkov184c54e2011-11-15 12:44:39 +010078 uint32 activation_state,
79 uint32 activation_error,
80 const DBusPropertiesMap &status_changes);
Nathan Williams3022be52012-04-19 17:40:49 -040081 void OnRegistrationStateChangedSignal(
Eric Shienbrood9a245532012-03-07 14:20:39 -050082 uint32 state_1x, uint32 state_evdo);
Nathan Williams3022be52012-04-19 17:40:49 -040083 void OnSignalQualitySignal(uint32 strength);
Eric Shienbrood9a245532012-03-07 14:20:39 -050084
85 // Method reply callbacks from the Modem.CDMA interface
Nathan Williams3022be52012-04-19 17:40:49 -040086 void OnActivateReply(const ResultCallback &callback,
87 uint32 status, const Error &error);
Eric Shienbrood9a245532012-03-07 14:20:39 -050088
Nathan Williams3022be52012-04-19 17:40:49 -040089 void OnGetRegistrationStateReply(uint32 state_1x, uint32 state_evdo,
90 const Error &error);
91 void OnGetSignalQualityReply(uint32 strength, const Error &error);
Darin Petkov184c54e2011-11-15 12:44:39 +010092
93 scoped_ptr<ModemCDMAProxyInterface> proxy_;
Eric Shienbrood3e20a232012-02-16 11:35:56 -050094 base::WeakPtrFactory<CellularCapabilityCDMA> weak_ptr_factory_;
Darin Petkova3d3be52011-11-14 21:34:16 +010095
Darin Petkovae0c64e2011-11-15 15:50:27 +010096 uint32 activation_state_;
Darin Petkov184c54e2011-11-15 12:44:39 +010097 uint32 registration_state_evdo_;
98 uint32 registration_state_1x_;
Darin Petkovae0c64e2011-11-15 15:50:27 +010099 uint16 prl_version_;
Darin Petkov381928f2012-02-02 23:00:12 +0100100 CellularService::OLP olp_;
Darin Petkovae0c64e2011-11-15 15:50:27 +0100101 std::string usage_url_;
Darin Petkov184c54e2011-11-15 12:44:39 +0100102
Darin Petkovac635a82012-01-10 16:51:58 +0100103 static unsigned int friendly_service_name_id_;
104
Darin Petkovdaf43862011-10-27 11:37:28 +0200105 DISALLOW_COPY_AND_ASSIGN(CellularCapabilityCDMA);
106};
107
108} // namespace shill
109
110#endif // SHILL_CELLULAR_CAPABILITY_CDMA_