Tag UnsupportedAppUsages in SurfaceView with alternatives
There is little evidence that the fields annoatated with @UnsupportedAppUsage are actually used, and even if they were by some long-tail of apps there are either public api alternatives to accessing these fields or there are no good use-cases. Populate the usages with publicAlternative so that we can start removing them during future refactors. The only @UnsupportedAppUsage that remains untouched is SurfaceView#setFrame, because View#setFrame is also annotated with @UnsuportedAppUsage and possibly has a higher usage level. Bug: 249858453 Test: builds Change-Id: I51c918c10ca087d87791899f7bce4b1425130902
This commit is contained in:
@@ -121,16 +121,23 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
|
||||
private static final boolean DEBUG = false;
|
||||
private static final boolean DEBUG_POSITION = false;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
@UnsupportedAppUsage(
|
||||
maxTargetSdk = Build.VERSION_CODES.TIRAMISU,
|
||||
publicAlternatives = "Track {@link SurfaceHolder#addCallback} instead")
|
||||
final ArrayList<SurfaceHolder.Callback> mCallbacks = new ArrayList<>();
|
||||
|
||||
final int[] mLocation = new int[2];
|
||||
|
||||
@UnsupportedAppUsage
|
||||
@UnsupportedAppUsage(
|
||||
maxTargetSdk = Build.VERSION_CODES.TIRAMISU,
|
||||
publicAlternatives = "Use {@link SurfaceHolder#lockCanvas} instead")
|
||||
final ReentrantLock mSurfaceLock = new ReentrantLock();
|
||||
@UnsupportedAppUsage
|
||||
@UnsupportedAppUsage(
|
||||
maxTargetSdk = Build.VERSION_CODES.TIRAMISU,
|
||||
publicAlternatives = "Use {@link SurfaceHolder#getSurface} instead")
|
||||
final Surface mSurface = new Surface(); // Current surface in use
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023,
|
||||
publicAlternatives = "Use {@link View#getVisibility} instead")
|
||||
boolean mDrawingStopped = true;
|
||||
// We use this to track if the application has produced a frame
|
||||
// in to the Surface. Up until that point, we should be careful not to punch
|
||||
@@ -156,13 +163,16 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
|
||||
int mSubLayer = APPLICATION_MEDIA_SUBLAYER;
|
||||
int mRequestedSubLayer = APPLICATION_MEDIA_SUBLAYER;
|
||||
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023,
|
||||
publicAlternatives = "Use {@link SurfaceHolder#isCreating} instead")
|
||||
boolean mIsCreating = false;
|
||||
|
||||
private final ViewTreeObserver.OnScrollChangedListener mScrollChangedListener =
|
||||
this::updateSurface;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
@UnsupportedAppUsage(
|
||||
maxTargetSdk = Build.VERSION_CODES.TIRAMISU,
|
||||
publicAlternatives = "Rely on {@link ViewTreeObserver#dispatchOnPreDraw} instead")
|
||||
private final ViewTreeObserver.OnPreDrawListener mDrawListener = () -> {
|
||||
// reposition ourselves where the surface is
|
||||
mHaveFrame = getWidth() > 0 && getHeight() > 0;
|
||||
@@ -176,24 +186,32 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
|
||||
boolean mViewVisibility = false;
|
||||
boolean mWindowStopped = false;
|
||||
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023,
|
||||
publicAlternatives = "Use {@link View#getWidth} instead")
|
||||
int mRequestedWidth = -1;
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023,
|
||||
publicAlternatives = "Use {@link View#getHeight} instead")
|
||||
int mRequestedHeight = -1;
|
||||
/* Set SurfaceView's format to 565 by default to maintain backward
|
||||
* compatibility with applications assuming this format.
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@UnsupportedAppUsage(
|
||||
maxTargetSdk = Build.VERSION_CODES.TIRAMISU,
|
||||
publicAlternatives = "Use {@code SurfaceHolder.Callback#surfaceChanged} instead")
|
||||
int mRequestedFormat = PixelFormat.RGB_565;
|
||||
|
||||
float mAlpha = 1f;
|
||||
boolean mClipSurfaceToBounds;
|
||||
int mBackgroundColor = Color.BLACK;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
@UnsupportedAppUsage(
|
||||
maxTargetSdk = Build.VERSION_CODES.TIRAMISU,
|
||||
publicAlternatives = "Use {@link View#getWidth} and {@link View#getHeight} to "
|
||||
+ "determine if the SurfaceView is onscreen and has a frame")
|
||||
boolean mHaveFrame = false;
|
||||
boolean mSurfaceCreated = false;
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023,
|
||||
publicAlternatives = "Time {@link SurfaceHolder#lockCanvas} instead")
|
||||
long mLastLockTime = 0;
|
||||
|
||||
boolean mVisible = false;
|
||||
@@ -202,9 +220,13 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
|
||||
int mSurfaceWidth = -1;
|
||||
int mSurfaceHeight = -1;
|
||||
float mCornerRadius;
|
||||
@UnsupportedAppUsage
|
||||
@UnsupportedAppUsage(
|
||||
maxTargetSdk = Build.VERSION_CODES.TIRAMISU,
|
||||
publicAlternatives = "Use {@code SurfaceHolder.Callback#surfaceChanged} "
|
||||
+ "instead")
|
||||
int mFormat = -1;
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023,
|
||||
publicAlternatives = "Use {@link SurfaceHolder#getSurfaceFrame} instead")
|
||||
final Rect mSurfaceFrame = new Rect();
|
||||
int mLastSurfaceWidth = -1, mLastSurfaceHeight = -1;
|
||||
@SurfaceControl.BufferTransform int mTransformHint = 0;
|
||||
@@ -1410,7 +1432,9 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
|
||||
* @return true if the surface has dimensions that are fixed in size
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@UnsupportedAppUsage(
|
||||
maxTargetSdk = Build.VERSION_CODES.TIRAMISU,
|
||||
publicAlternatives = "Track {@link SurfaceHolder#setFixedSize} instead")
|
||||
public boolean isFixedSize() {
|
||||
return (mRequestedWidth != -1 || mRequestedHeight != -1);
|
||||
}
|
||||
@@ -1446,7 +1470,9 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
|
||||
updateBackgroundColor(t);
|
||||
}
|
||||
|
||||
@UnsupportedAppUsage
|
||||
@UnsupportedAppUsage(
|
||||
maxTargetSdk = Build.VERSION_CODES.TIRAMISU,
|
||||
publicAlternatives = "Use {@link SurfaceView#getHolder} instead")
|
||||
private final SurfaceHolder mSurfaceHolder = new SurfaceHolder() {
|
||||
private static final String LOG_TAG = "SurfaceHolder";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user