hwsecurity / de.cotech.hw.util

Package de.cotech.hw.util

Types

Name Summary
Arrays

class Arrays

General array utilities.

HashUtil open class HashUtil
Hex

open class Hex

Converts hexadecimal Strings. This class is thread-safe.

HwTimber

class HwTimber

Last Java version of Timber from https://github.com/JakeWharton/timber/blob/0b84566c667a9b9d0559787ea28417e75377cd38/timber/src/main/java/timber/log/Timber.java

NfcStatusObserver

open class NfcStatusObserver : LifecycleObserver

A helper class to monitor whether NFC hardware is available and enabled.

Note that this class does not communicate with the NFC device on its own - its only purpose is to tell when NFC functionality is available, and has been enabled or disabled!

Example:

public class NfcActionActivity extends AppCompatActivity {
      private NfcStatusObserver nfcStatusObserver;
 
      
      protected void onCreate(@Nullable Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
 
          if (!SecurityKeyManager.getInstance().isNfcHardwareAvailable()) {
              startActivityToNicelyTellUserThatNfcHardwareIsUnavailable();
              finish();
              return;
          }
 
          this.nfcStatusObserver = new NfcStatusObserver((Context) this, (LifecycleOwner) this,
                  nfcEnabled -> showOrHideNfcDisabledView(nfcEnabled));
 
          // this button should be part of the "nfc disabled view"
          View buttonPleaseEnableNfc = findViewById(R.id.buttonPleaseEnableNfc);
          buttonPleaseEnableNfc.setOnClickListener(v -> startAndroidNfcConfigActivityWithHint());
      }
 
      private void startAndroidNfcConfigActivityWithHint() {
          Toast.makeText(getApplicationContext(),
                  "Please activate NFC and press Back to return to MyApplication", Toast.LENGTH_SHORT).show();
          startActivity(new Intent(android.provider.Settings.ACTION_NFC_SETTINGS));
      }
 
      
      protected void onResume() {
          super.onResume();
          // In case we missed a change while the activity was in the background
          showOrHideNfcDisabledView(nfcStatusObserver.isNfcEnabled());
      }
  }