Skip to content

Commit

Permalink
CTS test app <intent-filter> priorities (#307)
Browse files Browse the repository at this point in the history
* Specify both priority and order for SeedVaultSimulator <intent-filter>s

* Declare low-priority <intent-filter>s for CTS test app

* Do not run 'csss' test case on Saga
sdlaver authored Oct 22, 2024
1 parent 34f72ae commit db06ba7
Showing 4 changed files with 79 additions and 13 deletions.
37 changes: 26 additions & 11 deletions SeedVaultSimulator/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -54,38 +54,45 @@
android:parentActivityName=".ui.seeds.SeedsActivity"
android:theme="@style/Theme.SeedVaultImpl.NoActionBar" />

<!-- NOTE: intent-filter order set below that of the privileged alias in case an app holds
both permissions. Apps normally should hold only one of the two permissions, but the
<!-- NOTE: Priority set to 100 (which only functions if this app is installed as a
privileged app) to ensure that non-privileged apps cannot handle Seed Vault implicit
intents. Order set below that of the privileged alias in case an app holds both
permissions. Apps normally should hold only one of the two permissions, but the
Seed Vault should gracefully handle the case where an app is granted both. -->
<activity-alias
android:name=".seedDetailsGenericAlias"
android:exported="true"
android:permission="com.solanamobile.seedvault.ACCESS_SEED_VAULT"
android:targetActivity=".ui.seeddetail.SeedDetailActivity">
<intent-filter android:order="-100">
<intent-filter android:priority="100" android:order="-100">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_CREATE_SEED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:order="-100">
<intent-filter android:priority="100" android:order="-100">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_IMPORT_SEED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity-alias>

<!-- NOTE: Priority set to 100 (which only functions if this app is installed as a
privileged app) to ensure that non-privileged apps cannot handle Seed Vault implicit
intents. Order set above that of the non-privileged alias in case an app holds both
permissions. Apps normally should hold only one of the two permissions, but the
Seed Vault should gracefully handle the case where an app is granted both. -->
<activity-alias
android:name=".seedDetailsPrivilegedAlias"
android:exported="true"
android:permission="com.solanamobile.seedvault.ACCESS_SEED_VAULT_PRIVILEGED"
android:targetActivity=".ui.seeddetail.SeedDetailActivity">
<intent-filter>
<intent-filter android:priority="100" android:order="0">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_CREATE_SEED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<intent-filter android:priority="100" android:order="0">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_IMPORT_SEED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="100">
<intent-filter android:priority="100" android:order="0">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_SEED_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
@@ -97,6 +104,10 @@
android:noHistory="true"
android:theme="@style/Theme.SeedVaultImpl.Transparent" />

<!-- NOTE: Order set below that of the privileged alias in case an app holds both
permissions. Apps normally should hold only one of the two permissions, but the
Seed Vault should gracefully handle the case where an app is granted both. These
intents are always explicit, so no elevated priority is required. -->
<activity-alias
android:name=".authActivityGenericAlias"
android:exported="true"
@@ -120,24 +131,28 @@
</intent-filter>
</activity-alias>

<!-- NOTE: Order set above that of the non-privileged alias in case an app holds both
permissions. Apps normally should hold only one of the two permissions, but the
Seed Vault should gracefully handle the case where an app is granted both. These
intents are always explicit, so no elevated priority is required. -->
<activity-alias
android:name=".authActivityPrivilegedAlias"
android:exported="true"
android:permission="com.solanamobile.seedvault.ACCESS_SEED_VAULT_PRIVILEGED"
android:targetActivity=".ui.AuthorizeActivity">
<intent-filter>
<intent-filter android:order="0">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_AUTHORIZE_SEED_ACCESS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<intent-filter android:order="0">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_SIGN_TRANSACTION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<intent-filter android:order="0">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_SIGN_MESSAGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<intent-filter android:order="0">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_GET_PUBLIC_KEY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
37 changes: 36 additions & 1 deletion cts/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -22,7 +22,6 @@
android:theme="@style/Theme.WalletAPISDK">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
@@ -36,6 +35,42 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>

<!-- This activity exists to catch unhandled Intents and ensure that they return immediately
with RESULT_CANCELED. Any proper implementation of Seed Vault will have higher priority
handling of these, and so these should never be used. -->
<activity
android:name=".UnhandledIntentActivity"
android:exported="true">
<intent-filter android:priority="-100">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_AUTHORIZE_SEED_ACCESS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="-100">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_SIGN_TRANSACTION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="-100">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_SIGN_MESSAGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="-100">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_GET_PUBLIC_KEY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="-100">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_CREATE_SEED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="-100">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_IMPORT_SEED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="-100">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_SEED_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2024 Solana Mobile Inc.
*/

package com.solanamobile.seedvault.cts

import android.os.Bundle
import androidx.activity.ComponentActivity

class UnhandledIntentActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setResult(RESULT_CANCELED)
finish()
}
}
Original file line number Diff line number Diff line change
@@ -78,7 +78,7 @@ internal object TestCorpusProvider {
signatureRequestsExceedLimitTestCase,
denySignTransactionTestCase,
incorrectPinSignTransactionFailureTestCase,
cannotShowSeedSettingsTestCase.takeIf { isGenericBuild },
cannotShowSeedSettingsTestCase.takeIf { isGenericBuild && !isSaga },
showSeedSettingsTestCase.takeIf { !isGenericBuild },
deauthorizeSeed12TestCase.takeIf { isGenericBuild },
hasUnauthorizedSeedsContentProviderTestCase.takeIf { isGenericBuild },

0 comments on commit db06ba7

Please sign in to comment.