Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #615 Add Meta Quest support #704

Merged
10 changes: 6 additions & 4 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,13 @@ parse the Web manifest and generate default values for the Android project, wher
will prompt the user to confirm or input values where one could not be generated.

```
bubblewrap init --manifest="<web-manifest-url>" [--directory="<path-to-output-location>"] [--chromeosonly]
bubblewrap init --manifest="<web-manifest-url>" [--directory="<path-to-output-location>"] [--chromeosonly] [--metaquest]
```

Options:
- `--directory`: path where to generate the project. Defaults to the current directory.
- `--chromeosonly`: this flag specifies that the build will be used for Chrome OS only and prevents non-Chrome OS devices from installing the app.
- `--chromeosonly`: this flag specifies that the build will be used for Chrome OS only and prevents non-Chrome OS devices (except Meta Quest devices) from installing the app.
- `--metaquest`: this flag specifies that the build will be compatible with Meta Quest devices.
- `--alphaDependencies`: enables features that depend on upcoming version of the Android library
for Trusted Web Activity or that are still unstable.

Expand Down Expand Up @@ -350,7 +351,8 @@ Fields:
|generatorApp|string|false|Identifier for tool used to generate the Android project. Bubblewrap uses `bubblewrap-cli`. Should only be modified by generator apps.|
|host|string|true|The origin that will be opened in the Trusted Web Activity.|
|iconUrl|string|true|Full URL to an the icon used for the application launcher and splash screen. Must be at least 512x512 px.|
|isChromeOSOnly|boolean|false|Generates an application that targets only ChromeOS devices. Defaults to `false`.|
|isChromeOSOnly|boolean|false|Generates an application that targets only ChromeOS devices (except Meta Quest devices). Defaults to `false`.|
|isMetaQuest|boolean|false|Generates an application that compatible with Meta Quest devices. Defaults to `false`.|
|launcherName|string|false|A short name for the Android application, displayed on the Android launcher|
|maskableIconUrl|string|false|Full URL to an the icon used for maskable icons, when supported by the device.|
|monochromeIconUrl|string|false|Full URL to a monochrome icon, used when displaying notifications.|
Expand All @@ -369,7 +371,7 @@ Fields:
|splashScreenFadeOutDuration|number|true|Duration for the splash screen fade out animation.|
|startUrl|string|true|The start path for the TWA. Must be relative to the domain.|
|themeColor|string|true|The color used for the status bar.|
|webManifestUrl|string|false|Full URL to the PWA Web Manifest. Required for the application to be compatible with Chrome OS devices.|
|webManifestUrl|string|false|Full URL to the PWA Web Manifest. Required for the application to be compatible with Chrome OS and Meta Quest devices.|

### Features

Expand Down
4 changes: 3 additions & 1 deletion packages/cli/src/lib/cmds/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ const HELP_MESSAGES = new Map<string, string>(
'--directory ........... path where to generate the project. Defaults to the current' +
' directory',
'--chromeosonly ........ specifies that the build will be used for Chrome OS only and' +
' prevents non-Chrome OS devices from installing the app.',
' prevents non-Chrome OS devices (except Meta Quest devices) from installing the app.',
'--metaquest ........... specifies that the build will be compatible with Meta Quest' +
' devices.',
'--alphaDependencies ... enables features that depend on upcoming version of the ' +
' Android library for Trusted Web Activity or that are still unstable.',
].join('\n')],
Expand Down
5 changes: 5 additions & 0 deletions packages/cli/src/lib/cmds/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface InitArgs {
manifest?: string;
directory?: string;
chromeosonly?: boolean;
metaquest?: boolean;
alphaDependencies?: boolean;
}

Expand Down Expand Up @@ -245,6 +246,10 @@ export async function init(
twaManifest.isChromeOSOnly = true;
}

if (args.metaquest) {
twaManifest.isMetaQuest = true;
}

