Skip to content

Commit a6ecb48

Browse files
authored
Merge pull request #97 from marnberg/twoAuth
Update sample to Android 12 and fixes conclave problem
2 parents fbe5c87 + 32379ba commit a6ecb48

5 files changed

Lines changed: 40 additions & 14 deletions

File tree

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
author: Tony Myles
33
title: "AferoJavaSDK"
4-
date: 2022-Feb-28
5-
status: 1.5.0
4+
date: 2022-March-10
5+
status: 1.5.1
66
---
77

88
# AferoJavaSDK
@@ -32,24 +32,24 @@ The SDK is composed of four separate modules.
3232

3333
The `afero-sdk-core` module is required for base functionality such as interacting with the Afero Cloud and manipulating devices.
3434
```Gradle
35-
implementation 'io.afero.sdk:afero-sdk-core:1.5.0'
35+
implementation 'io.afero.sdk:afero-sdk-core:1.5.1'
3636
```
3737

3838
The `afero-sdk-client-retrofit2` module provides an optional implementation of the AferoClient REST API interface using [Retrofit2](http://square.github.io/retrofit/) and [okhttp3](http://square.github.io/okhttp/). If you choose not to include this module in your project, you will need to develop your own implementation of AferoClient using your preferred http client library.
3939

4040
```Gradle
41-
implementation 'io.afero.sdk:afero-sdk-client-retrofit2:1.5.0'
41+
implementation 'io.afero.sdk:afero-sdk-client-retrofit2:1.5.1'
4242
```
4343

4444
The `afero-sdk-android` module is required for Android development.
4545
```Gradle
46-
implementation 'io.afero.sdk:afero-sdk-android:1.5.0'
46+
implementation 'io.afero.sdk:afero-sdk-android:1.5.1'
4747
```
4848

4949
The `afero-sdk-softhub` module is required for soft hub functionality on Android.
5050
```Gradle
51-
implementation 'io.afero.sdk:afero-sdk-softhub:1.5.0'
52-
implementation "io.afero.sdk:hubby:1.0.844@aar"
51+
implementation 'io.afero.sdk:afero-sdk-softhub:1.5.1'
52+
implementation "io.afero.sdk:hubby:1.0.957@aar"
5353
```
5454

5555
## License

afero-sdk-core/src/main/java/io/afero/sdk/device/DeviceCollection.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,10 @@ public void call(Throwable t) {
523523
@Override
524524
public void call(InvalidateMessage im) {
525525
try {
526+
if (im.deviceId == null) {
527+
AfLog.e("Got invalidate without deviceId");
528+
return;
529+
}
526530
DeviceModel deviceModel = getDevice(im.deviceId);
527531
if (deviceModel == null) {
528532
AfLog.e("Got invalidate on unknown deviceId: " + im.deviceId);

samples/afero-lab/app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
apply plugin: 'com.android.application'
66

77
final String sdkRepoKey = project.findProperty('aferoSDKConsumeRepoKey') ?: 'afero-java-sdk'
8-
final String sdkVersion = project.findProperty('aferoSDKVersion') ?: '1.5.0'
8+
final String sdkVersion = project.findProperty('aferoSDKVersion') ?: '1.5.1'
99

1010
repositories {
1111
maven {
@@ -31,12 +31,12 @@ configurations.all {
3131

3232

3333
android {
34-
compileSdkVersion 30
34+
compileSdkVersion 32
3535

3636
defaultConfig {
3737
applicationId 'io.afero.aferolab'
3838
minSdkVersion 26
39-
targetSdkVersion 30
39+
targetSdkVersion 32
4040

4141
versionCode 1
4242
versionName '1.0'

samples/afero-lab/app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
1313
<uses-permission android:name="android.permission.CAMERA"/>
1414

15+
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
16+
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
17+
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
18+
1519
<application
1620
android:allowBackup="false"
1721
android:icon="@mipmap/sdk_app_icon_android"
@@ -24,7 +28,8 @@
2428
android:name=".MainActivity"
2529
android:configChanges="orientation|screenSize"
2630
android:launchMode="singleTop"
27-
android:windowSoftInputMode="adjustResize">
31+
android:windowSoftInputMode="adjustResize"
32+
android:exported="true">
2833

2934
<intent-filter>
3035
<action android:name="android.intent.action.MAIN"/>
@@ -34,7 +39,7 @@
3439
<activity
3540
android:name="net.openid.appauth.RedirectUriReceiverActivity"
3641
tools:node="replace"
37-
>
42+
android:exported="true">
3843
<intent-filter>
3944
<action android:name="android.intent.action.VIEW" />
4045
<category android:name="android.intent.category.DEFAULT" />

samples/afero-lab/app/src/main/java/io/afero/aferolab/helper/PermissionsHelper.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,16 @@ public class PermissionsHelper {
2222

2323
// See http://developer.radiusnetworks.com/2015/09/29/is-your-beacon-app-ready-for-android-6.html
2424
public static void checkRequiredPermissions(Activity activity) {
25-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
25+
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
26+
boolean hasCamera = activity.checkSelfPermission(Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED;
27+
boolean hasBluetooth = activity.checkSelfPermission(Manifest.permission.BLUETOOTH_CONNECT) == PackageManager.PERMISSION_GRANTED;
28+
29+
if (!hasCamera || !hasBluetooth) {
30+
askUserForAllPermissions(activity);
31+
} else {
32+
AfLog.d("checkRequiredPermissions: permissions granted");
33+
}
34+
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
2635
// Android M Permission check
2736
boolean hasLocation = activity.checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED;
2837
boolean hasCamera = activity.checkSelfPermission(Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED;
@@ -42,7 +51,15 @@ private static void askUserForAllPermissions(final Activity activity) {
4251
builder.setPositiveButton(android.R.string.ok, null);
4352
builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
4453
public void onDismiss(DialogInterface dialog) {
45-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
54+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
55+
activity.requestPermissions(
56+
new String[]{
57+
Manifest.permission.BLUETOOTH_SCAN,
58+
Manifest.permission.BLUETOOTH_CONNECT,
59+
Manifest.permission.CAMERA
60+
},
61+
PERMISSION_REQUEST_ALL);
62+
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
4663
activity.requestPermissions(
4764
new String[]{
4865
Manifest.permission.ACCESS_FINE_LOCATION,

0 commit comments

Comments
 (0)