Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1253ebc7 authored by Martijn Coenen's avatar Martijn Coenen
Browse files

Fixed NfcAdapter init and getTechnology().

- GetTechnology() used a binary search, but the array was linked to another
  array (extras) which was not sorted. So made it linear.
- The tag technologies were instantiated with a null NfcAdapter.

Change-Id: Iae15169a89155c3a5c9f81824f809d6010ebac01
parent 90245641
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -71,7 +71,6 @@ public class Tag implements Parcelable {
        }
        mId = id;
        mTechList = Arrays.copyOf(techList, techList.length);
        Arrays.sort(mTechList);
        // Ensure mTechExtras is as long as mTechList
        mTechExtras = Arrays.copyOf(techListExtras, techList.length);
        mServiceHandle = serviceHandle;
@@ -122,13 +121,19 @@ public class Tag implements Parcelable {
     * Returns the technology, or null if not present
     */
    public TagTechnology getTechnology(int tech) {
        int pos = Arrays.binarySearch(mTechList, tech);
        int pos = -1;
        for (int idx = 0; idx < mTechList.length; idx++) {
          if (mTechList[idx] == tech) {
              pos = idx;
              break;
          }
        }
        if (pos < 0) {
            return null;
        }

        Bundle extras = mTechExtras[pos];
        NfcAdapter adapter = null;
        NfcAdapter adapter = NfcAdapter.getDefaultAdapter();
        try {
            switch (tech) {
                case TagTechnology.NFC_A: {
+5 −1
Original line number Diff line number Diff line
@@ -63,7 +63,11 @@ import android.util.Log;

        mAdapter = adapter;
        mService = mAdapter.getService();
        try {
          mTagService = mService.getNfcTagInterface();
        } catch (RemoteException e) {
            attemptDeadServiceRecovery(e);
        }
        mTag = tag;
        mSelectedTechnology = tech;
    }