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

isSimulator() call added to Device Info extension #208

Merged
merged 4 commits into from
Oct 4, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,7 @@ string TemplateJS::InvokeMethod(const string& command) {
return m_pTemplateController->getRoamingStatus();
else if (strCommand == "getMNC")
return m_pTemplateController->getMNC();
else if (strCommand == "isSimulator")
return m_pTemplateController->isSimulator();
return "Unknown C++ method";
}
18 changes: 18 additions & 0 deletions BB10/deviceInfo/NDK_project/src/template_ndk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

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

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

std::string DeviceInfo::getModelNumber() {
Expand All @@ -52,7 +55,22 @@ std::string DeviceInfo::getMNC() {
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() {
bps_shutdown();
}


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

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

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

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

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

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
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,9 @@ module.exports = {

getMNC: function (success, fail) {
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ JNEXT.Template = function () {
return JNEXT.invoke(self.m_id, "getMNC");
};

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

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