Skip to content
This repository has been archived by the owner on Sep 4, 2019. It is now read-only.

Commit

Permalink
Merge pull request #208 from timwindsor/deviceInfoUpdate
Browse files Browse the repository at this point in the history
isSimulator() call added to Device Info extension
  • Loading branch information
timwindsor committed Oct 4, 2013
2 parents 4eb7134 + 5df5663 commit 3ac5235
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 380 deletions.
380 changes: 0 additions & 380 deletions BB10/deviceInfo/NDK_project/.cproject

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions BB10/deviceInfo/NDK_project/src/template_js.cpp
Expand Up @@ -85,5 +85,7 @@ string TemplateJS::InvokeMethod(const string& command) {
return m_pTemplateController->getRoamingStatus(); return m_pTemplateController->getRoamingStatus();
else if (strCommand == "getMNC") else if (strCommand == "getMNC")
return m_pTemplateController->getMNC(); return m_pTemplateController->getMNC();
else if (strCommand == "isSimulator")
return m_pTemplateController->isSimulator();
return "Unknown C++ method"; return "Unknown C++ method";
} }
18 changes: 18 additions & 0 deletions BB10/deviceInfo/NDK_project/src/template_ndk.cpp
Expand Up @@ -16,6 +16,8 @@


#include <string> #include <string>
#include <sstream> #include <sstream>
#include <bps/bps.h>
#include <bps/deviceinfo.h>
#include <bb/device/SimCardInfo> #include <bb/device/SimCardInfo>
#include <bb/device/HardwareInfo> #include <bb/device/HardwareInfo>
#include <bb/device/CellularNetworkInfo> #include <bb/device/CellularNetworkInfo>
Expand All @@ -29,6 +31,7 @@ namespace webworks {


DeviceInfo::DeviceInfo(TemplateJS *parent) { DeviceInfo::DeviceInfo(TemplateJS *parent) {
m_pParent = parent; m_pParent = parent;
bps_initialize();
} }


std::string DeviceInfo::getModelNumber() { std::string DeviceInfo::getModelNumber() {
Expand All @@ -52,7 +55,22 @@ std::string DeviceInfo::getMNC() {
return simInfo.mobileNetworkCode().toLocal8Bit().data(); return simInfo.mobileNetworkCode().toLocal8Bit().data();
} }


std::string DeviceInfo::isSimulator() {
deviceinfo_details_t *details;

if (BPS_SUCCESS == deviceinfo_get_details(&details)) {
if(deviceinfo_details_is_simulator(details)) {
return "true";
} else {
return "false";
}
deviceinfo_free_details(&details);
}
return "null";
}

DeviceInfo::~DeviceInfo() { DeviceInfo::~DeviceInfo() {
bps_shutdown();
} }




Expand Down
1 change: 1 addition & 0 deletions BB10/deviceInfo/NDK_project/src/template_ndk.hpp
Expand Up @@ -32,6 +32,7 @@ class DeviceInfo {
std::string getRoamingStatus(); std::string getRoamingStatus();
std::string getMCC(); std::string getMCC();
std::string getMNC(); std::string getMNC();
std::string isSimulator();


private: private:
TemplateJS *m_pParent; TemplateJS *m_pParent;
Expand Down
5 changes: 5 additions & 0 deletions BB10/deviceInfo/Readme.md
Expand Up @@ -21,6 +21,11 @@ Copy the ext\community.deviceInfo folder into the Framework\ext folder of the We
community.deviceInfo.getModelNumber() community.deviceInfo.getModelNumber()
</pre> </pre>


<pre>
//returns whether the device is a Simulator - 'true' or 'false'
community.deviceInfo.isSimulator()
</pre>

<pre> <pre>
//returns Roaming Status as 'true' or 'false' //returns Roaming Status as 'true' or 'false'
community.deviceInfo.getRoamingStatus() community.deviceInfo.getRoamingStatus()
Expand Down
6 changes: 6 additions & 0 deletions BB10/deviceInfo/ext/community.deviceInfo/client.js
Expand Up @@ -40,4 +40,10 @@ var _self = {},
_self.getMNC = function () { _self.getMNC = function () {
return window.webworks.execSync(_ID, "getMNC", null); return window.webworks.execSync(_ID, "getMNC", null);
}; };

//get Mobile Network Code
_self.isSimulator = function () {
return window.webworks.execSync(_ID, "isSimulator", null);
};

module.exports = _self; module.exports = _self;
Binary file modified BB10/deviceInfo/ext/community.deviceInfo/device/libDeviceInfo.so
Binary file not shown.
4 changes: 4 additions & 0 deletions BB10/deviceInfo/ext/community.deviceInfo/index.js
Expand Up @@ -34,5 +34,9 @@ module.exports = {


getMNC: function (success, fail) { getMNC: function (success, fail) {
success(template.getInstance().getMNC()); success(template.getInstance().getMNC());
},

isSimulator: function (success, fail) {
success(template.getInstance().isSimulator());
} }
}; };
Binary file not shown.
4 changes: 4 additions & 0 deletions BB10/deviceInfo/ext/community.deviceInfo/templateJNEXT.js
Expand Up @@ -64,6 +64,10 @@ JNEXT.Template = function () {
return JNEXT.invoke(self.m_id, "getMNC"); return JNEXT.invoke(self.m_id, "getMNC");
}; };


self.isSimulator = function () {
return JNEXT.invoke(self.m_id, "isSimulator");
};

// ************************ // ************************
// End of methods to edit // End of methods to edit
// ************************ // ************************
Expand Down

0 comments on commit 3ac5235

Please sign in to comment.