Skip to content

Commit

Permalink
add WithType for ShadowActivityManager, ShadowBitmap
Browse files Browse the repository at this point in the history
  • Loading branch information
Wenyi Shi authored and Wenyi Shi committed May 8, 2024
1 parent 81831fc commit 7574da1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.robolectric.util.ReflectionHelpers.ClassParameter;
import org.robolectric.util.reflector.Direct;
import org.robolectric.util.reflector.ForType;
import org.robolectric.util.reflector.WithType;

/** Shadow for {@link android.app.ActivityManager} */
@Implements(value = ActivityManager.class, looseSignatures = true)
Expand Down Expand Up @@ -330,7 +331,9 @@ public void setBackgroundRestricted(boolean isBackgroundRestricted) {
* {@code packageName} is ignored.
*/
@Implementation(minSdk = R)
protected Object getHistoricalProcessExitReasons(Object packageName, Object pid, Object maxNum) {
protected Object getHistoricalProcessExitReasons(
@WithType("java.lang.String") Object packageName,
@WithType("int") Object pid, @WithType("int") Object maxNum) {
return appExitInfoList.stream()
.filter(
appExitInfo ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.robolectric.util.reflector.Accessor;
import org.robolectric.util.reflector.Direct;
import org.robolectric.util.reflector.ForType;
import org.robolectric.util.reflector.WithType;
import org.robolectric.versioning.AndroidVersions.U;

/** Base class for {@link Bitmap} shadows. */
Expand Down Expand Up @@ -136,7 +137,7 @@ public static String visualize(Bitmap bitmap) {
public abstract void setDescription(String s);

@Implementation(minSdk = U.SDK_INT)
protected void setGainmap(Object gainmap) {
protected void setGainmap(@WithType("android.graphics.Gainmap") Object gainmap) {
Preconditions.checkState(!realBitmap.isRecycled(), "Bitmap is recycled");
reflector(BitmapReflector.class, realBitmap).setGainmap(gainmap);
}
Expand Down

0 comments on commit 7574da1

Please sign in to comment.