From 39373b2e8124f48354e0116f356b3d140b16338f Mon Sep 17 00:00:00 2001 From: Tom Cherry Date: Thu, 19 Sep 2019 08:28:27 -0700 Subject: [PATCH] Document that SystemProperties.set() can throw RuntimeException Bug: 140148206 Test: n/a Change-Id: I32df2ed4979edcc0d9abc46830ebd3defc431c57 --- core/java/android/os/SystemProperties.java | 2 ++ core/jni/android_os_SystemProperties.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core/java/android/os/SystemProperties.java b/core/java/android/os/SystemProperties.java index 45384105cc8fe..7bf1c4b68390d 100644 --- a/core/java/android/os/SystemProperties.java +++ b/core/java/android/os/SystemProperties.java @@ -184,6 +184,8 @@ public class SystemProperties { * Set the value for the given {@code key} to {@code val}. * * @throws IllegalArgumentException if the {@code val} exceeds 91 characters + * @throws RuntimeException if the property cannot be set, for example, if it was blocked by + * SELinux. libc will log the underlying reason. * @hide */ @UnsupportedAppUsage diff --git a/core/jni/android_os_SystemProperties.cpp b/core/jni/android_os_SystemProperties.cpp index 9ec7517754d9a..87f498a710c10 100644 --- a/core/jni/android_os_SystemProperties.cpp +++ b/core/jni/android_os_SystemProperties.cpp @@ -109,7 +109,7 @@ void SystemProperties_set(JNIEnv *env, jobject clazz, jstring keyJ, if (!ConvertKeyAndForward(env, keyJ, true, handler)) { // Must have been a failure in SetProperty. jniThrowException(env, "java/lang/RuntimeException", - "failed to set system property"); + "failed to set system property (check logcat for reason)"); } }