From e4fd3bb73928db1ba54af2700c385e7202721cd8 Mon Sep 17 00:00:00 2001 From: Justin Stephenson Date: Fri, 9 Dec 2022 11:41:41 -0500 Subject: [PATCH] Log: Add basic "info" level logging --- mobile/src/main/java/org/fedorahosted/freeotp/Token.java | 2 ++ .../main/java/org/fedorahosted/freeotp/main/Activity.java | 2 ++ .../main/java/org/fedorahosted/freeotp/main/Adapter.java | 6 +++++- .../main/java/org/fedorahosted/freeotp/main/ViewHolder.java | 6 ++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/mobile/src/main/java/org/fedorahosted/freeotp/Token.java b/mobile/src/main/java/org/fedorahosted/freeotp/Token.java index 941cbfd7..6dd5d541 100644 --- a/mobile/src/main/java/org/fedorahosted/freeotp/Token.java +++ b/mobile/src/main/java/org/fedorahosted/freeotp/Token.java @@ -21,6 +21,7 @@ package org.fedorahosted.freeotp; import android.net.Uri; +import android.util.Log; import android.util.Pair; import com.google.gson.Gson; @@ -338,6 +339,7 @@ public Code getCode(Key key) throws InvalidKeyException { Mac mac; // Prepare the input. + Log.i("Token", String.format("token.GetCode(): prepare input")); ByteBuffer bb = ByteBuffer.allocate(8); bb.order(ByteOrder.BIG_ENDIAN); switch (mType) { diff --git a/mobile/src/main/java/org/fedorahosted/freeotp/main/Activity.java b/mobile/src/main/java/org/fedorahosted/freeotp/main/Activity.java index ed28dfc0..4d93cfa2 100644 --- a/mobile/src/main/java/org/fedorahosted/freeotp/main/Activity.java +++ b/mobile/src/main/java/org/fedorahosted/freeotp/main/Activity.java @@ -133,6 +133,7 @@ public void onItemRangeRemoved(int positionStart, int itemCount) { private void onActivate(ViewHolder vh) { try { + Log.i(LOGTAG, String.format("onActivate: adapter.getCode()")); Code code = mTokenAdapter.getCode(vh.getAdapterPosition()); if (mSettings.getBoolean(AUTO_COPY_CLIPBOARD, false)) { ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); @@ -141,6 +142,7 @@ private void onActivate(ViewHolder vh) { } Token.Type type = mTokenAdapter.getTokenType(vh.getAdapterPosition()); + Log.i(LOGTAG, String.format("onActivate: vh.displayCode()")); vh.displayCode(code, type); } catch (UserNotAuthenticatedException e) { diff --git a/mobile/src/main/java/org/fedorahosted/freeotp/main/Adapter.java b/mobile/src/main/java/org/fedorahosted/freeotp/main/Adapter.java index c832fba2..8cb5c5bf 100644 --- a/mobile/src/main/java/org/fedorahosted/freeotp/main/Adapter.java +++ b/mobile/src/main/java/org/fedorahosted/freeotp/main/Adapter.java @@ -168,6 +168,7 @@ public void onBindViewHolder(@NonNull final ViewHolder holder, int position) { Token token = Token.deserialize(mSharedPreferences.getString(uuid, null)); TokenIcon token_icon = new TokenIcon(token, mContext); Pair image = token_icon.mImage; + Log.i(LOGTAG, String.format("Bind to view token [%s][%s]", token.getIssuer(), token.getLabel())); holder.bind(token, token_icon.mColor, image.first, image.second, mActive.get(getItemId(position)), isSelected(position), token.getType()); } @@ -216,7 +217,6 @@ private int add(SecretKey key, Token token, boolean lock, String existingUuid) t } Log.i(LOGTAG, String.format("Token added uuid [%s]", uuid)); - this.notifyItemInserted(mItems.size() - 1); return mItems.size() - 1; } @@ -280,11 +280,13 @@ public Code getCode(int position) Code code; try { + Log.i(LOGTAG, String.format("getCode: deserialize token")); Token token = Token.deserialize(mSharedPreferences.getString(uuid, null)); Key key = mKeyStore.getKey(uuid, null); code = token.getCode(key); mSharedPreferences.edit().putString(uuid, token.serialize()).apply(); } catch (UserNotAuthenticatedException | KeyPermanentlyInvalidatedException e) { + Log.e(LOGTAG, "Exception", e); throw e; } catch (GeneralSecurityException e) { Log.e(LOGTAG, "Exception", e); @@ -307,6 +309,8 @@ public void run() { } }, code.timeLeft()); + Log.i(LOGTAG, String.format("getCode: returning code")); + return code; } diff --git a/mobile/src/main/java/org/fedorahosted/freeotp/main/ViewHolder.java b/mobile/src/main/java/org/fedorahosted/freeotp/main/ViewHolder.java index 4927de2b..0444121d 100644 --- a/mobile/src/main/java/org/fedorahosted/freeotp/main/ViewHolder.java +++ b/mobile/src/main/java/org/fedorahosted/freeotp/main/ViewHolder.java @@ -23,6 +23,7 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; +import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.view.animation.AccelerateDecelerateInterpolator; @@ -48,6 +49,7 @@ interface EventListener { void onActivated(ViewHolder holder); void onShare(String code); } + private static final String LOGTAG = "Adapter"; private EventListener mEventListener; private ObjectAnimator mCountdown; @@ -123,6 +125,7 @@ private void displayCode(Code code, Token.Type type, int animationDuration) { return; String text = code.getCode(); + Log.i(LOGTAG, String.format("displaying Code")); /* Add spaces for readability */ for (int segment : new int[] { 7, 5, 4, 3 }) { if (text.length() % segment != 0) @@ -191,13 +194,16 @@ public void onAnimationCancel(Animator animation) { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); + /* Fade in */ + Log.i(LOGTAG, String.format("onAnimationStart: fade")); fade(mPassive, false, 500); fade(mActive, true, 500); } @Override public void onAnimationEnd(Animator animation) { + Log.i(LOGTAG, String.format("onAnimationEnd: fade")); /* Fade out */ fade(mPassive, true, 500); fade(mActive, false, 500);