1 import { wrt } from '../browser/wrt';
3 function checkSystemInfoApiPrivilege(func: any, permissions: string[]) {
4 let override_func = func;
5 return (...args: any[]) => {
6 if (args[0] === "CELLULAR_NETWORK" && !permissions.includes("http://tizen.org/privilege/telephony")) {
7 console.log('The telephony permission is missing.');
10 return override_func.call(global.tizen.systeminfo, ...args);
14 export function initialize(packageId: string, appId: string, permissions: string[]) {
15 let webapis = global.webapis;
16 let tizen = global.tizen;
17 if (!permissions.includes("http://tizen.org/privilege/account.read")) {
18 webapis.mde.getCurrentLoginId = () => {
19 console.log('The account.read permission is missing.');
22 Object.defineProperties(webapis.mde, {
23 getCurrentLoginId: { writable: false, enumerable: true }
25 if (!permissions.includes("http://tizen.org/privilege/alarm")) {
28 tizen.alarm.removeAll =
31 tizen.alarm.getAlarmNotification =
32 tizen.alarm.addAlarmNotification = function() {
33 console.log('The alarm permission is missing.');
36 if (!permissions.includes("http://tizen.org/privilege/apphistory.read")) {
37 tizen.application.getAppsUsageInfo =
38 tizen.application.getBatteryUsageInfo = function() {
39 console.log('The application.read permission is missing.');
42 if (!permissions.includes("http://tizen.org/privilege/application.launch") &&
43 !permissions.includes("http://tizen.org/privilege/appmanager.launch")) {
44 tizen.application.launch =
45 tizen.application.launchAppControl = function() {
46 console.log('The application.launch and appmanager.launch permission is missing.');
49 if (!permissions.includes("http://tizen.org/privilege/application.info")) {
50 tizen.application.getAppMetaData = function() {
51 console.log('The application.info permission is missing.');
54 if (!permissions.includes("http://tizen.org/privilege/appmanager.certificate")) {
55 tizen.application.getAppCerts = function() {
56 console.log('The application.certificate permission is missing.');
59 if (!permissions.includes("http://tizen.org/privilege/appmanager.kill")) {
60 tizen.application.kill = function() {
61 console.log('The application.kill permission is missing.');
64 if (!permissions.includes("http://tizen.org/privilege/appmanager.launch") ||
65 !permissions.includes("http://tizen.org/privilege/datasharing")) {
66 tizen.datacontrol.addChangeListener =
67 tizen.datacontrol.removeChangeListener = function() {
68 console.log('The appmanager.launch or datasharing permission is missing.');
71 if (!permissions.includes("http://tizen.org/privilege/datacontrol.consumer")) {
72 tizen.datacontrol.getValue =
73 tizen.datacontrol.updateValue =
74 tizen.datacontrol.insert =
75 tizen.datacontrol.update =
76 tizen.datacontrol.remove =
77 tizen.datacontrol.select =
78 tizen.datacontrol.addValue =
79 tizen.datacontrol.removeValue =
80 tizen.datacontrol.getDataControlConsumer = function() {
81 console.log('The datacontrol.consumer permission is missing.');
84 if (!permissions.includes("http://tizen.org/privilege/filesystem.read")) {
85 tizen.filesystem.listDirectory =
86 tizen.filesystem.isFile =
87 tizen.filesystem.isDirectory =
88 tizen.filesystem.pathExists =
89 tizen.filesystem.copyFile =
90 tizen.filesystem.copyDirectory =
91 tizen.filesystem.moveFile =
92 tizen.filesystem.moveDirectory =
93 tizen.filesystem.resolve = function() {
94 console.log('The filesystem.read permission is missing.');
97 if (!permissions.includes("http://tizen.org/privilege/filesystem.write")) {
98 tizen.filesystem.createDirectory =
99 tizen.filesystem.deleteFile =
100 tizen.filesystem.deleteDirectory =
101 tizen.filesystem.copyFile =
102 tizen.filesystem.copyDirectory =
103 tizen.filesystem.moveFile =
104 tizen.filesystem.moveDirectory =
105 tizen.filesystem.rename = function() {
106 console.log('The filesystem.write permission is missing.');
109 if (!permissions.includes("http://tizen.org/privilege/notification")) {
110 tizen.alarm.addAlarmNotification = function() {
111 console.log('The notification permission is missing.');
114 if (!permissions.includes("http://tizen.org/privilege/package.info")) {
115 tizen.package.setPackageInfoEventListener =
116 tizen.package.unsetPackageInfoEventListener =
117 tizen.package.getPackageInfo =
118 tizen.package.getPackagesInfo = function() {
119 console.log('The package.info permission is missing.');
122 if (!permissions.includes("http://tizen.org/privilege/packagemanager.install")) {
123 tizen.package.install =
124 tizen.package.uninstall = function() {
125 console.log('The packagemanager.install permission is missing.');
128 // systeminfo : Runtime privilege validation is required, based on parameters
129 tizen.systeminfo.getPropertyValue =
130 checkSystemInfoApiPrivilege(tizen.systeminfo.getPropertyValue, permissions);
131 tizen.systeminfo.getPropertyValueArray =
132 checkSystemInfoApiPrivilege(tizen.systeminfo.getPropertyValueArray, permissions);
133 tizen.systeminfo.addPropertyValueChangeListener =
134 checkSystemInfoApiPrivilege(tizen.systeminfo.addPropertyValueChangeListener, permissions);
135 tizen.systeminfo.addPropertyValueArrayChangeListener =
136 checkSystemInfoApiPrivilege(tizen.systeminfo.addPropertyValueArrayChangeListener, permissions);