From a27da72cd1b03cf99cbe810c985a9c8bde1cbbb5 Mon Sep 17 00:00:00 2001 From: Lorenzo Colitti Date: Tue, 22 Jan 2019 17:11:01 +0900 Subject: [PATCH] Expose ServiceSpecificException as @SystemApi. This class is useful as a system API because: - It is one of the few exceptions that is natively Parcelable. - It is directly supported by native code without using JNI, using Status::fromServiceSpecificError. - Unlike other natively parcelable exceptions, it contains both an error message and an error code. Test: m Bug: 112869080 Change-Id: Ica3e88c2b6877e429a61b053d75f69b9f19fc74a --- api/system-current.txt | 6 ++++++ config/hiddenapi-greylist.txt | 2 -- core/java/android/os/ServiceSpecificException.java | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/api/system-current.txt b/api/system-current.txt index 1320d146d9020..bf1368b018dc1 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -4001,6 +4001,12 @@ package android.os { method public void onResult(android.os.Bundle); } + public class ServiceSpecificException extends java.lang.RuntimeException { + ctor public ServiceSpecificException(int, String); + ctor public ServiceSpecificException(int); + field public final int errorCode; + } + public final class StatsDimensionsValue implements android.os.Parcelable { method public int describeContents(); method public boolean getBooleanValue(); diff --git a/config/hiddenapi-greylist.txt b/config/hiddenapi-greylist.txt index 2bd813e149370..3194b8b3c0d4d 100644 --- a/config/hiddenapi-greylist.txt +++ b/config/hiddenapi-greylist.txt @@ -1057,8 +1057,6 @@ Landroid/os/ServiceManager;->sServiceManager:Landroid/os/IServiceManager; Landroid/os/ServiceManagerNative;->asInterface(Landroid/os/IBinder;)Landroid/os/IServiceManager; Landroid/os/ServiceManagerProxy;->getService(Ljava/lang/String;)Landroid/os/IBinder; Landroid/os/ServiceManagerProxy;->mRemote:Landroid/os/IBinder; -Landroid/os/ServiceSpecificException;->(ILjava/lang/String;)V -Landroid/os/ServiceSpecificException;->errorCode:I Landroid/os/SharedMemory;->getFd()I Landroid/os/ShellCommand;->peekNextArg()Ljava/lang/String; Landroid/os/StatFs;->mStat:Landroid/system/StructStatVfs; diff --git a/core/java/android/os/ServiceSpecificException.java b/core/java/android/os/ServiceSpecificException.java index 3e0f6dae04d8b..3b0f26ae88677 100644 --- a/core/java/android/os/ServiceSpecificException.java +++ b/core/java/android/os/ServiceSpecificException.java @@ -15,6 +15,8 @@ */ package android.os; +import android.annotation.SystemApi; + /** * An exception specific to a service. * @@ -28,6 +30,7 @@ package android.os; * * @hide */ +@SystemApi public class ServiceSpecificException extends RuntimeException { public final int errorCode;