Skip to content

Commit a0ebe4f

Browse files
committed
v2.4.0
1 parent 58c71c1 commit a0ebe4f

26 files changed

+836
-159
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ allprojects {
2121
ext {
2222
compileSdkVersion = 28
2323
hwSdkIncludeAsSubmodule = false
24-
hwSdkVersionCode = 8
25-
hwSdkVersionName = '2.3.3'
24+
hwSdkVersionCode = 9
25+
hwSdkVersionName = '2.4.0'
2626
}

hwsecurity-fido/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ dependencies {
1111

1212
implementation 'de.cotech:nfc-sweetspot:1.1'
1313

14-
implementation 'com.jakewharton.timber:timber:4.7.0'
15-
1614
implementation 'com.google.android.material:material:1.0.0'
1715

1816
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

hwsecurity-fido/src/main/java/de/cotech/hw/fido/WebViewFidoBridge.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
import de.cotech.hw.fido.ui.FidoDialogFragment.OnFidoAuthenticateCallback;
5858
import de.cotech.hw.fido.ui.FidoDialogFragment.OnFidoRegisterCallback;
5959
import de.cotech.hw.fido.ui.FidoDialogOptions;
60-
import timber.log.Timber;
60+
import de.cotech.hw.util.HwTimber;
6161

6262

6363
@TargetApi(VERSION_CODES.LOLLIPOP)
@@ -113,11 +113,11 @@ public void sign(String requestJson) {
113113

114114
@SuppressWarnings("unused") // parity with WebViewClient.shouldInterceptRequest
115115
public void delegateShouldInterceptRequest(WebView view, WebResourceRequest request) {
116-
Timber.d("shouldInterceptRequest %s", request.getUrl());
116+
HwTimber.d("shouldInterceptRequest %s", request.getUrl());
117117

118118
if (loadingNewPage) {
119119
loadingNewPage = false;
120-
Timber.d("Scheduling fido bridge injection!");
120+
HwTimber.d("Scheduling fido bridge injection!");
121121
Handler handler = new Handler(context.getMainLooper());
122122
handler.postAtFrontOfQueue(this::injectJavascriptFidoBridge);
123123
}
@@ -134,7 +134,7 @@ public void delegateOnPageStarted(WebView view, String url, Bitmap favicon) {
134134
Uri uri = Uri.parse(url);
135135

136136
if (!"https".equalsIgnoreCase(uri.getScheme())) {
137-
Timber.e("Fido only supported for HTTPS websites!");
137+
HwTimber.e("Fido only supported for HTTPS websites!");
138138
return;
139139
}
140140

@@ -147,7 +147,7 @@ private void injectJavascriptFidoBridge() {
147147
String jsContent = AndroidUtils.loadTextFromAssets(context, ASSETS_BRIDGE_JS, Charset.defaultCharset());
148148
webView.evaluateJavascript("javascript:(" + jsContent + ")()", null);
149149
} catch (IOException e) {
150-
Timber.e(e);
150+
HwTimber.e(e);
151151
throw new IllegalStateException();
152152
}
153153
}
@@ -161,7 +161,7 @@ private void handleRegisterRequest(String requestJson) {
161161
try {
162162
u2fRegisterRequest = U2fJsonParser.parseU2fRegisterRequest(requestJson);
163163
} catch (IOException e) {
164-
Timber.e(e);
164+
HwTimber.e(e);
165165
return;
166166
}
167167
RequestData requestData = RequestData.create(u2fRegisterRequest.type(), u2fRegisterRequest.requestId());
@@ -173,7 +173,7 @@ private void handleRegisterRequest(String requestJson) {
173173

174174
showRegisterFragment(requestData, appId, challenge, u2fRegisterRequest.timeoutSeconds());
175175
} catch (IOException e) {
176-
Timber.e(e);
176+
HwTimber.e(e);
177177
handleError(requestData, ErrorCode.BAD_REQUEST);
178178
}
179179
}
@@ -201,13 +201,13 @@ public void onFidoRegisterResponse(@NonNull FidoRegisterResponse registerRespons
201201
public void onFidoRegisterCancel(@NonNull FidoRegisterRequest fidoRegisterRequest) {
202202
// Google's Authenticator does not return any error code when the user closes the activity
203203
// but we do
204-
Timber.d("onRegisterCancel");
204+
HwTimber.d("onRegisterCancel");
205205
handleError(fidoRegisterRequest.getCustomData(), ErrorCode.OTHER_ERROR);
206206
}
207207

208208
@Override
209209
public void onFidoRegisterTimeout(@NonNull FidoRegisterRequest fidoRegisterRequest) {
210-
Timber.d("onRegisterTimeout");
210+
HwTimber.d("onRegisterTimeout");
211211
handleError(fidoRegisterRequest.getCustomData(), ErrorCode.TIMEOUT);
212212
}
213213
};
@@ -221,7 +221,7 @@ private void handleSignRequest(String requestJson) {
221221
try {
222222
u2fAuthenticateRequest = U2fJsonParser.parseU2fAuthenticateRequest(requestJson);
223223
} catch (IOException e) {
224-
Timber.e(e);
224+
HwTimber.e(e);
225225
return;
226226
}
227227
RequestData requestData = RequestData.create(u2fAuthenticateRequest.type(), u2fAuthenticateRequest.requestId());
@@ -234,7 +234,7 @@ private void handleSignRequest(String requestJson) {
234234
showSignFragment(requestData, appId, keyHandles,
235235
u2fAuthenticateRequest.challenge(), u2fAuthenticateRequest.timeoutSeconds());
236236
} catch (IOException e) {
237-
Timber.e(e);
237+
HwTimber.e(e);
238238
handleError(requestData, ErrorCode.BAD_REQUEST);
239239
}
240240
}
@@ -253,7 +253,7 @@ private void showSignFragment(
253253
private OnFidoAuthenticateCallback fidoAuthenticateCallback = new OnFidoAuthenticateCallback() {
254254
@Override
255255
public void onFidoAuthenticateResponse(@NonNull FidoAuthenticateResponse authenticateResponse) {
256-
Timber.d("onAuthenticateResponse");
256+
HwTimber.d("onAuthenticateResponse");
257257
U2fResponse u2fResponse = U2fResponse.createAuthenticateResponse(
258258
authenticateResponse.<RequestData>getCustomData().getRequestId(),
259259
authenticateResponse.getClientData(),
@@ -266,13 +266,13 @@ public void onFidoAuthenticateResponse(@NonNull FidoAuthenticateResponse authent
266266
public void onFidoAuthenticateCancel(@NonNull FidoAuthenticateRequest fidoAuthenticateRequest) {
267267
// Google's Authenticator does not return any error code when the user closes the activity
268268
// but we do
269-
Timber.d("onAuthenticateCancel");
269+
HwTimber.d("onAuthenticateCancel");
270270
handleError(fidoAuthenticateRequest.getCustomData(), ErrorCode.OTHER_ERROR);
271271
}
272272

273273
@Override
274274
public void onFidoAuthenticateTimeout(@NonNull FidoAuthenticateRequest fidoAuthenticateRequest) {
275-
Timber.d("onAuthenticateTimeout");
275+
HwTimber.d("onAuthenticateTimeout");
276276
handleError(fidoAuthenticateRequest.getCustomData(), ErrorCode.TIMEOUT);
277277
}
278278
};

hwsecurity-fido/src/main/java/de/cotech/hw/fido/internal/FidoU2fAppletConnection.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
import de.cotech.hw.internal.transport.SecurityKeyInfo.TransportType;
4444
import de.cotech.hw.internal.transport.Transport;
4545
import de.cotech.hw.util.Hex;
46-
import timber.log.Timber;
46+
import de.cotech.hw.util.HwTimber;
4747

4848

4949
@RestrictTo(Scope.LIBRARY_GROUP)
@@ -55,7 +55,7 @@ public class FidoU2fAppletConnection {
5555
// see to "FIDO U2F NFC protocol", Section 5. Applet selection
5656
// https://fidoalliance.org/specs/fido-u2f-v1.2-ps-20170411/fido-u2f-nfc-protocol-v1.2-ps-20170411.html
5757
Hex.decodeHexOrFail("A0000006472F0001"),
58-
// Workaround for Solokey: https://github.com/solokeys/solo/issues/213
58+
// Workaround for Solokey for firmware < 2.4.0: https://github.com/solokeys/solo/issues/213
5959
Hex.decodeHexOrFail("A0000006472F000100"),
6060
// old Yubico demo applet AID
6161
Hex.decodeHexOrFail("A0000005271002")
@@ -90,12 +90,12 @@ public void connectIfNecessary() throws IOException {
9090
private void connectToDevice() throws IOException {
9191
try {
9292
if (transport.getTransportType() == TransportType.USB_U2FHID) {
93-
Timber.d("Using USB U2F HID as a transport. No need to select AID.");
93+
HwTimber.d("Using USB U2F HID as a transport. No need to select AID.");
9494
byte[] versionBytes = readVersion();
9595
checkVersionOrThrow(versionBytes);
9696
} else {
9797
byte[] selectedAid = selectFilesFromPrefixOrFail();
98-
Timber.d("Connected to AID %s", Hex.encodeHexString(selectedAid));
98+
HwTimber.d("Connected to AID %s", Hex.encodeHexString(selectedAid));
9999
}
100100

101101
isFidoAppletConnected = true;
@@ -119,9 +119,9 @@ private void checkVersionOrThrow(byte[] versionBytes) throws IOException {
119119
String version = new String(versionBytes, Charset.forName("ASCII"));
120120

121121
if ("U2F_V2".equals(version)) {
122-
Timber.d("U2F applet answered correctly with version U2F_V2");
122+
HwTimber.d("U2F applet answered correctly with version U2F_V2");
123123
} else {
124-
Timber.e("U2F applet did NOT answer with a correct version string!");
124+
HwTimber.e("U2F applet did NOT answer with a correct version string!");
125125
throw new IOException("Applet replied with incorrect version string!");
126126
}
127127
}
@@ -211,7 +211,7 @@ private ResponseApdu sendWithChaining(CommandApdu commandApdu) throws IOExceptio
211211
if (response.getSw() != WrongRequestLengthException.SW_WRONG_REQUEST_LENGTH) {
212212
return response;
213213
} else {
214-
Timber.d("Received WRONG_REQUEST_LENGTH error. Retrying with compatibility workaround");
214+
HwTimber.d("Received WRONG_REQUEST_LENGTH error. Retrying with compatibility workaround");
215215
}
216216
}
217217

hwsecurity-fido/src/main/java/de/cotech/hw/fido/internal/async/FidoAuthenticateOperationThread.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
import de.cotech.hw.fido.internal.operations.AuthenticateOp;
4646
import de.cotech.hw.util.HashUtil;
4747
import de.cotech.hw.util.Hex;
48-
import timber.log.Timber;
48+
import de.cotech.hw.util.HwTimber;
4949

5050

5151
@RestrictTo(Scope.LIBRARY_GROUP)
@@ -74,9 +74,9 @@ void prepareOperation() {
7474
challengeParam = HashUtil.sha256(authenticateRequest.getClientData());
7575
applicationParam = HashUtil.sha256(authenticateRequest.getAppId());
7676

77-
Timber.d("challenge param: %s", Hex.encodeHexString(challengeParam));
78-
Timber.d("application param: %s", Hex.encodeHexString(applicationParam));
79-
Timber.d("client data: %s", authenticateRequest.getClientData());
77+
HwTimber.d("challenge param: %s", Hex.encodeHexString(challengeParam));
78+
HwTimber.d("application param: %s", Hex.encodeHexString(applicationParam));
79+
HwTimber.d("client data: %s", authenticateRequest.getClientData());
8080
}
8181

8282
@Override
@@ -99,7 +99,7 @@ private FidoAuthenticateResponse attemptAuthWithAllKeyHandles() throws IOExcepti
9999
acceptedKeyHandle = keyHandle;
100100
throw e;
101101
} catch (WrongRequestLengthException e) {
102-
Timber.d("Received %s, treating as WRONG_DATA", e.getShortErrorName());
102+
HwTimber.d("Received %s, treating as WRONG_DATA", e.getShortErrorName());
103103
lastWrongKeyHandleException = e;
104104
} catch (FidoWrongKeyHandleException e) {
105105
lastWrongKeyHandleException = e;

hwsecurity-fido/src/main/java/de/cotech/hw/fido/internal/async/FidoOperationThread.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import de.cotech.hw.exceptions.TransportGoneException;
4040
import de.cotech.hw.fido.exceptions.FidoPresenceRequiredException;
4141
import de.cotech.hw.fido.internal.FidoU2fAppletConnection;
42-
import timber.log.Timber;
42+
import de.cotech.hw.util.HwTimber;
4343

4444

4545
@RestrictTo(Scope.LIBRARY_GROUP)
@@ -82,10 +82,10 @@ public void run() {
8282
postToHandler(() -> deliverResponse(response));
8383
break;
8484
} catch (InterruptedException e) {
85-
Timber.e("Fido operation was interrupted");
85+
HwTimber.e("Fido operation was interrupted");
8686
break;
8787
} catch (TransportGoneException e) {
88-
Timber.e("Transport gone during fido operation");
88+
HwTimber.e("Transport gone during fido operation");
8989
break;
9090
} catch (FidoPresenceRequiredException e) {
9191
try {
@@ -95,7 +95,7 @@ public void run() {
9595
}
9696
} catch (IOException e) {
9797
if (e.getCause() instanceof InterruptedException) {
98-
Timber.e("Fido operation was interrupted");
98+
HwTimber.e("Fido operation was interrupted");
9999
break;
100100
}
101101
postToHandler(() -> deliverIoException(e));

hwsecurity-fido/src/main/java/de/cotech/hw/fido/internal/async/FidoRegisterOperationThread.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import de.cotech.hw.fido.internal.operations.RegisterOp;
4242
import de.cotech.hw.util.HashUtil;
4343
import de.cotech.hw.util.Hex;
44-
import timber.log.Timber;
44+
import de.cotech.hw.util.HwTimber;
4545

4646

4747
@RestrictTo(Scope.LIBRARY_GROUP)
@@ -67,9 +67,9 @@ void prepareOperation() {
6767
challengeParam = HashUtil.sha256(registerRequest.getClientData());
6868
applicationParam = HashUtil.sha256(registerRequest.getAppId());
6969

70-
Timber.d("challenge param: %s", Hex.encodeHexString(challengeParam));
71-
Timber.d("application param: %s", Hex.encodeHexString(applicationParam));
72-
Timber.d("client data: %s", registerRequest.getClientData());
70+
HwTimber.d("challenge param: %s", Hex.encodeHexString(challengeParam));
71+
HwTimber.d("application param: %s", Hex.encodeHexString(applicationParam));
72+
HwTimber.d("client data: %s", registerRequest.getClientData());
7373
}
7474

7575
@Override

hwsecurity-fido/src/main/java/de/cotech/hw/fido/internal/jsapi/U2fApiUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import java.util.ArrayList;
3030
import java.util.List;
3131

32-
import timber.log.Timber;
32+
import de.cotech.hw.util.HwTimber;
3333

3434
public class U2fApiUtils {
3535
private static final String U2F_VERSION2 = "U2F_V2";
@@ -48,7 +48,7 @@ public static String pickChallengeForU2fV2(List<U2fRegisterRequest.RegisterReque
4848
throws IOException {
4949
for (U2fRegisterRequest.RegisterRequest request : registerRequests) {
5050
if (U2fApiUtils.U2F_VERSION2.equals(request.version())) {
51-
Timber.d("picking registerRequest: version=%s, challenge=%s", request.version(), request.challenge());
51+
HwTimber.d("picking registerRequest: version=%s, challenge=%s", request.version(), request.challenge());
5252
return request.challenge();
5353
}
5454
}

hwsecurity-fido/src/main/java/de/cotech/hw/fido/ui/FidoDialogFragment.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,11 @@
3535
import android.content.DialogInterface;
3636
import android.content.Intent;
3737
import android.content.pm.ActivityInfo;
38-
import android.graphics.drawable.Animatable;
3938
import android.graphics.drawable.Drawable;
4039
import android.nfc.TagLostException;
4140
import android.os.Build;
4241
import android.os.Bundle;
4342
import android.os.Handler;
44-
import android.os.Looper;
4543
import android.provider.Settings;
4644
import android.util.DisplayMetrics;
4745
import android.util.Pair;
@@ -72,7 +70,6 @@
7270
import androidx.transition.Transition;
7371
import androidx.transition.TransitionManager;
7472
import androidx.vectordrawable.graphics.drawable.Animatable2Compat;
75-
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat;
7673

7774
import com.google.android.material.bottomsheet.BottomSheetBehavior;
7875
import com.google.android.material.bottomsheet.BottomSheetDialog;
@@ -98,7 +95,7 @@
9895
import de.cotech.hw.fido.internal.AnimatedVectorDrawableHelper;
9996
import de.cotech.hw.util.NfcStatusObserver;
10097
import de.cotech.sweetspot.NfcSweetspotData;
101-
import timber.log.Timber;
98+
import de.cotech.hw.util.HwTimber;
10299

103100

104101
public class FidoDialogFragment extends BottomSheetDialogFragment implements SecurityKeyCallback<FidoSecurityKey> {
@@ -268,7 +265,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
268265

269266
if (fidoRegisterCallback == null && fidoAuthenticateCallback == null) {
270267
if (savedInstanceState != null) {
271-
Timber.e("Dismissing FidoDialogFragment left without callbacks after configuration change!");
268+
HwTimber.e("Dismissing FidoDialogFragment left without callbacks after configuration change!");
272269
dismiss();
273270
return;
274271
}
@@ -294,7 +291,7 @@ public void onDetach() {
294291
int keyboardChanges = ActivityInfo.CONFIG_KEYBOARD | ActivityInfo.CONFIG_KEYBOARD_HIDDEN;
295292
boolean isKeyboardConfigChange = (changingConfigurations & keyboardChanges) != 0;
296293
if (isKeyboardConfigChange) {
297-
Timber.e("Activity is recreated due to a keyboard config change, which may cause UI flickering!\n" +
294+
HwTimber.e("Activity is recreated due to a keyboard config change, which may cause UI flickering!\n" +
298295
"To fix this issue, the Activity's configChanges attribute " +
299296
"in AndroidManifest.xml should include keyboard|keyboardHidden");
300297
}
@@ -304,7 +301,7 @@ public void onDetach() {
304301
private void initTimeout(long timeoutSeconds) {
305302
final Handler handler = new Handler();
306303
handler.postDelayed(() -> {
307-
Timber.d("Timeout after %s seconds.", timeoutSeconds);
304+
HwTimber.d("Timeout after %s seconds.", timeoutSeconds);
308305

309306
textError.setText(R.string.hwsecurity_error_timeout);
310307
gotoState(State.ERROR);
@@ -640,7 +637,7 @@ public void onAnimationEnd(Drawable drawable) {
640637
private void fadeToNfcSweetSpot() {
641638
Pair<Double, Double> nfcPosition = NfcSweetspotData.getSweetspotForBuildModel();
642639
if (nfcPosition == null) {
643-
Timber.d("No NFC sweetspot data available for this model.");
640+
HwTimber.d("No NFC sweetspot data available for this model.");
644641
return;
645642
}
646643

@@ -830,7 +827,7 @@ public void onSecurityKeyDiscovered(@NonNull FidoSecurityKey securityKey) {
830827
break;
831828
}
832829
default: {
833-
Timber.d("onSecurityKeyDiscovered unhandled state: %s", currentState.name());
830+
HwTimber.d("onSecurityKeyDiscovered unhandled state: %s", currentState.name());
834831
}
835832
}
836833

@@ -875,14 +872,14 @@ public void onIoException(IOException e) {
875872

876873
@Override
877874
public void onSecurityKeyDisconnected(@NonNull FidoSecurityKey securityKey) {
878-
Timber.d("onSecurityKeyDisconnected");
875+
HwTimber.d("onSecurityKeyDisconnected");
879876

880877
switch (currentState) {
881878
case USB_PRESS_BUTTON:
882879
case USB_SELECT_AND_PRESS_BUTTON:
883880
gotoState(State.START);
884881
default:
885-
Timber.d("onSecurityKeyDisconnected unhandled state: %s", currentState.name());
882+
HwTimber.d("onSecurityKeyDisconnected unhandled state: %s", currentState.name());
886883
}
887884
}
888885

@@ -892,7 +889,7 @@ public void onSecurityKeyDiscoveryFailed(@NonNull IOException exception) {
892889
}
893890

894891
private void handleError(IOException exception) {
895-
Timber.d(exception);
892+
HwTimber.d(exception);
896893

897894
if (currentState == State.ERROR) {
898895
// keep stateBeforeError

0 commit comments

Comments
 (0)