From 1c2bf03d1082fc6b7eb42cbd163c60c07cf2bccc Mon Sep 17 00:00:00 2001 From: Tor Norbye Date: Mon, 2 Mar 2015 10:57:08 -0800 Subject: [PATCH] Annotate return values with @CheckReturn Change-Id: Icd8fb6adb591ccd7f35f2336ae716b198abf69c5 --- core/java/android/content/Context.java | 8 ++++++++ core/java/android/content/pm/PackageManager.java | 4 ++++ graphics/java/android/graphics/Bitmap.java | 3 +++ 3 files changed, 15 insertions(+) diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 010c860b0df48..61cdec3d9e9ae 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -16,6 +16,7 @@ package android.content; +import android.annotation.CheckResult; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; @@ -3041,6 +3042,7 @@ public final T getSystemService(Class serviceClass) { * @see PackageManager#checkPermission(String, String) * @see #checkCallingPermission */ + @CheckResult(suggest="#enforcePermission(String,int,int,String)") @PackageManager.PermissionResult public abstract int checkPermission(@NonNull String permission, int pid, int uid); @@ -3070,6 +3072,7 @@ public abstract int checkPermission(@NonNull String permission, int pid, int uid * @see #checkPermission * @see #checkCallingOrSelfPermission */ + @CheckResult(suggest="#enforceCallingPermission(String,String)") @PackageManager.PermissionResult public abstract int checkCallingPermission(@NonNull String permission); @@ -3089,6 +3092,7 @@ public abstract int checkPermission(@NonNull String permission, int pid, int uid * @see #checkPermission * @see #checkCallingPermission */ + @CheckResult(suggest="#enforceCallingOrSelfPermission(String,String)") @PackageManager.PermissionResult public abstract int checkCallingOrSelfPermission(@NonNull String permission); @@ -3233,6 +3237,7 @@ public abstract void grantUriPermission(String toPackage, Uri uri, * * @see #checkCallingUriPermission */ + @CheckResult(suggest="#enforceUriPermission(Uri,int,int,String)") public abstract int checkUriPermission(Uri uri, int pid, int uid, @Intent.AccessUriMode int modeFlags); @@ -3261,6 +3266,7 @@ public abstract int checkUriPermission(Uri uri, int pid, int uid, * * @see #checkUriPermission(Uri, int, int, int) */ + @CheckResult(suggest="#enforceCallingUriPermission(Uri,int,String)") public abstract int checkCallingUriPermission(Uri uri, @Intent.AccessUriMode int modeFlags); /** @@ -3280,6 +3286,7 @@ public abstract int checkUriPermission(Uri uri, int pid, int uid, * * @see #checkCallingUriPermission */ + @CheckResult(suggest="#enforceCallingOrSelfUriPermission(Uri,int,String)") public abstract int checkCallingOrSelfUriPermission(Uri uri, @Intent.AccessUriMode int modeFlags); @@ -3305,6 +3312,7 @@ public abstract int checkCallingOrSelfUriPermission(Uri uri, * is allowed to access that uri or holds one of the given permissions, or * {@link PackageManager#PERMISSION_DENIED} if it is not. */ + @CheckResult(suggest="#enforceUriPermission(Uri,String,String,int,int,int,String)") public abstract int checkUriPermission(@Nullable Uri uri, @Nullable String readPermission, @Nullable String writePermission, int pid, int uid, @Intent.AccessUriMode int modeFlags); diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index ebc8e1efdf017..036568952e3e5 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -16,6 +16,7 @@ package android.content.pm; +import android.annotation.CheckResult; import android.annotation.DrawableRes; import android.annotation.IntDef; import android.annotation.NonNull; @@ -2121,6 +2122,7 @@ public abstract List getPackagesHoldingPermissions( * @see #PERMISSION_GRANTED * @see #PERMISSION_DENIED */ + @CheckResult public abstract int checkPermission(String permName, String pkgName); /** @@ -2248,6 +2250,7 @@ public Intent buildPermissionRequestIntent(String... permissions) { * @see #SIGNATURE_NO_MATCH * @see #SIGNATURE_UNKNOWN_PACKAGE */ + @CheckResult public abstract int checkSignatures(String pkg1, String pkg2); /** @@ -2270,6 +2273,7 @@ public Intent buildPermissionRequestIntent(String... permissions) { * @see #SIGNATURE_NO_MATCH * @see #SIGNATURE_UNKNOWN_PACKAGE */ + @CheckResult public abstract int checkSignatures(int uid1, int uid2); /** diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java index aae11cd8a8db0..e2f7799786a0a 100644 --- a/graphics/java/android/graphics/Bitmap.java +++ b/graphics/java/android/graphics/Bitmap.java @@ -16,6 +16,7 @@ package android.graphics; +import android.annotation.CheckResult; import android.annotation.ColorInt; import android.annotation.NonNull; import android.os.Parcel; @@ -1501,6 +1502,7 @@ public void writeToParcel(Parcel p, int flags) { * * @return new bitmap containing the alpha channel of the original bitmap. */ + @CheckResult public Bitmap extractAlpha() { return extractAlpha(null, null); } @@ -1530,6 +1532,7 @@ public Bitmap extractAlpha() { * Canvas.drawBitmap(), where the color(s) will be taken from the * paint that is passed to the draw call. */ + @CheckResult public Bitmap extractAlpha(Paint paint, int[] offsetXY) { checkRecycled("Can't extractAlpha on a recycled bitmap"); long nativePaint = paint != null ? paint.getNativeInstance() : 0;