Repository navigation
Expand file tree
/
Copy pathsettings.js
More file actions
164 lines (133 loc) · 5.21 KB
/
Copy pathsettings.js
File metadata and controls
164 lines (133 loc) · 5.21 KB
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
'use strict';
var utils = require('./utils');
function setWallpaper(settings, config) {
// 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.resolve(
utils.joinPath(config.GAIA_DISTRIBUTION_DIR, 'wallpapers',
'default' + devpixels + '.jpg'), config.GAIA_DIR);
if (!wallpaper.exists()) {
wallpaper = utils.resolve(
utils.joinPath(config.GAIA_DISTRIBUTION_DIR, 'wallpapers', 'default.jpg'),
config.GAIA_DIR);
}
if (!wallpaper.exists()) {
wallpaper = utils.resolve(
utils.joinPath('build', 'config', 'wallpaper' + devpixels + '.jpg'),
config.GAIA_DIR);
}
if (!wallpaper.exists()) {
wallpaper = utils.resolve(utils.joinPath('build', 'config', 'wallpaper.jpg'),
config.GAIA_DIR);
}
settings['wallpaper.image'] = utils.getFileAsDataURI(wallpaper);
}
function setRingtone(settings, config) {
// 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.resolve(ringtone_name,
config.GAIA_DIR);
settings['dialer.ringtone'] = utils.getFileAsDataURI(ringtone);
}
function setNotification(settings, config) {
// Grab notifier_bell.opus and convert it into a base64 string
let notification_name = 'shared/resources/media/notifications/' +
'notifier_bell.opus';
let notification = utils.resolve(notification_name,
config.GAIA_DIR);
settings['notification.ringtone'] = utils.getFileAsDataURI(notification);
}
function overrideSettings(settings, config) {
// See if any override file exists and eventually override
9B5D
settings
let override = utils.resolve(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(settings, config) {
// 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(config) {
var settingsFile = utils.getFile(config.GAIA_DIR, 'build', 'config',
'common-settings.json');
if (!settingsFile.exists()) {
throw new Error('file not found: ' + settingsFile.path);
}
var settings = utils.getJSON(settingsFile);
if (config.TARGET_BUILD_VARIANT != 'user') {
// We want the console to be disabled for device builds using the user variant.
settings['debug.console.enabled'] = true;
// Activate developer menu under the system menu when long pressing
// the power button by default for devs.
settings['developer.menu.enabled'] = true;
// Turn on APZ for developers. The final activation for everything will
// be done in bug 909877, but it will be good to get as many regressions
// and bugs as possible before turning it on definitively.
settings['apz.force-enable'] = 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);
}
// Set the ftu ping URL -- we set this regardless of NOFTU for now
settings['ftu.pingURL'] = config.FTU_PING_URL;
// Set the rocketbar URL
settings['rocketbar.searchAppURL'] = utils.gaiaOriginURL('search',
config.GAIA_SCHEME, config.GAIA_DOMAIN, config.GAIA_PORT) + '/index.html';
if (config.ROCKETBAR && config.ROCKETBAR !== 'none') {
settings['rocketbar.enabled'] = true;
}
settings['debugger.remote-mode'] = config.REMOTE_DEBUGGER ? 'adb-only'
: 'disabled';
if (config.PRODUCTION === '1') {
settings['feedback.url'] = 'https://input.mozilla.org/api/v1/feedback/';
settings['debugger.remote-mode'] = 'disabled';
}
settings['language.current'] = config.GAIA_DEFAULT_LOCALE;
if (config.DEVICE_DEBUG) {
settings['debugger.remote-mode'] = 'adb-devtools';
}
if (config.NO_LOCK_SCREEN) {
settings['screen.timeout'] = 0;
settings['lockscreen.enabled'] = false;
settings['lockscreen.locked'] = false;
}
var queue = utils.Q.defer();
queue.resolve();
var result = queue.promise.then(function() {
setWallpaper(settings, config);
}).then(function() {
setRingtone(settings, config);
}).then(function() {
setNotification(settings, config);
}).then(function() {
overrideSettings(settings, config);
}).then(function() {
writeSettings(settings, config);
return settings;
});
// Ensure not quitting xpcshell before all asynchronous code is done
utils.processEvents(function(){return {wait : false}});
return result;
}
exports.execute = execute;
exports.setWallpaper = setWallpaper;
exports.setRingtone = setRingtone;
exports.setNotification = setNotification;
exports.overrideSettings = overrideSettings;
exports.writeSettings = writeSettings;