OSDN Git Service

Document that SystemProperties.set() can throw RuntimeException
authorTom Cherry <tomcherry@google.com>
Thu, 19 Sep 2019 15:28:27 +0000 (08:28 -0700)
committerTom Cherry <tomcherry@google.com>
Thu, 19 Sep 2019 15:41:44 +0000 (08:41 -0700)
Bug: 140148206
Test: n/a
Change-Id: I32df2ed4979edcc0d9abc46830ebd3defc431c57

core/java/android/os/SystemProperties.java
core/jni/android_os_SystemProperties.cpp

index 4538410..7bf1c4b 100644 (file)
@@ -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
index 9ec7517..87f498a 100644 (file)
@@ -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)");
     }
 }