From 045c55c4b3fd6a9cb6b06b7bb00e1a6a40798ab3 Mon Sep 17 00:00:00 2001 From: Alessandra Loro Date: Wed, 2 Nov 2022 12:42:38 +0000 Subject: [PATCH] Expose ro.secure test endpoint for cts. Bug: 247053706 Test: android.os.cts.BuildTest Change-Id: If0d0b13a53717d221a7eab8ffbd4b08f71db00c5 --- core/api/test-current.txt | 1 + core/java/android/os/Build.java | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/core/api/test-current.txt b/core/api/test-current.txt index f0763950ba378..ae5a5ee88d98f 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -1711,6 +1711,7 @@ package android.os { public class Build { method public static boolean is64BitAbi(String); method public static boolean isDebuggable(); + method public static boolean isSecure(); field public static final boolean IS_EMULATOR; } diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java index 249f48608d404..44a1fa51e9bfb 100755 --- a/core/java/android/os/Build.java +++ b/core/java/android/os/Build.java @@ -1446,6 +1446,28 @@ public class Build { return IS_DEBUGGABLE; } + + /** + * Returns true if the device is running a secure build, such as "user" or "userdebug". + * + * Secure builds drop adbd privileges by default, though debuggable builds still allow users + * to gain root access via local shell. See should_drop_privileges() in adb for details. + * @hide + */ + private static final boolean IS_SECURE = + SystemProperties.getBoolean("ro.secure", true); + /** + * Returns true if the device is running a secure build, such as "user" or "userdebug". + * + * Secure builds drop adbd privileges by default, though debuggable builds still allow users + * to gain root access via local shell. See should_drop_privileges() in adb for details. + * @hide + */ + @TestApi + public static boolean isSecure() { + return IS_SECURE; + } + /** {@hide} */ public static final boolean IS_ENG = "eng".equals(TYPE); /** {@hide} */