import * as vm from 'vm';
+function checkSystemInfoApiPrivilege(func: any, permissions: string[]) {
+ let override_func = func;
+ return (type: string, onSuccess: any, onError: any) => {
+ if (type === "CELLULAR_NETWORK" && !permissions.includes("http://tizen.org/privilege/telephony")) {
+ console.log('The telephony permission is missing.');
+ return ;
+ }
+ override_func.call(global.tizen.systeminfo, type, onSuccess, onError);
+ }
+}
+
export function initialize(permissions: string[], sandbox: vm.Context) {
let tizen = sandbox.tizen;
if (!permissions.includes("http://tizen.org/privilege/alarm")) {
}
}
// systeminfo : Runtime privilege validation is required, based on parameters
- let getPropertyValue = tizen.systeminfo.getPropertyValue;
- tizen.systeminfo.getPropertyValue = (type: string, onSuccessCallback: any, onErrorCallback: any) => {
- if (type === "CELLULAR_NETWORK" && !permissions.includes("http://tizen.org/privilege/telephony")) {
- console.log('The telephony permission is missing.');
- return;
- }
- getPropertyValue.apply(tizen.systeminfo, arguments);
- };
+ tizen.systeminfo.getPropertyValue =
+ checkSystemInfoApiPrivilege(tizen.systeminfo.getPropertyValue, permissions);
+ tizen.systeminfo.getPropertyValueArray =
+ checkSystemInfoApiPrivilege(tizen.systeminfo.getPropertyValueArray, permissions);
+ tizen.systeminfo.addPropertyValueChangeListener =
+ checkSystemInfoApiPrivilege(tizen.systeminfo.addPropertyValueChangeListener, permissions);
+ tizen.systeminfo.addPropertyValueArrayChangeListener =
+ checkSystemInfoApiPrivilege(tizen.systeminfo.addPropertyValueArrayChangeListener, permissions);
+
}