ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
CTS สำหรับ Instant Apps
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Instant App เป็นฟีเจอร์หลักของ Android 10 จึงจำเป็นต้องทํางานได้อย่างถูกต้อง ระบบจะติดตั้งแอปด่วนโดยปริยาย ดังนั้นแอปเหล่านี้จึงมีชุดความสามารถที่จำกัดและทำงานในแซนด์บ็อกซ์ด้านความปลอดภัยที่เข้มงวดมากขึ้น เนื่องจากข้อจำกัดเหล่านี้มีอยู่ในแทบทุกส่วนของระบบ ชิ้นส่วนใดๆ ของระบบจึงมีความเสี่ยงที่จะใช้งานกับ Instant App อย่างไม่ถูกต้อง ระบบจะสร้างชุดย่อยการทดสอบ CTS เพื่อให้แน่ใจว่าลักษณะการทำงานที่ Instant Apps อนุญาตทํางานได้ แนวคิดหลักคือลดขนาด CTS โดยการแยกชุดการทดสอบขั้นต่ำเพื่อพอร์ต CTS ที่ทำงานในโหมด Instant App หมายถึงการติดตั้ง APK ทดสอบเป็น Instant App และทำการทดสอบ
ข้อจำกัดของ Instant App
ผู้ใช้ไม่ได้ติดตั้ง Instant App ดังนั้นแอปจะทำงานในแซนด์บ็อกซ์ที่มีข้อจำกัดต่อไปนี้
- มีสิทธิ์ได้เพียงบางสิทธิ์
- ไม่เห็นแอปอื่นๆ เว้นแต่ว่าแอปเหล่านั้นจะมีการทำเครื่องหมายว่าแสดงใน Instant App
- เข้าถึงการตั้งค่าระบบบางอย่างได้เท่านั้น
- เข้าถึงได้เฉพาะพร็อพเพอร์ตี้ระบบบางรายการ
- แสดงบริการ/ผู้ให้บริการไม่ได้
- รับและส่งได้โดยมีกฎพิเศษเกี่ยวกับประกาศ
นอกจากนี้ Instant App ยังต้องเลือกใช้เพื่ออนุญาตให้แซนด์บ็อกซ์ความปลอดภัยใหม่เพิ่มข้อจำกัดเพิ่มเติม ลักษณะการทำงานพิเศษที่หลากหลายนี้ของ Instant App ส่งผลต่อทั้งแพลตฟอร์ม จึงต้องมีวิธีตรวจสอบว่า Instant App ทำงานได้ตามที่คาดไว้สำหรับอุปกรณ์ทั้งหมดในระบบนิเวศ
การทดสอบที่ทำงานในโหมด Instant App
โมดูล CTS บางรายการไม่มีการทดสอบที่ใช้กับ Instant App ได้ หากฟังก์ชันที่โมดูลทดสอบมีการโต้ตอบกับเซิร์ฟเวอร์ระบบ การทดสอบเหล่านี้ควรทําในโหมด Instant Apps ตัวอย่างเช่น การทดสอบ OpenGL ไม่ได้โต้ตอบกับเซิร์ฟเวอร์ระบบ จึงไม่จำเป็นต้องเรียกใช้การทดสอบในโหมด Instant Apps ขณะที่การทดสอบการช่วยเหลือพิเศษโต้ตอบกับเซิร์ฟเวอร์ระบบ จึงจำเป็นต้องเรียกใช้การทดสอบในโหมด Instant Apps
นอกเหนือจากการระบุข้อบังคับที่เกี่ยวข้องแล้ว ผู้ใช้ยังต้องระบุการทดสอบในข้อบังคับเหล่านี้ที่เกี่ยวข้องด้วย ตัวอย่างเช่น การทดสอบลักษณะการทำงานเฉพาะบริการสำหรับสถาปัตยกรรมแบบปลั๊กอิน (เช่น AccessibilityService) จะใช้ไม่ได้กับโหมด Instant App เนื่องจาก Instant App ไม่สามารถแสดงบริการต่อแอปอื่นๆ (รวมถึงแพลตฟอร์ม) ได้ ขณะที่การทดสอบเพื่อตรวจสอบลักษณะการทำงานฝั่งแอปจะใช้ได้กับโหมด Instant App อีกตัวอย่างหนึ่งคือ การทดสอบที่ตรวจสอบความถูกต้องของลักษณะการทำงานที่อยู่เบื้องหลังสิทธิ์ที่ Instant App ไม่มีสิทธิ์ใช้และไม่เกี่ยวข้องในโหมด Instant App มีการทดสอบชุดหนึ่งที่ใช้กับ Instant App เท่านั้น ซึ่งจะตรวจสอบกฎเกี่ยวกับลักษณะการทํางาน เช่น ไม่แสดงบริการ หรือไม่เห็นแอปอื่นๆ โดยปกติแล้ว ไฟล์เหล่านี้จะเขียนไว้แล้วและไม่จำเป็นต้องพอร์ต
การทดสอบไม่สําเร็จในโหมด Instant App
หากการทดสอบไม่สำเร็จเนื่องจากตรวจสอบฟังก์ชันการทำงานที่ Instant App เข้าถึงไม่ได้ แสดงว่าฟังก์ชันดังกล่าวใช้ไม่ได้ในโหมด Instant App ทําเครื่องหมายการทดสอบให้ทํางานในโหมดแอปแบบเต็มเท่านั้นโดยกำกับเนื้อหาด้วย @AppModeFull
คุณใช้คำอธิบายประกอบนี้กับระดับชั้นเรียนเพื่อยกเว้นการทดสอบทั้งหมดในชั้นเรียนได้
หากการทดสอบไม่สำเร็จเนื่องจากฟังก์ชันบางอย่างที่ Instant App เข้าถึงได้ใช้งานไม่ได้ ให้รายงานข้อบกพร่อง
การแก้ปัญหา
หากการทดสอบล้มเหลวโดยขึ้นข้อความว่าติดตั้ง MyCtsModule.apk ใน DEVICE ไม่สำเร็จ เหตุผล: '-116' ให้มองหาข้อความ PackageManager ใน Logcat ตัวอย่างเช่น หากข้อความระบุว่า แทนที่แอปแบบสมบูรณ์ด้วยแอป Instant ไม่ได้: your_app แสดงว่า adb จะถอนการติดตั้งแอปของคุณก่อน
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 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-07-27 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."]]