This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
/
settings.js
367 lines (341 loc) · 11.9 KB
/
settings.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
'use strict';
var utils = require('./utils');
var config;
const { Cc, Ci, Cr, Cu, CC} = require('chrome');
Cu.import('resource://gre/modules/Services.jsm');
let settings;
function readFileAsDataURL(file, mimetype, callback) {
let XMLHttpRequest = CC('@mozilla.org/xmlextras/xmlhttprequest;1');
let req = new XMLHttpRequest();
let url = Services.io.newFileURI(file).spec;
req.open('GET', url, false);
req.responseType = 'blob';
try {
req.send(null);
} catch (e) {
dump('XMLHttpRequest.send error: ' + e + '\n');
}
// Convert the blob to a base64 encoded data URI
let FileReader = CC('@mozilla.org/files/filereader;1');
let reader = new FileReader();
reader.onload = function() {
let dataURL = reader.result;
// There is a bug in XMLHttpRequest and file:// URL,
// the mimetype ends up always being application/xml...
dataURL = dataURL.replace('application/xml', mimetype);
callback(dataURL);
};
reader.onerror = function() {
dump('Unable to read file as data URL: ' + reader.error.name + '\n' +
reader.error + '\n');
};
reader.readAsDataURL(req.response);
}
function setWallpaper(callback) {
// Grab the default wallpaper and convert it into a base64 string
let devpixels = '';
if (config.GAIA_DEV_PIXELS_PER_PX != '1') {
devpixels = '@' + config.GAIA_DEV_PIXELS_PER_PX + 'x';
}
let wallpaper = utils.getAbsoluteOrRelativePath(
config.GAIA_DISTRIBUTION_DIR + '/wallpapers/default' +
devpixels + '.jpg', config.GAIA_DIR);
if (!wallpaper.exists()) {
wallpaper = utils.getAbsoluteOrRelativePath(
config.GAIA_DISTRIBUTION_DIR + '/wallpapers/default.jpg',
config.GAIA_DIR);
}
if (!wallpaper.exists()) {
wallpaper = utils.getAbsoluteOrRelativePath(
'build/wallpaper' + devpixels + '.jpg', config.GAIA_DIR);
}
if (!wallpaper.exists()) {
wallpaper = utils.getAbsoluteOrRelativePath('build/wallpaper.jpg',
config.GAIA_DIR);
}
readFileAsDataURL(wallpaper, 'image/jpeg', function(dataURL) {
settings['wallpaper.image'] = dataURL;
callback();
});
}
function setRingtone(callback) {
// Grab ringer_classic_courier.opus and convert it into a base64 string
let ringtone_name = 'shared/resources/media/ringtones/' +
'ringer_classic_courier.opus';
let ringtone = utils.getAbsoluteOrRelativePath(ringtone_name,
config.GAIA_DIR);
readFileAsDataURL(ringtone, 'audio/ogg', function(dataURL) {
settings['dialer.ringtone'] = dataURL;
callback();
});
}
function setNotification(callback) {
// Grab notifier_bell.opus and convert it into a base64 string
let notification_name = 'shared/resources/media/notifications/' +
'notifier_bell.opus';
let notification = utils.getAbsoluteOrRelativePath(notification_name,
config.GAIA_DIR);
readFileAsDataURL(notification, 'audio/ogg', function(dataURL) {
settings['notification.ringtone'] = dataURL;
callback();
});
}
function overrideSettings() {
// See if any override file exists and eventually override settings
let override = utils.getAbsoluteOrRelativePath(config.SETTINGS_PATH,
config.GAIA_DIR);
if (override.exists()) {
let content = utils.getJSON(override);
for (let key in content) {
settings[key] = content[key];
}
}
}
function writeSettings() {
// Finally write the settings file
let settingsFile = utils.getFile(config.PROFILE_DIR, 'settings.json');
let content = JSON.stringify(settings);
utils.writeContent(settingsFile, content + '\n');
}
function execute(options) {
config = options;
settings = {
'accessibility.invert': false,
'accessibility.screenreader': false,
'alarm.enabled': false,
'app.launch_path.blacklist': [],
'app.reportCrashes': 'ask',
'app.update.interval': 86400,
'audio.volume.alarm': 15,
'audio.volume.bt_sco': 15,
'audio.volume.dtmf': 15,
'audio.volume.content': 15,
'audio.volume.master': 5,
'audio.volume.notification': 15,
'audio.volume.tts': 15,
'audio.volume.telephony': 5,
'audio.volume.cemaxvol': 11,
'bluetooth.enabled': false,
'bluetooth.debugging.enabled': false,
'bluetooth.suspended': false,
'camera.shutter.enabled': true,
'camera.recordingsound.enabled': false,
'camera.recording.preferredSizes': [],
'clear.remote-windows.data': false,
'debug.console.enabled': false,
'debug.grid.enabled': false,
'debug.oop.disabled': false,
'debug.fps.enabled': false,
'debug.ttl.enabled': false,
'debug.log-animations.enabled': false,
'debug.paint-flashing.enabled': false,
'debug.peformancedata.shared': false,
'debug.gaia.enabled': false,
'deviceinfo.firmware_revision': '',
'deviceinfo.hardware': '',
'deviceinfo.mac': '',
'deviceinfo.os': '',
'deviceinfo.platform_build_id': '',
'deviceinfo.platform_version': '',
'deviceinfo.product_model': '',
'deviceinfo.software': '',
'deviceinfo.update_channel': '',
'device.storage.writable.name': 'sdcard',
'dom.mozContacts.debugging.enabled': false,
'feedback.url': 'https://input.allizom.org/api/v1/feedback/',
'gaia.system.checkForUpdates': false,
'geolocation.enabled': true,
'geolocation.suspended': false,
'icc.applications': null,
'icc.data': null,
'icc.displayTextTimeout': 40000,
'icc.inputTextTimeout': 40000,
'icc.goBackTimeout': 1000,
'icc.selectTimeout': 150000,
'keyboard.layouts.english': true,
'keyboard.layouts.dvorak': false,
'keyboard.layouts.czech': false,
'keyboard.layouts.french': false,
'keyboard.layouts.german': false,
'keyboard.layouts.hungarian': false,
'keyboard.layouts.norwegian': false,
'keyboard.layouts.slovak': false,
'keyboard.layouts.turkish': false,
'keyboard.layouts.romanian': false,
'keyboard.layouts.russian': false,
'keyboard.layouts.arabic': false,
'keyboard.layouts.hebrew': false,
'keyboard.layouts.zhuyin': false,
'keyboard.layouts.pinyin': false,
'keyboard.layouts.greek': false,
'keyboard.layouts.japanese': false,
'keyboard.layouts.polish': false,
'keyboard.layouts.portuguese': false,
'keyboard.layouts.serbian': false,
'keyboard.layouts.spanish': false,
'keyboard.layouts.catalan': false,
'keyboard.vibration': false,
'keyboard.clicksound': false,
'keyboard.autocorrect': true,
'keyboard.wordsuggestion': true,
'keyboard.current': 'en',
'keyboard.ftu.enabled': true,
'language.current': 'en-US',
'layers.draw-borders': false,
'lockscreen.passcode-lock.code': '0000',
'lockscreen.passcode-lock.timeout': 0,
'lockscreen.passcode-lock.enabled': false,
'lockscreen.notifications-preview.enabled': true,
'lockscreen.enabled': true,
'lockscreen.locked': true,
'lockscreen.unlock-sound.enabled': false,
'mail.sent-sound.enabled': true,
'message.sent-sound.enabled': true,
'operatorvariant.mcc': '0',
'operatorvariant.mnc': '0',
'phone.ring.keypad': true,
'phone.dtmf.type': 'long',
'powersave.enabled': false,
'powersave.threshold': -1,
'privacy.donottrackheader.value': '-1',
'privacy.donottrackheader.enabled': false,
'ril.data.suspended': false,
'ril.iccInfo.mbdn': '',
'ril.sms.requestStatusReport.enabled': false,
'ril.cellbroadcast.searchlist': '',
'ril.callwaiting.enabled': null,
'ril.cf.enabled': false,
'ril.data.enabled': false,
'ril.data.apn': '',
'ril.data.carrier': '',
'ril.data.passwd': '',
'ril.data.httpProxyHost': '',
'ril.data.httpProxyPort': 0,
'ril.data.mmsc': '',
'ril.data.mmsproxy': '',
'ril.data.mmsport': 0,
'ril.data.roaming_enabled': false,
'ril.data.user': '',
'ril.data.authtype': 'notDefined',
'ril.mms.apn': '',
'ril.mms.carrier': '',
'ril.mms.httpProxyHost': '',
'ril.mms.httpProxyPort': '',
'ril.mms.mmsc': '',
'ril.mms.mmsport': '',
'ril.mms.mmsproxy': '',
'ril.mms.passwd': '',
'ril.mms.user': '',
'ril.mms.retrieval_mode': 'automatic-home',
'ril.mms.authtype': 'notDefined',
'dom.mms.operatorSizeLimitation': 307200,
'ril.radio.preferredNetworkType': '',
'ril.radio.disabled': false,
'ril.supl.apn': '',
'ril.supl.carrier': '',
'ril.supl.httpProxyHost': '',
'ril.supl.httpProxyPort': '',
'ril.supl.passwd': '',
'ril.supl.user': '',
'ril.supl.authtype': 'notDefined',
'ril.sms.strict7BitEncoding.enabled': false,
'ril.cellbroadcast.disabled': false,
'ril.data.apnSettings': '',
'ril.callerId': 'CLIR_DEFAULT',
'screen.automatic-brightness': true,
'screen.brightness': 1,
'screen.timeout': 60,
'software-button.enabled': false,
'homegesture.enabled': false,
'support.onlinesupport.title': '',
'support.onlinesupport.href': '',
'support.callsupport1.title': '',
'support.callsupport1.href': '',
'support.callsupport2.title': '',
'support.callsupport2.href': '',
'telephony.speaker.enabled': false,
'tethering.usb.enabled': false,
'tethering.usb.ip': '192.168.0.1',
'tethering.usb.prefix': '24',
'tethering.usb.dhcpserver.startip': '192.168.0.10',
'tethering.usb.dhcpserver.endip': '192.168.0.30',
'tethering.wifi.enabled': false,
'tethering.wifi.ip': '192.168.1.1',
'tethering.wifi.prefix': '24',
'tethering.wifi.dhcpserver.startip': '192.168.1.10',
'tethering.wifi.dhcpserver.endip': '192.168.1.30',
'tethering.wifi.ssid': 'FirefoxHotspot',
'tethering.wifi.security.type': 'open',
'tethering.wifi.security.password': '1234567890',
'tethering.wifi.connectedClients': 0,
'tethering.usb.connectedClients': 0,
'time.clock.automatic-update.enabled': true,
'time.timezone.automatic-update.enabled': true,
'time.timezone': null,
'ums.enabled': false,
'ums.mode': 0,
'ums.volume.sdcard.enabled': true,
'ums.volume.extsdcard.enabled': false,
'vibration.enabled': true,
'wifi.enabled': true,
'wifi.screen_off_timeout': 600000,
'wifi.suspended': false,
'wifi.disabled_by_wakelock': false,
'wifi.notification': false,
'wifi.connect_via_settings': false,
'wap.push.enabled': true
};
// We want the console to be disabled for device builds using the user variant.
if (config.TARGET_BUILD_VARIANT != 'user')
settings['debug.console.enabled'] = true;
// Set the homescreen URL
settings['homescreen.manifestURL'] = utils.gaiaManifestURL('homescreen',
config.GAIA_SCHEME, config.GAIA_DOMAIN, config.GAIA_PORT);
// Set the ftu manifest URL
if (config.NOFTU === '0') {
settings['ftu.manifestURL'] = utils.gaiaManifestURL('communications',
config.GAIA_SCHEME, config.GAIA_DOMAIN, config.GAIA_PORT);
}
if (config.PRODUCTION === '1') {
settings['feedback.url'] = 'https://input.mozilla.org/api/v1/feedback/';
}
settings['language.current'] = config.GAIA_DEFAULT_LOCALE;
let file = utils.getGaia(config).sharedFolder.clone();
file.append('resources');
file.append('keyboard_layouts.json');
let keyboard_layouts_res = utils.getJSON(file);
let keyboard_layouts = keyboard_layouts_res['layout'];
let keyboard_nonLatins = keyboard_layouts_res['nonLatin'];
let default_layout;
if (config.GAIA_DEFAULT_LOCALE in keyboard_layouts) {
default_layout = keyboard_layouts[config.GAIA_DEFAULT_LOCALE];
if (!(config.GAIA_DEFAULT_LOCALE in keyboard_nonLatins)) {
settings['keyboard.layouts.english'] = false;
}
settings['keyboard.layouts.' + default_layout] = true;
}
settings['devtools.debugger.remote-enabled'] = config.REMOTE_DEBUGGER == true;
if (config.DEVICE_DEBUG) {
settings['devtools.debugger.remote-enabled'] = true;
settings['screen.timeout'] = 0;
settings['lockscreen.enabled'] = false;
settings['lockscreen.locked'] = false;
}
// Run all asynchronous code before overwriting and writing settings file
let done = false;
setWallpaper(function() {
setRingtone(function() {
setNotification(function() {
overrideSettings();
writeSettings();
done = true;
});
});
});
// Ensure not quitting xpcshell before all asynchronous code is done
let thread = Services.tm.currentThread;
while (thread.hasPendingEvents() || !done) {
thread.processNextEvent(true);
}
}
exports.execute = execute;