Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/broadcast receiver for android 14 #5

Draft
wants to merge 14 commits into
base: 4.1-patched
Choose a base branch
from
12 changes: 7 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
buildscript {
repositories {
google()
jcenter()
gradlePluginPortal()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath 'org.jetbrains.dokka:dokka-android-gradle-plugin:0.9.17'
classpath 'com.android.tools.build:gradle:8.2.0'
classpath 'org.jetbrains.dokka:dokka-android-gradle-plugin:0.9.18'
}
}

allprojects {
repositories {
google()
jcenter()
gradlePluginPortal()
mavenCentral()
}
}

ext {
compileSdkVersion = 29
compileSdkVersion = 34
hwSdkVersionName = '4.1.0'
}
7 changes: 5 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true


android.useAndroidX=true
org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
kotlin.daemon.jvmargs=-Xmx4096m
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.configureondemand=true
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
80 changes: 15 additions & 65 deletions hwsecurity/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,33 @@ apply plugin: 'maven-publish'
apply plugin: 'org.jetbrains.dokka-android'

dependencies {
implementation 'androidx.lifecycle:lifecycle-runtime:2.2.0'
api("androidx.core:core-ktx:1.12.0")
api 'androidx.lifecycle:lifecycle-runtime:2.6.2'
api "androidx.appcompat:appcompat:1.6.1"

compileOnly 'androidx.annotation:annotation:1.1.0'
api "androidx.annotation:annotation-jvm:1.7.0"

api 'com.google.auto.value:auto-value-annotations:1.6.2'
annotationProcessor 'com.google.auto.value:auto-value:1.6.2'
annotationProcessor 'com.ryanharter.auto.value:auto-value-parcel:0.2.6'
api 'com.google.auto.value:auto-value-annotations:1.10.4'
annotationProcessor 'com.google.auto.value:auto-value:1.10.4'
annotationProcessor 'com.ryanharter.auto.value:auto-value-parcel:0.2.9'

testImplementation 'junit:junit:4.12'
testImplementation 'org.robolectric:robolectric:3.8'
testImplementation 'org.mockito:mockito-core:2.18.0'
api 'junit:junit:4.12'
api 'org.robolectric:robolectric:3.8'
api 'org.mockito:mockito-core:2.18.0'
}

android {
compileSdkVersion rootProject.ext.compileSdkVersion
namespace "de.cotech.hw.core"

defaultConfig {
minSdkVersion 14
compileSdk 34
minSdkVersion 24
versionName rootProject.ext.hwSdkVersionName
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

// Do not abort build if lint finds errors
Expand All @@ -35,59 +38,6 @@ android {
}
}

// https://developer.android.com/studio/build/maven-publish-plugin
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release

groupId = 'de.cotech'
artifactId = 'hwsecurity'
version = android.defaultConfig.versionName

pom {
url = 'https://hwsecurity.dev'
licenses {
license {
name = 'Commercial'
url = 'https://hwsecurity.dev/sales/'
distribution = 'repo'
}
license {
name = 'GNU General Public License, version 3'
url = 'https://www.gnu.org/licenses/gpl-3.0.txt'
}
}
organization {
name = 'Confidential Technologies GmbH'
url = 'https://www.cotech.de'
}
}
}
}
/*
* To upload release, create file gradle.properties in ~/.gradle/ with this content:
*
* cotechMavenName=xxx
* cotechMavenPassword=xxx
*/
if (project.hasProperty('cotechMavenName') && project.hasProperty('cotechMavenPassword')) {
println "Found cotechMavenName, cotechMavenPassword in gradle.properties!"

repositories {
maven {
credentials {
username cotechMavenName
password cotechMavenPassword
}
url = "https://maven.cotech.de"
}
}
}
}
}

dokka {
// uses locally built dokka extension
dokkaFatJar = files('libs/dokka-hugo-fatjar-0.9.17.jar')
Expand Down
3 changes: 1 addition & 2 deletions hwsecurity/core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.cotech.hw">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.NFC" />
<application />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public static SecurityKeyInfo create(TransportType transportType, SecurityKeyTyp
fingerprintList.add(fingerprint);
}
}

