Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions docs/android.services.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
A name-value pair for an item of additional, arbitrary data that can be supplied to the application.

Equivalent to
[`<service>`](https://developer.android.com/guide/topics/manifest/service-element).

Example:

```xml
<application>
<service
android:name="com.example.locationService"
android:exported="true"
android:foregroundServiceType="location" />
</application>
```

becomes

```json
{
"android": {
"services": [
{
"android:name": "com.example.locationService",
"android:exported": true,
"android:foregroundServiceType": "location"
}
],
}
}
```

<details>
25 changes: 25 additions & 0 deletions packages/app/android/android-manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,31 @@ function generateAndroidManifest(appManifestPath, manifestOutput, fs = nodefs) {
}
}

// https://developer.android.com/guide/topics/manifest/service-element
const services = android.services;
if (Array.isArray(services)) {
const names = ["android:name"];
const attributes = [
"android:description",
"android:directBootAware",
"android:enabled",
"android:exported",
"android:foregroundServiceType",
"android:icon",
"android:isolatedProcess",
"android:label",
"android:name",
"android:permission",
"android:process",
"android:stopWithTask",
];
const entries = toXML(services, names, attributes, attributeNamePrefix);

if (entries.length > 0) {
manifest.application["service"] = entries;
}
}

const builder = new XMLBuilder(xmlOptions);
fs.mkdirSync(path.dirname(manifestOutput), { recursive: true, mode: 0o755 });
fs.writeFileSync(manifestOutput, builder.build(xml));
Expand Down
28 changes: 28 additions & 0 deletions packages/app/scripts/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,33 @@ export type AndroidConfig = {
"android:name": string;
"android:value": string;
}[];
services?: {
"android:name": string;
"android:description": string;
"android:directBootAware": "true" | "false";
"android:enabled": "true" | "false";
"android:exported": "true" | "false";
"android:foregroundServiceType":
| "camera"
| "connectedDevice"
| "dataSync"
| "health"
| "location"
| "mediaPlayback"
| "mediaProjection"
| "microphone"
| "phoneCall"
| "remoteMessaging"
| "shortService"
| "specialUse"
| "systemExempted";
"android:icon": string;
"android:isolatedProcess": "true" | "false";
"android:label": string;
"android:permission": string;
"android:process": string;
"android:stopWithTask": "true" | "false";
}[];
};
};

Expand All @@ -37,6 +64,7 @@ export type AndroidManifest = {
"uses-permission": Record<string, string>[];
application: {
"meta-data": Record<string, string>[];
service: Record<string, string>[];
};
};

Expand Down
Loading