if (args.alphaDependencies) {
twaManifest.alphaDependencies = {
enabled: true,
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/lib/TwaManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ type alphaDependencies = {
* // The duration of fade out animation in milliseconds to be played when removing splash screen.
* splashScreenFadeOutDuration: 300
* isChromeOSOnly: false, // Setting to true will enable a feature that prevents non-ChromeOS devices
* from installing the app.
* (except Meta Quest devices) from installing the app.
* isMetaQuest: false, // Setting to true will generate the build compatible with Meta Quest devices.
* serviceAccountJsonFile: '<%= serviceAccountJsonFile %>', // The service account used to communicate with
* Google Play.
*
Expand Down Expand Up @@ -155,6 +156,7 @@ export class TwaManifest {
alphaDependencies: alphaDependencies;
enableSiteSettingsShortcut: boolean;
isChromeOSOnly: boolean;
isMetaQuest: boolean;
shareTarget?: ShareTarget;
orientation: Orientation;
fingerprints: Fingerprint[];
Expand Down Expand Up @@ -201,6 +203,7 @@ export class TwaManifest {
this.enableSiteSettingsShortcut = data.enableSiteSettingsShortcut != undefined ?
data.enableSiteSettingsShortcut : true;
this.isChromeOSOnly = data.isChromeOSOnly != undefined ? data.isChromeOSOnly : false;
this.isMetaQuest = data.isMetaQuest != undefined ? data.isMetaQuest : false;
this.shareTarget = data.shareTarget;
this.orientation = data.orientation || DEFAULT_ORIENTATION;
this.fingerprints = data.fingerprints || [];
Expand Down Expand Up @@ -528,6 +531,7 @@ export interface TwaManifestJson {
};
enableSiteSettingsShortcut?: boolean;
isChromeOSOnly?: boolean;
isMetaQuest?: boolean;
shareTarget?: ShareTarget;
orientation?: Orientation;
fingerprints?: Fingerprint[];
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/spec/lib/TwaManifestSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ describe('TwaManifest', () => {
fallbackType: 'webview',
enableSiteSettingsShortcut: false,
isChromeOSOnly: false,
isMetaQuest: false,
serviceAccountJsonFile: '/home/service-account.json',
additionalTrustedOrigins: ['test.com'],
retainedBundles: [3, 4, 5],
Expand Down Expand Up @@ -255,6 +256,7 @@ describe('TwaManifest', () => {
expect(twaManifest.fallbackType).toBe('webview');
expect(twaManifest.enableSiteSettingsShortcut).toEqual(false);
expect(twaManifest.isChromeOSOnly).toEqual(false);
expect(twaManifest.isMetaQuest).toEqual(false);
expect(twaManifest.serviceAccountJsonFile).toEqual(twaManifestJson.serviceAccountJsonFile);
expect(twaManifest.additionalTrustedOrigins).toEqual(['test.com']);
expect(twaManifest.retainedBundles).toEqual([3, 4, 5]);
Expand Down Expand Up @@ -381,6 +383,7 @@ describe('TwaManifest', () => {
'features': {},
'enableSiteSettingsShortcut': true,
'isChromeOSOnly': false,
'isMetaQuest': false,
'appVersion': '1',
'serviceAccountJsonFile': '/home/service-account.json',
});
Expand Down Expand Up @@ -439,6 +442,7 @@ describe('TwaManifest', () => {
'features': {},
'enableSiteSettingsShortcut': true,
'isChromeOSOnly': false,
'isMetaQuest': false,
'appVersion': '1',
'serviceAccountJsonFile': '/home/service-account.json',
});
Expand Down
4 changes: 2 additions & 2 deletions packages/core/template_project/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ android {

<% if (webManifestUrl) { %>
// The URL the Web Manifest for the Progressive Web App that the TWA points to. This
// is used by Chrome OS to open the Web version of the PWA instead of the TWA, as it
// will probably give a better user experience for non-mobile devices.
// is used by Chrome OS and Meta Quest to open the Web version of the PWA instead of
// the TWA, as it will probably give a better user experience for non-mobile devices.
resValue "string", "webManifestUrl", '<%= webManifestUrl %>'
<% } %>

Expand Down
29 changes: 29 additions & 0 deletions packages/core/template_project/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,25 @@
<uses-permission android:name="<%= permission %>"/>
<% } %>

<% if (isMetaQuest) { %>
<uses-permission android:name="com.oculus.permission.HAND_TRACKING" />
<% } %>

<% if (isChromeOSOnly) { %>
<uses-feature android:name="org.chromium.arc" android:required="true" />
<% } %>

<% if (isMetaQuest) { %>
<uses-feature
android:name="android.hardware.vr.headtracking"
android:required="false"
android:version="1" />

<uses-feature
android:name="oculus.software.handtracking"
android:required="false" />
<% } %>

<application
android:name="Application"
android:allowBackup="true"
Expand Down Expand Up @@ -61,6 +76,20 @@
android:value="<%= metadata.value %>" />
<% } %>

<% if (isMetaQuest) { %>
<meta-data
android:name="com.oculus.pwa.NAME"
android:value="@string/appName" />

<meta-data
android:name="com.oculus.pwa.START_URL"
android:value="@string/launchUrl" />

<meta-data
android:name="com.oculus.pwa.SCOPE"
android:value="@string/launchUrl" />
<% } %>

<% if (enableSiteSettingsShortcut) { %>
<activity android:name="com.google.androidbrowserhelper.trusted.ManageDataLauncherActivity">
<meta-data
Expand Down