device_state.h revision a3f7b4e666c476898878fa745f637129375cd889
1// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef CHROMEOS_NETWORK_DEVICE_STATE_H_ 6#define CHROMEOS_NETWORK_DEVICE_STATE_H_ 7 8#include "base/values.h" 9#include "chromeos/network/managed_state.h" 10#include "chromeos/network/network_util.h" 11 12namespace chromeos { 13 14// Simple class to provide device state information. Similar to NetworkState; 15// see network_state.h for usage guidelines. 16class CHROMEOS_EXPORT DeviceState : public ManagedState { 17 public: 18 typedef std::vector<CellularScanResult> CellularScanResults; 19 20 explicit DeviceState(const std::string& path); 21 virtual ~DeviceState(); 22 23 // ManagedState overrides 24 virtual bool PropertyChanged(const std::string& key, 25 const base::Value& value) OVERRIDE; 26 27 // Accessors 28 const std::string& mac_address() const { return mac_address_; } 29 30 // Cellular specific accessors 31 const std::string& home_provider_id() const { return home_provider_id_; } 32 bool provider_requires_roaming() const { return provider_requires_roaming_; } 33 bool support_network_scan() const { return support_network_scan_; } 34 bool scanning() const { return scanning_; } 35 const std::string& technology_family() const { return technology_family_; } 36 const std::string& carrier() const { return carrier_; } 37 const std::string& sim_lock_type() const { return sim_lock_type_; } 38 uint32 sim_retries_left() const { return sim_retries_left_; } 39 bool sim_lock_enabled() const { return sim_lock_enabled_; } 40 const std::string& meid() const { return meid_; } 41 const std::string& imei() const { return imei_; } 42 const std::string& iccid() const { return iccid_; } 43 const std::string& mdn() const { return mdn_; } 44 const CellularScanResults& scan_results() const { return scan_results_; } 45 const DictionaryValue& properties() const { return properties_; } 46 47 // Returns true if the technology family is GSM and sim_present_ is false. 48 bool IsSimAbsent() const; 49 50 private: 51 // Common Device Properties 52 std::string mac_address_; 53 // Cellular specific propeties 54 std::string home_provider_id_; 55 bool provider_requires_roaming_; 56 bool support_network_scan_; 57 bool scanning_; 58 std::string technology_family_; 59 std::string carrier_; 60 std::string sim_lock_type_; 61 uint32 sim_retries_left_; 62 bool sim_lock_enabled_; 63 bool sim_present_; 64 std::string meid_; 65 std::string imei_; 66 std::string iccid_; 67 std::string mdn_; 68 CellularScanResults scan_results_; 69 // Keep all Device properties in a dictionary. Devices are limited and should 70 // change rarely if ever, so the overhead for this is small. 71 DictionaryValue properties_; 72 73 DISALLOW_COPY_AND_ASSIGN(DeviceState); 74}; 75 76} // namespace chromeos 77 78#endif // CHROMEOS_NETWORK_DEVICE_STATE_H_ 79