Merge "Replace IS_DEBUGGABLE with isDebuggable module API" am: ba77876dbd am: 4290766ae7 am: 116bab20ab

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1667304

Change-Id: I3a64653b1a9cb283ba04d4c5a363d3b44fa7b987
diff --git a/core/api/current.txt b/core/api/current.txt
index 88080f0..69d097a 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -30677,7 +30677,6 @@
     field public static final String HARDWARE;
     field public static final String HOST;
     field public static final String ID;
-    field public static final boolean IS_DEBUGGABLE;
     field public static final String MANUFACTURER;
     field public static final String MODEL;
     field @NonNull public static final String ODM_SKU;
diff --git a/core/api/module-lib-current.txt b/core/api/module-lib-current.txt
index 5379468..3962778 100644
--- a/core/api/module-lib-current.txt
+++ b/core/api/module-lib-current.txt
@@ -255,6 +255,10 @@
     method public final void markVintfStability();
   }
 
+  public class Build {
+    method public static boolean isDebuggable();
+  }
+
   public static class Build.VERSION {
     field public static final int FIRST_SDK_INT;
   }
diff --git a/core/api/test-current.txt b/core/api/test-current.txt
index 906524e..69f923c 100644
--- a/core/api/test-current.txt
+++ b/core/api/test-current.txt
@@ -1582,6 +1582,7 @@
 
   public class Build {
     method public static boolean is64BitAbi(String);
+    method public static boolean isDebuggable();
     field public static final boolean IS_EMULATOR;
   }
 
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index 8adb79b..834ae33 100755
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -1324,10 +1324,25 @@
      * Debuggable builds allow users to gain root access via local shell, attach debuggers to any
      * application regardless of whether they have the "debuggable" attribute set, or downgrade
      * selinux into "permissive" mode in particular.
+     * @hide
      */
     public static final boolean IS_DEBUGGABLE =
             SystemProperties.getInt("ro.debuggable", 0) == 1;
 
+    /**
+     * Returns true if the device is running a debuggable build such as "userdebug" or "eng".
+     *
+     * Debuggable builds allow users to gain root access via local shell, attach debuggers to any
+     * application regardless of whether they have the "debuggable" attribute set, or downgrade
+     * selinux into "permissive" mode in particular.
+     * @hide
+     */
+    @TestApi
+    @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
+    public static boolean isDebuggable() {
+        return IS_DEBUGGABLE;
+    }
+
     /** {@hide} */
     public static final boolean IS_ENG = "eng".equals(TYPE);
     /** {@hide} */
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 922b21a..4081fd5 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -7685,7 +7685,7 @@
         }
 
         void addRequestReassignment(@NonNull final RequestReassignment reassignment) {
-            if (Build.IS_DEBUGGABLE) {
+            if (Build.isDebuggable()) {
                 // The code is never supposed to add two reassignments of the same request. Make
                 // sure this stays true, but without imposing this expensive check on all
                 // reassignments on all user devices.