Release Vulpes OS 2.7 Preview 25 for Desktop, Android and Pixel 3a
This commit is contained in:
parent
6a44daeaaa
commit
3a1fba4efe
21 changed files with 1301 additions and 196 deletions
|
|
@ -51,13 +51,14 @@ export class Alarms {
|
|||
throw new Error('InvalidStateError');
|
||||
if (this.state.records.filter((r) => r.owner === app.id).length >= 256)
|
||||
throw new Error('QuotaExceededError');
|
||||
if (JSON.stringify(data).length > 65536) throw new Error('QuotaExceededError');
|
||||
const encodedData = JSON.stringify(data ?? null);
|
||||
if (encodedData.length > 65536) throw new Error('QuotaExceededError');
|
||||
const record = {
|
||||
owner: app.id,
|
||||
id: this.state.nextId++,
|
||||
date,
|
||||
respectTimezone,
|
||||
data,
|
||||
data: JSON.parse(encodedData),
|
||||
local,
|
||||
};
|
||||
this.state.records.push(record);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,25 @@ export class Contacts {
|
|||
contacts: [],
|
||||
};
|
||||
}
|
||||
async importCards(app, cards) {
|
||||
if (!app.manifest.permissions?.contacts?.access?.includes('write')) throw Error('PERMISSION_DENIED');
|
||||
const commit = this.queue.then(async () => {
|
||||
const now = new Date().toISOString();
|
||||
const imported = cards.map(card => ({
|
||||
...card, id: Services.uuid.generateUUID().toString(), published: now, updated: now,
|
||||
}));
|
||||
const next = {
|
||||
contacts: this.data.contacts.concat(imported),
|
||||
revision: this.data.revision + imported.length,
|
||||
};
|
||||
await this.storage.run('vulpes-private-contacts', 'put', [next, 'state']);
|
||||
this.data = next;
|
||||
for (const contact of imported) this.notify({contactID: contact.id, reason: 'create'});
|
||||
return imported.length === 1 ? imported[0] : {count: imported.length};
|
||||
});
|
||||
this.queue = commit.catch(() => {});
|
||||
return commit;
|
||||
}
|
||||
async request(app, { operation, contact, options = {}, id }) {
|
||||
const access = app.manifest.permissions?.contacts?.access || '';
|
||||
const write = ['save', 'remove', 'clear'].includes(operation);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import {readVCards} from 'resource://vulpes/host/VCard.sys.mjs';
|
||||
import {receivedMms} from 'resource://vulpes/services/mms.mjs';
|
||||
import { authorizePlatform } from 'resource://vulpes/services/platform.mjs';
|
||||
import {
|
||||
|
|
@ -222,6 +223,7 @@ export class Platform {
|
|||
return null;
|
||||
}
|
||||
if (Services.env.get('VULPES_TUNDRA') === '1') {
|
||||
if (operation === 'contact') return this.deviceContact(app, params);
|
||||
if (operation === 'capabilities') return tundraCapabilities(this.runtime.release);
|
||||
if (operation === 'cameraPreview') return this.nativeCamera.request(actor, params);
|
||||
if (operation === 'snapshot') return tundraSnapshot();
|
||||
|
|
@ -231,6 +233,10 @@ export class Platform {
|
|||
if (operation === 'mobileSettings') return tundraRadio('mobileSettings', params);
|
||||
if (operation === 'bluetooth') return tundraBluetooth(params);
|
||||
if (['callHistory','ackCallHistory'].includes(operation)) return this.radio(operation, params);
|
||||
if (operation === 'imei') {
|
||||
if (!actor.manager.documentURI.filePath.startsWith('/dialer/')) throw Error('PERMISSION_DENIED');
|
||||
return tundraRadio('imei', {});
|
||||
}
|
||||
if (operation === 'dial') return this.radio('dial', params);
|
||||
if (operation === 'hangup') return tundraRadio('hangup', params);
|
||||
if (operation === 'calls') return Date.now() - this.lastCallsAt < 1500 ? this.lastCalls : this.radio('calls');
|
||||
|
|
@ -326,7 +332,7 @@ export class Platform {
|
|||
videos: Ci.nsIFilePicker.filterVideo,
|
||||
}[kind];
|
||||
if (filter) picker.appendFilters(filter);
|
||||
else picker.appendFilter('vCard', '*.vcf');
|
||||
else picker.appendFilter('vCard', '*.vcf; *.vcard');
|
||||
if ((await new Promise((resolve) => picker.open(resolve))) !== Ci.nsIFilePicker.returnOK)
|
||||
throw Error('AbortError');
|
||||
return multiple
|
||||
|
|
@ -348,32 +354,34 @@ export class Platform {
|
|||
}
|
||||
return names;
|
||||
}
|
||||
async deviceContact(app, params) {
|
||||
// Sargo has no microSD slot or desktop file-picker service. Only list
|
||||
// ordinary vCards from the user's Downloads folder inside the Gaia UI.
|
||||
if (app.id !== 'communications') throw Error('PERMISSION_DENIED');
|
||||
const {Downloads} = ChromeUtils.importESModule('resource://gre/modules/Downloads.sys.mjs');
|
||||
const dir = file(await Downloads.getPreferredDownloadsDirectory());
|
||||
const files = [];
|
||||
if (dir.exists() && dir.isDirectory() && !dir.isSymlink()) {
|
||||
for (const entry of dir.directoryEntries) {
|
||||
const item = entry.QueryInterface(Ci.nsIFile);
|
||||
if (/\.(vcf|vcard)$/i.test(item.leafName) && !item.isSymlink() && item.isFile())
|
||||
files.push(item);
|
||||
}
|
||||
}
|
||||
if (params.action === 'list') return files.map(item=>item.leafName).sort();
|
||||
const selected = files.find(item=>item.leafName === params.name);
|
||||
if (params.action !== 'import' || !selected) throw Error('FILE_NOT_FOUND');
|
||||
return this.importContactFile(app, selected);
|
||||
}
|
||||
async contact(actor, app) {
|
||||
const [item] = await this.select(actor, 'contact');
|
||||
return this.importContactFile(app, item);
|
||||
}
|
||||
async importContactFile(app, item) {
|
||||
if (item.fileSize > 1024 * 1024) throw Error('QuotaExceededError');
|
||||
const raw = await IOUtils.readUTF8(item.path);
|
||||
const lines = raw.replace(/\r?\n[ \t]/g, '').split(/\r?\n/);
|
||||
const decode = (s) => s.replace(/\\n/gi, '\n').replace(/\\([,;\\])/g, '$1');
|
||||
const value = { name: [], tel: [], email: [] };
|
||||
let inside = false;
|
||||
for (const line of lines) {
|
||||
if (line.toUpperCase() === 'BEGIN:VCARD') {
|
||||
inside = true;
|
||||
continue;
|
||||
}
|
||||
if (line.toUpperCase() === 'END:VCARD') break;
|
||||
if (!inside) continue;
|
||||
const i = line.indexOf(':');
|
||||
if (i < 0) continue;
|
||||
const key = line.slice(0, i).split(';')[0].toUpperCase(),
|
||||
v = decode(line.slice(i + 1));
|
||||
if (key === 'FN') value.name = [v];
|
||||
if (key === 'TEL') value.tel.push({ value: v.replace(/^tel:/, ''), type: ['other'] });
|
||||
if (key === 'EMAIL') value.email.push({ value: v, type: ['other'] });
|
||||
}
|
||||
if (!value.name.length && !value.tel.length && !value.email.length)
|
||||
throw Error('InvalidModificationError');
|
||||
return this.runtime.contacts.request(app, { operation: 'save', contact: value });
|
||||
const cards = readVCards(raw);
|
||||
return this.runtime.contacts.importCards(app, cards);
|
||||
}
|
||||
async capture(actor, app) {
|
||||
if (!app.manifest.permissions?.['device-storage:pictures']?.access?.includes('write'))
|
||||
|
|
|
|||
|
|
@ -302,8 +302,10 @@ export const Runtime = {
|
|||
return {error:{code:'METHOD_NOT_SUPPORTED'}};
|
||||
}
|
||||
if(method==='hardware.vibrate') {
|
||||
if(app.id!=='system' || (Services.env.get('VULPES_TUNDRA')!=='1' && !beatlesHardware())) return {error:{code:'NOT_SUPPORTED'}};
|
||||
if(!['system','keyboard'].includes(app.id) || (Services.env.get('VULPES_TUNDRA')!=='1' && !beatlesHardware())) return {error:{code:'NOT_SUPPORTED'}};
|
||||
const pattern=params?.pattern;
|
||||
if(app.id==='keyboard' && (!Array.isArray(pattern) || pattern.length!==1 || pattern[0]>100))
|
||||
return {error:{code:'INVALID_VALUE'}};
|
||||
if(!Array.isArray(pattern) || pattern.length>32 || pattern.some(n=>!Number.isInteger(n) || n<0 || n>10000) || pattern.reduce((a,b)=>a+b,0)>10000)
|
||||
return {error:{code:'INVALID_VALUE'}};
|
||||
try {
|
||||
|
|
@ -442,6 +444,7 @@ export const Runtime = {
|
|||
}
|
||||
if (method === 'layout.current') return { result: {
|
||||
mode: this.values['vulpes.layout'] || 'auto',
|
||||
homeButtonOverlay: Services.env.get('VULPES_KEYPAD') !== '1',
|
||||
compactDefault: Services.env.get('VULPES_KEYPAD') === '1',
|
||||
coverScreen: Services.env.get('VULPES_DEVICE') === 'beatles',
|
||||
reducedMotion: Services.env.get('VULPES_DEVICE') === 'beatles',
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@
|
|||
// Only byte counts for Vulpes-owned storage cross the application boundary.
|
||||
let pending, cached;
|
||||
export async function storageStats(app) {
|
||||
if(app.id!=='settings')throw Error('PERMISSION_DENIED');
|
||||
const canReadStats = app.id === 'settings' ||
|
||||
(app.id === 'system' && app.manifest.permissions?.['device-storage:apps']?.access === 'readonly');
|
||||
if(!canReadStats)throw Error('PERMISSION_DENIED');
|
||||
if(cached && Date.now()-cached.at<5000)return cached.value;
|
||||
if(pending)return pending;
|
||||
pending=(async()=>{
|
||||
|
|
|
|||
|
|
@ -13,7 +13,28 @@ export async function auditTickets({win,evaluate,wait,tap,sleep,root}) {
|
|||
await sleep(600);
|
||||
};
|
||||
win.focus();win.document.getElementById('system').focus();
|
||||
await step('unlock',()=>ev('system','ScreenManager.turnScreenOn(true);if(Service.query("locked"))lockScreen.unlock(true);return !Service.query("locked");'));
|
||||
await step('unlock',()=>ev('system','ScreenManager.turnScreenOn(true);if(Service.query("locked"))await Service.request("unlock",{forcibly:true});return !Service.query("locked");'));
|
||||
await step('alarmTime',async()=>{
|
||||
await launch('clock');
|
||||
await tap('clock','#alarm-new',10000);
|
||||
await tap('clock','#time-select + button',10000);
|
||||
await wait('system',"return !!document.querySelector('.value-selector-time-picker-popup:not([hidden])');",10000);
|
||||
const minute=await ev('system',`const picker=Service.query('getActiveApp').valueSelector._timePicker.minute;
|
||||
const next=(picker.getSelectedIndex()+1)%60;picker.setSelectedIndex(next);return next;`);
|
||||
await tap('system','.value-selector-time-picker-popup:not([hidden]) .value-selector-confirm',10000);
|
||||
return await wait('clock',`return Number(document.querySelector('#time-select').value.split(':')[1])===${minute};`,10000);
|
||||
});
|
||||
await step('browserAddress',async()=>{
|
||||
await launch('search');
|
||||
await tap('system','.appWindow.active .urlbar',10000);
|
||||
await wait('system',`const k=document.querySelector('#vulpes-gaia-keyboard');
|
||||
return !!k && !k.hidden && k.offsetHeight>0 && document.activeElement.id==='rocketbar-input';`,10000);
|
||||
await wait('keyboard','return !!navigator.mozInputMethod.inputcontext;',10000);
|
||||
await ev('keyboard',"await navigator.mozInputMethod.inputcontext.replaceSurroundingText('v',0,0);return true;");
|
||||
return await wait('system',"return document.getElementById('rocketbar-input').value.includes('v');",5000);
|
||||
});
|
||||
win.document.getElementById('home').click();
|
||||
await sleep(700);
|
||||
await step('cameraOpen',async()=>{
|
||||
await launch('camera');
|
||||
await wait('camera','return !!app.camera.mozCamera && !app.camera.isBusy;',15000);
|
||||
|
|
@ -36,12 +57,18 @@ export async function auditTickets({win,evaluate,wait,tap,sleep,root}) {
|
|||
await step('cameraVideo',async()=>{
|
||||
try{
|
||||
Services.perms.addFromPrincipal(principal,'microphone',Ci.nsIPermissionManager.ALLOW_ACTION,Ci.nsIPermissionManager.EXPIRE_SESSION);
|
||||
await ev('camera','window.__ticketVideo=null;app.once("newmedia",v=>{window.__ticketVideo=v;});app.settings.mode.select("video");return true;');
|
||||
await ev('camera','window.__ticketVideo=null;app.once("newmedia",v=>{window.__ticketVideo=v;});return true;');
|
||||
await tap('camera','.js-switch-handle',10000);
|
||||
await wait('camera', "return app.camera.mode==='video' && document.querySelector('.viewfinder.visible')?.checkVisibility({checkOpacity:true});", 10000);
|
||||
await wait('camera','return app.camera.mode==="video" && !!app.camera.mozCamera && !app.camera.isBusy;',15000);
|
||||
await wait('camera', "const e=document.querySelector('.js-capture'),r=e.getBoundingClientRect();return e.contains(document.elementFromPoint(r.x+r.width/2,r.y+r.height/2));", 10000);
|
||||
await tap('camera','.js-capture',10000);
|
||||
await wait('camera','return app.camera.get("recording")==="started";',15000);
|
||||
const shutterHasRadius=radius=>`const c=document.querySelector('.js-capture .center');return getComputedStyle(c,'::before').borderRadius===${JSON.stringify(radius)};`;
|
||||
await wait('camera',shutterHasRadius('3px'),5000);
|
||||
await sleep(2200);await tap('camera','.js-capture',10000);
|
||||
await wait('camera','return !!window.__ticketVideo?.blob;',20000);
|
||||
await wait('camera',shutterHasRadius('50%'),5000);
|
||||
return await ev('camera',`const v=__ticketVideo,el=document.createElement('video');el.muted=true;el.src=URL.createObjectURL(v.blob);
|
||||
try{await Promise.race([new Promise((ok,no)=>{el.onloadeddata=ok;el.onerror=()=>no(Error('Decode failed'));}),new Promise((_,no)=>setTimeout(()=>no(Error('Decode timeout')),7000))]);
|
||||
return {bytes:v.blob.size,type:v.blob.type,width:el.videoWidth,height:el.videoHeight,poster:v.poster.blob.size};}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ export function tundraCapabilities(release) {
|
|||
|
||||
export async function tundraRadio(operation, params = {}) {
|
||||
if (Services.env.get('VULPES_TUNDRA_RADIO') !== '1') throw Error('RADIO_UNAVAILABLE');
|
||||
if (!['radioPower', 'hardware', 'volumeState', 'volume', 'deviceSettings', 'mobileSettings', 'status', 'calls', 'dial', 'hangup', 'answer', 'sms', 'incomingMessages', 'ackMessages', 'messageState', 'callAudio'].includes(operation)) throw Error('RADIO_INVALID_REQUEST');
|
||||
if (!['radioPower', 'hardware', 'volumeState', 'volume', 'deviceSettings', 'mobileSettings', 'imei', 'status', 'calls', 'dial', 'hangup', 'answer', 'sms', 'incomingMessages', 'ackMessages', 'messageState', 'callAudio'].includes(operation)) throw Error('RADIO_INVALID_REQUEST');
|
||||
if(socketControl())return localControl('radio',{...params,version:1,operation});
|
||||
const { Subprocess } = ChromeUtils.importESModule('resource://gre/modules/Subprocess.sys.mjs');
|
||||
const process = await Subprocess.call({
|
||||
|
|
|
|||
50
host/VCard.sys.mjs
Normal file
50
host/VCard.sys.mjs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
// Gaia contacts imported from a user-selected UTF-8 vCard file.
|
||||
function unescapeText(value) {
|
||||
return value.replace(/\\([nN,;\\])/g, (_, char) => /n/i.test(char) ? '\n' : char);
|
||||
}
|
||||
|
||||
export function readVCards(raw) {
|
||||
const cards = [];
|
||||
let card;
|
||||
const lines = raw.replace(/^\uFEFF/, '').replace(/\r\n?/g, '\n').replace(/\n[ \t]/g, '').split('\n');
|
||||
for (const line of lines) {
|
||||
if (!line.trim()) continue;
|
||||
if (/^BEGIN:VCARD$/i.test(line)) {
|
||||
if (card) throw Error('INVALID_VCARD');
|
||||
card = {name: [], tel: [], email: []};
|
||||
continue;
|
||||
}
|
||||
if (!card) throw Error('INVALID_VCARD');
|
||||
if (/^END:VCARD$/i.test(line)) {
|
||||
if (!card.name.length) {
|
||||
const name = [...(card.givenName || []), ...(card.familyName || [])].join(' ');
|
||||
if (name) card.name.push(name);
|
||||
}
|
||||
if (!card.name.length && !card.tel.length && !card.email.length) throw Error('INVALID_VCARD');
|
||||
cards.push(card);
|
||||
card = null;
|
||||
continue;
|
||||
}
|
||||
const field = /^((?:[^":]|"[^"]*")*):(.*)$/.exec(line);
|
||||
if (!field || !field[2]) continue;
|
||||
const [property, ...params] = field[1].split(';');
|
||||
const key = property.split('.').pop().toUpperCase();
|
||||
const value = unescapeText(field[2]);
|
||||
if (key === 'FN') card.name = [value];
|
||||
if (key === 'N') {
|
||||
const [, family, given] = /^((?:\\.|[^;\\])*)(?:;((?:\\.|[^;\\])*))?/.exec(field[2]);
|
||||
if (family) card.familyName = [unescapeText(family)];
|
||||
if (given) card.givenName = [unescapeText(given)];
|
||||
}
|
||||
if (key === 'TEL' || key === 'EMAIL') {
|
||||
const types = params.flatMap(param => {
|
||||
if (param.includes('=') && !/^TYPE=/i.test(param)) return [];
|
||||
return param.replace(/^TYPE=/i, '').replace(/"/g, '').toLowerCase().split(',');
|
||||
}).filter(Boolean).map(type => type === 'cell' ? 'mobile' : type);
|
||||
const clean = key === 'TEL' ? value.replace(/^tel:/i, '') : value.replace(/^mailto:/i, '');
|
||||
if (clean) card[key.toLowerCase()].push({value: clean, type: types.length ? types : ['other']});
|
||||
}
|
||||
}
|
||||
if (card || !cards.length) throw Error('INVALID_VCARD');
|
||||
return cards;
|
||||
}
|
||||
|
|
@ -53,7 +53,10 @@ export const Views = {
|
|||
Services.ppmm.sharedData.flush();
|
||||
},
|
||||
hideAll() {
|
||||
for (const entry of this.entries.values()) entry.browser.style.visibility='hidden';
|
||||
for (const entry of this.entries.values()) {
|
||||
entry.browser.style.visibility = 'hidden';
|
||||
entry.browser.docShellIsActive = false;
|
||||
}
|
||||
},
|
||||
async layout(entry) {
|
||||
const geometry=entry.geometry;
|
||||
|
|
@ -81,6 +84,8 @@ export const Views = {
|
|||
Object.assign(entry.browser.style,{left:(left-x)+'px',top:(top-y)+'px',
|
||||
width:Math.max(0,right-left)+'px',height:Math.max(0,bottom-top)+'px',
|
||||
visibility:visible && right>left && bottom>top?'visible':'hidden'});
|
||||
const active = entry.browser.style.visibility === 'visible';
|
||||
if (entry.browser.docShellIsActive !== active) entry.browser.docShellIsActive = active;
|
||||
// Remote Wayland surfaces need the same layout flush as the Gaia browser.
|
||||
entry.browser.getBoundingClientRect();
|
||||
entry.browser.frameLoader?.requestUpdatePosition?.();
|
||||
|
|
@ -164,6 +169,7 @@ export const Views = {
|
|||
browser.style.cssText =
|
||||
'display:block;position:absolute;background:white;visibility:hidden';
|
||||
shell.document.getElementById('screen').append(browser);
|
||||
browser.suspendMediaWhenInactive = true;
|
||||
if (!Services.ppmm.sharedData.get('vulpes:native-touch')) {
|
||||
browser.browsingContext.inRDMPane = true;
|
||||
browser.browsingContext.setRDMPaneMaxTouchPoints(1);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,11 @@ import {frameUnobscured} from 'resource://vulpes/services/view-visibility.mjs';
|
|||
import {requestMediaPermission} from 'resource://vulpes/services/media-permission.mjs';
|
||||
export class VulpesChild extends JSWindowActorChild {
|
||||
handleEvent(event) {
|
||||
if(['focusin','pointerdown','click'].includes(event.type)) {
|
||||
if (event.type === 'vulpes-address-focus' &&
|
||||
(this.browsingContext.parent || this.document.location.origin !== 'http://system.localhost:8765' ||
|
||||
this.document.hidden || event.target !== this.document.activeElement ||
|
||||
!event.target.matches?.('#rocketbar.active #rocketbar-input'))) return;
|
||||
if(['focusin','pointerdown','click','vulpes-address-focus'].includes(event.type)) {
|
||||
if(this._editor?.editing) return;
|
||||
if(!Services.cpmm.sharedData.get('vulpes:native-input')) return;
|
||||
let element=event.target;
|
||||
|
|
|
|||
|
|
@ -3,9 +3,25 @@ import {InputEditor} from 'resource://vulpes/services/input-editor.mjs';
|
|||
// Web pages may edit their focused field, but receive no Gaia service bridge.
|
||||
export class WebInputChild extends JSWindowActorChild {
|
||||
handleEvent(event) {
|
||||
if (!Services.cpmm.sharedData.get('vulpes:native-input') || this.editor?.editing) return;
|
||||
if (this.editor?.editing) return;
|
||||
const contexts = Services.cpmm.sharedData.get('vulpes:host-contexts') || [];
|
||||
if (!contexts.includes(this.browsingContext.top.id)) return;
|
||||
// The standalone host has no Firefox tab strip for target=_blank. Use
|
||||
// the current web view so Gecko retains its normal link security checks.
|
||||
if (event.type === 'click' && event.isTrusted && this.browsingContext === this.browsingContext.top) {
|
||||
const link = event.composedPath().find(node => node.localName === 'a' && node.href);
|
||||
const target = link?.getAttribute('target') ?? this.document.querySelector('base[target]')?.target;
|
||||
if (link && target?.toLowerCase() === '_blank' && /^https?:/.test(link.href) && !link.hasAttribute('download')) {
|
||||
const original = link.getAttribute('target');
|
||||
link.target = '_self';
|
||||
this.contentWindow.setTimeout(() => {
|
||||
if (link.target !== '_self') return;
|
||||
if (original === null) link.removeAttribute('target');
|
||||
else link.target = original;
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
if (!Services.cpmm.sharedData.get('vulpes:native-input')) return;
|
||||
// Standalone web views have no Firefox tabbrowser to focus their embedder.
|
||||
// Keep Gecko's picker focus checks intact by activating only a touched view.
|
||||
if (event.isTrusted && ['pointerdown','mousedown','click'].includes(event.type))
|
||||
|
|
|
|||
|
|
@ -483,6 +483,8 @@
|
|||
if (value.pictureSize) stream.setPictureSize(value.pictureSize);
|
||||
if (value.mode && !['picture',...(videoMime ? ['video'] : [])].includes(value.mode))
|
||||
throw new DOMException('Video unavailable', 'NotSupportedError');
|
||||
// Gaia hides the viewfinder on reconfiguration and deduplicates preview states.
|
||||
emit(stream, 'previewstatechange', { newState: 'stopped' });
|
||||
if(value.mode)mode=value.mode;
|
||||
queueMicrotask(() => emit(stream, 'previewstatechange', { newState: 'started' }));
|
||||
return configuration();
|
||||
|
|
|
|||
|
|
@ -275,6 +275,11 @@
|
|||
}
|
||||
if (type === 'screen-on') window.ScreenManager?.turnScreenOn(true);
|
||||
if (type === 'home' || type === 'holdhome') {
|
||||
if (window.VulpesPlatform === 'tundra' && type === 'home') {
|
||||
call('settings.get', {key:'vibration.enabled'}).then(setting => {
|
||||
if (setting.value !== false) navigator.vibrate(30);
|
||||
}).catch(console.error);
|
||||
}
|
||||
call('activities.cancel', {}).catch(console.error);
|
||||
dispatchEvent(new CustomEvent(type));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -336,6 +336,9 @@
|
|||
}
|
||||
function apnSettingsPanel() {
|
||||
return {onInit(panel){
|
||||
panel.querySelector('gaia-header').addEventListener('action',event=>{
|
||||
event.stopImmediatePropagation();navigate('carrier');
|
||||
},true);
|
||||
for(const anchor of panel.querySelectorAll('[data-apn-type]')) {
|
||||
const supported=['default','mms'].includes(anchor.dataset.apnType);
|
||||
if(!supported)anchor.setAttribute('aria-disabled','true');
|
||||
|
|
@ -351,7 +354,9 @@
|
|||
}
|
||||
function apnListPanel() {
|
||||
let panel,type='default';
|
||||
return {onInit(element){panel=element;panel.querySelector('.add-apn').disabled=true;panel.querySelector('gaia-header').dataset.href='#apn-settings';},
|
||||
return {onInit(element){panel=element;panel.querySelector('.add-apn').disabled=true;panel.querySelector('gaia-header').addEventListener('action',event=>{
|
||||
event.stopImmediatePropagation();navigate('apn-settings');
|
||||
},true);},
|
||||
async onBeforeShow(element,options={}) {
|
||||
type=options.type==='mms'?'mms':'default';
|
||||
document.l10n.setAttributes(panel.querySelector('h1'),type==='mms'?'messageSettings-header':'dataSettings-header');
|
||||
|
|
|
|||
|
|
@ -43,6 +43,16 @@
|
|||
'This feature is not available on this platform yet.');
|
||||
window.VulpesGaiaUI = {notice};
|
||||
async function ready() {
|
||||
if (window.VulpesPlatform === 'tundra') {
|
||||
window.addEventListener('click', event => {
|
||||
if (!event.isTrusted || event.defaultPrevented || event.button !== 0) return;
|
||||
const link = event.target.closest?.('a[href]');
|
||||
if (!link || link.hasAttribute('download') || !/^https?:$/.test(link.protocol)) return;
|
||||
if (link.hostname === 'localhost' || link.hostname.endsWith('.localhost')) return;
|
||||
event.preventDefault();
|
||||
new MozActivity({name:'view', data:{type:'url', url:link.href}});
|
||||
});
|
||||
}
|
||||
if (app === 'system') {
|
||||
// Android reserves the edge swipe for its own shade. A tap on Gaia's
|
||||
// status bar provides access without competing with that system gesture.
|
||||
|
|
@ -97,6 +107,35 @@
|
|||
document.addEventListener('click', event => {
|
||||
if (!event.target.closest('#import-sd-option')) return;
|
||||
event.preventDefault(); event.stopImmediatePropagation();
|
||||
if (window.VulpesPlatform === 'tundra') {
|
||||
VulpesCompat.call('platform.contact',{action:'list'}).then(names=>{
|
||||
if (!names.length) {
|
||||
notice(label('Placez un fichier vCard (.vcf) dans Téléchargements, puis réessayez.',
|
||||
'Place a vCard (.vcf) file in Downloads, then try again.'));
|
||||
return;
|
||||
}
|
||||
notice(label('Choisissez un fichier de contacts dans Téléchargements.',
|
||||
'Choose a contact file from Downloads.'));
|
||||
const form=document.getElementById('vulpes-gaia-notice');
|
||||
const select=document.createElement('select');
|
||||
select.setAttribute('aria-label',label('Fichier de contacts','Contact file'));
|
||||
for(const name of names)select.add(new Option(name,name));
|
||||
form.querySelector('section').append(select);
|
||||
const submit=document.createElement('button');
|
||||
submit.type='button';submit.className='recommend';submit.textContent=label('Importer','Import');
|
||||
form.querySelector('menu').append(submit);
|
||||
submit.onclick=async()=>{
|
||||
submit.disabled=true;
|
||||
try {
|
||||
await VulpesCompat.call('platform.contact',{action:'import',name:select.value});
|
||||
notice(label('Import terminé.','Import complete.'));
|
||||
} catch (error) {
|
||||
notice(label('Impossible de lire cette vCard.', 'Could not read this vCard.'));
|
||||
}
|
||||
};
|
||||
}).catch(()=>notice(unavailable()));
|
||||
return;
|
||||
}
|
||||
VulpesCompat.call('platform.contact', {}).catch(error => {
|
||||
if (error.name !== 'AbortError' && error.message !== 'AbortError') notice(unavailable());
|
||||
});
|
||||
|
|
|
|||
|
|
@ -110,6 +110,13 @@
|
|||
event.preventDefault();open(event.target);
|
||||
}
|
||||
}, true);
|
||||
// Gaia FormButton opens an invisible select through a visible button.
|
||||
// Embedded Gecko does not supply the original value-selector behavior.
|
||||
addEventListener('vulpes-select-open', event => {
|
||||
if (event.target.tagName !== 'SELECT') return;
|
||||
event.preventDefault();
|
||||
open(event.target);
|
||||
}, true);
|
||||
addEventListener('pagehide', () => close(false));
|
||||
document.addEventListener('visibilitychange', () => {if (document.hidden) close(false);});
|
||||
addEventListener('panelready', event => {
|
||||
|
|
@ -157,14 +164,16 @@
|
|||
window.close = () => parent.postMessage({type:'vulpes-keyboard-close'}, systemOrigin);
|
||||
}
|
||||
let pending, sequence=0;
|
||||
addEventListener('click', event => {
|
||||
function openDateTime(event) {
|
||||
const input=event.target;
|
||||
if (input.tagName !== 'INPUT' || !['date','time'].includes(input.type) || input.disabled || input.readOnly) return;
|
||||
event.preventDefault();event.stopImmediatePropagation();
|
||||
pending={input,id:++sequence};
|
||||
parent.postMessage({type:'vulpes-datetime-open',id:sequence,inputType:input.type,
|
||||
value:input.value,min:input.min,max:input.max},systemOrigin);
|
||||
},true);
|
||||
}
|
||||
addEventListener('click',openDateTime,true);
|
||||
addEventListener('vulpes-select-open',openDateTime,true);
|
||||
addEventListener('message', event => {
|
||||
if(event.source!==parent || event.origin!==systemOrigin || event.data?.type!=='vulpes-datetime-result' || event.data.id!==pending?.id)return;
|
||||
const {input}=pending;pending=null;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
(() => {
|
||||
const { call, request, handlers } = window.VulpesCompat;
|
||||
document.documentElement.dataset.vulpesApp = location.hostname.split('.')[0];
|
||||
if(window.VulpesPlatform==='tundra' && location.hostname==='system.localhost') {
|
||||
if(window.VulpesPlatform==='tundra' && ['system.localhost','keyboard.localhost'].includes(location.hostname)) {
|
||||
Object.defineProperty(navigator,'vibrate',{value:pattern=>{
|
||||
pattern=Array.isArray(pattern)?pattern:[pattern];
|
||||
if(pattern.length>32 || pattern.some(n=>!Number.isInteger(n) || n<0 || n>10000) || pattern.reduce((a,b)=>a+b,0)>10000) return false;
|
||||
|
|
@ -323,12 +323,15 @@
|
|||
});
|
||||
Object.defineProperty(navigator, 'mozMobileMessage', { value: messages });
|
||||
}
|
||||
const appName = location.hostname.split('.')[0];
|
||||
if (
|
||||
['settings', 'gallery', 'music', 'video', 'camera', 'ringtones'].includes(location.hostname.split('.')[0])
|
||||
['settings', 'gallery', 'music', 'video', 'camera', 'ringtones', 'system'].includes(appName)
|
||||
) {
|
||||
const stores = new Map();
|
||||
function storage(type) {
|
||||
if (!['pictures', 'music', 'videos', ...(location.hostname==='settings.localhost'?['apps','sdcard']:[])].includes(type)) return null;
|
||||
const allowedTypes = appName === 'system' ? ['pictures', 'apps'] :
|
||||
['pictures', 'music', 'videos', ...(appName === 'settings' ? ['apps', 'sdcard'] : [])];
|
||||
if (!allowedTypes.includes(type)) return null;
|
||||
if (stores.has(type)) return stores.get(type);
|
||||
const s = new EventTarget();
|
||||
s.storageName = 'sdcard';
|
||||
|
|
|
|||
|
|
@ -174,6 +174,18 @@ html[data-vulpes-app="homescreen"] body.edit-mode gaia-grid#icons {
|
|||
padding-bottom: calc(5rem + var(--software-home-button-height, 5rem));
|
||||
}
|
||||
|
||||
/* shell.css overlays the 44px Home button on the active homescreen. */
|
||||
@media (orientation: portrait) {
|
||||
html[data-vulpes-home-overlay][data-vulpes-app="homescreen"] .edit-mode #bottombar {
|
||||
bottom: 44px;
|
||||
}
|
||||
}
|
||||
@media (orientation: landscape) {
|
||||
html[data-vulpes-home-overlay][data-vulpes-app="homescreen"] .edit-mode #bottombar {
|
||||
right: 44px;
|
||||
}
|
||||
}
|
||||
|
||||
/* A single applications panel; saved pinned pages remain available in classic mode. */
|
||||
html[data-vulpes-layout="compact"][data-vulpes-app="homescreen"] :is(#page-indicator-header, #pages-panel, #shadow) {
|
||||
display: none;
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@
|
|||
});
|
||||
VulpesCompat.call('layout.current', {}).then(value => {
|
||||
compactDefault = value.compactDefault;
|
||||
document.documentElement.toggleAttribute('data-vulpes-home-overlay', value.homeButtonOverlay === true);
|
||||
document.documentElement.dataset.vulpesMotion = value.reducedMotion ? 'reduced' : 'standard';
|
||||
if (value.reducedMotion) {
|
||||
// Preserve animationend callbacks used by Gaia, and leave busy indicators running.
|
||||
|
|
|
|||
|
|
@ -19,24 +19,31 @@
|
|||
emit(enabled ? 'enabled' : 'disabled');
|
||||
if (!enabled) update(null);
|
||||
}
|
||||
function update(network) {
|
||||
const status = network ? 'connected' : 'disconnected';
|
||||
let pendingNetwork = null;
|
||||
function update(network, status = network ? 'connected' : 'disconnected') {
|
||||
const changed = manager.connection.status !== status || manager.connection.network?.ssid !== network?.ssid;
|
||||
manager.connection = {status, network};
|
||||
manager.connectionInformation = network ? {...connectionInfo,relSignalStrength:network.relSignalStrength} : null;
|
||||
manager.connectionInformation = status === 'connected' && network ? {...connectionInfo,relSignalStrength:network.relSignalStrength} : null;
|
||||
if (changed) emit('statuschange', manager.connection);
|
||||
// Gaia's signal listeners require the associated network. A scan while
|
||||
// disconnected must not announce connection information for a missing AP.
|
||||
if (network) emit('connectioninfoupdate', {network, ...manager.connectionInformation});
|
||||
if (manager.connectionInformation) emit('connectioninfoupdate', {network, ...manager.connectionInformation});
|
||||
}
|
||||
function applyState(state) {
|
||||
power(state.enabled === true);
|
||||
manager.macAddress=state.macAddress || manager.macAddress;
|
||||
if (state.state) {
|
||||
connectionInfo=state.connectionInformation || {};
|
||||
if (state.enabled && (state.state === 'connecting' || (pendingNetwork && state.state === 'disconnected'))) {
|
||||
const target = state.network;
|
||||
const network = target ? {ssid:target.ssid, security:securityTypes(target.security)} : pendingNetwork;
|
||||
if (network) update(network, 'connecting');
|
||||
return;
|
||||
}
|
||||
const network=state.state==='connected' && state.network;
|
||||
update(network ? {
|
||||
...networks.find(n=>n.ssid===network.ssid),ssid:network.ssid,
|
||||
...networks.find(n => network.id ? n.vulpesId === network.id : n.connected && n.ssid === network.ssid),
|
||||
ssid:network.ssid,
|
||||
security:securityTypes(network.security),
|
||||
relSignalStrength:network.signal,savedId:network.savedId,connected:true
|
||||
} : null);
|
||||
|
|
@ -56,7 +63,8 @@
|
|||
networks = result.networks.map(n => ({ssid:n.ssid, relSignalStrength:n.signal,
|
||||
security:securityTypes(n.security),
|
||||
known:n.known === true, connected:n.connected, vulpesId:n.id, savedId:n.savedId}));
|
||||
update(networks.find(n => n.connected) || null);
|
||||
if (result.state) applyState(result);
|
||||
else if (!pendingNetwork) update(networks.find(n => n.connected) || null);
|
||||
return networks;
|
||||
}
|
||||
manager.getNetworks = () => request(scan());
|
||||
|
|
@ -68,8 +76,19 @@
|
|||
manager.associate = network => request((async () => {
|
||||
const security=(network.security || []).filter(Boolean);
|
||||
if (security.length && security[0] !== 'WPA-PSK') throw Error('WIFI_UNSUPPORTED_SECURITY');
|
||||
await call('platform.wifi',network.hidden ? {operation:'connectHidden',ssid:network.ssid,security:security.length?'wpa-psk':'open',password:network.psk || ''} : {operation:'connect',id:network.vulpesId,password:network.psk || ''});
|
||||
await scan(); return network;
|
||||
if (pendingNetwork) throw Error('WIFI_BUSY');
|
||||
pendingNetwork = {ssid:network.ssid, security};
|
||||
update(pendingNetwork, 'connecting');
|
||||
try {
|
||||
await call('platform.wifi',network.hidden ? {operation:'connectHidden',ssid:network.ssid,security:security.length?'wpa-psk':'open',password:network.psk || ''} : {operation:'connect',id:network.vulpesId || network.savedId,password:network.psk || ''});
|
||||
} catch (error) {
|
||||
update(null);
|
||||
throw error;
|
||||
} finally {
|
||||
pendingNetwork = null;
|
||||
}
|
||||
applyState(await call('platform.wifi',{operation:'status'}));
|
||||
return network;
|
||||
})());
|
||||
manager.forget = network => request(call('platform.wifi',{operation:'forget',id:network.savedId}).then(()=>scan()));
|
||||
const unsupported = () => request(Promise.reject(new DOMException('Not supported by this adapter','NotSupportedError')));
|
||||
|
|
@ -161,14 +180,24 @@
|
|||
}
|
||||
window.VulpesWifiSettings={panels:{hotspot:hotspotPanel},dialogs:{'hotspot-wifiSettings':hotspotDialog}};
|
||||
}
|
||||
addEventListener('DOMContentLoaded', async () => {
|
||||
let retryTimer, closed = false;
|
||||
addEventListener('pagehide', () => { closed = true; clearTimeout(retryTimer); }, {once:true});
|
||||
async function initialize() {
|
||||
let state;
|
||||
try {
|
||||
state = await call('platform.wifi',{operation:'status'});
|
||||
} catch (error) {
|
||||
// The WLAN driver may still be starting when Gaia opens.
|
||||
if (!closed) retryTimer = setTimeout(initialize, 5000);
|
||||
return;
|
||||
}
|
||||
if (closed) return;
|
||||
try {
|
||||
const state = await call('platform.wifi',{operation:'status'});
|
||||
applyState(state);
|
||||
if (location.hostname.startsWith('system.')) {
|
||||
let queue=Promise.resolve();
|
||||
navigator.mozSettings.addObserver('wifi.enabled', event => {
|
||||
const enabled=event.settingValue===true;
|
||||
let powerChanges = 0;
|
||||
function requestPower(enabled) {
|
||||
queue=queue.then(async () => {
|
||||
if(manager.enabled===enabled) {power(enabled,true);return;}
|
||||
try {
|
||||
|
|
@ -181,9 +210,18 @@
|
|||
await call('settings.set',{values:{'wifi.enabled':manager.enabled}});
|
||||
console.warn('Wi-Fi radio change failed',error);
|
||||
}
|
||||
});
|
||||
}).catch(error => console.warn('Wi-Fi settings synchronization failed', error));
|
||||
return queue;
|
||||
}
|
||||
navigator.mozSettings.addObserver('wifi.enabled', event => {
|
||||
powerChanges++;
|
||||
requestPower(event.settingValue === true);
|
||||
});
|
||||
await call('settings.set',{values:{'wifi.enabled':state.enabled}});
|
||||
const saved = await call('settings.get',{key:'wifi.enabled'});
|
||||
if (!powerChanges) {
|
||||
if (typeof saved?.value === 'boolean') await requestPower(saved.value);
|
||||
else await call('settings.set',{values:{'wifi.enabled':state.enabled}});
|
||||
}
|
||||
} else {
|
||||
navigator.mozSettings.addObserver('wifi.enabled', () => {
|
||||
call('platform.wifi',{operation:'status'}).then(applyState).catch(console.warn);
|
||||
|
|
@ -204,5 +242,6 @@
|
|||
}
|
||||
if(manager.enabled) await scan();
|
||||
} catch(error) { console.warn('Wi-Fi initialization failed',error); }
|
||||
}, {once:true});
|
||||
}
|
||||
addEventListener('DOMContentLoaded', initialize, {once:true});
|
||||
})();
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue