Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
21
.gitignore
vendored
Normal file
21
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/engines/
|
||||
/downloads/
|
||||
/profiles/
|
||||
/logs/
|
||||
__pycache__/
|
||||
*.pyc
|
||||
# Installed app payload is versioned; these indexes are generated by the server.
|
||||
/assets/registry.json
|
||||
/assets/build-info.json
|
||||
/assets/settings-current-defaults.json
|
||||
/node_modules/
|
||||
/npm-debug.log*
|
||||
/.venv/
|
||||
*.keystore
|
||||
*.jks
|
||||
.env
|
||||
.env.*
|
||||
/local.properties
|
||||
|
||||
# Old B2G registry is unused by the modern host and contains historical paths.
|
||||
/assets/webapps/webapps.json
|
||||
1
.nvmrc
Normal file
1
.nvmrc
Normal file
|
|
@ -0,0 +1 @@
|
|||
22
|
||||
13
.prettierignore
Normal file
13
.prettierignore
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
gaia/
|
||||
assets/
|
||||
engines/
|
||||
downloads/
|
||||
profiles/
|
||||
logs/
|
||||
android/toolchain/
|
||||
android/.gradle/
|
||||
android/build/
|
||||
android/app/build/
|
||||
android/app/src/main/assets/
|
||||
android/dist/
|
||||
android/keys/
|
||||
7
.prettierrc.json
Normal file
7
.prettierrc.json
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"singleQuote": true,
|
||||
"printWidth": 100,
|
||||
"trailingComma": "all",
|
||||
"tabWidth": 2,
|
||||
"plugins": ["prettier-plugin-java"]
|
||||
}
|
||||
373
LICENSE
Normal file
373
LICENSE
Normal file
|
|
@ -0,0 +1,373 @@
|
|||
Mozilla Public License Version 2.0
|
||||
==================================
|
||||
|
||||
1. Definitions
|
||||
--------------
|
||||
|
||||
1.1. "Contributor"
|
||||
means each individual or legal entity that creates, contributes to
|
||||
the creation of, or owns Covered Software.
|
||||
|
||||
1.2. "Contributor Version"
|
||||
means the combination of the Contributions of others (if any) used
|
||||
by a Contributor and that particular Contributor's Contribution.
|
||||
|
||||
1.3. "Contribution"
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
1.4. "Covered Software"
|
||||
means Source Code Form to which the initial Contributor has attached
|
||||
the notice in Exhibit A, the Executable Form of such Source Code
|
||||
Form, and Modifications of such Source Code Form, in each case
|
||||
including portions thereof.
|
||||
|
||||
1.5. "Incompatible With Secondary Licenses"
|
||||
means
|
||||
|
||||
(a) that the initial Contributor has attached the notice described
|
||||
in Exhibit B to the Covered Software; or
|
||||
|
||||
(b) that the Covered Software was made available under the terms of
|
||||
version 1.1 or earlier of the License, but not also under the
|
||||
terms of a Secondary License.
|
||||
|
||||
1.6. "Executable Form"
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
1.7. "Larger Work"
|
||||
means a work that combines Covered Software with other material, in
|
||||
a separate file or files, that is not Covered Software.
|
||||
|
||||
1.8. "License"
|
||||
means this document.
|
||||
|
||||
1.9. "Licensable"
|
||||
means having the right to grant, to the maximum extent possible,
|
||||
whether at the time of the initial grant or subsequently, any and
|
||||
all of the rights conveyed by this License.
|
||||
|
||||
1.10. "Modifications"
|
||||
means any of the following:
|
||||
|
||||
(a) any file in Source Code Form that results from an addition to,
|
||||
deletion from, or modification of the contents of Covered
|
||||
Software; or
|
||||
|
||||
(b) any new file in Source Code Form that contains any Covered
|
||||
Software.
|
||||
|
||||
1.11. "Patent Claims" of a Contributor
|
||||
means any patent claim(s), including without limitation, method,
|
||||
process, and apparatus claims, in any patent Licensable by such
|
||||
Contributor that would be infringed, but for the grant of the
|
||||
License, by the making, using, selling, offering for sale, having
|
||||
made, import, or transfer of either its Contributions or its
|
||||
Contributor Version.
|
||||
|
||||
1.12. "Secondary License"
|
||||
means either the GNU General Public License, Version 2.0, the GNU
|
||||
Lesser General Public License, Version 2.1, the GNU Affero General
|
||||
Public License, Version 3.0, or any later versions of those
|
||||
licenses.
|
||||
|
||||
1.13. "Source Code Form"
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
1.14. "You" (or "Your")
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, "You" includes any entity that
|
||||
controls, is controlled by, or is under common control with You. For
|
||||
purposes of this definition, "control" means (a) the power, direct
|
||||
or indirect, to cause the direction or management of such entity,
|
||||
whether by contract or otherwise, or (b) ownership of more than
|
||||
fifty percent (50%) of the outstanding shares or beneficial
|
||||
ownership of such entity.
|
||||
|
||||
2. License Grants and Conditions
|
||||
--------------------------------
|
||||
|
||||
2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
(a) under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or
|
||||
as part of a Larger Work; and
|
||||
|
||||
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
||||
for sale, have made, import, and otherwise transfer either its
|
||||
Contributions or its Contributor Version.
|
||||
|
||||
2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution
|
||||
become effective for each Contribution on the date the Contributor first
|
||||
distributes such Contribution.
|
||||
|
||||
2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under
|
||||
this License. No additional rights or licenses will be implied from the
|
||||
distribution or licensing of Covered Software under this License.
|
||||
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||
Contributor:
|
||||
|
||||
(a) for any code that a Contributor has removed from Covered Software;
|
||||
or
|
||||
|
||||
(b) for infringements caused by: (i) Your and any other third party's
|
||||
modifications of Covered Software, or (ii) the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
|
||||
(c) under Patent Claims infringed by Covered Software in the absence of
|
||||
its Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks,
|
||||
or logos of any Contributor (except as may be necessary to comply with
|
||||
the notice requirements in Section 3.4).
|
||||
|
||||
2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this
|
||||
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||
permitted under the terms of Section 3.3).
|
||||
|
||||
2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its
|
||||
Contributions are its original creation(s) or it has sufficient rights
|
||||
to grant the rights to its Contributions conveyed by this License.
|
||||
|
||||
2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under
|
||||
applicable copyright doctrines of fair use, fair dealing, or other
|
||||
equivalents.
|
||||
|
||||
2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
||||
in Section 2.1.
|
||||
|
||||
3. Responsibilities
|
||||
-------------------
|
||||
|
||||
3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under
|
||||
the terms of this License. You must inform recipients that the Source
|
||||
Code Form of the Covered Software is governed by the terms of this
|
||||
License, and how they can obtain a copy of this License. You may not
|
||||
attempt to alter or restrict the recipients' rights in the Source Code
|
||||
Form.
|
||||
|
||||
3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
(a) such Covered Software must also be made available in Source Code
|
||||
Form, as described in Section 3.1, and You must inform recipients of
|
||||
the Executable Form how they can obtain a copy of such Source Code
|
||||
Form by reasonable means in a timely manner, at a charge no more
|
||||
than the cost of distribution to the recipient; and
|
||||
|
||||
(b) You may distribute such Executable Form under the terms of this
|
||||
License, or sublicense it under different terms, provided that the
|
||||
license for the Executable Form does not attempt to limit or alter
|
||||
the recipients' rights in the Source Code Form under this License.
|
||||
|
||||
3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for
|
||||
the Covered Software. If the Larger Work is a combination of Covered
|
||||
Software with a work governed by one or more Secondary Licenses, and the
|
||||
Covered Software is not Incompatible With Secondary Licenses, this
|
||||
License permits You to additionally distribute such Covered Software
|
||||
under the terms of such Secondary License(s), so that the recipient of
|
||||
the Larger Work may, at their option, further distribute the Covered
|
||||
Software under the terms of either this License or such Secondary
|
||||
License(s).
|
||||
|
||||
3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices
|
||||
(including copyright notices, patent notices, disclaimers of warranty,
|
||||
or limitations of liability) contained within the Source Code Form of
|
||||
the Covered Software, except that You may alter any license notices to
|
||||
the extent required to remedy known factual inaccuracies.
|
||||
|
||||
3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on
|
||||
behalf of any Contributor. You must make it absolutely clear that any
|
||||
such warranty, support, indemnity, or liability obligation is offered by
|
||||
You alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation
|
||||
---------------------------------------------------
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this
|
||||
License with respect to some or all of the Covered Software due to
|
||||
statute, judicial order, or regulation then You must: (a) comply with
|
||||
the terms of this License to the maximum extent possible; and (b)
|
||||
describe the limitations and the code they affect. Such description must
|
||||
be placed in a text file included with all distributions of the Covered
|
||||
Software under this License. Except to the extent prohibited by statute
|
||||
or regulation, such description must be sufficiently detailed for a
|
||||
recipient of ordinary skill to be able to understand it.
|
||||
|
||||
5. Termination
|
||||
--------------
|
||||
|
||||
5.1. The rights granted under this License will terminate automatically
|
||||
if You fail to comply with any of its terms. However, if You become
|
||||
compliant, then the rights granted under this License from a particular
|
||||
Contributor are reinstated (a) provisionally, unless and until such
|
||||
Contributor explicitly and finally terminates Your grants, and (b) on an
|
||||
ongoing basis, if such Contributor fails to notify You of the
|
||||
non-compliance by some reasonable means prior to 60 days after You have
|
||||
come back into compliance. Moreover, Your grants from a particular
|
||||
Contributor are reinstated on an ongoing basis if such Contributor
|
||||
notifies You of the non-compliance by some reasonable means, this is the
|
||||
first time You have received notice of non-compliance with this License
|
||||
from such Contributor, and You become compliant prior to 30 days after
|
||||
Your receipt of the notice.
|
||||
|
||||
5.2. If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions,
|
||||
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||
directly or indirectly infringes any patent, then the rights granted to
|
||||
You by any and all Contributors for the Covered Software under Section
|
||||
2.1 of this License shall terminate.
|
||||
|
||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
||||
end user license agreements (excluding distributors and resellers) which
|
||||
have been validly granted by You or Your distributors under this License
|
||||
prior to termination shall survive termination.
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 6. Disclaimer of Warranty *
|
||||
* ------------------------- *
|
||||
* *
|
||||
* Covered Software is provided under this License on an "as is" *
|
||||
* basis, without warranty of any kind, either expressed, implied, or *
|
||||
* statutory, including, without limitation, warranties that the *
|
||||
* Covered Software is free of defects, merchantable, fit for a *
|
||||
* particular purpose or non-infringing. The entire risk as to the *
|
||||
* quality and performance of the Covered Software is with You. *
|
||||
* Should any Covered Software prove defective in any respect, You *
|
||||
* (not any Contributor) assume the cost of any necessary servicing, *
|
||||
* repair, or correction. This disclaimer of warranty constitutes an *
|
||||
* essential part of this License. No use of any Covered Software is *
|
||||
* authorized under this License except under this disclaimer. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 7. Limitation of Liability *
|
||||
* -------------------------- *
|
||||
* *
|
||||
* Under no circumstances and under no legal theory, whether tort *
|
||||
* (including negligence), contract, or otherwise, shall any *
|
||||
* Contributor, or anyone who distributes Covered Software as *
|
||||
* permitted above, be liable to You for any direct, indirect, *
|
||||
* special, incidental, or consequential damages of any character *
|
||||
* including, without limitation, damages for lost profits, loss of *
|
||||
* goodwill, work stoppage, computer failure or malfunction, or any *
|
||||
* and all other commercial damages or losses, even if such party *
|
||||
* shall have been informed of the possibility of such damages. This *
|
||||
* limitation of liability shall not apply to liability for death or *
|
||||
* personal injury resulting from such party's negligence to the *
|
||||
* extent applicable law prohibits such limitation. Some *
|
||||
* jurisdictions do not allow the exclusion or limitation of *
|
||||
* incidental or consequential damages, so this exclusion and *
|
||||
* limitation may not apply to You. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
8. Litigation
|
||||
-------------
|
||||
|
||||
Any litigation relating to this License may be brought only in the
|
||||
courts of a jurisdiction where the defendant maintains its principal
|
||||
place of business and such litigation shall be governed by laws of that
|
||||
jurisdiction, without reference to its conflict-of-law provisions.
|
||||
Nothing in this Section shall prevent a party's ability to bring
|
||||
cross-claims or counter-claims.
|
||||
|
||||
9. Miscellaneous
|
||||
----------------
|
||||
|
||||
This License represents the complete agreement concerning the subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. Any law or regulation which provides
|
||||
that the language of a contract shall be construed against the drafter
|
||||
shall not be used to construe this License against a Contributor.
|
||||
|
||||
10. Versions of the License
|
||||
---------------------------
|
||||
|
||||
10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version
|
||||
of the License under which You originally received the Covered Software,
|
||||
or under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a
|
||||
modified version of this License if you rename the license and remove
|
||||
any references to the name of the license steward (except to note that
|
||||
such modified license differs from this License).
|
||||
|
||||
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||
Licenses
|
||||
|
||||
If You choose to distribute Source Code Form that is Incompatible With
|
||||
Secondary Licenses under the terms of this version of the License, the
|
||||
notice described in Exhibit B of this License must be attached.
|
||||
|
||||
Exhibit A - Source Code Form License Notice
|
||||
-------------------------------------------
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular
|
||||
file, then You may include the notice in a location (such as a LICENSE
|
||||
file in a relevant directory) where a recipient would be likely to look
|
||||
for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||
---------------------------------------------------------
|
||||
|
||||
This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
defined by the Mozilla Public License, v. 2.0.
|
||||
24
NOTICE
Normal file
24
NOTICE
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
Vulpes OS — community project by oversu / NNS Production
|
||||
https://vulpes-os.org
|
||||
https://nnsprod.com/git/oversu/VulpesOS
|
||||
|
||||
Original Vulpes host, adapter and tooling additions are licensed under the
|
||||
Mozilla Public License 2.0 (see LICENSE). Preserve the applicable copyright,
|
||||
license and attribution notices when redistributing modified files.
|
||||
|
||||
Inherited components retain their original licenses:
|
||||
- Gaia: Mozilla Foundation and contributors; see gaia/LICENSE (Apache 2.0)
|
||||
and the notices in individual files and bundled components.
|
||||
- Firefox / Gecko / GeckoView: Mozilla and contributors; engine versions,
|
||||
download locations and source archives are pinned in engine-lock.json,
|
||||
release.json and the Android Gradle configuration. Engines are downloaded
|
||||
separately; they are not stored in this Git repository.
|
||||
- Fira fonts and Gaia icons: see gaia/shared/elements/vulpes-fonts/ and the
|
||||
notices included with each font and application.
|
||||
- Tundra references AOSP, Debian, Droidian, libhybris, UBports, Capyloon and
|
||||
other upstream projects. Their original licenses remain applicable.
|
||||
Publishing the Tundra tooling does not relicense proprietary vendor files.
|
||||
|
||||
Vulpes OS is independent of Mozilla. Firefox and other third-party trademarks
|
||||
belong to their respective owners. This project is not an official Firefox OS
|
||||
release or an endorsement by those organizations.
|
||||
257
README.fr.md
257
README.fr.md
|
|
@ -1,219 +1,92 @@
|
|||
<p align="center">
|
||||
<a href="https://nnsprod.com/git/oversu/VulpesOS" lang="en" hreflang="en">🇬🇧 English</a> · <a href="https://nnsprod.com/git/oversu/VulpesOS/src/branch/main/README.fr.md" lang="fr" hreflang="fr"><strong>🇫🇷 Français</strong></a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="docs/media/vulpes-logo.png" width="160" alt="Logo Vulpes OS — un renard blanc et bleu">
|
||||
</p>
|
||||
|
||||
<p align="center"><a href="https://nnsprod.com/git/oversu/VulpesOS">🇬🇧 English</a> · <strong>🇫🇷 Français</strong></p>
|
||||
<p align="center"><img src="docs/media/vulpes-logo.png" width="160" alt="Logo renard de Vulpes OS"></p>
|
||||
<h1 align="center">Vulpes OS</h1>
|
||||
|
||||
<p align="center"><strong>L'esprit de Firefox OS. Un Gecko moderne. Une base Gaia commune.</strong><br>Un projet communautaire pour retrouver une expérience mobile fondée sur le Web, sur PC, Android et téléphone natif.</p>
|
||||
<p align="center">
|
||||
<strong>L’esprit Firefox OS. Un moteur Gecko d’aujourd’hui.</strong><br>
|
||||
A community continuation of Firefox OS.
|
||||
<img src="https://img.shields.io/badge/Vulpes-2.7_preview.15-0755be?style=flat-square" alt="Vulpes Preview 15">
|
||||
<img src="https://img.shields.io/badge/Gecko_bureau-156.0.1-0099cc?style=flat-square" alt="Gecko bureau 156.0.1">
|
||||
<img src="https://img.shields.io/badge/Statut-Expérimental-f3a712?style=flat-square" alt="Expérimental">
|
||||
</p>
|
||||
<p align="center"><a href="https://vulpes-os.org">🌐 Le projet</a> · <a href="https://nnsprod.com/git/oversu/VulpesOS/releases">📦 Téléchargements</a> · <a href="https://vulpes-os.org/changelog.php">📝 Changelog</a> · <a href="https://nnsprod.com/git/oversu/VulpesOS/issues">🐞 Signaler un bug</a></p>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://img.shields.io/badge/Vulpes-2.7-0755be?style=flat-square" alt="Vulpes 2.7">
|
||||
<img src="https://img.shields.io/badge/Gecko_desktop-156.0.1-0099cc?style=flat-square" alt="Gecko desktop 156.0.1">
|
||||
<img src="https://img.shields.io/badge/Statut-Preview-f3a712?style=flat-square" alt="Statut : Preview">
|
||||
<img src="https://img.shields.io/badge/Plateformes-Linux_%C2%B7_Android-334155?style=flat-square" alt="Linux et Android">
|
||||
</p>
|
||||
## 🦊 Le Web comme interface
|
||||
|
||||
<p align="center">
|
||||
<a href="https://vulpes-os.org"><strong>🌐 Découvrir le projet</strong></a>
|
||||
·
|
||||
<a href="#telechargements"><strong>📥 APK Android</strong></a>
|
||||
·
|
||||
<a href="#points-forts">Les points forts</a>
|
||||
·
|
||||
<a href="#architecture">L’architecture</a>
|
||||
·
|
||||
<a href="#suite">La suite</a>
|
||||
</p>
|
||||
Accueil, paramètres, appareil photo, galerie, messages : **Gaia reste l'interface**, composée de HTML, CSS et JavaScript. Vulpes adapte les API attendues par ces applications Firefox OS à un moteur Gecko moderne et à des services propres à chaque plateforme.
|
||||
|
||||
---
|
||||
Ce dépôt contient désormais l'interface commune, l'hôte PC, l'application Android, le runtime Tundra et les outils de développement. C'est une **première préversion pour développeurs**, pas un système mobile terminé.
|
||||
|
||||
## 🦊 Le Web comme plateforme d’applications
|
||||
<p align="center"><img src="docs/media/vulpes-desktop.png" width="290" alt="Capture réelle du bureau Gaia en anglais"> <img src="docs/media/vulpes-gecko.png" width="290" alt="Capture réelle des informations système et du moteur Gecko"></p>
|
||||
<p align="center"><em>Captures de l'environnement de développement PC. Les fonctionnalités dépendent de la plateforme et du matériel disponible.</em></p>
|
||||
|
||||
Et si l’interface de votre téléphone était faite avec les mêmes technologies que vos sites web ?
|
||||
## 📥 Choisissez votre plateforme
|
||||
|
||||
**Vulpes redonne vie à cette idée de Firefox OS.** L’accueil, les paramètres et les applications Gaia retrouvent un environnement d’exécution sur un Gecko récent. HTML, CSS et JavaScript restent au cœur de l’expérience : une interface que l’on peut lire, comprendre et modifier.
|
||||
| Plateforme | Disponible aujourd'hui | Moteur |
|
||||
| --- | --- | --- |
|
||||
| **PC Linux** | Sources, fenêtre Gaia au format téléphone, développement et tests d'applications | Gecko **156.0.1** |
|
||||
| **APK Android** | Preview installable ; Android et ses permissions restent en dessous | GeckoView **156.0** |
|
||||
| **Pixel 3a · Sargo** | Sources Tundra ; build natif de développement testé sur notre appareil | Gecko **156.0.1** ARM64 |
|
||||
|
||||
Le projet relie deux générations : **les applications et l’interface historiques de Firefox OS**, et **le moteur web maintenu par Mozilla**. Son ambition est de faire évoluer l’un sans devoir réécrire l’autre à chaque version.
|
||||
### Android — Preview 15
|
||||
|
||||
**Un seul projet, deux façons de l’utiliser : l’émulateur desktop Linux et l’application Android Vulpes OS - Preview (APK).** Ils partagent Gaia et les services Vulpes, avec une intégration Gecko adaptée à chaque plateforme.
|
||||
Téléchargez l'APK et `SHA256SUMS.txt` depuis [la release Preview 15](https://nnsprod.com/git/oversu/VulpesOS/releases/tag/v2.7-preview.15). Une installation par-dessus une ancienne Preview Vulpes signée conserve ses données.
|
||||
|
||||
> **Disponible :** les trois Preview Android sont téléchargeables dans les [Releases](https://nnsprod.com/git/oversu/VulpesOS/releases). Les sources complètes, la distribution desktop et leurs instructions d’installation sont en préparation. Les captures ci-dessous montrent le prototype desktop.
|
||||
- Minimum déclaré : **Android 8 / API 26**. Cible : **API 37**.
|
||||
- APK universel : **ARM64, ARMv7 et x86_64** ; environ **600 Mio**, moteur GeckoView inclus.
|
||||
- Photo et Galerie utilisent Gaia, avec les permissions et l'import de fichiers Android.
|
||||
- Les appels et SMS sont transmis aux applications Android ; Vulpes n'est pas l'application Téléphone/SMS par défaut.
|
||||
- Des parcours sur émulateur Android 16 sont testés. Le minimum SDK déclaré ne signifie pas que tous les appareils Android ont été validés.
|
||||
- Il s'agit d'un **build de développement signé**, avec débogage Gecko accessible via ADB autorisé, pas d'une application durcie pour la production.
|
||||
|
||||
<p align="center">
|
||||
<a href="https://nnsprod.com/git/oversu/VulpesOS/media/branch/main/docs/media/vulpes-desktop.png"><img src="docs/media/vulpes-desktop.png" width="300" alt="Capture réelle de Vulpes : accueil Gaia en anglais"></a>
|
||||
|
||||
<a href="https://nnsprod.com/git/oversu/VulpesOS/media/branch/main/docs/media/vulpes-gecko.png"><img src="docs/media/vulpes-gecko.png" width="300" alt="Paramètres Vulpes en anglais, affichant la version réelle du moteur Gecko"></a>
|
||||
</p>
|
||||
### Linux — lancer depuis les sources
|
||||
|
||||
<p align="center"><em>Accueil et informations système — captures réelles du prototype desktop en anglais. Le champ « Platform Version » affiche la version Gecko renvoyée par le moteur exécuté. Cliquer sur une image pour l’agrandir.</em></p>
|
||||
Prérequis : Linux x86_64, Python 3, Git et les bibliothèques système nécessaires à Firefox. Sur Debian/Ubuntu : `git python3 libgtk-3-0 libdbus-glib-1-2 libasound2` (les noms de paquets peuvent varier selon la distribution).
|
||||
|
||||
<a name="telechargements"></a>
|
||||
|
||||
## 📥 Tester la Preview Android
|
||||
|
||||
**Pour commencer, choisissez [Vulpes OS - Preview 2.7-156.0.1](https://nnsprod.com/git/oversu/VulpesOS/releases/tag/android-2.7-156.0.1)**, la plus récente des trois versions. Chaque page contient l’APK, les notes FR/EN et le fichier de contrôle `SHA256SUMS.txt`.
|
||||
|
||||
| Version | Contenu | Usage |
|
||||
| :--- | :--- | :--- |
|
||||
| [2.7-156.0.1](https://nnsprod.com/git/oversu/VulpesOS/releases/tag/android-2.7-156.0.1) | Nom et icône Vulpes OS - Preview ; correctif du fond d’écran inclus | **Preview conseillée** |
|
||||
| [2.7-preview.2](https://nnsprod.com/git/oversu/VulpesOS/releases/tag/android-2.7-preview.2) | Correction du fond d’écran clignotant | Archive |
|
||||
| [2.7-preview.1](https://nnsprod.com/git/oversu/VulpesOS/releases/tag/android-2.7-preview.1) | Première Preview Android | Archive — clignotement du fond d’écran connu |
|
||||
|
||||
Téléchargez l’APK et ouvrez-le sur Android pour l’installer. Les versions successives conservent le même identifiant et la même signature : une mise à jour par-dessus la précédente permet de garder les données.
|
||||
|
||||
- **Android 8.0 / API 26 minimum déclaré.** Validation sur un émulateur Android 16 / API 36 ; les autres configurations restent à tester.
|
||||
- **Environ 592 Mio par APK**, avec les architectures ARM64, ARM 32 bits et x86_64 intégrées.
|
||||
- **Preview de développement :** elle ne remplace pas Android et ne fournit pas les appels/SMS cellulaires. L’import des médias Android reste à porter.
|
||||
- **Desktop Linux :** environnement de développement distinct, encore sans distribution publique prête à installer. Ce simulateur affiche Gaia ; il n’émule pas tout le matériel d’un téléphone.
|
||||
|
||||
Les APK sont joints aux Releases, sans alourdir l’historique Git. Ces tags désignent les APK historiques publiés ; ils ne représentent pas encore leurs sources de compilation complètes.
|
||||
|
||||
<a name="points-forts"></a>
|
||||
|
||||
## ✨ Ce qui rend Vulpes intéressant
|
||||
|
||||
### 🔄 Un moteur qui peut évoluer
|
||||
|
||||
Le passage de Gecko 45 à 52 a servi de première étape. Le prototype desktop utilise maintenant **Gecko 156.0.1** avec une architecture qui sépare l’interface, les services et l’intégration au moteur.
|
||||
|
||||
Un outil automatise le téléchargement d’une version candidate, le contrôle de son empreinte et les tests de compatibilité. Le basculement reste explicite et un retour arrière est prévu. Les incompatibilités sont détectées et documentées ; elles ne sont pas réparées automatiquement.
|
||||
|
||||
### 🧩 Faire vivre les applications Firefox OS
|
||||
|
||||
Vulpes adapte les anciennes API dont Gaia a besoin : réglages, registre des applications, contacts locaux, stockage et communications entre applications. Le travail porte sur leur fonctionnement, leurs permissions et leurs données persistantes.
|
||||
|
||||
Des essais avec des applications historiques accompagnent le portage. **La compatibilité progresse application par application** : la présence d’une ancienne API ne garantit pas encore le fonctionnement de tout le catalogue Firefox OS.
|
||||
|
||||
### 🛠️ Modifier l’interface sans reconstruire Gecko
|
||||
|
||||
Une grande partie de l’interface se travaille dans les fichiers HTML, CSS et JavaScript. Les ressources servies et les surcharges peuvent être modifiées puis rechargées, sans recompiler le moteur.
|
||||
|
||||
Certaines applications conservent des bundles issus de l’ancien système de construction Gaia. Leur modification demande de vérifier quel fichier est réellement chargé : tous les fichiers des sources historiques ne sont pas encore reliés directement à l’interface exécutée.
|
||||
|
||||
### 📱 Deux façons d’explorer le projet
|
||||
|
||||
- **Sur Linux :** une fenêtre au format téléphone, avec Gaia, le multitâche et un navigateur utilisant des vues Gecko séparées.
|
||||
- **Sur Android :** **Vulpes OS – Preview**, une application GeckoView pour découvrir l’expérience sans remplacer le système du téléphone.
|
||||
|
||||
La Preview Android est un terrain d’essai. Elle n’est pas une ROM et ne remplace pas les fonctions de téléphonie d’Android.
|
||||
|
||||
## 🧪 Où en est le prototype ?
|
||||
|
||||
| Fonction | Desktop Linux | Preview Android |
|
||||
| :--- | :--- | :--- |
|
||||
| Accueil Gaia, lancement des applications | ✅ Fonctionnel | ✅ Disponible |
|
||||
| Réglages persistants et interface traduite | ✅ Parcours testés | ✅ Intégrés, validation mobile à poursuivre |
|
||||
| Navigation web | ✅ Vues Gecko séparées | ✅ Sessions GeckoView séparées |
|
||||
| Contacts | ✅ Contacts locaux au profil | ✅ Contacts locaux à Vulpes |
|
||||
| SMS | 🧪 Interface et brouillons locaux | 🧪 Interface locale |
|
||||
| Galerie et musique | ✅ Import et lecture testés | 🚧 Import des médias Android à porter |
|
||||
| Alarmes | ✅ Création, déclenchement et persistance testés | 🧪 Liées à la durée de vie du processus Vulpes |
|
||||
| Appels et SMS sur le réseau mobile | 🚧 Non intégrés | 🚧 Non intégrés |
|
||||
| Installation comme système de téléphone | 🚧 Futur chantier | 🚧 L’APK ne remplace pas Android |
|
||||
|
||||
**Versions de référence — septembre 2026**
|
||||
|
||||
| Élément | Version |
|
||||
| :--- | :--- |
|
||||
| Produit communautaire | Vulpes OS 2.7 |
|
||||
| Moteur desktop | Gecko 156.0.1 |
|
||||
| Application Android | Preview 2.7-156.0.1 |
|
||||
| Dépendance GeckoView | `156.0.20260921121718` |
|
||||
| Minimum Android déclaré | Android 8.0 · API 26 |
|
||||
|
||||
La version de l’APK, celle du moteur et celle du produit sont distinctes. Le `.1` final de la Preview désigne sa révision ; GeckoView rapporte ici **156.0**. Le minimum Android déclaré ne signifie pas que chaque appareil a été testé.
|
||||
|
||||
<a name="architecture"></a>
|
||||
|
||||
## ⚙️ Sous le capot
|
||||
|
||||
```text
|
||||
Gaia + applications web
|
||||
HTML · CSS · JS
|
||||
│
|
||||
Compatibilité des anciennes API moz*
|
||||
Contrats Vulpes versionnés
|
||||
│
|
||||
Réglages · Applications · Contacts · Stockage
|
||||
Messages locaux · Alarmes
|
||||
│
|
||||
┌────────────┴────────────┐
|
||||
│ │
|
||||
Hôte desktop Hôte Android
|
||||
Fenêtre privilégiée GeckoView + passerelle
|
||||
et vues web séparées WebExtension/native
|
||||
│ │
|
||||
Firefox / Gecko GeckoView
|
||||
│ │
|
||||
Linux Android
|
||||
```sh
|
||||
git clone https://nnsprod.com/git/oversu/VulpesOS.git
|
||||
cd VulpesOS
|
||||
./setup.sh
|
||||
./run.sh
|
||||
```
|
||||
|
||||
### Une frontière claire entre les applications et le système
|
||||
`setup.sh` télécharge le moteur Mozilla verrouillé et vérifie son empreinte. Le lancement normal ouvre Gaia sans débogueur. Les profils et moteurs téléchargés restent hors Git.
|
||||
|
||||
Les applications passent par des services dont les permissions sont contrôlées par l’hôte. Les pages web externes utilisent des contextes de navigation séparés et n’obtiennent pas les API privilégiées de Vulpes.
|
||||
### Pixel 3a — développement natif Tundra
|
||||
|
||||
Le port desktop actuel s’appuie sur le **binaire officiel de Firefox**, avec un hôte et des adaptateurs Vulpes, sans modification native du moteur. Certaines interfaces utilisées par cet hôte restent internes à Gecko : les tests à chaque changement de version sont donc essentiels.
|
||||
**Le build natif démarre directement dans Vulpes**, avec des services matériels Android sélectionnés, un espace utilisateur Linux, Gecko et Gaia. Phosh et l'environnement applicatif Android ne sont pas démarrés.
|
||||
|
||||
### Des mises à jour vérifiées avant activation
|
||||
Notre image de développement Sargo installée a passé les contrôles de démarrage et de persistance. Des appels réels et des SMS dans les deux sens ont été observés ; les derniers essais couvrent les conversations, les bascules de capteur photo, la capture JPEG pleine résolution, le focus tactile, le zoom numérique et l'arrêt du vibreur.
|
||||
|
||||
```text
|
||||
Télécharger → Vérifier l’empreinte → Tester les interfaces
|
||||
↓
|
||||
Ancien moteur conservé ← Activer ← Tester Gaia et la persistance
|
||||
**Cette release ne contient pas d'image générique à flasher.** Le boot privé dépend encore de la disposition du stockage du téléphone inventorié, d'images système/données déjà déployées et d'accès de maintenance. Publier ce fichier ne fournirait pas une installation fonctionnelle à un autre Pixel. Les recettes Tundra sont incluses pour les contributeurs ; elles nécessitent un inventaire, des sauvegardes vérifiées et des composants matériels fournis localement. Ne réutilisez pas la sauvegarde d'un autre appareil et ne considérez pas un boot isolé comme une ROM complète.
|
||||
|
||||
## ✨ Ce que nous partageons
|
||||
|
||||
- **Une base Gaia :** interface et services communs pour PC, Android et Tundra.
|
||||
- **Les applications d'origine :** Photo, Galerie, Paramètres et Messages conservent leur interface Gaia, reliée aux adaptateurs de chaque plateforme.
|
||||
- **Du code Web éditable :** les ressources servies sont dans `assets/webapps/`, la compatibilité commune dans `host/`, les remplacements dans `overrides/`. Rechargez ou redémarrez pour tester, sans recompiler Gecko. Certaines sources historiques de `gaia/` nécessitent encore la mise à jour de leur version regroupée.
|
||||
- **Un moteur remplaçable :** téléchargements verrouillés, contrôle d'empreinte, tests isolés et outils de retour arrière. Une mise à jour du moteur se teste et se sélectionne explicitement ; la compatibilité n'est pas garantie automatiquement.
|
||||
- **Des versions distinctes :** Vulpes, Gaia, Gecko et adaptation matérielle sont identifiés séparément. GeckoView 156.0 n'est pas présenté comme Gecko bureau 156.0.1.
|
||||
|
||||
## 🧪 Limites actuelles
|
||||
|
||||
Cette Preview contient des adaptateurs matériels incomplets et des comportements hérités à corriger. Sur Sargo, l'aperçu photo tourne autour de 16 images/s ; flash/vidéo, rotation automatique par capteur et suspension complète restent incomplets. L'enregistrement réseau peut être instable et l'audio d'une conversation dans les deux sens reste à qualifier. Un grand dialogue signalé après envoi de SMS est encore en cours d'analyse.
|
||||
|
||||
Sur Android, les intégrations suivent les permissions et les restrictions de cycle de vie du système. Les alarmes Gaia ne sont pas garanties après l'arrêt de Vulpes par Android. Certaines commandes non prises en charge restent visibles mais désactivées. Des applications de développement/test sont incluses.
|
||||
|
||||
Conservez une sauvegarde avant vos essais. Pour signaler un problème, indiquez la plateforme, les versions Vulpes/Gecko et les étapes de reproduction ; retirez des logs les numéros, contacts et autres informations personnelles.
|
||||
|
||||
## 🛠️ Construire l'APK Android
|
||||
|
||||
```sh
|
||||
cd android
|
||||
./build-apk.sh
|
||||
```
|
||||
|
||||
Les profils de test sont séparés des données utilisateur. L’outil conserve l’ancien moteur et son profil pour permettre un retour arrière. Le pipeline concerne aujourd’hui le desktop ; les mises à jour Android suivent le cycle de construction de l’APK.
|
||||
Le script installe les outils verrouillés, prépare les ressources Gaia communes et construit un APK de développement signé dans `android/dist/`. L'acceptation des licences SDK Android peut être nécessaire. Un clone neuf génère sa propre clé de signature : il ne pourra pas mettre à jour un APK signé avec la clé privée du projet.
|
||||
|
||||
### Une base de travail testée
|
||||
## 📜 Remerciements et licences
|
||||
|
||||
Les contrôles automatisés couvrent notamment :
|
||||
Vulpes OS est un projet communautaire d'**oversu / NNS Production**, inspiré de Firefox OS. Merci à **Mozilla, aux contributeurs Gaia, à Capyloon, Droidian, UBports, libhybris, Debian, AOSP** et aux communautés qui font vivre les systèmes mobiles ouverts.
|
||||
|
||||
- le démarrage de la vraie interface Gaia et le chargement des icônes ;
|
||||
- les langues, les réglages et la persistance après redémarrage ;
|
||||
- les contacts, le pavé numérique et le compositeur SMS ;
|
||||
- les médias importés, les alarmes et la navigation ;
|
||||
- les refus d’accès lorsque l’origine ou les permissions ne conviennent pas.
|
||||
Les nouveaux fichiers Vulpes utilisent **MPL 2.0**. Gaia conserve **Apache 2.0** ; les composants hérités conservent leurs licences et mentions. Voir [LICENSE](LICENSE), [NOTICE](NOTICE) et [la licence Gaia](gaia/LICENSE). Les forks doivent conserver les mentions d'attribution et de licence applicables.
|
||||
|
||||
Un export des fichiers prévus pour publication a également démarré et passé les tests desktop sans les anciens dossiers de développement. Le packaging Android et la compilation de l’APK ont été vérifiés. Cela ne constitue pas une validation exhaustive de Firefox OS ni de tous les téléphones Android.
|
||||
|
||||
<a name="suite"></a>
|
||||
|
||||
## 🗺️ La suite
|
||||
|
||||
- **Publier une base autonome :** sources, licences, documentation et procédure de démarrage.
|
||||
- **Consolider la compatibilité :** poursuivre les essais d’applications historiques et les corrections des parcours du quotidien.
|
||||
- **Améliorer la Preview Android :** accès aux médias, intégration à la plateforme et retours d’usage sur appareils réels.
|
||||
- **Réduire le coût des mises à jour Gecko :** maintenir des contrats stables et limiter les adaptations propres au moteur.
|
||||
- **Explorer un véritable port mobile :** matériel, modem, pilotes et intégration système, une fois la base consolidée.
|
||||
|
||||
## 🤝 Participer
|
||||
|
||||
Les retours utiles décrivent **l’appareil ou la distribution Linux, la version utilisée, les étapes pour reproduire le problème et le résultat attendu**. Une capture et un extrait de journal sans données personnelles aident beaucoup.
|
||||
|
||||
Le projet a aussi besoin de contributions en JavaScript, CSS, intégration Gecko/GeckoView, tests, traduction et documentation. Les consignes de contribution accompagneront la publication des sources.
|
||||
|
||||
## 📜 Origines et licences
|
||||
|
||||
Vulpes est construit à partir du travail de Mozilla et des contributeurs de **Boot to Gecko / Firefox OS**, notamment Gaia.
|
||||
|
||||
La licence retenue pour les nouveaux fichiers Vulpes est la **Mozilla Public License 2.0 (`MPL-2.0`)**. Gaia et les autres composants hérités conservent leurs licences, notamment **Apache 2.0** pour la base Gaia, ainsi que leurs mentions d’attribution. Les textes de licence et le détail des composants accompagneront la publication des sources.
|
||||
|
||||
---
|
||||
|
||||
<p align="center">
|
||||
<strong>VULPES</strong><br>
|
||||
Firefox OS Community Project<br><br>
|
||||
<a href="https://vulpes-os.org">vulpes-os.org</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<sub>Vulpes est un projet communautaire indépendant, sans affiliation ni approbation de Mozilla.<br>
|
||||
Vulpes is an independent community project and is not affiliated with or endorsed by Mozilla.</sub>
|
||||
</p>
|
||||
Vulpes OS est indépendant de Mozilla et n'est pas une version officielle de Firefox OS.
|
||||
|
|
|
|||
254
README.md
254
README.md
|
|
@ -1,218 +1,92 @@
|
|||
<p align="center">
|
||||
<a href="https://nnsprod.com/git/oversu/VulpesOS" lang="en" hreflang="en"><strong>🇬🇧 English</strong></a> · <a href="https://nnsprod.com/git/oversu/VulpesOS/src/branch/main/README.fr.md" lang="fr" hreflang="fr">🇫🇷 Français</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="docs/media/vulpes-logo.png" width="160" alt="Vulpes OS logo — a white and blue fox">
|
||||
</p>
|
||||
|
||||
<p align="center"><strong>🇬🇧 English</strong> · <a href="https://nnsprod.com/git/oversu/VulpesOS/src/branch/main/README.fr.md">🇫🇷 Français</a></p>
|
||||
<p align="center"><img src="docs/media/vulpes-logo.png" width="160" alt="Vulpes OS fox logo"></p>
|
||||
<h1 align="center">Vulpes OS</h1>
|
||||
|
||||
<p align="center"><strong>The spirit of Firefox OS. A modern Gecko. One shared Gaia.</strong><br>A community project bringing a web-based phone experience to desktop, Android and native hardware.</p>
|
||||
<p align="center">
|
||||
<strong>The spirit of Firefox OS. Powered by a modern Gecko.</strong><br>
|
||||
A community continuation of Firefox OS.
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://img.shields.io/badge/Vulpes-2.7-0755be?style=flat-square" alt="Vulpes 2.7">
|
||||
<img src="https://img.shields.io/badge/Vulpes-2.7_preview.15-0755be?style=flat-square" alt="Vulpes Preview 15">
|
||||
<img src="https://img.shields.io/badge/Desktop_Gecko-156.0.1-0099cc?style=flat-square" alt="Desktop Gecko 156.0.1">
|
||||
<img src="https://img.shields.io/badge/Status-Preview-f3a712?style=flat-square" alt="Status: Preview">
|
||||
<img src="https://img.shields.io/badge/Platforms-Linux_%C2%B7_Android-334155?style=flat-square" alt="Linux and Android">
|
||||
<img src="https://img.shields.io/badge/Status-Experimental-f3a712?style=flat-square" alt="Experimental">
|
||||
</p>
|
||||
<p align="center"><a href="https://vulpes-os.org">🌐 Website</a> · <a href="https://nnsprod.com/git/oversu/VulpesOS/releases">📦 Downloads</a> · <a href="https://vulpes-os.org/changelog.php">📝 Changelog</a> · <a href="https://nnsprod.com/git/oversu/VulpesOS/issues">🐞 Report a bug</a></p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://vulpes-os.org"><strong>🌐 Discover the project</strong></a>
|
||||
·
|
||||
<a href="#downloads"><strong>📥 Android APK</strong></a>
|
||||
·
|
||||
<a href="#highlights">Highlights</a>
|
||||
·
|
||||
<a href="#architecture">Architecture</a>
|
||||
·
|
||||
<a href="#roadmap">Roadmap</a>
|
||||
</p>
|
||||
## 🦊 The Web as your interface
|
||||
|
||||
---
|
||||
Home screen, settings, camera, gallery, messages: **Gaia remains the interface**, built from HTML, CSS and JavaScript. Vulpes adapts the APIs that these Firefox OS applications expect to a modern Gecko engine and platform-specific services.
|
||||
|
||||
## 🦊 The Web as an application platform
|
||||
This repository now contains the shared interface, desktop host, Android application, Tundra runtime and development tools. This is an **early developer preview**, not a finished phone operating system.
|
||||
|
||||
What if your phone’s interface were built with the same technologies as your websites?
|
||||
<p align="center"><img src="docs/media/vulpes-desktop.png" width="290" alt="Actual desktop screenshot of the Gaia home screen in English"> <img src="docs/media/vulpes-gecko.png" width="290" alt="Actual desktop screenshot of device information showing the Gecko engine"></p>
|
||||
<p align="center"><em>Desktop development screenshots. Capabilities depend on the platform and available hardware.</em></p>
|
||||
|
||||
**Vulpes brings that Firefox OS idea back to life.** The Gaia home screen, settings and applications run on a recent Gecko engine. HTML, CSS and JavaScript remain at the heart of the experience: an interface you can read, understand and modify.
|
||||
## 📥 Choose your platform
|
||||
|
||||
The project connects two generations: **the original Firefox OS interface and applications**, and **the web engine maintained by Mozilla**. The aim is to let one evolve without having to rewrite the other for every release.
|
||||
| Platform | Available today | Engine |
|
||||
| --- | --- | --- |
|
||||
| **Linux desktop** | Source checkout, phone-sized Gaia window, development and app tests | Gecko **156.0.1** |
|
||||
| **Android APK** | Installable Preview; keeps Android and its permissions underneath | GeckoView **156.0** |
|
||||
| **Pixel 3a · Sargo** | Tundra sources; native development build tested on our device | Gecko **156.0.1** ARM64 |
|
||||
|
||||
**One project, two ways to run it: the Linux desktop emulator and the Vulpes OS - Preview Android application (APK).** They share Gaia and Vulpes services, with Gecko integration adapted to each platform.
|
||||
### Android — Preview 15
|
||||
|
||||
> **Available now:** all three Android Previews can be downloaded from [Releases](https://nnsprod.com/git/oversu/VulpesOS/releases). Full sources, the desktop distribution and their installation instructions are being prepared. The screenshots below show the desktop prototype.
|
||||
Download the APK and `SHA256SUMS.txt` from [the Preview 15 release](https://nnsprod.com/git/oversu/VulpesOS/releases/tag/v2.7-preview.15). Installing over an earlier signed Vulpes Preview preserves its data.
|
||||
|
||||
<p align="center">
|
||||
<a href="https://nnsprod.com/git/oversu/VulpesOS/media/branch/main/docs/media/vulpes-desktop.png"><img src="docs/media/vulpes-desktop.png" width="300" alt="Actual Vulpes screenshot: the Gaia home screen in English"></a>
|
||||
|
||||
<a href="https://nnsprod.com/git/oversu/VulpesOS/media/branch/main/docs/media/vulpes-gecko.png"><img src="docs/media/vulpes-gecko.png" width="300" alt="Vulpes Settings in English, showing the actual Gecko engine version"></a>
|
||||
</p>
|
||||
- Minimum declared: **Android 8 / API 26**. Target: **API 37**.
|
||||
- Universal APK: **ARM64, ARMv7 and x86_64**; approximately **600 MiB** including GeckoView.
|
||||
- Camera and Gallery use Gaia, with Android permissions and file import.
|
||||
- Calls and SMS hand off to Android's applications; Vulpes is not the default SMS or phone app.
|
||||
- Android 16 emulator workflows are tested. Minimum SDK support is not a claim that every Android device is validated.
|
||||
- This is a signed **development build** with Gecko debugging available through authorized ADB, not a production-hardened app.
|
||||
|
||||
<p align="center"><em>Home screen and device information — actual desktop captures in English. The “Platform Version” field shows the Gecko version reported by the running engine. Click either image to enlarge it.</em></p>
|
||||
### Linux — run from source
|
||||
|
||||
<a name="downloads"></a>
|
||||
Linux x86_64, Python 3, Git and the system libraries needed by Firefox are required. On Debian/Ubuntu, install `git python3 libgtk-3-0 libdbus-glib-1-2 libasound2` (package names may differ by distribution).
|
||||
|
||||
## 📥 Try the Android Preview
|
||||
|
||||
**Start with [Vulpes OS - Preview 2.7-156.0.1](https://nnsprod.com/git/oversu/VulpesOS/releases/tag/android-2.7-156.0.1)**, the latest of the three builds. Each release page includes the APK, English/French notes and a `SHA256SUMS.txt` checksum file.
|
||||
|
||||
| Version | Changes | Use |
|
||||
| :--- | :--- | :--- |
|
||||
| [2.7-156.0.1](https://nnsprod.com/git/oversu/VulpesOS/releases/tag/android-2.7-156.0.1) | Vulpes OS - Preview name and icon; wallpaper fix included | **Recommended Preview** |
|
||||
| [2.7-preview.2](https://nnsprod.com/git/oversu/VulpesOS/releases/tag/android-2.7-preview.2) | Fixes wallpaper flashing | Archive |
|
||||
| [2.7-preview.1](https://nnsprod.com/git/oversu/VulpesOS/releases/tag/android-2.7-preview.1) | First Android Preview | Archive — known wallpaper flashing |
|
||||
|
||||
Download the APK and open it on Android to install it. Successive versions share the same package ID and signature: installing the newer build over the previous one preserves application data.
|
||||
|
||||
- **Declared minimum: Android 8.0 / API 26.** Validated on an Android 16 / API 36 emulator; other configurations still need testing.
|
||||
- **Approximately 592 MiB per APK**, including ARM64, 32-bit ARM and x86_64 architectures.
|
||||
- **Development Preview:** it does not replace Android or provide cellular calls/SMS. Android media import remains to be ported.
|
||||
- **Linux desktop:** a separate development environment, with no ready-to-install public distribution yet. This simulator runs Gaia; it does not emulate all phone hardware.
|
||||
|
||||
APKs are attached to Releases, keeping binaries out of Git history. These tags identify the historical APK publications; they do not yet contain their complete build sources.
|
||||
|
||||
<a name="highlights"></a>
|
||||
|
||||
## ✨ What makes Vulpes interesting
|
||||
|
||||
### 🔄 An engine that can keep evolving
|
||||
|
||||
Moving from Gecko 45 to 52 was the first step. The desktop prototype now uses **Gecko 156.0.1**, with an architecture that separates the interface, services and engine integration.
|
||||
|
||||
An update tool automates downloading a candidate version, checking its checksum and running compatibility tests. Switching versions remains an explicit action, with rollback available. Incompatibilities are detected and documented; they are not repaired automatically.
|
||||
|
||||
### 🧩 Keeping Firefox OS applications alive
|
||||
|
||||
Vulpes adapts the legacy APIs Gaia needs: settings, the application registry, local contacts, storage and communication between applications. This work covers their behavior, permissions and persistent data.
|
||||
|
||||
Tests with archived applications accompany the porting effort. **Compatibility improves one application at a time**: the presence of a legacy API does not yet guarantee that the entire Firefox OS catalog will work.
|
||||
|
||||
### 🛠️ Edit the interface without rebuilding Gecko
|
||||
|
||||
Much of the interface can be developed directly in HTML, CSS and JavaScript files. Served resources and overrides can be edited and reloaded without recompiling the engine.
|
||||
|
||||
Some applications still use bundles produced by the old Gaia build system. Editing them means checking which file is actually loaded: not every file in the historical sources is directly connected to the running interface yet.
|
||||
|
||||
### 📱 Two ways to explore the project
|
||||
|
||||
- **On Linux:** a phone-sized window with Gaia, multitasking and a browser using separate Gecko views.
|
||||
- **On Android:** **Vulpes OS – Preview**, a GeckoView application for exploring the experience without replacing your phone’s operating system.
|
||||
|
||||
The Android Preview is a testing environment. It is not a ROM and does not replace Android’s telephony features.
|
||||
|
||||
## 🧪 Prototype status
|
||||
|
||||
| Feature | Linux desktop | Android Preview |
|
||||
| :--- | :--- | :--- |
|
||||
| Gaia home screen and application launching | ✅ Working | ✅ Available |
|
||||
| Persistent settings and translated interface | ✅ Tested workflows | ✅ Integrated; further mobile validation needed |
|
||||
| Web browsing | ✅ Separate Gecko views | ✅ Separate GeckoView sessions |
|
||||
| Contacts | ✅ Local to the profile | ✅ Local to Vulpes |
|
||||
| SMS | 🧪 Interface and local drafts | 🧪 Local interface |
|
||||
| Gallery and music | ✅ Import and playback tested | 🚧 Android media import still to be ported |
|
||||
| Alarms | ✅ Creation, delivery and persistence tested | 🧪 Tied to the Vulpes process lifetime |
|
||||
| Cellular calls and SMS | 🚧 Not integrated | 🚧 Not integrated |
|
||||
| Installation as a phone operating system | 🚧 Future work | 🚧 The APK does not replace Android |
|
||||
|
||||
**Reference versions — September 2026**
|
||||
|
||||
| Component | Version |
|
||||
| :--- | :--- |
|
||||
| Community product | Vulpes OS 2.7 |
|
||||
| Desktop engine | Gecko 156.0.1 |
|
||||
| Android application | Preview 2.7-156.0.1 |
|
||||
| GeckoView dependency | `156.0.20260921121718` |
|
||||
| Declared Android minimum | Android 8.0 · API 26 |
|
||||
|
||||
The APK, engine and product have separate version numbers. The final `.1` in the Preview version identifies its revision; GeckoView reports **156.0** here. The declared Android minimum does not mean every device has been tested.
|
||||
|
||||
<a name="architecture"></a>
|
||||
|
||||
## ⚙️ Under the hood
|
||||
|
||||
```text
|
||||
Gaia + web applications
|
||||
HTML · CSS · JS
|
||||
│
|
||||
Legacy moz* API compatibility
|
||||
Versioned Vulpes contracts
|
||||
│
|
||||
Settings · Applications · Contacts · Storage
|
||||
Local messages · Alarms
|
||||
│
|
||||
┌─────────────┴─────────────┐
|
||||
│ │
|
||||
Desktop host Android host
|
||||
Privileged window GeckoView + bridge
|
||||
and separate web views WebExtension/native
|
||||
│ │
|
||||
Firefox / Gecko GeckoView
|
||||
│ │
|
||||
Linux Android
|
||||
```sh
|
||||
git clone https://nnsprod.com/git/oversu/VulpesOS.git
|
||||
cd VulpesOS
|
||||
./setup.sh
|
||||
./run.sh
|
||||
```
|
||||
|
||||
### A clear boundary between applications and the system
|
||||
`setup.sh` downloads the pinned Mozilla engine and verifies its checksum. Normal startup opens the Gaia interface without a debugger. Profiles and downloaded engines stay outside Git.
|
||||
|
||||
Applications use services whose permissions are checked by the host. External web pages use separate browsing contexts and do not receive Vulpes’s privileged APIs.
|
||||
### Pixel 3a — native Tundra development
|
||||
|
||||
The current desktop port uses the **official Firefox binary**, with a Vulpes host and adapters, without native engine patches. Some interfaces used by this host remain internal to Gecko, making tests essential whenever the engine version changes.
|
||||
**The native build boots directly into Vulpes**, with selected Android hardware services, Linux userspace, Gecko and Gaia; Phosh and the Android application framework are not started.
|
||||
|
||||
### Updates checked before activation
|
||||
Our installed Sargo development image has passed startup and persistence checks. Real calls and two-way SMS have been observed; the latest checks cover conversation rendering, camera sensor switching, full-resolution JPEG capture, touch focus, digital zoom and bounded vibration.
|
||||
|
||||
```text
|
||||
Download → Verify checksum → Test engine interfaces
|
||||
↓
|
||||
Keep old engine ← Activate ← Test Gaia and persistence
|
||||
**A generic flashable image is not included in this release.** The current private boot depends on the inventoried phone's storage layout, staged system/data images and maintenance credentials. Publishing that file would not give another Pixel a working installation. Tundra's source recipes are included for contributors; they require device inventory, verified backups and locally supplied hardware components. Do not use another device's backup or treat a boot image as a complete ROM.
|
||||
|
||||
## ✨ What is shared
|
||||
|
||||
- **One Gaia base:** interface and common services serve desktop, Android and Tundra.
|
||||
- **Original applications:** Camera, Gallery, Settings and Messages keep their Gaia UI, backed by platform adapters.
|
||||
- **Editable web code:** change served assets in `assets/webapps/`, shared compatibility code in `host/`, and replacements in `overrides/`. Restart/reload to test; no Gecko rebuild is needed for these changes. Some historical `gaia/` sources still need their bundled counterparts updated.
|
||||
- **A replaceable engine:** pinned downloads, checksum verification, isolated compatibility checks and rollback tools. An engine update is tested and explicitly selected; compatibility is not guaranteed automatically.
|
||||
- **Separate version numbers:** Vulpes release, Gaia, Gecko and hardware adaptation are reported independently. GeckoView 156.0 is not presented as desktop Gecko 156.0.1.
|
||||
|
||||
## 🧪 Current limits
|
||||
|
||||
This preview contains incomplete hardware adapters and legacy application behavior. On Sargo, camera preview is around 16 fps; flash/video, automatic sensor rotation and full suspend remain incomplete. Network registration can be unstable and two-way call audio still needs end-to-end qualification. A reported large dialog after SMS sending remains under investigation.
|
||||
|
||||
On Android, platform integration follows Android permissions and lifecycle restrictions. Gaia alarms are not guaranteed after Android stops Vulpes. Unsupported controls may remain visible but disabled. Development/test applications are included.
|
||||
|
||||
Keep a backup before testing. Include the platform, Vulpes/Gecko versions and reproduction steps when reporting a problem; remove phone numbers, contacts and other personal information from logs.
|
||||
|
||||
## 🛠️ Build the Android APK
|
||||
|
||||
```sh
|
||||
cd android
|
||||
./build-apk.sh
|
||||
```
|
||||
|
||||
Test profiles are separate from user data. The tool keeps the previous engine and its profile to allow rollback. This pipeline currently covers the desktop; Android updates follow the APK build cycle.
|
||||
The script installs the pinned toolchain, packages the shared Gaia resources and builds a signed development APK in `android/dist/`. Android SDK licenses may need acceptance. A fresh checkout generates its own signing key; it cannot update an APK signed by the project's private release key.
|
||||
|
||||
### A tested development base
|
||||
## 📜 Credits and licenses
|
||||
|
||||
Automated checks cover, among other things:
|
||||
Vulpes OS is a community project by **oversu / NNS Production**, inspired by Firefox OS. Thanks to **Mozilla, Gaia contributors, Capyloon, Droidian, UBports, libhybris, Debian, AOSP** and the communities keeping open mobile systems alive.
|
||||
|
||||
- booting the actual Gaia interface and loading application icons;
|
||||
- languages, settings and persistence across restarts;
|
||||
- contacts, the dial pad and the SMS composer;
|
||||
- imported media, alarms and web browsing;
|
||||
- rejecting access when the origin or permissions do not match.
|
||||
New Vulpes code uses **MPL 2.0**. Gaia retains **Apache 2.0** and inherited components retain their own licenses and notices. See [LICENSE](LICENSE), [NOTICE](NOTICE) and [Gaia's license](gaia/LICENSE). Preserve the applicable attribution and license notices in forks.
|
||||
|
||||
An export of the files planned for publication also booted and passed the desktop tests without the old development directories. Android asset packaging and APK compilation have been verified. This is not exhaustive validation of Firefox OS or every Android phone.
|
||||
|
||||
<a name="roadmap"></a>
|
||||
|
||||
## 🗺️ What’s next
|
||||
|
||||
- **Publish a self-contained base:** source code, licenses, documentation and startup instructions.
|
||||
- **Strengthen compatibility:** continue testing historical applications and improving everyday workflows.
|
||||
- **Improve the Android Preview:** media access, platform integration and feedback from real devices.
|
||||
- **Reduce Gecko update maintenance:** keep service contracts stable and limit engine-specific adaptations.
|
||||
- **Explore a full mobile port:** hardware, modem, drivers and system integration once the foundation is ready.
|
||||
|
||||
## 🤝 Get involved
|
||||
|
||||
Useful reports include **the device or Linux distribution, the version in use, steps to reproduce the issue and the expected result**. A screenshot and a log excerpt without personal data help a lot.
|
||||
|
||||
The project also welcomes work on JavaScript, CSS, Gecko/GeckoView integration, testing, translation and documentation. Contribution guidelines will accompany the source release.
|
||||
|
||||
## 📜 Origins and licenses
|
||||
|
||||
Vulpes builds on the work of Mozilla and the contributors to **Boot to Gecko / Firefox OS**, including Gaia.
|
||||
|
||||
The license selected for new Vulpes files is the **Mozilla Public License 2.0 (`MPL-2.0`)**. Gaia and other inherited components retain their own licenses, including **Apache 2.0** for the Gaia base, along with their attribution notices. License texts and component details will accompany the source release.
|
||||
|
||||
---
|
||||
|
||||
<p align="center">
|
||||
<strong>VULPES</strong><br>
|
||||
Firefox OS Community Project<br><br>
|
||||
<a href="https://vulpes-os.org">vulpes-os.org</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<sub>Vulpes is an independent community project and is not affiliated with or endorsed by Mozilla.</sub>
|
||||
</p>
|
||||
Vulpes OS is independent of Mozilla and is not an official Firefox OS release.
|
||||
|
|
|
|||
72
adapters/datastores-indexeddb.mjs
Normal file
72
adapters/datastores-indexeddb.mjs
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
export class DataStoresIndexedDB {
|
||||
constructor(factory, keyRange, uuid) {
|
||||
Object.assign(this, { factory, keyRange, uuid });
|
||||
}
|
||||
open() {
|
||||
return (this.database ||= new Promise((resolve, reject) => {
|
||||
const request = this.factory.open('vulpes-datastores-v1', 1);
|
||||
request.onupgradeneeded = () => {
|
||||
request.result.createObjectStore('values');
|
||||
request.result.createObjectStore('revisions');
|
||||
};
|
||||
request.onerror = () => reject(request.error);
|
||||
request.onsuccess = () => {
|
||||
request.result.onversionchange = () => request.result.close();
|
||||
resolve(request.result);
|
||||
};
|
||||
}));
|
||||
}
|
||||
async run(key, operation, args) {
|
||||
const db = await this.open();
|
||||
return new Promise((resolve, reject) => {
|
||||
const write = ['add', 'put', 'remove', 'clear'].includes(operation);
|
||||
const tx = db.transaction(['values', 'revisions'], write ? 'readwrite' : 'readonly');
|
||||
const store = tx.objectStore('values'),
|
||||
revisions = tx.objectStore('revisions');
|
||||
const range = this.keyRange.bound([key], [key, []]);
|
||||
let value,
|
||||
revisionId = '',
|
||||
entries = [];
|
||||
tx.onabort = () => reject(tx.error || new Error('TRANSACTION_ABORTED'));
|
||||
tx.onerror = () => {};
|
||||
tx.oncomplete = () => resolve({ value, revisionId });
|
||||
if (operation === 'get') {
|
||||
value = [];
|
||||
args.forEach((id, index) => {
|
||||
store.get([key, id]).onsuccess = (event) => {
|
||||
if (args.length === 1) value = event.target.result;
|
||||
else value[index] = event.target.result;
|
||||
};
|
||||
});
|
||||
} else if (operation === 'snapshot') {
|
||||
revisions.get(key).onsuccess = (event) => {
|
||||
revisionId = event.target.result || '';
|
||||
};
|
||||
store.openCursor(range).onsuccess = (event) => {
|
||||
const cursor = event.target.result;
|
||||
if (cursor) {
|
||||
entries.push({ id: cursor.key[1], data: cursor.value });
|
||||
cursor.continue();
|
||||
} else value = { revisionId, entries };
|
||||
};
|
||||
} else if (operation === 'length') {
|
||||
store.count(range).onsuccess = (event) => {
|
||||
value = event.target.result;
|
||||
};
|
||||
} else if (write) {
|
||||
revisionId = this.uuid();
|
||||
revisions.put(revisionId, key);
|
||||
if (operation === 'clear') store.delete(range);
|
||||
else if (operation === 'remove') {
|
||||
store.count([key, args[0]]).onsuccess = (event) => {
|
||||
value = event.target.result > 0;
|
||||
};
|
||||
store.delete([key, args[0]]);
|
||||
} else {
|
||||
value = args[1] === undefined ? this.uuid() : args[1];
|
||||
store[operation === 'add' ? 'add' : 'put'](args[0], [key, value]);
|
||||
}
|
||||
} else tx.abort();
|
||||
});
|
||||
}
|
||||
}
|
||||
39
adapters/indexeddb.mjs
Normal file
39
adapters/indexeddb.mjs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
// Web-standard storage adapter. Schema version is independent of Gecko version.
|
||||
export class IndexedDBStorage {
|
||||
constructor(database) {
|
||||
this.database = database;
|
||||
}
|
||||
static open(name = 'vulpes-services-v1') {
|
||||
return new Promise((resolve, reject) => {
|
||||
const req = indexedDB.open(name, 1);
|
||||
req.onupgradeneeded = () => req.result.createObjectStore('settings');
|
||||
req.onsuccess = () => {
|
||||
const db = req.result;
|
||||
db.onversionchange = () => db.close();
|
||||
resolve(new IndexedDBStorage(db));
|
||||
};
|
||||
req.onerror = () => reject(req.error);
|
||||
req.onblocked = () => reject(new Error('DATABASE_BLOCKED'));
|
||||
});
|
||||
}
|
||||
get(key) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const tx = this.database.transaction('settings', 'readonly');
|
||||
const req = tx.objectStore('settings').get(key);
|
||||
tx.oncomplete = () => resolve(req.result);
|
||||
tx.onabort = () => reject(tx.error);
|
||||
});
|
||||
}
|
||||
setMany(entries) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const tx = this.database.transaction('settings', 'readwrite');
|
||||
tx.oncomplete = () => resolve();
|
||||
tx.onabort = () => reject(tx.error);
|
||||
const store = tx.objectStore('settings');
|
||||
for (const [key, value] of entries) store.put(value, key);
|
||||
});
|
||||
}
|
||||
close() {
|
||||
this.database.close();
|
||||
}
|
||||
}
|
||||
9
android/.gitignore
vendored
Normal file
9
android/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
/toolchain/
|
||||
/.gradle/
|
||||
/build/
|
||||
/app/build/
|
||||
/app/src/main/assets/
|
||||
/local.properties
|
||||
/dist/
|
||||
/keys/
|
||||
/logs/
|
||||
20
android/app/build.gradle
Normal file
20
android/app/build.gradle
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
plugins { id 'com.android.application' }
|
||||
def vulpesRelease = new groovy.json.JsonSlurper().parse(rootProject.file('../release.json'))
|
||||
def productVersion = vulpesRelease.version ?: "${vulpesRelease.gaia}-${vulpesRelease.channel}.${vulpesRelease.revision}"
|
||||
android {
|
||||
namespace 'org.vulpes_os.preview'
|
||||
compileSdk { version = release(37) { minorApiLevel = 1 } }
|
||||
buildToolsVersion '37.0.0'
|
||||
defaultConfig {
|
||||
applicationId 'org.vulpes_os.preview'
|
||||
minSdk 26
|
||||
targetSdk 37
|
||||
versionCode vulpesRelease.androidVersionCode as int
|
||||
versionName productVersion
|
||||
ndk { abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86_64' }
|
||||
}
|
||||
signingConfigs { debug { storeFile rootProject.file('keys/preview.keystore'); storePassword 'android'; keyAlias 'androiddebugkey'; keyPassword 'android' } }
|
||||
compileOptions { sourceCompatibility JavaVersion.VERSION_17; targetCompatibility JavaVersion.VERSION_17 }
|
||||
packaging { jniLibs { useLegacyPackaging = false } }
|
||||
}
|
||||
dependencies { implementation "org.mozilla.geckoview:geckoview:${vulpesRelease.geckoview}" }
|
||||
30
android/app/src/main/AndroidManifest.xml
Normal file
30
android/app/src/main/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-feature android:name="android.hardware.camera.any" android:required="false" />
|
||||
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||
<application android:name=".VulpesApplication" android:label="@string/app_name"
|
||||
android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher" android:theme="@android:style/Theme.Material.Light.NoActionBar"
|
||||
android:allowBackup="false" android:supportsRtl="true" android:usesCleartextTraffic="true">
|
||||
<activity android:name=".MainActivity" android:exported="true"
|
||||
android:launchMode="singleTop"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden|smallestScreenSize|uiMode"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.HOME" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<provider android:name=".CaptureProvider" android:authorities="${applicationId}.capture"
|
||||
android:exported="false" android:grantUriPermissions="true" />
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
@ -0,0 +1,161 @@
|
|||
package org.vulpes_os.preview;
|
||||
|
||||
import android.app.*;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import java.util.HashMap;
|
||||
import org.json.*;
|
||||
import org.mozilla.geckoview.*;
|
||||
|
||||
final class AndroidNotifications implements WebNotificationDelegate {
|
||||
|
||||
private final VulpesApplication app;
|
||||
private final NotificationManager manager;
|
||||
private final HashMap<String, WebNotification> live = new HashMap<>();
|
||||
private final HashMap<String, Integer> ids = new HashMap<>();
|
||||
private int nextId = 1;
|
||||
|
||||
AndroidNotifications(VulpesApplication app) {
|
||||
this.app = app;
|
||||
manager = app.getSystemService(NotificationManager.class);
|
||||
manager.createNotificationChannel(
|
||||
new NotificationChannel("vulpes", "Vulpes OS", NotificationManager.IMPORTANCE_DEFAULT)
|
||||
);
|
||||
}
|
||||
|
||||
private String key(WebNotification n) {
|
||||
return n.origin + "|" + (n.tag == null || n.tag.isEmpty() ? System.identityHashCode(n) : n.tag);
|
||||
}
|
||||
|
||||
public void onShowNotification(WebNotification n) {
|
||||
if (!manager.areNotificationsEnabled()) {
|
||||
n.dismiss();
|
||||
return;
|
||||
}
|
||||
String key = key(n);
|
||||
int id = ids.computeIfAbsent(key, k -> nextId++);
|
||||
live.put(key, n);
|
||||
Intent open = new Intent(app, MainActivity.class)
|
||||
.setAction("org.vulpes_os.preview.NOTIFICATION")
|
||||
.putExtra("notificationKey", key)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
PendingIntent action = PendingIntent.getActivity(
|
||||
app,
|
||||
id,
|
||||
open,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE
|
||||
);
|
||||
Notification notification = new Notification.Builder(app, "vulpes")
|
||||
.setSmallIcon(android.R.drawable.ic_dialog_info)
|
||||
.setContentTitle(n.title)
|
||||
.setContentText(n.text)
|
||||
.setStyle(new Notification.BigTextStyle().bigText(n.text))
|
||||
.setContentIntent(action)
|
||||
.setAutoCancel(true)
|
||||
.setOnlyAlertOnce(true)
|
||||
.build();
|
||||
try {
|
||||
manager.notify(id, notification);
|
||||
n.show();
|
||||
} catch (SecurityException e) {
|
||||
live.remove(key);
|
||||
n.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
public void onCloseNotification(WebNotification n) {
|
||||
String key = key(n);
|
||||
Integer id = ids.remove(key);
|
||||
live.remove(key);
|
||||
if (id != null) manager.cancel(id);
|
||||
}
|
||||
|
||||
Object local(JSONObject p) throws JSONException {
|
||||
String owner = p.getString("owner"),
|
||||
operation = p.getString("operation");
|
||||
SharedPreferences store = app.getSharedPreferences("notifications", 0);
|
||||
if (operation.equals("query")) return manager.areNotificationsEnabled() ? "granted" : "denied";
|
||||
if (operation.equals("list")) {
|
||||
JSONArray rows = new JSONArray();
|
||||
for (android.service.notification.StatusBarNotification item : manager.getActiveNotifications()) {
|
||||
String raw = store.getString("local." + item.getId(), null);
|
||||
if (raw == null) continue;
|
||||
JSONObject data = new JSONObject(raw);
|
||||
if (data.optString("owner").equals(owner)) rows.put(data);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
if (operation.equals("close")) {
|
||||
int id = p.getInt("id");
|
||||
JSONObject data = new JSONObject(store.getString("local." + id, "{}"));
|
||||
if (!data.optString("owner").equals(owner)) throw new SecurityException("PERMISSION_DENIED");
|
||||
manager.cancel(id);
|
||||
store.edit().remove("local." + id).apply();
|
||||
return null;
|
||||
}
|
||||
if (!operation.equals("show")) throw new IllegalArgumentException(
|
||||
"UNKNOWN_NOTIFICATION_OPERATION"
|
||||
);
|
||||
if (!manager.areNotificationsEnabled()) throw new SecurityException("NOTIFICATIONS_DENIED");
|
||||
String tag = p.optString("tag");
|
||||
int id = 0;
|
||||
if (
|
||||
!tag.isEmpty()
|
||||
) for (android.service.notification.StatusBarNotification item : manager.getActiveNotifications()) {
|
||||
JSONObject saved = new JSONObject(store.getString("local." + item.getId(), "{}"));
|
||||
if (owner.equals(saved.optString("owner")) && tag.equals(saved.optString("tag"))) id =
|
||||
item.getId();
|
||||
}
|
||||
if (id == 0) {
|
||||
id = store.getInt("next", 10000);
|
||||
store.edit().putInt("next", id + 1).apply();
|
||||
}
|
||||
JSONObject data = new JSONObject(p.toString()).put("id", id);
|
||||
store.edit().putString("local." + id, data.toString()).apply();
|
||||
Intent open = new Intent(app, MainActivity.class)
|
||||
.setAction("org.vulpes_os.preview.LOCAL_NOTIFICATION")
|
||||
.putExtra("localNotification", id)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
PendingIntent action = PendingIntent.getActivity(
|
||||
app,
|
||||
id,
|
||||
open,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE
|
||||
);
|
||||
Notification n = new Notification.Builder(app, "vulpes")
|
||||
.setSmallIcon(android.R.drawable.ic_dialog_info)
|
||||
.setContentTitle(p.optString("title", "Vulpes OS"))
|
||||
.setContentText(p.optString("body"))
|
||||
.setStyle(new Notification.BigTextStyle().bigText(p.optString("body")))
|
||||
.setContentIntent(action)
|
||||
.setAutoCancel(true)
|
||||
.setOnlyAlertOnce(true)
|
||||
.build();
|
||||
manager.notify(id, n);
|
||||
return id;
|
||||
}
|
||||
|
||||
void click(Intent intent) {
|
||||
if (intent != null && "org.vulpes_os.preview.LOCAL_NOTIFICATION".equals(intent.getAction())) {
|
||||
int id = intent.getIntExtra("localNotification", -1);
|
||||
SharedPreferences store = app.getSharedPreferences("notifications", 0);
|
||||
String raw = store.getString("local." + id, null);
|
||||
if (raw != null && app.port != null) try {
|
||||
JSONObject data = new JSONObject(raw);
|
||||
app.port.postMessage(new JSONObject().put("type", "notification-click").put("data", data));
|
||||
store.edit().remove("local." + id).apply();
|
||||
intent.removeExtra("localNotification");
|
||||
} catch (Exception e) {
|
||||
android.util.Log.w("Vulpes", "Notification click", e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (intent == null || !"org.vulpes_os.preview.NOTIFICATION".equals(intent.getAction())) return;
|
||||
String key = intent.getStringExtra("notificationKey");
|
||||
WebNotification n = live.remove(key);
|
||||
Integer id = ids.remove(key);
|
||||
if (id != null) manager.cancel(id);
|
||||
if (n != null) n.click();
|
||||
intent.removeExtra("notificationKey");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,508 @@
|
|||
package org.vulpes_os.preview;
|
||||
|
||||
import android.app.*;
|
||||
import android.content.*;
|
||||
import android.database.Cursor;
|
||||
import android.media.AudioManager;
|
||||
import android.net.Uri;
|
||||
import android.os.*;
|
||||
import android.provider.*;
|
||||
import android.util.Base64;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import java.io.*;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import org.json.*;
|
||||
import org.mozilla.geckoview.GeckoResult;
|
||||
|
||||
/** Android operations reachable only from the bundled extension's authorized RPC. */
|
||||
final class AndroidServices {
|
||||
|
||||
static final int PICK = 410,
|
||||
CAPTURE = 411,
|
||||
CONTACT = 412;
|
||||
static final long MAX_MEDIA = 32L * 1024 * 1024;
|
||||
final VulpesApplication app;
|
||||
final ExecutorService io = Executors.newSingleThreadExecutor();
|
||||
final Handler main = new Handler(Looper.getMainLooper());
|
||||
GeckoResult<Object> pending;
|
||||
String pendingType;
|
||||
|
||||
AndroidServices(VulpesApplication app) {
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
GeckoResult<Object> request(JSONObject message) {
|
||||
String op = message.optString("type");
|
||||
GeckoResult<Object> result = new GeckoResult<>();
|
||||
try {
|
||||
JSONObject p = message.optJSONObject("params");
|
||||
if (p == null) p = new JSONObject();
|
||||
switch (op) {
|
||||
case "android.notification":
|
||||
JSONObject request = p;
|
||||
if (p.optString("operation").equals("permission")) {
|
||||
activity().notificationPermission(granted ->
|
||||
result.complete(granted ? "granted" : "denied")
|
||||
);
|
||||
} else result.complete(app.notifications.local(request));
|
||||
break;
|
||||
case "android.settings":
|
||||
openSettings(p.getString("panel"));
|
||||
result.complete(null);
|
||||
break;
|
||||
case "android.snapshot":
|
||||
result.complete(snapshot());
|
||||
break;
|
||||
case "android.set":
|
||||
set(p);
|
||||
result.complete(snapshot());
|
||||
break;
|
||||
case "android.pick":
|
||||
pick(p.getString("type"), result);
|
||||
break;
|
||||
case "android.capture":
|
||||
capture(result);
|
||||
break;
|
||||
case "android.alarms":
|
||||
activity().startActivity(new Intent(AlarmClock.ACTION_SHOW_ALARMS));
|
||||
result.complete(null);
|
||||
break;
|
||||
case "android.contact":
|
||||
if (pending != null) throw new IllegalStateException("PICKER_BUSY");
|
||||
activity().startActivityForResult(
|
||||
new Intent(Intent.ACTION_PICK, ContactsContract.CommonDataKinds.Phone.CONTENT_URI),
|
||||
CONTACT
|
||||
);
|
||||
pending = result;
|
||||
pendingType = "contact";
|
||||
break;
|
||||
case "android.sms":
|
||||
String numbers = p.optString("number"),
|
||||
text = p.optString("body");
|
||||
if (
|
||||
!numbers.matches("[+0-9*# ,;()-]{0,200}") || text.length() > 10000
|
||||
) throw new IllegalArgumentException("INVALID_MESSAGE");
|
||||
activity().startActivity(
|
||||
new Intent(Intent.ACTION_SENDTO, Uri.fromParts("smsto", numbers, null)).putExtra(
|
||||
"sms_body",
|
||||
text
|
||||
)
|
||||
);
|
||||
result.complete(null);
|
||||
break;
|
||||
case "android.dial":
|
||||
String number = p.getString("number");
|
||||
if (!number.matches("[+0-9*# ,;()-]{1,80}")) throw new IllegalArgumentException(
|
||||
"INVALID_NUMBER"
|
||||
);
|
||||
activity().startActivity(
|
||||
new Intent(Intent.ACTION_DIAL, Uri.fromParts("tel", number, null))
|
||||
);
|
||||
result.complete(null);
|
||||
break;
|
||||
case "android.media":
|
||||
JSONObject params = p;
|
||||
io.execute(() -> {
|
||||
try {
|
||||
Object value = media(params);
|
||||
main.post(() -> result.complete(value));
|
||||
} catch (Exception e) {
|
||||
fail(result, e);
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("METHOD_NOT_SUPPORTED");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
fail(result, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void fail(GeckoResult<Object> result, Exception e) {
|
||||
main.post(() -> {
|
||||
try {
|
||||
result.complete(
|
||||
new JSONObject().put(
|
||||
"error",
|
||||
e.getMessage() == null ? e.getClass().getSimpleName() : e.getMessage()
|
||||
)
|
||||
);
|
||||
} catch (JSONException ignored) {}
|
||||
});
|
||||
}
|
||||
|
||||
private MainActivity activity() {
|
||||
if (app.activity == null || app.activity.isFinishing()) throw new IllegalStateException(
|
||||
"ACTIVITY_UNAVAILABLE"
|
||||
);
|
||||
return app.activity;
|
||||
}
|
||||
|
||||
void openSettings(String panel) {
|
||||
Map<String, String> actions = new HashMap<>();
|
||||
actions.put("wifi", Settings.ACTION_WIFI_SETTINGS);
|
||||
actions.put("bluetooth", Settings.ACTION_BLUETOOTH_SETTINGS);
|
||||
actions.put("data", Settings.ACTION_WIRELESS_SETTINGS);
|
||||
actions.put("airplane-mode", Settings.ACTION_AIRPLANE_MODE_SETTINGS);
|
||||
actions.put("geolocation", Settings.ACTION_LOCATION_SOURCE_SETTINGS);
|
||||
actions.put("display", Settings.ACTION_DISPLAY_SETTINGS);
|
||||
actions.put("sound", Settings.ACTION_SOUND_SETTINGS);
|
||||
actions.put("dateTime", Settings.ACTION_DATE_SETTINGS);
|
||||
actions.put("screenLock", Settings.ACTION_SECURITY_SETTINGS);
|
||||
actions.put("battery", Settings.ACTION_BATTERY_SAVER_SETTINGS);
|
||||
actions.put("home", Settings.ACTION_HOME_SETTINGS);
|
||||
actions.put("storage", Settings.ACTION_INTERNAL_STORAGE_SETTINGS);
|
||||
actions.put("notifications", Settings.ACTION_APP_NOTIFICATION_SETTINGS);
|
||||
actions.put("apps", Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
actions.put("root", Settings.ACTION_SETTINGS);
|
||||
if (!actions.containsKey(panel)) throw new IllegalArgumentException("UNKNOWN_PANEL");
|
||||
Intent intent = new Intent(actions.get(panel));
|
||||
if (panel.equals("notifications")) intent.putExtra(
|
||||
Settings.EXTRA_APP_PACKAGE,
|
||||
app.getPackageName()
|
||||
);
|
||||
if (panel.equals("apps")) intent.setData(Uri.parse("package:" + app.getPackageName()));
|
||||
activity().startActivity(intent);
|
||||
}
|
||||
|
||||
JSONObject snapshot() throws Exception {
|
||||
AudioManager audio = app.getSystemService(AudioManager.class);
|
||||
JSONObject data = new JSONObject();
|
||||
Intent battery = app.registerReceiver(null, new android.content.IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||
if (battery != null) {
|
||||
int level = battery.getIntExtra(android.os.BatteryManager.EXTRA_LEVEL, -1);
|
||||
int scale = battery.getIntExtra(android.os.BatteryManager.EXTRA_SCALE, -1);
|
||||
int status = battery.getIntExtra(android.os.BatteryManager.EXTRA_STATUS, -1);
|
||||
if (level >= 0 && scale > 0) data.put("battery", new JSONObject()
|
||||
.put("level", (double) level / scale)
|
||||
.put("charging", status == android.os.BatteryManager.BATTERY_STATUS_CHARGING ||
|
||||
status == android.os.BatteryManager.BATTERY_STATUS_FULL));
|
||||
}
|
||||
|
||||
data.put(
|
||||
"screen.brightness",
|
||||
app
|
||||
.getSharedPreferences("android", 0)
|
||||
.getFloat(
|
||||
"brightness",
|
||||
Settings.System.getInt(app.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, 128) /
|
||||
255f
|
||||
)
|
||||
);
|
||||
data.put(
|
||||
"audio.volume.content",
|
||||
Math.round(
|
||||
(15f * audio.getStreamVolume(AudioManager.STREAM_MUSIC)) /
|
||||
audio.getStreamMaxVolume(AudioManager.STREAM_MUSIC)
|
||||
)
|
||||
);
|
||||
data.put("audio.volume.content.max", audio.getStreamMaxVolume(AudioManager.STREAM_MUSIC));
|
||||
data.put(
|
||||
"airplaneMode.enabled",
|
||||
Settings.Global.getInt(app.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0) != 0
|
||||
);
|
||||
data.put(
|
||||
"geolocation.enabled",
|
||||
app
|
||||
.getSystemService(android.location.LocationManager.class)
|
||||
.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER)
|
||||
);
|
||||
data.put("wifi.enabled", Settings.Global.getInt(app.getContentResolver(), "wifi_on", 0) != 0);
|
||||
data.put(
|
||||
"bluetooth.enabled",
|
||||
Settings.Global.getInt(app.getContentResolver(), "bluetooth_on", 0) != 0
|
||||
);
|
||||
data.put("deviceinfo.product_model", Build.MANUFACTURER + " " + Build.MODEL);
|
||||
data.put("deviceinfo.hardware", Build.HARDWARE);
|
||||
data.put("deviceinfo.firmware_revision", "Android " + Build.VERSION.RELEASE);
|
||||
data.put("deviceinfo.software", "Vulpes OS " + app.getPackageManager().getPackageInfo(app.getPackageName(), 0).versionName);
|
||||
data.put(
|
||||
"android.notifications.enabled",
|
||||
app.getSystemService(NotificationManager.class).areNotificationsEnabled()
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
void set(JSONObject p) throws JSONException {
|
||||
String key = p.getString("key");
|
||||
if (key.equals("screen.brightness")) {
|
||||
float value = (float) p.getDouble("value");
|
||||
if (!Float.isFinite(value) || value < 0 || value > 1) throw new IllegalArgumentException(
|
||||
"INVALID_VALUE"
|
||||
);
|
||||
android.view.WindowManager.LayoutParams attrs = activity().getWindow().getAttributes();
|
||||
attrs.screenBrightness = Math.max(.02f, value);
|
||||
activity().getWindow().setAttributes(attrs);
|
||||
app.getSharedPreferences("android", 0).edit().putFloat("brightness", value).apply();
|
||||
} else if (key.equals("audio.volume.content")) {
|
||||
AudioManager audio = app.getSystemService(AudioManager.class);
|
||||
int value = p.getInt("value");
|
||||
if (value < 0 || value > 15) throw new IllegalArgumentException("INVALID_VALUE");
|
||||
audio.setStreamVolume(
|
||||
AudioManager.STREAM_MUSIC,
|
||||
Math.round((value * audio.getStreamMaxVolume(AudioManager.STREAM_MUSIC)) / 15f),
|
||||
0
|
||||
);
|
||||
} else throw new IllegalArgumentException("SETTING_REQUIRES_ANDROID_PANEL");
|
||||
}
|
||||
|
||||
void pick(String type, GeckoResult<Object> result) {
|
||||
checkType(type);
|
||||
if (pending != null) throw new IllegalStateException("PICKER_BUSY");
|
||||
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT)
|
||||
.addCategory(Intent.CATEGORY_OPENABLE)
|
||||
.setType(prefix(type) + "*")
|
||||
.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
|
||||
activity().startActivityForResult(intent, PICK);
|
||||
pending = result;
|
||||
pendingType = type;
|
||||
app
|
||||
.getSharedPreferences("pending-media", 0)
|
||||
.edit()
|
||||
.putString("type", type)
|
||||
.putInt("code", PICK)
|
||||
.commit();
|
||||
}
|
||||
|
||||
void capture(GeckoResult<Object> result) throws IOException {
|
||||
if (pending != null) throw new IllegalStateException("PICKER_BUSY");
|
||||
Files.deleteIfExists(new File(app.getCacheDir(), "capture.jpg").toPath());
|
||||
Uri uri = Uri.parse("content://" + app.getPackageName() + ".capture/capture.jpg");
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE)
|
||||
.putExtra(MediaStore.EXTRA_OUTPUT, uri)
|
||||
.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
intent.setClipData(ClipData.newRawUri("Vulpes photo", uri));
|
||||
activity().startActivityForResult(intent, CAPTURE);
|
||||
pending = result;
|
||||
pendingType = "pictures";
|
||||
app
|
||||
.getSharedPreferences("pending-media", 0)
|
||||
.edit()
|
||||
.putString("type", "pictures")
|
||||
.putInt("code", CAPTURE)
|
||||
.commit();
|
||||
}
|
||||
|
||||
void onResult(int code, int status, Intent intent) {
|
||||
if (code == CONTACT) {
|
||||
GeckoResult<Object> result = pending;
|
||||
pending = null;
|
||||
pendingType = null;
|
||||
if (result == null) return;
|
||||
if (status != Activity.RESULT_OK || intent == null || intent.getData() == null) {
|
||||
fail(result, new IOException("AbortError"));
|
||||
return;
|
||||
}
|
||||
Uri uri = intent.getData();
|
||||
io.execute(() -> {
|
||||
try (
|
||||
Cursor c = app
|
||||
.getContentResolver()
|
||||
.query(
|
||||
uri,
|
||||
new String[] {
|
||||
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
|
||||
ContactsContract.CommonDataKinds.Phone.NUMBER,
|
||||
},
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)
|
||||
) {
|
||||
if (c == null || !c.moveToFirst()) throw new IOException("NotFoundError");
|
||||
JSONObject contact = new JSONObject()
|
||||
.put("name", new JSONArray().put(c.getString(0)))
|
||||
.put("givenName", new JSONArray().put(c.getString(0)))
|
||||
.put(
|
||||
"tel",
|
||||
new JSONArray().put(
|
||||
new JSONObject()
|
||||
.put("value", c.getString(1))
|
||||
.put("type", new JSONArray().put("mobile"))
|
||||
)
|
||||
);
|
||||
main.post(() -> result.complete(contact));
|
||||
} catch (Exception e) {
|
||||
fail(result, e);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (code != PICK && code != CAPTURE) return;
|
||||
SharedPreferences saved = app.getSharedPreferences("pending-media", 0);
|
||||
if (pending == null && saved.getInt("code", 0) != code) return;
|
||||
GeckoResult<Object> result = pending == null ? new GeckoResult<>() : pending;
|
||||
String type = pendingType == null ? saved.getString("type", "pictures") : pendingType;
|
||||
pending = null;
|
||||
pendingType = null;
|
||||
saved.edit().clear().commit();
|
||||
if (status != Activity.RESULT_OK) {
|
||||
fail(result, new IOException("AbortError"));
|
||||
return;
|
||||
}
|
||||
ArrayList<Uri> uris = new ArrayList<>();
|
||||
if (code == CAPTURE) uris.add(Uri.fromFile(new File(app.getCacheDir(), "capture.jpg")));
|
||||
else if (intent != null && intent.getClipData() != null) {
|
||||
for (int i = 0; i < intent.getClipData().getItemCount(); i++) uris.add(
|
||||
intent.getClipData().getItemAt(i).getUri()
|
||||
);
|
||||
} else if (intent != null && intent.getData() != null) uris.add(intent.getData());
|
||||
io.execute(() -> {
|
||||
try {
|
||||
JSONArray names = new JSONArray();
|
||||
for (Uri uri : uris) {
|
||||
String mime = code == CAPTURE ? "image/jpeg" : app.getContentResolver().getType(uri);
|
||||
String name = code == CAPTURE
|
||||
? "Photo-" + System.currentTimeMillis() + ".jpg"
|
||||
: displayName(uri);
|
||||
if (mime == null) mime = mime(name);
|
||||
if (!mime.startsWith(prefix(type))) throw new IOException("TypeMismatchError");
|
||||
name = UUID.randomUUID() + "-" + name.replaceAll("[^a-zA-Z0-9._-]", "_");
|
||||
File target = path(type, name);
|
||||
try (
|
||||
InputStream in = code == CAPTURE
|
||||
? new FileInputStream(new File(uri.getPath()))
|
||||
: app.getContentResolver().openInputStream(uri)
|
||||
) {
|
||||
copy(in, target);
|
||||
}
|
||||
names.put("/sdcard/" + name);
|
||||
}
|
||||
main.post(() -> result.complete(names));
|
||||
} catch (Exception e) {
|
||||
fail(result, e);
|
||||
} finally {
|
||||
if (code == CAPTURE) new File(app.getCacheDir(), "capture.jpg").delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String displayName(Uri uri) {
|
||||
try (
|
||||
Cursor c = app
|
||||
.getContentResolver()
|
||||
.query(uri, new String[] { OpenableColumns.DISPLAY_NAME }, null, null, null)
|
||||
) {
|
||||
if (c != null && c.moveToFirst()) return c.getString(0);
|
||||
} catch (Exception ignored) {}
|
||||
return "media";
|
||||
}
|
||||
|
||||
static void checkType(String type) {
|
||||
if (
|
||||
!Arrays.asList("pictures", "videos", "music").contains(type)
|
||||
) throw new IllegalArgumentException("INVALID_MEDIA_TYPE");
|
||||
}
|
||||
|
||||
static String prefix(String type) {
|
||||
checkType(type);
|
||||
return type.equals("pictures") ? "image/" : type.equals("videos") ? "video/" : "audio/";
|
||||
}
|
||||
|
||||
static String mime(String name) {
|
||||
String ext = name.substring(name.lastIndexOf('.') + 1).toLowerCase(Locale.ROOT);
|
||||
String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext);
|
||||
return type == null ? "application/octet-stream" : type;
|
||||
}
|
||||
|
||||
File path(String type, String name) throws IOException {
|
||||
checkType(type);
|
||||
if (name.startsWith("/sdcard/")) name = name.substring(8);
|
||||
File root = new File(app.getFilesDir(), "media/" + type);
|
||||
root.mkdirs();
|
||||
File file = new File(root, name);
|
||||
if (
|
||||
!file.getCanonicalPath().startsWith(root.getCanonicalPath() + "/") ||
|
||||
name.contains("..") ||
|
||||
name.startsWith("/")
|
||||
) throw new IOException("SecurityError");
|
||||
return file;
|
||||
}
|
||||
|
||||
void copy(InputStream in, File file) throws IOException {
|
||||
if (in == null) throw new IOException("NotFoundError");
|
||||
file.getParentFile().mkdirs();
|
||||
File temp = new File(file.getPath() + ".tmp");
|
||||
try (OutputStream out = new FileOutputStream(temp)) {
|
||||
byte[] buf = new byte[32768];
|
||||
int n;
|
||||
long total = 0;
|
||||
while ((n = in.read(buf)) != -1) {
|
||||
total += n;
|
||||
if (total > MAX_MEDIA) throw new IOException("MEDIA_TOO_LARGE_32_MIB");
|
||||
out.write(buf, 0, n);
|
||||
}
|
||||
Files.move(temp.toPath(), file.toPath());
|
||||
} finally {
|
||||
temp.delete();
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject info(File root, File f) throws JSONException {
|
||||
return new JSONObject()
|
||||
.put("name", "/sdcard/" + root.toPath().relativize(f.toPath()).toString())
|
||||
.put("size", f.length())
|
||||
.put("lastModified", f.lastModified())
|
||||
.put("type", mime(f.getName()));
|
||||
}
|
||||
|
||||
Object media(JSONObject p) throws Exception {
|
||||
String type = p.getString("type"),
|
||||
op = p.getString("operation");
|
||||
checkType(type);
|
||||
File root = path(type, "dummy").getParentFile();
|
||||
if (op.equals("available")) return "available";
|
||||
if (op.equals("freeSpace")) return root.getUsableSpace();
|
||||
if (op.equals("enumerate") || op.equals("usedSpace")) {
|
||||
JSONArray rows = new JSONArray();
|
||||
long used = 0;
|
||||
try (java.util.stream.Stream<Path> paths = Files.walk(root.toPath())) {
|
||||
for (Path path : (Iterable<Path>) paths.filter(Files::isRegularFile)::iterator) {
|
||||
File f = path.toFile();
|
||||
if (f.getName().endsWith(".tmp")) continue;
|
||||
used += f.length();
|
||||
String name = root.toPath().relativize(path).toString();
|
||||
if (
|
||||
name.startsWith(p.optString("name", "").replaceFirst("^/sdcard/", "")) &&
|
||||
f.lastModified() >= p.optLong("since", 0)
|
||||
) rows.put(info(root, f));
|
||||
}
|
||||
}
|
||||
return op.equals("usedSpace") ? used : rows;
|
||||
}
|
||||
File f = path(type, p.getString("name"));
|
||||
if (op.equals("get")) {
|
||||
if (!f.isFile()) throw new IOException("NotFoundError");
|
||||
if (f.length() > MAX_MEDIA) throw new IOException("MEDIA_TOO_LARGE_32_MIB");
|
||||
return info(root, f).put(
|
||||
"blob",
|
||||
new JSONObject()
|
||||
.put("__vulpesBlobV1", true)
|
||||
.put("type", mime(f.getName()))
|
||||
.put("base64", Base64.encodeToString(Files.readAllBytes(f.toPath()), Base64.NO_WRAP))
|
||||
);
|
||||
}
|
||||
if (op.equals("delete")) {
|
||||
if (!f.isFile() || !f.delete()) throw new IOException("NotFoundError");
|
||||
return "/sdcard/" + root.toPath().relativize(f.toPath());
|
||||
}
|
||||
if (op.equals("add")) {
|
||||
JSONObject blob = p.getJSONObject("blob");
|
||||
if (
|
||||
!blob.optBoolean("__vulpesBlobV1") || !blob.getString("type").startsWith(prefix(type))
|
||||
) throw new IOException("TypeMismatchError");
|
||||
if (f.exists()) throw new IOException("NoModificationAllowedError");
|
||||
String encoded = blob.getString("base64");
|
||||
if (encoded.length() > (MAX_MEDIA * 4) / 3 + 4) throw new IOException(
|
||||
"MEDIA_TOO_LARGE_32_MIB"
|
||||
);
|
||||
copy(new ByteArrayInputStream(Base64.decode(encoded, Base64.DEFAULT)), f);
|
||||
return "/sdcard/" + root.toPath().relativize(f.toPath());
|
||||
}
|
||||
throw new IllegalArgumentException("NotSupportedError");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
package org.vulpes_os.preview;
|
||||
|
||||
import android.content.*;
|
||||
import android.database.Cursor;
|
||||
import android.database.MatrixCursor;
|
||||
import android.net.Uri;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.provider.OpenableColumns;
|
||||
import java.io.*;
|
||||
|
||||
/** Grants the selected camera access to one temporary output, never the profile. */
|
||||
public final class CaptureProvider extends ContentProvider {
|
||||
|
||||
public boolean onCreate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private File file(Uri uri) throws FileNotFoundException {
|
||||
if (!"/capture.jpg".equals(uri.getPath())) throw new FileNotFoundException();
|
||||
return new File(getContext().getCacheDir(), "capture.jpg");
|
||||
}
|
||||
|
||||
public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
|
||||
return ParcelFileDescriptor.open(file(uri), ParcelFileDescriptor.parseMode(mode));
|
||||
}
|
||||
|
||||
public String getType(Uri uri) {
|
||||
return "image/jpeg";
|
||||
}
|
||||
|
||||
public Cursor query(Uri uri, String[] columns, String selection, String[] args, String order) {
|
||||
try {
|
||||
File f = file(uri);
|
||||
if (columns == null) columns = new String[] {
|
||||
OpenableColumns.DISPLAY_NAME,
|
||||
OpenableColumns.SIZE,
|
||||
};
|
||||
MatrixCursor cursor = new MatrixCursor(columns);
|
||||
Object[] row = new Object[columns.length];
|
||||
for (int i = 0; i < columns.length; i++) row[i] = OpenableColumns.SIZE.equals(columns[i])
|
||||
? f.length()
|
||||
: f.getName();
|
||||
cursor.addRow(row);
|
||||
return cursor;
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Uri insert(Uri uri, ContentValues values) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public int delete(Uri uri, String selection, String[] args) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public int update(Uri uri, ContentValues values, String selection, String[] args) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
161
android/app/src/main/java/org/vulpes_os/preview/GaiaServer.java
Normal file
161
android/app/src/main/java/org/vulpes_os/preview/GaiaServer.java
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
package org.vulpes_os.preview;
|
||||
|
||||
import android.content.Context;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.zip.*;
|
||||
|
||||
/** Read-only APK assets, loopback only. Never serves profile data or native RPC. */
|
||||
final class GaiaServer implements Closeable {
|
||||
|
||||
static final int PORT = 18765;
|
||||
private final ZipFile zip;
|
||||
private final ServerSocket socket;
|
||||
private final ExecutorService workers = Executors.newFixedThreadPool(4);
|
||||
|
||||
GaiaServer(Context context) throws IOException {
|
||||
File archive = new File(context.getCacheDir(), "gaia.zip");
|
||||
// Atomic refresh on every process start; the APK is the source of truth.
|
||||
File temp = new File(context.getCacheDir(), "gaia.zip.tmp");
|
||||
try (
|
||||
InputStream in = context.getAssets().open("gaia.zip");
|
||||
OutputStream out = new FileOutputStream(temp)
|
||||
) {
|
||||
copy(in, out);
|
||||
}
|
||||
Files.move(temp.toPath(), archive.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
zip = new ZipFile(archive);
|
||||
socket = new ServerSocket();
|
||||
socket.setReuseAddress(true);
|
||||
socket.bind(new InetSocketAddress(InetAddress.getByName("127.0.0.1"), PORT));
|
||||
Thread accept = new Thread(
|
||||
() -> {
|
||||
while (!socket.isClosed()) try {
|
||||
Socket client = socket.accept();
|
||||
workers.submit(() -> serve(client));
|
||||
} catch (IOException e) {
|
||||
if (!socket.isClosed()) android.util.Log.e("Vulpes", "HTTP accept", e);
|
||||
}
|
||||
},
|
||||
"Vulpes-assets"
|
||||
);
|
||||
accept.setDaemon(true);
|
||||
accept.start();
|
||||
}
|
||||
|
||||
private static void copy(InputStream in, OutputStream out) throws IOException {
|
||||
byte[] buf = new byte[32768];
|
||||
int n;
|
||||
while ((n = in.read(buf)) != -1) out.write(buf, 0, n);
|
||||
}
|
||||
|
||||
private static String line(InputStream in) throws IOException {
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
int c;
|
||||
while ((c = in.read()) != -1 && c != '\n') {
|
||||
if (b.size() > 8192) throw new IOException("Header too long");
|
||||
if (c != '\r') b.write(c);
|
||||
}
|
||||
return b.toString("UTF-8");
|
||||
}
|
||||
|
||||
private void serve(Socket client) {
|
||||
try (Socket c = client) {
|
||||
c.setSoTimeout(5000);
|
||||
InputStream in = c.getInputStream();
|
||||
OutputStream out = c.getOutputStream();
|
||||
String[] start = line(in).split(" ");
|
||||
String host = "",
|
||||
origin = "";
|
||||
int total = 0;
|
||||
for (String h; (h = line(in)).length() > 0; ) {
|
||||
total += h.length();
|
||||
if (total > 32768) throw new IOException("Headers too large");
|
||||
int i = h.indexOf(':');
|
||||
if (i > 0) {
|
||||
String key = h.substring(0, i);
|
||||
String value = h.substring(i + 1).trim();
|
||||
if (key.equalsIgnoreCase("Host")) host = value.toLowerCase(Locale.ROOT);
|
||||
if (key.equalsIgnoreCase("Origin")) origin = value;
|
||||
}
|
||||
}
|
||||
if (
|
||||
start.length < 2 ||
|
||||
!start[0].equals("GET") ||
|
||||
!host.matches("[a-z0-9_-]+\\.localhost:" + PORT)
|
||||
) {
|
||||
error(out, 403);
|
||||
return;
|
||||
}
|
||||
String app = host.substring(0, host.indexOf('.'));
|
||||
if (app.equals("theme")) app = "default_theme";
|
||||
if (zip.getEntry(app + "/manifest.webapp") == null) {
|
||||
error(out, 404);
|
||||
return;
|
||||
}
|
||||
String path = URLDecoder.decode(start[1].split("\\?", 2)[0].replace("+", "%2B"), "UTF-8");
|
||||
if (
|
||||
!path.startsWith("/") ||
|
||||
path.contains("\\") ||
|
||||
path.indexOf('\0') >= 0 ||
|
||||
Arrays.asList(path.split("/")).contains("..")
|
||||
) {
|
||||
error(out, 400);
|
||||
return;
|
||||
}
|
||||
if (path.endsWith("/")) path += "index.html";
|
||||
String key = path.startsWith("/_vulpes/") ? path.substring(1) : app + path;
|
||||
ZipEntry entry = zip.getEntry(key);
|
||||
if (entry == null && path.startsWith("/shared/")) entry = zip.getEntry(
|
||||
"_shared/" + path.substring(8)
|
||||
);
|
||||
if (entry == null || entry.isDirectory()) {
|
||||
error(out, 404);
|
||||
return;
|
||||
}
|
||||
String ext = path.substring(path.lastIndexOf('.') + 1).toLowerCase(Locale.ROOT);
|
||||
String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext);
|
||||
if (ext.equals("js") || ext.equals("mjs")) mime = "text/javascript";
|
||||
if (ext.equals("webapp") || ext.equals("json")) mime = "application/json";
|
||||
if (ext.equals("properties")) mime = "text/plain";
|
||||
if (mime == null) mime = "application/octet-stream";
|
||||
String headers =
|
||||
"HTTP/1.1 200 OK\r\nContent-Type: " +
|
||||
mime +
|
||||
"\r\nContent-Length: " +
|
||||
entry.getSize() +
|
||||
"\r\nConnection: close\r\nX-Content-Type-Options: nosniff\r\nCache-Control: no-cache\r\nContent-Security-Policy: script-src 'self' 'unsafe-eval'; object-src 'none'; base-uri 'self'; worker-src 'self' blob:; frame-ancestors http://*.localhost:" +
|
||||
PORT +
|
||||
"\r\n";
|
||||
if (
|
||||
origin.matches("http://[a-z0-9_-]+\\.localhost:" + PORT) &&
|
||||
zip.getEntry(new URI(origin).getHost().split("\\.")[0] + "/manifest.webapp") != null
|
||||
) headers += "Access-Control-Allow-Origin: " + origin + "\r\nVary: Origin\r\n";
|
||||
out.write((headers + "\r\n").getBytes(StandardCharsets.US_ASCII));
|
||||
try (InputStream body = zip.getInputStream(entry)) {
|
||||
copy(body, out);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
android.util.Log.d("Vulpes", "HTTP closed: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static void error(OutputStream out, int code) throws IOException {
|
||||
out.write(
|
||||
("HTTP/1.1 " + code + " Error\r\nContent-Length: 0\r\nConnection: close\r\n\r\n").getBytes(
|
||||
StandardCharsets.US_ASCII
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
socket.close();
|
||||
workers.shutdownNow();
|
||||
zip.close();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,647 @@
|
|||
package org.vulpes_os.preview;
|
||||
|
||||
import android.app.*;
|
||||
import android.content.*;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.*;
|
||||
import android.text.InputType;
|
||||
import android.view.*;
|
||||
import android.widget.*;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import org.mozilla.geckoview.*;
|
||||
|
||||
public final class MainActivity extends Activity {
|
||||
|
||||
private VulpesApplication app;
|
||||
private GeckoSession gaia, web;
|
||||
private GeckoView gaiaView, webView;
|
||||
private LinearLayout root, webPanel;
|
||||
private TextView notice;
|
||||
private EditText address;
|
||||
private Button home;
|
||||
private boolean webBack;
|
||||
private boolean resumed, recoverGaia, recoverWeb;
|
||||
private long lastCrash;
|
||||
private int crashCount;
|
||||
private final java.util.Map<Integer, java.util.function.Consumer<Boolean>> permissionResults =
|
||||
new java.util.HashMap<>();
|
||||
private final java.util.List<java.util.function.Consumer<Boolean>> resumedCameraPermissions =
|
||||
new java.util.ArrayList<>();
|
||||
private int nextPermission = 500;
|
||||
private GeckoResult<GeckoSession.PromptDelegate.PromptResponse> fileResult;
|
||||
private GeckoSession.PromptDelegate.FilePrompt filePrompt;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
super.onCreate(state);
|
||||
app = (VulpesApplication) getApplication();
|
||||
app.activity = this;
|
||||
root = new LinearLayout(this);
|
||||
root.setOrientation(LinearLayout.VERTICAL);
|
||||
root.setBackgroundColor(Color.rgb(18, 35, 50));
|
||||
root.setOnApplyWindowInsetsListener((v, insets) -> {
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
android.graphics.Insets bars = insets.getInsets(
|
||||
WindowInsets.Type.systemBars() |
|
||||
WindowInsets.Type.ime() |
|
||||
WindowInsets.Type.displayCutout()
|
||||
);
|
||||
v.setPadding(bars.left, bars.top, bars.right, bars.bottom);
|
||||
} else v.setPadding(
|
||||
insets.getSystemWindowInsetLeft(),
|
||||
insets.getSystemWindowInsetTop(),
|
||||
insets.getSystemWindowInsetRight(),
|
||||
insets.getSystemWindowInsetBottom()
|
||||
);
|
||||
return insets;
|
||||
});
|
||||
setContentView(root);
|
||||
// Respect Android's screen timeout; Gaia must not keep the phone awake indefinitely.
|
||||
float brightness = app.getSharedPreferences("android", 0).getFloat("brightness", -1);
|
||||
if (brightness >= 0) {
|
||||
WindowManager.LayoutParams attrs = getWindow().getAttributes();
|
||||
attrs.screenBrightness = Math.max(.02f, brightness);
|
||||
getWindow().setAttributes(attrs);
|
||||
}
|
||||
notice = new TextView(this);
|
||||
notice.setText("VULPES\nChargement de Firefox OS…");
|
||||
notice.setTextColor(Color.WHITE);
|
||||
notice.setGravity(Gravity.CENTER);
|
||||
root.addView(notice, new LinearLayout.LayoutParams(-1, dp(90)));
|
||||
gaiaView = new GeckoView(this);
|
||||
root.addView(gaiaView, new LinearLayout.LayoutParams(-1, 0, 1));
|
||||
webPanel = new LinearLayout(this);
|
||||
webPanel.setOrientation(LinearLayout.VERTICAL);
|
||||
webPanel.setBackgroundColor(Color.WHITE);
|
||||
webPanel.setVisibility(View.GONE);
|
||||
root.addView(webPanel, new LinearLayout.LayoutParams(-1, 0, 1));
|
||||
LinearLayout nav = new LinearLayout(this);
|
||||
webPanel.addView(nav, new LinearLayout.LayoutParams(-1, dp(52)));
|
||||
Button back = new Button(this);
|
||||
back.setText("‹");
|
||||
back.setContentDescription("Retour au bureau");
|
||||
back.setOnClickListener(v -> closeBrowser());
|
||||
nav.addView(back, new LinearLayout.LayoutParams(dp(55), -1));
|
||||
address = new EditText(this);
|
||||
address.setSingleLine(true);
|
||||
address.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
|
||||
address.setTextSize(14);
|
||||
nav.addView(address, new LinearLayout.LayoutParams(0, -1, 1));
|
||||
address.setOnEditorActionListener((v, id, event) -> {
|
||||
String url = address.getText().toString().trim();
|
||||
openBrowser(url.contains("://") ? url : "https://" + url);
|
||||
((android.view.inputmethod.InputMethodManager) getSystemService(
|
||||
INPUT_METHOD_SERVICE
|
||||
)).hideSoftInputFromWindow(address.getWindowToken(), 0);
|
||||
return true;
|
||||
});
|
||||
webView = new GeckoView(this);
|
||||
webPanel.addView(webView, new LinearLayout.LayoutParams(-1, 0, 1));
|
||||
home = new Button(this);
|
||||
home.setText("◯");
|
||||
home.setTextColor(Color.WHITE);
|
||||
home.setBackgroundColor(Color.rgb(18, 35, 50));
|
||||
home.setContentDescription("Accueil Vulpes. Appui long : applications ouvertes.");
|
||||
root.addView(home, new LinearLayout.LayoutParams(-1, dp(44)));
|
||||
home.setOnClickListener(v -> {
|
||||
closeBrowser();
|
||||
app.home(false);
|
||||
});
|
||||
home.setOnLongClickListener(v -> {
|
||||
closeBrowser();
|
||||
app.home(true);
|
||||
return true;
|
||||
});
|
||||
setHomeSurface(app.homeVisible);
|
||||
if (Build.VERSION.SDK_INT >= 33) getOnBackInvokedDispatcher().registerOnBackInvokedCallback(
|
||||
0,
|
||||
this::back
|
||||
);
|
||||
try {
|
||||
app.prepare();
|
||||
boolean retained = app.gaiaSession != null;
|
||||
gaia = retained
|
||||
? app.gaiaSession
|
||||
: new GeckoSession(
|
||||
new GeckoSessionSettings.Builder()
|
||||
.displayMode(GeckoSessionSettings.DISPLAY_MODE_STANDALONE)
|
||||
.build()
|
||||
);
|
||||
app.gaiaSession = gaia;
|
||||
gaia.setContentDelegate(content);
|
||||
gaia.setPromptDelegate(prompts);
|
||||
gaia.setPermissionDelegate(permissions);
|
||||
gaia.setNavigationDelegate(
|
||||
new GeckoSession.NavigationDelegate() {
|
||||
@Override
|
||||
public GeckoResult<AllowOrDeny> onLoadRequest(GeckoSession s, LoadRequest r) {
|
||||
if (r.uri.startsWith("http://") && isGaia(r.uri)) return GeckoResult.fromValue(
|
||||
AllowOrDeny.ALLOW
|
||||
);
|
||||
if (r.uri.equals("about:blank")) return GeckoResult.fromValue(AllowOrDeny.ALLOW);
|
||||
openBrowser(r.uri);
|
||||
return GeckoResult.fromValue(AllowOrDeny.DENY);
|
||||
}
|
||||
}
|
||||
);
|
||||
if (!gaia.isOpen()) gaia.open(app.runtime);
|
||||
gaiaView.setSession(gaia);
|
||||
app.extension.accept(
|
||||
ext -> {
|
||||
notice.setVisibility(View.GONE);
|
||||
if (isDestroyed()) return;
|
||||
if (!retained) gaia.loadUri(gaiaUrl());
|
||||
app.notifications.click(getIntent());
|
||||
},
|
||||
e -> {
|
||||
notice.setText("Impossible de démarrer Vulpes : " + e.getMessage());
|
||||
}
|
||||
);
|
||||
} catch (Exception e) {
|
||||
notice.setText("Impossible de démarrer Vulpes : " + e.getMessage());
|
||||
android.util.Log.e("Vulpes", "Startup", e);
|
||||
}
|
||||
}
|
||||
|
||||
private int dp(int value) {
|
||||
return Math.round(value * getResources().getDisplayMetrics().density);
|
||||
}
|
||||
|
||||
private boolean isGaia(String url) {
|
||||
try {
|
||||
URI u = new URI(url);
|
||||
return (
|
||||
u.getHost() != null && u.getHost().endsWith(".localhost") && u.getPort() == GaiaServer.PORT
|
||||
);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void openBrowser(String url) {
|
||||
try {
|
||||
URI uri = new URI(url);
|
||||
if (
|
||||
!("https".equals(uri.getScheme()) || "http".equals(uri.getScheme())) || isGaia(url)
|
||||
) return;
|
||||
} catch (Exception e) {
|
||||
return;
|
||||
}
|
||||
if (web == null) {
|
||||
web = new GeckoSession();
|
||||
web.setContentDelegate(content);
|
||||
web.setPromptDelegate(prompts);
|
||||
web.setPermissionDelegate(permissions);
|
||||
web.setNavigationDelegate(
|
||||
new GeckoSession.NavigationDelegate() {
|
||||
@Override
|
||||
public void onCanGoBack(GeckoSession s, boolean can) {
|
||||
webBack = can;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChange(
|
||||
GeckoSession s,
|
||||
String url,
|
||||
java.util.List<GeckoSession.PermissionDelegate.ContentPermission> permissions,
|
||||
Boolean gesture
|
||||
) {
|
||||
address.setText(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoResult<AllowOrDeny> onLoadRequest(GeckoSession s, LoadRequest r) {
|
||||
return GeckoResult.fromValue(
|
||||
(r.uri.startsWith("https://") || r.uri.startsWith("http://")) && !isGaia(r.uri)
|
||||
? AllowOrDeny.ALLOW
|
||||
: AllowOrDeny.DENY
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoResult<GeckoSession> onNewSession(GeckoSession s, String uri) {
|
||||
openBrowser(uri);
|
||||
return GeckoResult.fromValue(null);
|
||||
}
|
||||
}
|
||||
);
|
||||
web.open(app.runtime);
|
||||
webView.setSession(web);
|
||||
}
|
||||
gaiaView.setVisibility(View.GONE);
|
||||
webPanel.setVisibility(View.VISIBLE);
|
||||
setHomeSurface(false);
|
||||
address.setText(url);
|
||||
web.loadUri(url);
|
||||
syncActive();
|
||||
}
|
||||
|
||||
void setHomeSurface(boolean visible) {
|
||||
runOnUiThread(() -> {
|
||||
boolean overlay = visible && webPanel.getVisibility() != View.VISIBLE;
|
||||
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) home.getLayoutParams();
|
||||
boolean landscape = getResources().getConfiguration().orientation ==
|
||||
android.content.res.Configuration.ORIENTATION_LANDSCAPE;
|
||||
root.setOrientation(landscape ? LinearLayout.HORIZONTAL : LinearLayout.VERTICAL);
|
||||
gaiaView.setLayoutParams(landscape ? new LinearLayout.LayoutParams(0, -1, 1) :
|
||||
new LinearLayout.LayoutParams(-1, 0, 1));
|
||||
webPanel.setLayoutParams(landscape ? new LinearLayout.LayoutParams(0, -1, 1) :
|
||||
new LinearLayout.LayoutParams(-1, 0, 1));
|
||||
params.width = landscape ? dp(44) : -1;
|
||||
params.height = landscape ? -1 : dp(44);
|
||||
// Only Home overlays Gaia wallpaper. Apps keep their full usable area.
|
||||
params.topMargin = !landscape && overlay ? -dp(44) : 0;
|
||||
params.leftMargin = landscape && overlay ? -dp(44) : 0;
|
||||
home.setLayoutParams(params);
|
||||
if (overlay && app.homeAtBottom) home.setBackgroundColor(Color.TRANSPARENT);
|
||||
else if (overlay) home.setBackground(
|
||||
new android.graphics.drawable.GradientDrawable(
|
||||
landscape ? android.graphics.drawable.GradientDrawable.Orientation.RIGHT_LEFT :
|
||||
android.graphics.drawable.GradientDrawable.Orientation.BOTTOM_TOP,
|
||||
new int[] { Color.argb(204, 0, 0, 0), Color.TRANSPARENT }
|
||||
)
|
||||
);
|
||||
else home.setBackgroundColor(Color.rgb(18, 35, 50));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(android.content.res.Configuration config) {
|
||||
super.onConfigurationChanged(config);
|
||||
setHomeSurface(app.homeVisible);
|
||||
}
|
||||
|
||||
private void closeBrowser() {
|
||||
webPanel.setVisibility(View.GONE);
|
||||
gaiaView.setVisibility(View.VISIBLE);
|
||||
setHomeSurface(app.homeVisible);
|
||||
syncActive();
|
||||
}
|
||||
|
||||
private void back() {
|
||||
if (webPanel.getVisibility() == View.VISIBLE) {
|
||||
if (webBack) web.goBack();
|
||||
else closeBrowser();
|
||||
} else app.home(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
back();
|
||||
}
|
||||
|
||||
private String gaiaUrl() {
|
||||
return "http://system.localhost:" + GaiaServer.PORT + "/index.html";
|
||||
}
|
||||
|
||||
private void syncActive() {
|
||||
boolean browsing = webPanel != null && webPanel.getVisibility() == View.VISIBLE;
|
||||
if (gaia != null && gaia.isOpen()) gaia.setActive(resumed && !browsing);
|
||||
if (web != null && web.isOpen()) web.setActive(resumed && browsing);
|
||||
}
|
||||
|
||||
private void recover(GeckoSession session, boolean crashed) {
|
||||
if (isDestroyed()) return;
|
||||
if (crashed) {
|
||||
long now = SystemClock.elapsedRealtime();
|
||||
crashCount = now - lastCrash < 30000 ? crashCount + 1 : 1;
|
||||
lastCrash = now;
|
||||
if (crashCount > 2) {
|
||||
notice.setText("Vulpes s’est arrêté. Touchez ici pour réessayer.");
|
||||
notice.setVisibility(View.VISIBLE);
|
||||
notice.setOnClickListener(v -> {
|
||||
crashCount = 0;
|
||||
recover(session, false);
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!resumed) {
|
||||
if (session == gaia) recoverGaia = true;
|
||||
else recoverWeb = true;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (!session.isOpen()) session.open(app.runtime);
|
||||
session.loadUri(session == gaia ? gaiaUrl() : address.getText().toString());
|
||||
syncActive();
|
||||
android.util.Log.i(
|
||||
"Vulpes",
|
||||
"Recovered " + (session == gaia ? "Gaia" : "browser") + " session"
|
||||
);
|
||||
} catch (Exception e) {
|
||||
notice.setText("Reprise impossible : " + e.getMessage());
|
||||
notice.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private final GeckoSession.ContentDelegate content = new GeckoSession.ContentDelegate() {
|
||||
public void onCrash(GeckoSession session) {
|
||||
recover(session, true);
|
||||
}
|
||||
|
||||
public void onKill(GeckoSession session) {
|
||||
recover(session, false);
|
||||
}
|
||||
|
||||
public void onFirstComposite(GeckoSession session) {
|
||||
if (session == gaia) notice.setVisibility(View.GONE);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
resumed = true;
|
||||
app.activity = this;
|
||||
if (recoverGaia) {
|
||||
recoverGaia = false;
|
||||
recover(gaia, false);
|
||||
}
|
||||
if (recoverWeb && web != null) {
|
||||
recoverWeb = false;
|
||||
recover(web, false);
|
||||
}
|
||||
syncActive();
|
||||
// Android delivers permission results before onResume. Start the sensor only
|
||||
// after GeckoView has been made active again.
|
||||
java.util.List<java.util.function.Consumer<Boolean>> grants = new java.util.ArrayList<>(
|
||||
resumedCameraPermissions
|
||||
);
|
||||
resumedCameraPermissions.clear();
|
||||
for (java.util.function.Consumer<Boolean> grant : grants) grant.accept(true);
|
||||
gaiaView.requestLayout();
|
||||
app.resumed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
resumed = false;
|
||||
syncActive();
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
setIntent(intent);
|
||||
if (intent.hasCategory(Intent.CATEGORY_HOME)) { closeBrowser(); app.home(false); }
|
||||
if ("org.vulpes_os.preview.LOCAL_NOTIFICATION".equals(intent.getAction())) closeBrowser();
|
||||
if (app.notifications != null) app.notifications.click(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
gaiaView.releaseSession();
|
||||
webView.releaseSession();
|
||||
if (gaia != null) {
|
||||
gaia.setContentDelegate(null);
|
||||
gaia.setNavigationDelegate(null);
|
||||
gaia.setPromptDelegate(null);
|
||||
gaia.setPermissionDelegate(null);
|
||||
if (isFinishing()) {
|
||||
gaia.close();
|
||||
app.gaiaSession = null;
|
||||
}
|
||||
}
|
||||
if (web != null) web.close();
|
||||
if (fileResult != null) {
|
||||
fileResult.complete(filePrompt.dismiss());
|
||||
fileResult = null;
|
||||
}
|
||||
for (java.util.function.Consumer<Boolean> callback : permissionResults.values())
|
||||
callback.accept(false);
|
||||
permissionResults.clear();
|
||||
for (java.util.function.Consumer<Boolean> grant : resumedCameraPermissions) grant.accept(false);
|
||||
resumedCameraPermissions.clear();
|
||||
if (app.activity == this) app.activity = null;
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
void notificationPermission(java.util.function.Consumer<Boolean> callback) {
|
||||
if (!resumed) {
|
||||
callback.accept(false);
|
||||
return;
|
||||
}
|
||||
permission(
|
||||
Build.VERSION.SDK_INT >= 33
|
||||
? new String[] { android.Manifest.permission.POST_NOTIFICATIONS }
|
||||
: new String[0],
|
||||
callback
|
||||
);
|
||||
}
|
||||
|
||||
private void finishPermission(
|
||||
String[] names,
|
||||
boolean granted,
|
||||
java.util.function.Consumer<Boolean> callback
|
||||
) {
|
||||
if (
|
||||
granted &&
|
||||
!resumed &&
|
||||
java.util.Arrays.asList(names).contains(android.Manifest.permission.CAMERA)
|
||||
) resumedCameraPermissions.add(callback);
|
||||
else callback.accept(granted);
|
||||
}
|
||||
|
||||
private void permission(String[] names, java.util.function.Consumer<Boolean> callback) {
|
||||
boolean granted = true;
|
||||
for (String name : names)
|
||||
granted &= checkSelfPermission(name) == PackageManager.PERMISSION_GRANTED;
|
||||
if (granted) {
|
||||
finishPermission(names, true, callback);
|
||||
return;
|
||||
}
|
||||
int code = nextPermission++;
|
||||
permissionResults.put(code, callback);
|
||||
requestPermissions(names, code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int code, String[] names, int[] grants) {
|
||||
super.onRequestPermissionsResult(code, names, grants);
|
||||
java.util.function.Consumer<Boolean> callback = permissionResults.remove(code);
|
||||
if (callback != null) {
|
||||
boolean granted = grants.length > 0;
|
||||
// Approximate location is a valid choice; do not require fine location as well.
|
||||
if (
|
||||
java.util.Arrays.asList(names).contains(android.Manifest.permission.ACCESS_COARSE_LOCATION)
|
||||
) granted =
|
||||
checkSelfPermission(android.Manifest.permission.ACCESS_COARSE_LOCATION) ==
|
||||
PackageManager.PERMISSION_GRANTED;
|
||||
else for (int grant : grants) granted &= grant == PackageManager.PERMISSION_GRANTED;
|
||||
finishPermission(names, granted, callback);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int code, int status, Intent intent) {
|
||||
super.onActivityResult(code, status, intent);
|
||||
if (code == 420 && fileResult != null) {
|
||||
GeckoResult<GeckoSession.PromptDelegate.PromptResponse> result = fileResult;
|
||||
fileResult = null;
|
||||
ArrayList<Uri> uris = new ArrayList<>();
|
||||
if (status == RESULT_OK && intent != null) {
|
||||
if (intent.getClipData() != null) for (
|
||||
int i = 0;
|
||||
i < intent.getClipData().getItemCount();
|
||||
i++
|
||||
) uris.add(intent.getClipData().getItemAt(i).getUri());
|
||||
else if (intent.getData() != null) uris.add(intent.getData());
|
||||
}
|
||||
result.complete(
|
||||
uris.isEmpty() ? filePrompt.dismiss() : filePrompt.confirm(this, uris.toArray(new Uri[0]))
|
||||
);
|
||||
filePrompt = null;
|
||||
} else if (app.services != null) app.services.onResult(code, status, intent);
|
||||
}
|
||||
|
||||
private final GeckoSession.PermissionDelegate permissions =
|
||||
new GeckoSession.PermissionDelegate() {
|
||||
@Override
|
||||
public void onAndroidPermissionsRequest(
|
||||
GeckoSession session,
|
||||
String[] names,
|
||||
Callback callback
|
||||
) {
|
||||
permission(names, granted -> {
|
||||
if (granted) callback.grant();
|
||||
else callback.reject();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMediaPermissionRequest(
|
||||
GeckoSession session,
|
||||
String uri,
|
||||
MediaSource[] video,
|
||||
MediaSource[] audio,
|
||||
MediaCallback callback
|
||||
) {
|
||||
Uri origin = Uri.parse(uri);
|
||||
boolean camera =
|
||||
session == gaia &&
|
||||
"http".equals(origin.getScheme()) &&
|
||||
"camera.localhost".equals(origin.getHost()) &&
|
||||
origin.getPort() == 18765;
|
||||
if (!camera || (audio != null && audio.length > 0) || video == null || video.length == 0) {
|
||||
callback.reject();
|
||||
return;
|
||||
}
|
||||
permission(new String[] { android.Manifest.permission.CAMERA }, granted -> {
|
||||
if (granted) callback.grant(video[0], null);
|
||||
else callback.reject();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoResult<Integer> onContentPermissionRequest(
|
||||
GeckoSession session,
|
||||
ContentPermission permission
|
||||
) {
|
||||
boolean local = session == gaia && isGaia(permission.uri);
|
||||
if (
|
||||
permission.permission == PERMISSION_DESKTOP_NOTIFICATION ||
|
||||
permission.permission == PERMISSION_GEOLOCATION
|
||||
) {
|
||||
GeckoResult<Integer> result = new GeckoResult<>();
|
||||
Runnable ask = () -> {
|
||||
String[] names = permission.permission == PERMISSION_GEOLOCATION
|
||||
? new String[] {
|
||||
android.Manifest.permission.ACCESS_COARSE_LOCATION,
|
||||
android.Manifest.permission.ACCESS_FINE_LOCATION,
|
||||
}
|
||||
: Build.VERSION.SDK_INT >= 33
|
||||
? new String[] { android.Manifest.permission.POST_NOTIFICATIONS }
|
||||
: new String[0];
|
||||
permission(names, granted ->
|
||||
result.complete(
|
||||
granted ? ContentPermission.VALUE_ALLOW : ContentPermission.VALUE_DENY
|
||||
)
|
||||
);
|
||||
};
|
||||
new AlertDialog.Builder(MainActivity.this)
|
||||
.setTitle("Autorisation Vulpes")
|
||||
.setMessage(
|
||||
permission.uri +
|
||||
(permission.permission == PERMISSION_GEOLOCATION
|
||||
? "\nAccéder à votre position ?"
|
||||
: "\nAfficher des notifications Android ?")
|
||||
)
|
||||
.setPositiveButton("Autoriser", (d, w) -> ask.run())
|
||||
.setNegativeButton("Refuser", (d, w) -> result.complete(ContentPermission.VALUE_DENY))
|
||||
.setOnCancelListener(d -> result.complete(ContentPermission.VALUE_DENY))
|
||||
.show();
|
||||
return result;
|
||||
}
|
||||
boolean allow =
|
||||
local &&
|
||||
(permission.permission == PERMISSION_PERSISTENT_STORAGE ||
|
||||
permission.permission == PERMISSION_AUTOPLAY_INAUDIBLE ||
|
||||
permission.permission == PERMISSION_AUTOPLAY_AUDIBLE);
|
||||
return GeckoResult.fromValue(
|
||||
allow ? ContentPermission.VALUE_ALLOW : ContentPermission.VALUE_DENY
|
||||
);
|
||||
}
|
||||
};
|
||||
private final GeckoSession.PromptDelegate prompts = new GeckoSession.PromptDelegate() {
|
||||
@Override
|
||||
public GeckoResult<PromptResponse> onFilePrompt(GeckoSession session, FilePrompt prompt) {
|
||||
if (fileResult != null) return GeckoResult.fromValue(prompt.dismiss());
|
||||
GeckoResult<PromptResponse> result = new GeckoResult<>();
|
||||
Intent pick = new Intent(Intent.ACTION_OPEN_DOCUMENT)
|
||||
.addCategory(Intent.CATEGORY_OPENABLE)
|
||||
.setType("*/*")
|
||||
.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, prompt.type == FilePrompt.Type.MULTIPLE);
|
||||
if (prompt.mimeTypes != null && prompt.mimeTypes.length > 0) pick.putExtra(
|
||||
Intent.EXTRA_MIME_TYPES,
|
||||
prompt.mimeTypes
|
||||
);
|
||||
try {
|
||||
startActivityForResult(pick, 420);
|
||||
fileResult = result;
|
||||
filePrompt = prompt;
|
||||
} catch (ActivityNotFoundException e) {
|
||||
result.complete(prompt.dismiss());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoResult<PromptResponse> onAlertPrompt(GeckoSession s, AlertPrompt p) {
|
||||
GeckoResult<PromptResponse> result = new GeckoResult<>();
|
||||
new AlertDialog.Builder(MainActivity.this)
|
||||
.setTitle(p.title)
|
||||
.setMessage(p.message)
|
||||
.setPositiveButton("OK", (d, w) -> result.complete(p.dismiss()))
|
||||
.setOnCancelListener(d -> result.complete(p.dismiss()))
|
||||
.show();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoResult<PromptResponse> onChoicePrompt(GeckoSession s, ChoicePrompt p) {
|
||||
ArrayList<ChoicePrompt.Choice> choices = new ArrayList<>();
|
||||
flatten(p.choices, choices);
|
||||
String[] labels = new String[choices.size()];
|
||||
for (int i = 0; i < labels.length; i++) labels[i] = choices.get(i).label;
|
||||
GeckoResult<PromptResponse> result = new GeckoResult<>();
|
||||
new AlertDialog.Builder(MainActivity.this)
|
||||
.setTitle(p.title)
|
||||
.setItems(labels, (d, n) -> result.complete(p.confirm(choices.get(n))))
|
||||
.setOnCancelListener(d -> result.complete(p.dismiss()))
|
||||
.show();
|
||||
return result;
|
||||
}
|
||||
|
||||
private void flatten(ChoicePrompt.Choice[] items, ArrayList<ChoicePrompt.Choice> out) {
|
||||
for (ChoicePrompt.Choice c : items) {
|
||||
if (c.items != null) flatten(c.items, out);
|
||||
else if (!c.disabled && !c.separator) out.add(c);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
package org.vulpes_os.preview;
|
||||
|
||||
import android.app.Application;
|
||||
import android.util.Log;
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import org.json.JSONObject;
|
||||
import org.mozilla.geckoview.*;
|
||||
|
||||
public final class VulpesApplication extends Application {
|
||||
|
||||
GeckoRuntime runtime;
|
||||
GaiaServer server;
|
||||
WebExtension.Port port;
|
||||
MainActivity activity;
|
||||
GeckoResult<WebExtension> extension;
|
||||
GeckoSession gaiaSession;
|
||||
AndroidServices services;
|
||||
AndroidNotifications notifications;
|
||||
boolean homeVisible;
|
||||
boolean homeAtBottom;
|
||||
|
||||
void prepare() throws IOException {
|
||||
if (runtime != null) return;
|
||||
server = new GaiaServer(this);
|
||||
File config = new File(getFilesDir(), "geckoview.yaml");
|
||||
try (FileOutputStream out = new FileOutputStream(config)) {
|
||||
out.write(
|
||||
("prefs:\n datareporting.policy.dataSubmissionEnabled: false\n toolkit.telemetry.enabled: false\n browser.tabs.warnOnClose: false\n" +
|
||||
(android.os.Build.HARDWARE.equals("ranchu")
|
||||
? " gfx.webrender.software: true\n"
|
||||
: "")).getBytes(StandardCharsets.UTF_8)
|
||||
);
|
||||
}
|
||||
runtime = GeckoRuntime.create(
|
||||
this,
|
||||
new GeckoRuntimeSettings.Builder()
|
||||
.configFilePath(config.getAbsolutePath())
|
||||
.consoleOutput(true)
|
||||
.remoteDebuggingEnabled(
|
||||
(getApplicationInfo().flags & android.content.pm.ApplicationInfo.FLAG_DEBUGGABLE) != 0
|
||||
)
|
||||
.locales(new String[] { "fr", "en-US" })
|
||||
.automaticFontSizeAdjustment(false)
|
||||
.fontInflation(false)
|
||||
.build()
|
||||
);
|
||||
services = new AndroidServices(this);
|
||||
notifications = new AndroidNotifications(this);
|
||||
runtime.setWebNotificationDelegate(notifications);
|
||||
extension = runtime
|
||||
.getWebExtensionController()
|
||||
.ensureBuiltIn("resource://android/assets/bridge/", "android-host@vulpes-os.org");
|
||||
extension.accept(
|
||||
ext ->
|
||||
ext.setMessageDelegate(
|
||||
new WebExtension.MessageDelegate() {
|
||||
@Override
|
||||
public void onConnect(WebExtension.Port p) {
|
||||
port = p;
|
||||
if (activity != null) notifications.click(activity.getIntent());
|
||||
p.setDelegate(
|
||||
new WebExtension.PortDelegate() {
|
||||
@Override
|
||||
public void onDisconnect(WebExtension.Port p) {
|
||||
if (port == p) port = null;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoResult<Object> onMessage(
|
||||
String app,
|
||||
Object message,
|
||||
WebExtension.MessageSender sender
|
||||
) {
|
||||
if (message instanceof JSONObject) {
|
||||
if (sender.environmentType != WebExtension.MessageSender.ENV_TYPE_EXTENSION) {
|
||||
return GeckoResult.fromException(new SecurityException("EXTENSION_REQUIRED"));
|
||||
}
|
||||
JSONObject json = (JSONObject) message;
|
||||
if (json.optString("type").equals("homeScroll")) {
|
||||
homeAtBottom = json.optBoolean("bottom");
|
||||
if (activity != null) activity.setHomeSurface(homeVisible);
|
||||
return GeckoResult.fromValue(null);
|
||||
}
|
||||
if (json.optString("type").equals("navigation")) {
|
||||
homeVisible = json.optBoolean("home");
|
||||
if (activity != null) activity.setHomeSurface(homeVisible);
|
||||
return GeckoResult.fromValue(null);
|
||||
}
|
||||
if (json.optString("type").startsWith("android.")) return services
|
||||
.request(json)
|
||||
.map(value -> {
|
||||
try {
|
||||
return new JSONObject()
|
||||
.put("result", value == null ? JSONObject.NULL : value)
|
||||
.toString();
|
||||
} catch (org.json.JSONException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
});
|
||||
if (json.optString("type").equals("open") && activity != null) activity.openBrowser(
|
||||
json.optString("url")
|
||||
);
|
||||
}
|
||||
return GeckoResult.fromValue(null);
|
||||
}
|
||||
},
|
||||
"vulpes"
|
||||
),
|
||||
error -> Log.e("Vulpes", "Extension failed", error)
|
||||
);
|
||||
}
|
||||
|
||||
void home(boolean held) {
|
||||
if (port == null) return;
|
||||
try {
|
||||
port.postMessage(new JSONObject().put("type", held ? "holdhome" : "home"));
|
||||
} catch (Exception e) {
|
||||
Log.e("Vulpes", "Home", e);
|
||||
}
|
||||
}
|
||||
|
||||
void resumed() {
|
||||
if (port == null) return;
|
||||
try {
|
||||
port.postMessage(new JSONObject().put("type", "android-resume"));
|
||||
} catch (Exception e) {
|
||||
Log.w("Vulpes", "Resume notification", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
android/app/src/main/res/drawable-nodpi/vulpes_logo.png
Normal file
BIN
android/app/src/main/res/drawable-nodpi/vulpes_logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 135 KiB |
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue