Skip to content

Commit fb43575

Browse files
committed
Update Android IDE example SDK to 30 for SSLParameters ALPN support
1 parent 364db70 commit fb43575

7 files changed

Lines changed: 56 additions & 26 deletions

File tree

IDE/Android/.idea/gradle.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

IDE/Android/.idea/misc.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

IDE/Android/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ project should be used for reference only.
66
Tool and version information used when testing this project:
77

88
- Ubuntu 20.04.3 LTS
9-
- Android Studio Bumblebeea 2021.1.1 Patch 3
9+
- Android Studio Chipmunk 2021.2.1
1010
- Android Gradle Plugin Version: 4.2.2
1111
- Gradle Version: 7.1.3
12-
- API 28: Android 9.0 (Pie)
13-
- Emulator: Nexus 5X API 28
12+
- API 30: Android 11
13+
- Emulator: Pixel 5 API 31
1414

1515
The following sections outline steps required to run this example on an
1616
Android device or emulator.

IDE/Android/app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 28
4+
compileSdkVersion 30
55
defaultConfig {
66
applicationId "com.example.wolfssl"
7-
minSdkVersion 23
8-
targetSdkVersion 28
7+
minSdkVersion 30
8+
targetSdkVersion 30
99
versionCode 1
1010
versionName "1.0"
1111
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

IDE/Android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="com.example.wolfssl">
4-
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
4+
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
55
<uses-permission android:name="android.permission.INTERNET"/>
66

77
<application
@@ -14,7 +14,6 @@
1414
<activity android:name=".MainActivity">
1515
<intent-filter>
1616
<action android:name="android.intent.action.MAIN" />
17-
1817
<category android:name="android.intent.category.LAUNCHER" />
1918
</intent-filter>
2019
</activity>

IDE/Android/app/src/main/java/com/example/wolfssl/MainActivity.java

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,22 @@
2222

2323
package com.example.wolfssl;
2424

25+
import android.content.Intent;
26+
import android.net.Uri;
27+
import android.os.Environment;
28+
import android.provider.Settings;
2529
import android.support.v7.app.AppCompatActivity;
2630
import android.os.Bundle;
31+
import android.view.View;
32+
import android.widget.Button;
2733
import android.widget.TextView;
28-
import android.Manifest;
29-
import android.content.pm.PackageManager;
3034

3135
import com.wolfssl.WolfSSL;
3236
import com.wolfssl.WolfSSLException;
3337
import com.wolfssl.provider.jsse.WolfSSLProvider;
3438
import com.wolfssl.provider.jsse.WolfSSLX509;
3539

3640
import java.io.FileInputStream;
37-
import java.io.FileNotFoundException;
3841
import java.io.IOException;
3942
import java.security.KeyStore;
4043
import java.security.KeyStoreException;
@@ -48,25 +51,38 @@
4851

4952
public class MainActivity extends AppCompatActivity {
5053

54+
private View.OnClickListener buttonListener = new View.OnClickListener() {
55+
@Override
56+
public void onClick(View v) {
57+
TextView tv = (TextView) findViewById(R.id.sample_text);
58+
59+
try {
60+
testLoadCert(tv);
61+
} catch (Exception e) {
62+
e.printStackTrace();
63+
}
64+
}
65+
};
66+
5167
@Override
5268
protected void onCreate(Bundle savedInstanceState) {
5369
int permission;
5470
super.onCreate(savedInstanceState);
5571
setContentView(R.layout.activity_main);
5672

73+
Button button = (Button) findViewById(R.id.button);
74+
button.setOnClickListener(buttonListener);
75+
5776
TextView tv = (TextView) findViewById(R.id.sample_text);
5877
tv.setText("wolfSSL JNI Android Studio Example App");
5978

6079

61-
permission = checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE);
62-
if (permission != PackageManager.PERMISSION_GRANTED) {
63-
requestPermissions(new String[] {Manifest.permission.READ_EXTERNAL_STORAGE},1);
64-
}
65-
66-
try {
67-
testLoadCert(tv);
68-
} catch (Exception e) {
69-
e.printStackTrace();
80+
if (Environment.isExternalStorageManager()) {
81+
} else {
82+
Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
83+
Uri uri = Uri.fromParts("package", getPackageName(), null);
84+
intent.setData(uri);
85+
startActivity(intent);
7086
}
7187
}
7288

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<android.support.constraint.ConstraintLayout
3-
xmlns:android="http://schemas.android.com/apk/res/android"
4-
xmlns:tools="http://schemas.android.com/tools"
2+
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
53
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
65
android:layout_width="match_parent"
76
android:layout_height="match_parent"
87
tools:context=".MainActivity">
98

9+
<Button
10+
android:id="@+id/button"
11+
android:layout_width="match_parent"
12+
android:layout_height="wrap_content"
13+
android:text="Load Cert File" />
14+
1015
<TextView
1116
android:id="@+id/sample_text"
12-
android:layout_width="wrap_content"
17+
android:layout_width="match_parent"
1318
android:layout_height="wrap_content"
19+
android:layout_marginTop="16dp"
20+
android:paddingVertical="16pt"
1421
android:text="Hello World!"
1522
app:layout_constraintBottom_toBottomOf="parent"
23+
app:layout_constraintHorizontal_bias="0.461"
1624
app:layout_constraintLeft_toLeftOf="parent"
1725
app:layout_constraintRight_toRightOf="parent"
18-
app:layout_constraintTop_toTopOf="parent" />
26+
app:layout_constraintTop_toTopOf="parent"
27+
app:layout_constraintVertical_bias="0.067" />
1928

2029
</android.support.constraint.ConstraintLayout>

0 commit comments

Comments
 (0)