return new AutoValue_SecurityKeyInfo(
transportType, securityKeyType, fingerprintList, aid, userId, url, verifyRetries, verifyAdminRetries, hasLifeCycleSupport);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
package de.cotech.hw.internal.transport.usb;


import android.annotation.SuppressLint;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
Expand All @@ -33,11 +34,14 @@
import android.content.pm.PackageManager;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbManager;
import android.os.Build;

import androidx.annotation.AnyThread;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.annotation.UiThread;
import androidx.core.content.ContextCompat;

import de.cotech.hw.util.HwTimber;


Expand Down Expand Up @@ -108,9 +112,14 @@ private boolean handleConnectedUsbDevice(UsbDevice usbDevice, boolean requestPer
return false;
}

@SuppressLint("UnspecifiedRegisterReceiverFlag")
@UiThread
public void onResume() {
context.registerReceiver(usbBroadcastReceiver, intentFilter);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
context.registerReceiver(usbBroadcastReceiver, intentFilter, Context.RECEIVER_NOT_EXPORTED);
} else {
context.registerReceiver(usbBroadcastReceiver, intentFilter);
}
}

@UiThread
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,13 @@ public void onReceive(Context context, Intent intent) {
};
}
IntentFilter filter = new IntentFilter(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED);
context.registerReceiver(nfcStateBroadcastReceiver, filter);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
context.registerReceiver(nfcStateBroadcastReceiver, filter, Context.RECEIVER_NOT_EXPORTED);
} else {
context.registerReceiver(nfcStateBroadcastReceiver, filter);
}
}

@TargetApi(VERSION_CODES.JELLY_BEAN_MR2)
private void unregisterNfcStateBroadcastListener() {
context.unregisterReceiver(nfcStateBroadcastReceiver);
}
Expand Down
77 changes: 7 additions & 70 deletions hwsecurity/fido/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,23 @@ apply plugin: 'maven-publish'
apply plugin: 'org.jetbrains.dokka-android'

dependencies {
api project(':hwsecurity:core')
api project(':hwsecurity:ui')

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

api 'com.google.auto.value:auto-value-annotations:1.6.2'
annotationProcessor 'com.google.auto.value:auto-value:1.6.2'
annotationProcessor 'com.ryanharter.auto.value:auto-value-parcel:0.2.6'

testImplementation 'junit:junit:4.12'
testImplementation 'org.robolectric:robolectric:3.8'
testImplementation 'org.mockito:mockito-core:2.18.0'
implementation project(':hwsecurity:core')
implementation project(':hwsecurity:ui')
}

android {
compileSdkVersion rootProject.ext.compileSdkVersion
namespace "de.cotech.hw.fido"

defaultConfig {
minSdkVersion 14
compileSdk 34
minSdkVersion 24
versionName rootProject.ext.hwSdkVersionName
vectorDrawables.useSupportLibrary = true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

// Do not abort build if lint finds errors
Expand All @@ -39,58 +28,6 @@ android {
}
}

// https://developer.android.com/studio/build/maven-publish-plugin
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release

groupId = 'de.cotech'
artifactId = 'hwsecurity-fido'
version = android.defaultConfig.versionName

pom {
url = 'https://hwsecurity.dev'
licenses {
license {
name = 'Commercial'
url = 'https://hwsecurity.dev/sales/'
distribution = 'repo'
}
license {
name = 'GNU General Public License, version 3'
url = 'https://www.gnu.org/licenses/gpl-3.0.txt'
}
}
organization {
name = 'Confidential Technologies GmbH'
url = 'https://www.cotech.de'
}
}
}
}
/*
* To upload release, create file gradle.properties in ~/.gradle/ with this content:
*
* cotechMavenName=xxx
* cotechMavenPassword=xxx
*/
if (project.hasProperty('cotechMavenName') && project.hasProperty('cotechMavenPassword')) {
println "Found cotechMavenName, cotechMavenPassword in gradle.properties!"

repositories {
maven {
credentials {
username cotechMavenName
password cotechMavenPassword
}
url = "https://maven.cotech.de"
}
}
}
}
}

dokka {
moduleName = 'hwsecurity-fido'
Expand Down
Loading