Skip to content

Commit

Permalink
Update Android IDE example SDK to 30 for SSLParameters ALPN support
Browse files Browse the repository at this point in the history
  • Loading branch information
cconlon committed Aug 10, 2022
1 parent 364db70 commit fb43575
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 26 deletions.
1 change: 0 additions & 1 deletion IDE/Android/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions IDE/Android/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions IDE/Android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ project should be used for reference only.
Tool and version information used when testing this project:

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

The following sections outline steps required to run this example on an
Android device or emulator.
Expand Down
6 changes: 3 additions & 3 deletions IDE/Android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
compileSdkVersion 30
defaultConfig {
applicationId "com.example.wolfssl"
minSdkVersion 23
targetSdkVersion 28
minSdkVersion 30
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down
3 changes: 1 addition & 2 deletions IDE/Android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.wolfssl">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET"/>

<application
Expand All @@ -14,7 +14,6 @@
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Expand Down
40 changes: 28 additions & 12 deletions IDE/Android/app/src/main/java/com/example/wolfssl/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,22 @@

package com.example.wolfssl;

import android.content.Intent;
import android.net.Uri;
import android.os.Environment;
import android.provider.Settings;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.Manifest;
import android.content.pm.PackageManager;

import com.wolfssl.WolfSSL;
import com.wolfssl.WolfSSLException;
import com.wolfssl.provider.jsse.WolfSSLProvider;
import com.wolfssl.provider.jsse.WolfSSLX509;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.security.KeyStore;
import java.security.KeyStoreException;
Expand All @@ -48,25 +51,38 @@

public class MainActivity extends AppCompatActivity {

private View.OnClickListener buttonListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
TextView tv = (TextView) findViewById(R.id.sample_text);

try {
testLoadCert(tv);
} catch (Exception e) {
e.printStackTrace();
}
}
};

@Override
protected void onCreate(Bundle savedInstanceState) {
int permission;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(buttonListener);

TextView tv = (TextView) findViewById(R.id.sample_text);
tv.setText("wolfSSL JNI Android Studio Example App");


permission = checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE);
if (permission != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[] {Manifest.permission.READ_EXTERNAL_STORAGE},1);
}

try {
testLoadCert(tv);
} catch (Exception e) {
e.printStackTrace();
if (Environment.isExternalStorageManager()) {
} else {
Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
Uri uri = Uri.fromParts("package", getPackageName(), null);
intent.setData(uri);
startActivity(intent);
}
}

Expand Down
19 changes: 14 additions & 5 deletions IDE/Android/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Load Cert File" />

<TextView
android:id="@+id/sample_text"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:paddingVertical="16pt"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.461"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.067" />

</android.support.constraint.ConstraintLayout>

0 comments on commit fb43575

Please sign in to comment.