diff options
| author | 2017-09-09 17:45:27 -0700 | |
|---|---|---|
| committer | 2017-09-09 17:45:27 -0700 | |
| commit | 9309c19513ef569043cfd08deae78e04d5eb5c24 (patch) | |
| tree | f444852e4ec74b265c68d7b0013c7ade88967838 | |
| parent | 627cc3c7ae03d46f775a0e681034c38ad0867bd7 (diff) | |
Revert "Remove a compat hack SurfaceView#setWindowType()"
This CL reverts my previous CL [1] that aimed to get rid of
a nasty compatibility hack that was introduced for Bug 36345857.
For those who are interested in, what happenned are:
1. @hide method SurfaceView#setWindowType() was removed [2].
2. It broke some app (Bug 36345857). We had to work around
it by re-introducing SurfaceView#setWindowType()
temporarily [3].
3. Some app switched to the correct implementation when
running on Android O devices.
4. We removed that compatibility hack [1] (Bug 62054282).
5. Android O MR1 is set to be "REL" [4].
6. It broke some app, probably because of some unfortunate
mistake in the version check logic in that app.
7. We end up introducing the same hack again for O MR1.
[1]: Icee198c554de558cfa4ffe0b264064969839654e
7a1ad6d97ca1984789446211a986d5ad1b5c81e2
[2]: Ie56b6f7ab16f32d7fc459b8eba26594337ad55de
d5c7dd6da810a6b89151b337bea79fd817e6b72a
[3]: I5217f6417a73690ae8a978754218b7b089070fdd
3b5011afc9e17963607269bfb6665d04e3ab4ca1
[4]: I054e3ecff49803e61e7741753fe6764a567d72c4
62a835d0ef89e51f4a97fecf8576224551b545a5
Bug: 36345857
Bug: 62054282
Fixes: 65508814
Test: Manually verified that Bug 65508814 is not reproducible
Change-Id: If8a3f726789daa22f73e1962e938f071d3c09414
| -rw-r--r-- | core/java/android/view/SurfaceView.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java index 1d206abbceea..cac27afa72cb 100644 --- a/core/java/android/view/SurfaceView.java +++ b/core/java/android/view/SurfaceView.java @@ -16,6 +16,7 @@ package android.view; +import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_PANEL; import static android.view.WindowManagerPolicy.APPLICATION_MEDIA_OVERLAY_SUBLAYER; import static android.view.WindowManagerPolicy.APPLICATION_MEDIA_SUBLAYER; import static android.view.WindowManagerPolicy.APPLICATION_PANEL_SUBLAYER; @@ -871,6 +872,31 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb return callbacks; } + /** + * This method still exists only for compatibility reasons because some applications have relied + * on this method via reflection. See Issue 36345857 for details. + * + * @deprecated No platform code is using this method anymore. + * @hide + */ + @Deprecated + public void setWindowType(int type) { + if (getContext().getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.O) { + throw new UnsupportedOperationException( + "SurfaceView#setWindowType() has never been a public API."); + } + + if (type == TYPE_APPLICATION_PANEL) { + Log.e(TAG, "If you are calling SurfaceView#setWindowType(TYPE_APPLICATION_PANEL) " + + "just to make the SurfaceView to be placed on top of its window, you must " + + "call setZOrderOnTop(true) instead.", new Throwable()); + setZOrderOnTop(true); + return; + } + Log.e(TAG, "SurfaceView#setWindowType(int) is deprecated and now does nothing. " + + "type=" + type, new Throwable()); + } + private void runOnUiThread(Runnable runnable) { Handler handler = getHandler(); if (handler != null && handler.getLooper() != Looper.myLooper()) { |