Skip to content

Commit 38bce36

Browse files
committed
live-update: add Brotli support for Android downloads
1 parent a614343 commit 38bce36

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

.changeset/odd-pianos-tap.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@capawesome/capacitor-live-update": patch
3+
---
4+
5+
fix(live-update): add Brotli download support on Android

packages/live-update/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ android {
7474

7575
If needed, you can define the following project variable in your app’s `variables.gradle` file to change the default version of the dependency:
7676

77-
- `$okhttp3Version` version of `com.squareup.okhttp3:okhttp` (default: `5.3.2`)
77+
- `$okhttp3Version` version of `com.squareup.okhttp3:okhttp` and `com.squareup.okhttp3:okhttp-brotli` (default: `5.3.2`)
7878
- `$zip4jVersion` version of `net.lingala.zip4j:zip4j` (default: `2.11.5`)
7979

8080
This can be useful if you encounter dependency conflicts with other plugins in your project.
@@ -963,7 +963,7 @@ Remove all listeners for this plugin.
963963
| **`bundleId`** | <code>string</code> | The unique identifier of the bundle. **Attention**: The value `public` is reserved and cannot be used as a bundle identifier. | | 5.0.0 |
964964
| **`checksum`** | <code>string</code> | The checksum of the self-hosted bundle as a SHA-256 hash in hex format to verify the integrity of the bundle. **Attention**: Only supported for the `zip` artifact type. | | 7.1.0 |
965965
| **`signature`** | <code>string</code> | The signature of the self-hosted bundle as a signed SHA-256 hash in base64 format to verify the integrity of the bundle. **Attention**: Only supported for the `zip` artifact type. | | 7.1.0 |
966-
| **`url`** | <code>string</code> | The URL of the bundle to download. For the `zip` artifact type, the URL must point to a ZIP file. For the `manifest` artifact type, the URL serves as the base URL to download the individual files. For example, if the URL is `https://example.com/download`, the plugin will download the file with the href `index.html` from `https://example.com/download?href=index.html`. To **verify the integrity** of the file, the server should return a `X-Checksum` header with the SHA-256 hash in hex format. To **verify the signature** of the file, the server should return a `X-Signature` header with the signed SHA-256 hash in base64 format. | | 5.0.0 |
966+
| **`url`** | <code>string</code> | The URL of the bundle to download. For the `zip` artifact type, the URL must point to a ZIP file. For the `manifest` artifact type, the URL serves as the base URL to download the individual files. For example, if the URL is `https://example.com/download`, the plugin will download the file with the href `index.html` from `https://example.com/download?href=index.html`. To **verify the integrity** of the file, the server should return a `X-Checksum` header with the SHA-256 hash in hex format. To **verify the signature** of the file, the server should return a `X-Signature` header with the signed SHA-256 hash in base64 format. Bundle downloads also support Brotli-compressed HTTP responses (`Content-Encoding: br`). | | 5.0.0 |
967967

968968

969969
#### FetchChannelsResult

packages/live-update/android/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ dependencies {
5656
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
5757
implementation "net.lingala.zip4j:zip4j:$zip4jVersion"
5858
implementation "com.squareup.okhttp3:okhttp:$okhttp3Version"
59+
implementation "com.squareup.okhttp3:okhttp-brotli:$okhttp3Version"
5960
testImplementation "junit:junit:$junitVersion"
6061
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
6162
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"

packages/live-update/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdateHttpClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import okhttp3.Request;
1616
import okhttp3.Response;
1717
import okhttp3.ResponseBody;
18+
import okhttp3.brotli.BrotliInterceptor;
1819
import okio.Buffer;
1920
import okio.BufferedSink;
2021
import okio.BufferedSource;
@@ -59,6 +60,7 @@ public LiveUpdateHttpClient(@NonNull LiveUpdateConfig config) {
5960

6061
this.okHttpClient = new OkHttpClient.Builder()
6162
.dispatcher(dispatcher)
63+
.addInterceptor(BrotliInterceptor.INSTANCE)
6264
.connectTimeout(httpTimeout, TimeUnit.MILLISECONDS)
6365
.readTimeout(httpTimeout, TimeUnit.MILLISECONDS)
6466
.writeTimeout(httpTimeout, TimeUnit.MILLISECONDS)

0 commit comments

Comments
 (0)