-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apollo: Release source code for 52.5
- Loading branch information
Showing
19 changed files
with
258 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
android/apollo/src/main/java/io/muun/apollo/data/os/NfcProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package io.muun.apollo.data.os | ||
|
||
import android.content.Context | ||
import android.content.pm.PackageManager | ||
import android.nfc.NfcAdapter | ||
import timber.log.Timber | ||
import javax.inject.Inject | ||
|
||
class NfcProvider @Inject constructor(private val context: Context) { | ||
|
||
// We could use getSystemService(Context.NFC_SERVICE) as? NfcManager but it's just a wrapper | ||
// of this. | ||
private val nfcAdapter: NfcAdapter? = try { | ||
NfcAdapter.getDefaultAdapter(context) | ||
} catch (e: Throwable) { | ||
null | ||
} | ||
|
||
fun hasNfcFeature(): Boolean { | ||
val packageManager = context.packageManager | ||
return packageManager.hasSystemFeature(PackageManager.FEATURE_NFC) | ||
} | ||
|
||
val hasNfcAdapter: Boolean | ||
get() = nfcAdapter != null | ||
|
||
val isNfcEnabled: Boolean | ||
get() = nfcAdapter != null && nfcAdapter.isEnabled | ||
|
||
fun getNfcAntennaPosition(): List<Pair<Float, Float>> { | ||
val result = mutableListOf<Pair<Float, Float>>() | ||
|
||
try { | ||
if (OS.supportsAvailableNfcAntennas()) { | ||
val antennas = nfcAdapter?.nfcAntennaInfo?.availableNfcAntennas.orEmpty() | ||
for (antenna in antennas) { | ||
result.add(Pair(antenna.locationX.toFloat(), antenna.locationY.toFloat())) | ||
} | ||
} | ||
} catch (e: Exception) { | ||
Timber.i("Error while reading NFC data from NFC compat device: ${e.message}") | ||
} | ||
|
||
return result | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
android/apollo/src/main/java/io/muun/apollo/domain/errors/data/MuunSerializationError.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.muun.apollo.domain.errors.data | ||
|
||
import io.muun.apollo.domain.errors.MuunError | ||
import io.muun.common.exception.PotentialBug | ||
import okhttp3.Request | ||
|
||
class MuunSerializationError( | ||
supportId: String, | ||
originalRequest: Request, | ||
cause: Throwable, | ||
) : MuunError(cause), PotentialBug { | ||
|
||
init { | ||
metadata["supportId"] = supportId | ||
metadata["request"] = originalRequest.url().uri().toString() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.