Make Parcelable classes final, API cleanup.
Remove some Context methods that leaked through. Add lint rule to
recommend using List<? extends Parcelable> instead of Parcelable[].
Bug: 27932224, 27930145, 27932911
Change-Id: Ia302de46cdb0c5101fa175a09316df91aeefcf0d
diff --git a/api/current.txt b/api/current.txt
index c416044..97ac8ea 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -8222,8 +8222,6 @@
method public java.lang.String getPackageResourcePath();
method public android.content.res.Resources getResources();
method public android.content.SharedPreferences getSharedPreferences(java.lang.String, int);
- method public android.content.SharedPreferences getSharedPreferences(java.io.File, int);
- method public java.io.File getSharedPreferencesPath(java.lang.String);
method public java.lang.Object getSystemService(java.lang.String);
method public java.lang.String getSystemServiceName(java.lang.Class<?>);
method public android.content.res.Resources.Theme getTheme();
@@ -9991,7 +9989,7 @@
field public java.lang.String permission;
}
- public class ShortcutInfo implements android.os.Parcelable {
+ public final class ShortcutInfo implements android.os.Parcelable {
method public int describeContents();
method public android.content.ComponentName getActivityComponent();
method public android.os.PersistableBundle getExtras();
@@ -29481,7 +29479,7 @@
method public android.os.health.HealthStats[] takeUidSnapshots(int[]);
}
- public class TimerStat implements android.os.Parcelable {
+ public final class TimerStat implements android.os.Parcelable {
ctor public TimerStat();
ctor public TimerStat(int, long);
ctor public TimerStat(android.os.Parcel);
@@ -37954,8 +37952,6 @@
method public java.lang.String getPackageResourcePath();
method public android.content.res.Resources getResources();
method public android.content.SharedPreferences getSharedPreferences(java.lang.String, int);
- method public android.content.SharedPreferences getSharedPreferences(java.io.File, int);
- method public java.io.File getSharedPreferencesPath(java.lang.String);
method public java.lang.Object getSystemService(java.lang.String);
method public java.lang.String getSystemServiceName(java.lang.Class<?>);
method public android.content.res.Resources.Theme getTheme();
diff --git a/api/system-current.txt b/api/system-current.txt
index e372d98..1b37619 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -8532,8 +8532,6 @@
method public java.lang.String getPackageResourcePath();
method public android.content.res.Resources getResources();
method public android.content.SharedPreferences getSharedPreferences(java.lang.String, int);
- method public android.content.SharedPreferences getSharedPreferences(java.io.File, int);
- method public java.io.File getSharedPreferencesPath(java.lang.String);
method public java.lang.Object getSystemService(java.lang.String);
method public java.lang.String getSystemServiceName(java.lang.Class<?>);
method public android.content.res.Resources.Theme getTheme();
@@ -10389,7 +10387,7 @@
field public java.lang.String permission;
}
- public class ShortcutInfo implements android.os.Parcelable {
+ public final class ShortcutInfo implements android.os.Parcelable {
method public int describeContents();
method public android.content.ComponentName getActivityComponent();
method public android.os.PersistableBundle getExtras();
@@ -31794,7 +31792,7 @@
method public android.os.health.HealthStats[] takeUidSnapshots(int[]);
}
- public class TimerStat implements android.os.Parcelable {
+ public final class TimerStat implements android.os.Parcelable {
ctor public TimerStat();
ctor public TimerStat(int, long);
ctor public TimerStat(android.os.Parcel);
@@ -40670,8 +40668,6 @@
method public java.lang.String getPackageResourcePath();
method public android.content.res.Resources getResources();
method public android.content.SharedPreferences getSharedPreferences(java.lang.String, int);
- method public android.content.SharedPreferences getSharedPreferences(java.io.File, int);
- method public java.io.File getSharedPreferencesPath(java.lang.String);
method public java.lang.Object getSystemService(java.lang.String);
method public java.lang.String getSystemServiceName(java.lang.Class<?>);
method public android.content.res.Resources.Theme getTheme();
diff --git a/api/test-current.txt b/api/test-current.txt
index e4153f1..e385aa0 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -8228,8 +8228,6 @@
method public java.lang.String getPackageResourcePath();
method public android.content.res.Resources getResources();
method public android.content.SharedPreferences getSharedPreferences(java.lang.String, int);
- method public android.content.SharedPreferences getSharedPreferences(java.io.File, int);
- method public java.io.File getSharedPreferencesPath(java.lang.String);
method public java.lang.Object getSystemService(java.lang.String);
method public java.lang.String getSystemServiceName(java.lang.Class<?>);
method public android.content.res.Resources.Theme getTheme();
@@ -10001,7 +9999,7 @@
field public java.lang.String permission;
}
- public class ShortcutInfo implements android.os.Parcelable {
+ public final class ShortcutInfo implements android.os.Parcelable {
method public int describeContents();
method public android.content.ComponentName getActivityComponent();
method public android.os.PersistableBundle getExtras();
@@ -29547,7 +29545,7 @@
method public android.os.health.HealthStats[] takeUidSnapshots(int[]);
}
- public class TimerStat implements android.os.Parcelable {
+ public final class TimerStat implements android.os.Parcelable {
ctor public TimerStat();
ctor public TimerStat(int, long);
ctor public TimerStat(android.os.Parcel);
@@ -38026,8 +38024,6 @@
method public java.lang.String getPackageResourcePath();
method public android.content.res.Resources getResources();
method public android.content.SharedPreferences getSharedPreferences(java.lang.String, int);
- method public android.content.SharedPreferences getSharedPreferences(java.io.File, int);
- method public java.io.File getSharedPreferencesPath(java.lang.String);
method public java.lang.Object getSystemService(java.lang.String);
method public java.lang.String getSystemServiceName(java.lang.Class<?>);
method public android.content.res.Resources.Theme getTheme();
diff --git a/core/java/android/content/ContextWrapper.java b/core/java/android/content/ContextWrapper.java
index b2df207..087ac47 100644
--- a/core/java/android/content/ContextWrapper.java
+++ b/core/java/android/content/ContextWrapper.java
@@ -164,6 +164,7 @@
return mBase.getSharedPreferences(name, mode);
}
+ /** @removed */
@Override
public SharedPreferences getSharedPreferences(File file, int mode) {
return mBase.getSharedPreferences(file, mode);
@@ -201,6 +202,7 @@
return mBase.getFileStreamPath(name);
}
+ /** @removed */
@Override
public File getSharedPreferencesPath(String name) {
return mBase.getSharedPreferencesPath(name);
diff --git a/core/java/android/content/pm/ShortcutInfo.java b/core/java/android/content/pm/ShortcutInfo.java
index ae75e3f..7cb3af9 100644
--- a/core/java/android/content/pm/ShortcutInfo.java
+++ b/core/java/android/content/pm/ShortcutInfo.java
@@ -47,7 +47,7 @@
*
* We will disallow byte[] icons, because they can easily go over binder size limit.
*/
-public class ShortcutInfo implements Parcelable {
+public final class ShortcutInfo implements Parcelable {
/* @hide */
public static final int FLAG_DYNAMIC = 1 << 0;
diff --git a/core/java/android/os/health/TimerStat.java b/core/java/android/os/health/TimerStat.java
index fc51b60..b9d8874 100644
--- a/core/java/android/os/health/TimerStat.java
+++ b/core/java/android/os/health/TimerStat.java
@@ -27,7 +27,7 @@
* object to be constructed, even internally, but the getTimers method on
* {@link android.os.health.HealthStats} does require TimerStat objects.
*/
-public class TimerStat implements Parcelable {
+public final class TimerStat implements Parcelable {
private int mCount;
private long mTime;
diff --git a/test-runner/src/android/test/mock/MockContext.java b/test-runner/src/android/test/mock/MockContext.java
index b739ead..c7cbf97 100644
--- a/test-runner/src/android/test/mock/MockContext.java
+++ b/test-runner/src/android/test/mock/MockContext.java
@@ -145,6 +145,7 @@
throw new UnsupportedOperationException();
}
+ /** @removed */
@Override
public SharedPreferences getSharedPreferences(File file, int mode) {
throw new UnsupportedOperationException();
@@ -180,6 +181,7 @@
throw new UnsupportedOperationException();
}
+ /** @removed */
@Override
public File getSharedPreferencesPath(String name) {
throw new UnsupportedOperationException();
diff --git a/tools/apilint/apilint.py b/tools/apilint/apilint.py
index a8a8c5c..ca2d2e7 100644
--- a/tools/apilint/apilint.py
+++ b/tools/apilint/apilint.py
@@ -980,6 +980,16 @@
warn(clazz, m, "M10", "Methods accepting File should also accept FileDescriptor or streams")
+def verify_manager_list(clazz):
+ """Verifies that managers return List<? extends Parcelable> instead of arrays."""
+
+ if not clazz.name.endswith("Manager"): return
+
+ for m in clazz.methods:
+ if m.typ.startswith("android.") and m.typ.endswith("[]"):
+ warn(clazz, m, None, "Methods should return List<? extends Parcelable> instead of Parcelable[] to support ParceledListSlice under the hood")
+
+
def examine_clazz(clazz):
"""Find all style issues in the given class."""
if clazz.pkg.name.startswith("java"): return
@@ -1025,6 +1035,7 @@
verify_listener_last(clazz)
verify_resource_names(clazz)
verify_files(clazz)
+ verify_manager_list(clazz)
def examine_stream(stream):