diff options
| author | Olivier Gaillard <gaillard@google.com> | 2018-12-03 17:51:46 +0000 |
|---|---|---|
| committer | Olivier Gaillard <gaillard@google.com> | 2018-12-12 10:29:05 +0000 |
| commit | 6dfdcf4334e5684d54a3a977b095c7ec67e0ebc6 (patch) | |
| tree | 9f8877e0ad137e7113387ee977b9af3ad538a9c5 /core/java | |
| parent | 02e7db9b6adfb83b714cd11c22f54c1eec9c084d (diff) | |
Make work source APIs visible to system apps.
- Adds @SystemApi to the work source apis. Work source will help us to
better understand who is responsible for resources usage (starting with
cpu usage)
- Adds @SystemApi to the transact listener to allow system apps to
intercept outgoing transactions in order to the set work source.
Bug: 111534779
Test: n/a - just adding annotations
Change-Id: Ie86696228bb9df57f640b978a1d78439c99626d3
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/os/Binder.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java index d45fa11de639..9939a3c8f36d 100644 --- a/core/java/android/os/Binder.java +++ b/core/java/android/os/Binder.java @@ -18,6 +18,7 @@ package android.os; import android.annotation.NonNull; import android.annotation.Nullable; +import android.annotation.SystemApi; import android.util.ExceptionUtils; import android.util.Log; import android.util.Slog; @@ -399,6 +400,9 @@ public class Binder implements IBinder { * reasons, we only support one UID. This UID represents the original user responsible for the * binder calls. * + * <p>{@link Binder#restoreCallingWorkSource(long)} must always be called after setting the + * worksource. + * * <p>A typical use case would be * <pre> * long token = Binder.setCallingWorkSourceUid(uid); @@ -417,6 +421,7 @@ public class Binder implements IBinder { * @hide **/ @CriticalNative + @SystemApi public static final native long setCallingWorkSourceUid(int workSource); /** @@ -430,6 +435,7 @@ public class Binder implements IBinder { * @hide */ @CriticalNative + @SystemApi public static final native int getCallingWorkSourceUid(); /** @@ -438,10 +444,24 @@ public class Binder implements IBinder { * <p>The work source will be propagated for future outgoing binder transactions * executed on this thread. * + * <p>{@link Binder#restoreCallingWorkSource(long)} must always be called after clearing the + * worksource. + * + * <p>A typical use case would be + * <pre> + * long token = Binder.clearCallingWorkSource(); + * try { + * // Call an API. + * } finally { + * Binder.restoreCallingWorkSource(token); + * } + * </pre> + * * @return token to restore original work source. * @hide **/ @CriticalNative + @SystemApi public static final native long clearCallingWorkSource(); /** @@ -461,6 +481,7 @@ public class Binder implements IBinder { * @hide **/ @CriticalNative + @SystemApi public static final native void restoreCallingWorkSource(long token); /** @@ -601,6 +622,7 @@ public class Binder implements IBinder { * See {@link setProxyTransactListener}. * @hide */ + @SystemApi public interface ProxyTransactListener { /** * Called before onTransact. @@ -663,6 +685,7 @@ public class Binder implements IBinder { * <li>Never execute another binder transaction inside the listener. * @hide */ + @SystemApi public static void setProxyTransactListener(@Nullable ProxyTransactListener listener) { BinderProxy.setTransactListener(listener); } |
