Skip to content

Commit

Permalink
Annotate return values with @CheckReturn
Browse files Browse the repository at this point in the history
Change-Id: Icd8fb6adb591ccd7f35f2336ae716b198abf69c5
  • Loading branch information
tnorbye committed Mar 8, 2015
1 parent c615c6f commit 1c2bf03
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core/java/android/content/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package android.content;

import android.annotation.CheckResult;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
Expand Down Expand Up @@ -3041,6 +3042,7 @@ public final <T> T getSystemService(Class<T> 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);

Expand Down Expand Up @@ -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);

Expand All @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

/**
Expand All @@ -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);

Expand All @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions core/java/android/content/pm/PackageManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package android.content.pm;

import android.annotation.CheckResult;
import android.annotation.DrawableRes;
import android.annotation.IntDef;
import android.annotation.NonNull;
Expand Down Expand Up @@ -2121,6 +2122,7 @@ public abstract List<PackageInfo> getPackagesHoldingPermissions(
* @see #PERMISSION_GRANTED
* @see #PERMISSION_DENIED
*/
@CheckResult
public abstract int checkPermission(String permName, String pkgName);

/**
Expand Down Expand Up @@ -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);

/**
Expand All @@ -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);

/**
Expand Down
3 changes: 3 additions & 0 deletions graphics/java/android/graphics/Bitmap.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package android.graphics;

import android.annotation.CheckResult;
import android.annotation.ColorInt;
import android.annotation.NonNull;
import android.os.Parcel;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1c2bf03

Please sign in to comment.