Skip to content

Commit a4044b0

Browse files
committed
support no-ssl mode for car's multimedia systems
1 parent efccaa4 commit a4044b0

3 files changed

Lines changed: 20 additions & 8 deletions

File tree

.github/workflows/build.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ on:
3737
description: 'Icon URL'
3838
startup_url:
3939
description: 'Start URL'
40-
40+
no_ssl:
41+
description: 'No SSL - Not recommended!!'
42+
type: boolean
43+
default: false
4144
jobs:
4245
id:
4346
# https://stackoverflow.com/a/73837663
@@ -131,6 +134,7 @@ jobs:
131134
ALLOWED_DOMAINS: ${{ env.ALLOWED_DOMAINS }}
132135
BLOCK_MEDIA: ${{ inputs.block_media }}
133136
BLOCK_ADS: ${{ inputs.block_ads }}
137+
NO_SSL: ${{ inputs.no_ssl }}
134138
- name: Rename APK
135139
run: mv app/build/outputs/apk/release/app-release.apk app/build/outputs/apk/release/webview-${{ env.PRIMARY_DOMAIN }}.apk
136140
- name: Create Release
@@ -148,6 +152,7 @@ jobs:
148152
Restricted WebView App.
149153
Domain: [${{ env.PRIMARY_DOMAIN }}](//${{ env.PRIMARY_DOMAIN }})
150154
Second Domain: [${{ env.SECOND_DOMAIN }}](//${{ env.SECOND_DOMAIN }})
155+
No Secured: ${{ inputs.no_ssl }}
151156
App Name: ${{ inputs.app_name }}
152157
View Mode: ${{ inputs.view_mode }}
153158
Block Media: ${{ inputs.block_media }}

app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ android {
2121
buildConfigField "String", "VIEW_MODE", "\"${System.getenv('VIEW_MODE') ?: 'AUTO'}\""
2222
buildConfigField "boolean", "BLOCK_MEDIA", "${System.getenv('BLOCK_MEDIA') ?: 'false'}"
2323
buildConfigField "boolean", "BLOCK_ADS", "${System.getenv('BLOCK_ADS') ?: 'true'}"
24+
buildConfigField "boolean", "NO_SSL", "${System.getenv('NO_SSL') ?: 'false'}"
2425
resValue "string", "app_name", System.getenv('APP_NAME') ?: "My Application"
2526
applicationId System.getenv('APPLICATION_ID') ?: "com.webview.myapplication"
2627

app/src/main/java/com/webview/myapplication/MainActivity.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,10 @@ public class MainActivity extends Activity {
108108
private final int STORAGE_PERMISSION_CODE = 1;
109109
private static final String[] ALLOWED_DOMAINS = BuildConfig.ALLOWED_DOMAINS.split(",");
110110
private static final String STARTUP_URL = BuildConfig.STARTUP_URL;
111+
private static final String VIEW_MODE = BuildConfig.VIEW_MODE;
111112
private static final boolean BLOCK_MEDIA = BuildConfig.BLOCK_MEDIA;
112113
private static final boolean BLOCK_ADS = BuildConfig.BLOCK_ADS;
113-
private static final String VIEW_MODE = BuildConfig.VIEW_MODE;
114+
private static final boolean NO_SSL = BuildConfig.NO_SSL;
114115
private WebView mWebView;
115116
private View mCustomView;
116117
private CustomViewCallback mCustomViewCallback;
@@ -332,12 +333,17 @@ public void onPageFinished(WebView view, String url) {
332333

333334
@Override
334335
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
335-
handler.cancel();
336-
view.loadData("<html><body><h1 style='color: grey'>SSL Error</h1></body></html>", "text/html; charset=utf-8", "UTF-8");
337-
if (Objects.equals(error.getCertificate().getIssuedBy().getOName(), "NetFree")) {
338-
Toast.makeText(view.getContext(), "טיפ: נראה שלא מותקנת תעודת אבטחה של נטפרי", Toast.LENGTH_LONG).show();
339-
} else if (Objects.equals(error.getCertificate().getIssuedBy().getOName(), "Netspark")) {
340-
Toast.makeText(view.getContext(), "טיפ: נראה שלא מותקנת תעודת אבטחה של אתרוג/רימון", Toast.LENGTH_LONG).show();
336+
String issuerName = error.getCertificate().getIssuedBy().getOName();
337+
if (NO_SSL && (Objects.equals(issuerName, "NetFree") || Objects.equals(issuerName, "Netspark"))) {
338+
handler.proceed();
339+
} else {
340+
handler.cancel();
341+
view.loadData("<html><body><h1 style='color: grey'>SSL Error</h1></body></html>", "text/html; charset=utf-8", "UTF-8");
342+
if (Objects.equals(issuerName, "NetFree")) {
343+
Toast.makeText(view.getContext(), "טיפ: נראה שלא מותקנת תעודת אבטחה של נטפרי", Toast.LENGTH_LONG).show();
344+
} else if (Objects.equals(issuerName, "Netspark")) {
345+
Toast.makeText(view.getContext(), "טיפ: נראה שלא מותקנת תעודת אבטחה של אתרוג/רימון", Toast.LENGTH_LONG).show();
346+
}
341347
}
342348
}
343349
}

0 commit comments

Comments
 (0)