Skip to content

Commit

Permalink
Collection of miscellaneous cleanups (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdlaver authored Nov 14, 2024
1 parent 1e98217 commit 98e6d55
Show file tree
Hide file tree
Showing 32 changed files with 138 additions and 24 deletions.
2 changes: 0 additions & 2 deletions SeedVaultSimulator/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,10 @@
android:authorities="com.solanamobile.seedvault.wallet.v1.walletprovider"
android:exported="true"
android:syncable="false">
<!--suppress AndroidElementNotAllowed -->
<path-permission
android:pathPrefix="/"
android:permission="com.solanamobile.seedvault.ACCESS_SEED_VAULT"
tools:ignore="InvalidPermission" />
<!--suppress AndroidElementNotAllowed -->
<path-permission
android:pathPrefix="/"
android:permission="com.solanamobile.seedvault.ACCESS_SEED_VAULT_PRIVILEGED"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<!--
~ Copyright (c) 2024 Solana Mobile Inc.
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<!--
~ Copyright (c) 2024 Solana Mobile Inc.
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2024 Solana Mobile Inc.
-->

<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2024 Solana Mobile Inc.
-->

<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground_debug"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2024 Solana Mobile Inc.
-->

<resources>
<color name="ic_launcher_background">#6B82FF</color>
</resources>
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
* Copyright (c) 2024 Solana Mobile Inc.
*/

package com.solanamobile.seedvault.cts.data.tests

import android.content.Context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ import dagger.hilt.android.components.ActivityRetainedComponent
internal object TestCorpusProvider {
@Provides
fun provideTestCorpus(
noPermissionsContentProviderCheck: NoPermissionsContentProviderCheck,
acquireSeedVaultPermissionTestCase: AcquireSeedVaultPermissionTestCase,
acquireSeedVaultPrivilegedPermissionTestCase: AcquireSeedVaultPrivilegedPermissionTestCase,
authorizeSeed12SagaTestCase: AuthorizeSeed12SagaTestCase,
authorizeSeed24SagaTestCase: AuthorizeSeed24SagaTestCase,
cannotShowSeedSettingsTestCase: CannotShowSeedSettingsTestCase,
createNewSeedTestCase: CreateNewSeedTestCase,
deauthorizeSeed12TestCase: DeauthorizeSeed12TestCase,
deauthorizeSeed24TestCase: DeauthorizeSeed24TestCase,
denySignTransactionTestCase: DenySignTransactionTestCase,
permissionedAccountFetchPubKeysTestCase: PermissionedAccountFetchPubKeysTestCase,
fetch10PubKeyTestCase: Fetch10PubKeyTestCase,
fetch11PubKeyTestCase: Fetch11PubKeyTestCase,
fetch1PubKeyTestCase: Fetch1PubKeyTestCase,
Expand All @@ -37,8 +38,9 @@ internal object TestCorpusProvider {
incorrectPinSignTransactionFailureTestCase: IncorrectPinSignTransactionFailureTestCase,
initialConditionsTestCase: InitialConditionsTestCase,
noAuthorizedSeedsContentProviderTestCase: NoAuthorizedSeedsContentProviderTestCase,
noPermissionsContentProviderCheck: NoPermissionsContentProviderCheck,
noUnauthorizedSeedsContentProviderTestCase: NoUnauthorizedSeedsContentProviderTestCase,
authorizeSeed12SagaTestCase: AuthorizeSeed12SagaTestCase,
permissionedAccountFetchPubKeysTestCase: PermissionedAccountFetchPubKeysTestCase,
reauthorizeSeed12TestCase: ReauthorizeSeed12TestCase,
seed12AccountsContentProviderTestCase: KnownSeed12AccountsContentProviderTestCase,
seed24AccountsContentProviderTestCase: KnownSeed24AccountsContentProviderTestCase,
Expand All @@ -47,8 +49,6 @@ internal object TestCorpusProvider {
signMaxTransactionWithMaxSignatureTestCase: SignMaxTransactionWithMaxSignatureTestCase,
signatureRequestsExceedLimitTestCase: SignatureRequestsExceedLimitTestCase,
signingRequestsExceedLimitTestCase: SigningRequestsExceedLimitTestCase,
deauthorizeSeed24TestCase: DeauthorizeSeed24TestCase,
authorizeSeed24SagaTestCase: AuthorizeSeed24SagaTestCase,
logger: TestSessionLogger,
sagaChecker: SagaChecker,
): TestCorpus {
Expand Down
4 changes: 4 additions & 0 deletions cts/src/main/res/drawable/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2024 Solana Mobile Inc.
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
Expand Down
4 changes: 4 additions & 0 deletions cts/src/main/res/drawable/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<!--
~ Copyright (c) 2024 Solana Mobile Inc.
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
Expand Down
4 changes: 4 additions & 0 deletions cts/src/main/res/mipmap-anydpi/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2024 Solana Mobile Inc.
-->

<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
Expand Down
4 changes: 4 additions & 0 deletions cts/src/main/res/mipmap-anydpi/ic_launcher_round.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2024 Solana Mobile Inc.
-->

<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
Expand Down
4 changes: 4 additions & 0 deletions cts/src/main/res/xml/provider_paths.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2024 Solana Mobile Inc.
-->

<paths>
<files-path name="files" path="/"/>
</paths>
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
* Copyright (c) 2024 Solana Mobile Inc.
*/

package com.solanamobile.fakewallet.ui

import android.content.Intent
Expand Down
4 changes: 4 additions & 0 deletions fakewallet/src/main/res/drawable/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<!--
~ Copyright (c) 2024 Solana Mobile Inc.
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<!--
~ Copyright (c) 2024 Solana Mobile Inc.
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
Expand Down
4 changes: 4 additions & 0 deletions fakewallet/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2024 Solana Mobile Inc.
-->

<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2024 Solana Mobile Inc.
-->

<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground_debug"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2024 Solana Mobile Inc.
-->

<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
Expand Down
4 changes: 4 additions & 0 deletions fakewallet/src/main/res/values/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2024 Solana Mobile Inc.
-->

<resources>
<color name="ic_launcher_background">#FF75BD</color>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public static Bip32DerivationPath fromUri(@NonNull Uri bip32Uri) {
throw new UnsupportedOperationException("BIP32 URI must be hierarchical");
}

if (bip32Uri.isAbsolute() && !bip32Uri.getScheme().equals(WalletContractV1.BIP32_URI_SCHEME)) {
if (bip32Uri.isAbsolute() && !WalletContractV1.BIP32_URI_SCHEME.equals(bip32Uri.getScheme())) {
throw new UnsupportedOperationException("BIP32 URI absolute scheme must be " + WalletContractV1.BIP32_URI_SCHEME);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public static Bip44DerivationPath fromUri(@NonNull Uri bip44Uri) {
throw new UnsupportedOperationException("BIP44 URI must be hierarchical");
}

if (!bip44Uri.isAbsolute() || !bip44Uri.getScheme().equals(WalletContractV1.BIP44_URI_SCHEME)) {
if (!bip44Uri.isAbsolute() || !WalletContractV1.BIP44_URI_SCHEME.equals(bip44Uri.getScheme())) {
throw new UnsupportedOperationException("BIP44 URI must be absolute with scheme " + WalletContractV1.BIP44_URI_SCHEME);
}

Expand All @@ -211,7 +211,8 @@ public static Bip44DerivationPath fromUri(@NonNull Uri bip44Uri) {
}

final List<String> path = bip44Uri.getPathSegments();
if (path.size() < 1 || path.size() > 3) {
final int pathLength = path.size();
if (pathLength < 1 || pathLength > 3) {
throw new UnsupportedOperationException("BIP44 URI path must contain between 1 and 3 elements");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ protected BipDerivationPath() {}
@NonNull
public static BipDerivationPath fromUri(@NonNull Uri bipUri) {
final String scheme = bipUri.getScheme();
if (scheme.equals(WalletContractV1.BIP32_URI_SCHEME)) {
if (WalletContractV1.BIP32_URI_SCHEME.equals(scheme)) {
return Bip32DerivationPath.fromUri(bipUri);
} else if (scheme.equals(WalletContractV1.BIP44_URI_SCHEME)) {
} else if (WalletContractV1.BIP44_URI_SCHEME.equals(scheme)) {
return Bip44DerivationPath.fromUri(bipUri);
} else {
throw new UnsupportedOperationException("Unknown BIP derivation URI scheme '" + scheme + "'");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ public PublicKeyResponse(@Nullable byte[] publicKey,
protected PublicKeyResponse(Parcel in) {
mPublicKey = in.createByteArray();
mPublicKeyEncoded = in.readString();
resolvedDerivationPath = in.readTypedObject(Uri.CREATOR);
final Uri rdp = in.readTypedObject(Uri.CREATOR);
if (rdp != null) {
resolvedDerivationPath = rdp;
} else {
resolvedDerivationPath = Uri.EMPTY;
}
}

@Override
Expand All @@ -87,7 +92,7 @@ public int describeContents() {
return 0;
}

public static final Creator<PublicKeyResponse> CREATOR = new Creator<PublicKeyResponse>() {
public static final Creator<PublicKeyResponse> CREATOR = new Creator<>() {
@Override
public PublicKeyResponse createFromParcel(Parcel in) {
return new PublicKeyResponse(in);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
* Copyright (c) 2024 Solana Mobile Inc.
*/

package com.solanamobile.seedvault;

import static android.content.pm.PermissionInfo.PROTECTION_FLAG_PRIVILEGED;
Expand Down Expand Up @@ -93,9 +97,11 @@ public static boolean isAvailable(@NonNull Context context, boolean allowSimulat
return true;
}

for (PermissionInfo permission : pi.permissions) {
if (WalletContractV1.PERMISSION_SEED_VAULT_IMPL.equals(permission.name)) {
return hasPrivilegedProtectionFlag(permission);
if (pi.permissions != null) {
for (PermissionInfo permission : pi.permissions) {
if (WalletContractV1.PERMISSION_SEED_VAULT_IMPL.equals(permission.name)) {
return hasPrivilegedProtectionFlag(permission);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,19 @@ public SigningRequest(@NonNull byte[] payload, @NonNull List<Uri> requestedSigna
}

protected SigningRequest(Parcel in) {
payload = in.createByteArray();
mRequestedSignatures = in.createTypedArrayList(Uri.CREATOR);
final byte[] p = in.createByteArray();
if (p != null) {
payload = p;
} else {
payload = new byte[0];
}

final ArrayList<Uri> rs = in.createTypedArrayList(Uri.CREATOR);
if (rs != null) {
mRequestedSignatures = rs;
} else {
mRequestedSignatures = new ArrayList<>();
}
}

@Override
Expand All @@ -59,7 +70,7 @@ public int describeContents() {
return 0;
}

public static final Creator<SigningRequest> CREATOR = new Creator<SigningRequest>() {
public static final Creator<SigningRequest> CREATOR = new Creator<>() {
@Override
public SigningRequest createFromParcel(Parcel in) {
return new SigningRequest(in);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ protected SigningResponse(Parcel in) {
for (int i = 0; i < size; i++) {
mSignatures.add(in.createByteArray());
}
mResolvedDerivationPaths = in.createTypedArrayList(Uri.CREATOR);
final ArrayList<Uri> rdp = in.createTypedArrayList(Uri.CREATOR);
if (rdp != null) {
mResolvedDerivationPaths = rdp;
} else {
mResolvedDerivationPaths = new ArrayList<>();
}
}

@Override
Expand All @@ -66,7 +71,7 @@ public int describeContents() {
return 0;
}

public static final Creator<SigningResponse> CREATOR = new Creator<SigningResponse>() {
public static final Creator<SigningResponse> CREATOR = new Creator<>() {
@Override
public SigningResponse createFromParcel(Parcel in) {
return new SigningResponse(in);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ public static boolean hasUnauthorizedSeedsForPurpose(
WalletContractV1.UNAUTHORIZED_SEEDS_ALL_COLUMNS,
null,
null);
if (!c.moveToFirst()) {
if (c == null || !c.moveToFirst()) {
throw new IllegalStateException("Cursor does not contain expected data");
}
boolean hasUnauthorizedSeeds = (c.getShort(1) != 0);
Expand Down Expand Up @@ -834,7 +834,7 @@ public static ArrayMap<String, Long> getImplementationLimitsForPurpose(
WalletContractV1.IMPLEMENTATION_LIMITS_ALL_COLUMNS,
null,
null);
if (!c.moveToNext()) {
if (c == null || !c.moveToNext()) {
throw new UnsupportedOperationException("Failed to get implementation limits");
}
final ArrayMap<String, Long> implementationLimitsMap = new ArrayMap<>(3);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
* Copyright (c) 2024 Solana Mobile Inc.
*/

package com.solanamobile.ui.apptheme

import androidx.compose.foundation.isSystemInDarkTheme
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
* Copyright (c) 2024 Solana Mobile Inc.
*/

package com.solanamobile.ui.apptheme

import androidx.compose.ui.unit.dp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
* Copyright (c) 2024 Solana Mobile Inc.
*/

package com.solanamobile.ui.apptheme

import androidx.compose.foundation.isSystemInDarkTheme
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
* Copyright (c) 2024 Solana Mobile Inc.
*/

package com.solanamobile.ui.apptheme

import android.util.DisplayMetrics
Expand Down

0 comments on commit 98e6d55

Please sign in to comment.