2025 年 3 月 27 日より、AOSP のビルドとコントリビューションには aosp-main
ではなく android-latest-release
を使用することをおすすめします。詳細については、AOSP の変更をご覧ください。
Instant App 用の CTS
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Instant Apps は、Android 10 の重要な機能であるため、正しく動作することが重要です。Instant App は、明示的なインストールが不要なため、機能に制約があり、制限の厳しいセキュリティ サンドボックス内で実行されます。このような制限が至る所にあるため、システムのどの部分にも Instant App の正常な動作を妨げる危険性があります。CTS テスト サブセットは、Instant Apps によって許可されている動作が正常に機能していることを確認するために作成されています。移植の必要な最小限のテストセットを分離して、CTS の肥大化を最小限に抑えようというのが基本的な考え方です。CTS を Instant Apps モードで実行するということは、つまり、テスト APK を Instant App としてインストールして、テストを実行するということです。
Instant App での制限
Instant Apps は、ユーザーがインストールするのではないため、以下のような制限のあるサンドボックス内で実行されます。
- 特定の権限のみを保持できる。
- 他のアプリを参照できない(Instant App から参照可能というマークが付いたアプリは除く)。
- 特定のシステム設定にのみアクセスできる。
- 特定のシステム プロパティにのみアクセスできる。
- サービスおよびプロバイダを公開できない。
- ブロードキャストは特別なルールに従えば送受信できる。
加えて、Instant Apps は新しいセキュリティ サンドボックスで制限が追加されることを受け入れる必要があります。このように、Instant App に関する特別な挙動は多岐にわたり、プラットフォーム全体に横断的に関係しているため、エコシステム内のすべてのデバイスで Instant App が正常に動作することを検証する手段が必要です。
Instant Apps モードで動作するテスト
Instant App に適用できるテストがすべての CTS モジュールにあるわけではありません。モジュールでテストされる機能にシステム サーバーとのやり取りがある場合、このようなテストは Instant Apps モードで実行する必要があります。たとえば、OpenGL テストにはシステム サーバーとのやり取りがないため、Instant Apps モードで実行する必要はありません。これに対して、ユーザー補助のテストはシステム サーバーとのやり取りがあるため、Instant Apps モードで実行する必要があります。
どのモジュールに適用できるかを確認するだけでなく、そのモジュール内のどのテストが適切かも確認する必要があります。たとえば、AccessibilityService などのプラガブル アーキテクチャのサービス固有の動作をテストする場合には、Instant App モードを適用できません。これは、Instant App が他のアプリ(プラットフォームを含む)に対してサービスを公開できないためです。これに対して、アプリ側の動作を検証するテストには Instant App モードを適用できます。Instant App が保持できない権限により制限されている動作を検証するテストも、Instant App モードには適していません。このようなテストには、サービスを公開しない、他のアプリを参照しないといった振る舞いに関するルールを検証する Instant App にのみ適用される一連のテストがあります。通常、これらは作成済みのため移植の必要はありません。
Instant Apps モードでのテスト失敗
Instant Apps からアクセスできない機能を検証したことが原因でテストのエラーが発生している場合、そのテストに Instant Apps モードは適用できません。テストがフルアプリ モードでのみ実行されるように、@AppModeFull
アノテーションを付けてください。このアノテーションをクラスレベルで適用すると、すべてのテストを除外できます。
Instant App がアクセスできる機能の不具合が原因でテストのエラーが発生した場合は、バグレポートをお寄せください。
トラブルシューティング
テストが「Failed to install MyCtsModule.apk on DEVICE. Reason: '-116'」のエラーになった場合、logcat で PackageManager のメッセージを探してください。たとえば、「Can't replace Full App with Instant App: your_app」というメッセージがあった場合、「adb uninstall」コマンドで先にアプリをアンインストールしてください。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-05-08 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-05-08 UTC。"],[],[],null,["# CTS for Instant Apps\n\nInstant Apps are a key feature of 10, so it's essential that they work\nproperly. Instant Apps are implicitly installed, so they have a restricted set of\ncapabilities and run in a more restrictive security sandbox. Due to the pervasive nature\nof these restrictions, any part of the system is at risk for not properly working with Instant\nApps. A CTS test subset is created to ensure that behaviors allowed by Instant Apps are\nworking. The key idea is to minimize the size growth of CTS by isolating the\nminimal set of tests to port. CTS running in Instant Apps mode means\ninstalling the test APK as an Instant App and running the tests.\n\nInstant App restrictions\n------------------------\n\n\nInstant Apps aren't installed by the user, so they run in a restricted sandbox with\nthe following restrictions:\n\n- Can hold only certain permissions.\n- Can't see other apps unless those apps are marked as visible to Instant Apps.\n- Can access only certain system settings.\n- Can access only certain system properties.\n- Can't expose services/providers.\n- Can receive and send with special rules around broadcasts.\n\n\nIn addition, Instant Apps have to opt in to allowing the new security sandbox to add more\nrestrictions. This wide range of special behaviors around Instant Apps cross cut\nthe entire platform, so there needs to be a way to validate that Instant Apps work as expected for all\ndevices in the ecosystem.\n\nTests running in Instant Apps mode\n----------------------------------\n\n\nNot all CTS modules have tests applicable to Instant Apps. If the functionality tested by\nthe module has interaction with the system server, then these tests should be run in the\nInstant Apps mode. For example, the OpenGL tests aren't interacting with the system server and so\nthere's no need to run them in Instant Apps mode while the accessibility tests interact with the\nsystem server but there is a need to run them in Instant Apps mode.\n\n\nIn addition to identifying which modules are applicable, users need to determine\nwhich tests in these modules are relevant. For example, testing service-specific behaviors for\na pluggable architecture (for example, AccessibilityService) isn't applicable for Instant App\nmode as Instant Apps can't expose services to other apps (including the platform) while tests\nvalidating app-side behaviors are applicable for Instant Apps mode. Another example is a test that\nvalidates behaviors behind a permission that an Instant App can't hold aren't relevant in Instant\nApp mode. There's a set of tests that apply only to Instant Apps that validate the rules around\nhow they behave, for example, not exposing services, or not seeing other apps. Typically,\nthese are already written and don't require porting.\n\nTest failures in Instant Apps mode\n----------------------------------\n\n\nIf the test is failing because it validates functionality that Instant Apps can't access, then it\nisn't applicable in Instant Apps mode. Mark the test to run only in Full App mode by annotating\nit with `@AppModeFull`. You can apply this annotation to the class level to exclude all\ntests in it.\n\n\nIf the test fails because some functionality accessible to Instant Apps is broken,\n[file a bug](/docs/setup/contribute/report-bugs).\n\nTroubleshooting\n---------------\n\n\nIf your test fails with *Failed to install MyCtsModule.apk on DEVICE. Reason: '-116'* ,\nlook for PackageManager messages on logcat. For example, if it says *Can't replace Full\nApp with Instant App: your_app*, then adb uninstall your app first."]]