From 5e05a9ae1c04f141f66ca4f420e314f625eec8c3 Mon Sep 17 00:00:00 2001 From: Sundong Ahn Date: Wed, 3 Jan 2018 19:16:01 +0900 Subject: Add SystemApi in SystemProperties for vendor apks The Apis in SystemProperties are needed for building ims.apk with LOCAL_SDK_VERSION := system_current. So @SystemApi is added to SystemProperties class and methods which are used by vendor apks (i.e. ims.apk) Bug: 67726847 Test: 1. build & boot on taimen 2. LOCAL_SDK_VERSION:=system_current in ims.apk && build ims.apk && check error count and android_system_stubs_current_intermediates. Change-Id: I178f8d9b0b1f6bb1455ceec919805c4cc549cb32 --- api/system-current.txt | 8 ++++++++ core/java/android/os/SystemProperties.java | 22 +++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/api/system-current.txt b/api/system-current.txt index a1ec2c44cd49..89c4374cd352 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -3505,6 +3505,14 @@ package android.os { method public abstract void onResult(android.os.Bundle); } + public class SystemProperties { + method public static java.lang.String get(java.lang.String); + method public static java.lang.String get(java.lang.String, java.lang.String); + method public static boolean getBoolean(java.lang.String, boolean); + method public static int getInt(java.lang.String, int); + method public static long getLong(java.lang.String, long); + } + public class SystemUpdateManager { method public android.os.Bundle retrieveSystemUpdateInfo(); method public void updateSystemUpdateInfo(android.os.PersistableBundle); diff --git a/core/java/android/os/SystemProperties.java b/core/java/android/os/SystemProperties.java index 4f6d322ba871..a9b86752ee54 100644 --- a/core/java/android/os/SystemProperties.java +++ b/core/java/android/os/SystemProperties.java @@ -18,6 +18,7 @@ package android.os; import android.annotation.NonNull; import android.annotation.Nullable; +import android.annotation.SystemApi; import android.util.Log; import android.util.MutableInt; @@ -33,6 +34,7 @@ import java.util.HashMap; * * {@hide} */ +@SystemApi public class SystemProperties { private static final String TAG = "SystemProperties"; private static final boolean TRACK_KEY_ACCESS = false; @@ -40,9 +42,11 @@ public class SystemProperties { /** * Android O removed the property name length limit, but com.amazon.kindle 7.8.1.5 * uses reflection to read this whenever text is selected (http://b/36095274). + * @hide */ public static final int PROP_NAME_MAX = Integer.MAX_VALUE; + /** @hide */ public static final int PROP_VALUE_MAX = 91; @GuardedBy("sChangeCallbacks") @@ -86,8 +90,10 @@ public class SystemProperties { * * @param key the key to lookup * @return an empty string if the {@code key} isn't found + * @hide */ @NonNull + @SystemApi public static String get(@NonNull String key) { if (TRACK_KEY_ACCESS) onKeyAccess(key); return native_get(key); @@ -100,8 +106,10 @@ public class SystemProperties { * @param def the default value in case the property is not set or empty * @return if the {@code key} isn't found, return {@code def} if it isn't null, or an empty * string otherwise + * @hide */ @NonNull + @SystemApi public static String get(@NonNull String key, @Nullable String def) { if (TRACK_KEY_ACCESS) onKeyAccess(key); return native_get(key, def); @@ -114,7 +122,9 @@ public class SystemProperties { * @param def a default value to return * @return the key parsed as an integer, or def if the key isn't found or * cannot be parsed + * @hide */ + @SystemApi public static int getInt(@NonNull String key, int def) { if (TRACK_KEY_ACCESS) onKeyAccess(key); return native_get_int(key, def); @@ -127,7 +137,9 @@ public class SystemProperties { * @param def a default value to return * @return the key parsed as a long, or def if the key isn't found or * cannot be parsed + * @hide */ + @SystemApi public static long getLong(@NonNull String key, long def) { if (TRACK_KEY_ACCESS) onKeyAccess(key); return native_get_long(key, def); @@ -145,7 +157,9 @@ public class SystemProperties { * @param def a default value to return * @return the key parsed as a boolean, or def if the key isn't found or is * not able to be parsed as a boolean. + * @hide */ + @SystemApi public static boolean getBoolean(@NonNull String key, boolean def) { if (TRACK_KEY_ACCESS) onKeyAccess(key); return native_get_boolean(key, def); @@ -155,6 +169,7 @@ public class SystemProperties { * Set the value for the given {@code key} to {@code val}. * * @throws IllegalArgumentException if the {@code val} exceeds 91 characters + * @hide */ public static void set(@NonNull String key, @Nullable String val) { if (val != null && !val.startsWith("ro.") && val.length() > PROP_VALUE_MAX) { @@ -170,6 +185,7 @@ public class SystemProperties { * * @param callback The {@link Runnable} that should be executed when a system property * changes. + * @hide */ public static void addChangeCallback(@NonNull Runnable callback) { synchronized (sChangeCallbacks) { @@ -194,10 +210,14 @@ public class SystemProperties { } } - /* + /** * Notifies listeners that a system property has changed + * @hide */ public static void reportSyspropChanged() { native_report_sysprop_change(); } + + private SystemProperties() { + } } -- cgit v1.2.3-59-g8ed1b