Loading src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java +17 −5 Original line number Diff line number Diff line Loading @@ -81,10 +81,12 @@ public class PreviewSurfaceRenderer implements IBinder.DeathRecipient { binderDied(); } SurfaceControlViewHost.SurfacePackage surfacePackage; try { mSurfaceControlViewHost = MAIN_EXECUTOR .submit(() -> new SurfaceControlViewHost(mContext, mDisplay, mHostToken)) .get(5, TimeUnit.SECONDS); surfacePackage = mSurfaceControlViewHost.getSurfacePackage(); mHostToken.linkToDeath(this, 0); } catch (Exception e) { e.printStackTrace(); Loading @@ -92,6 +94,14 @@ public class PreviewSurfaceRenderer implements IBinder.DeathRecipient { } MAIN_EXECUTOR.execute(() -> { // If mSurfaceControlViewHost is null due to any reason (e.g. binder died, // happening when user leaves the preview screen before preview rendering finishes), // we should return here. SurfaceControlViewHost host = mSurfaceControlViewHost; if (host == null) { return; } View view = new LauncherPreviewRenderer(mContext, mIdp).getRenderedView(); // This aspect scales the view to fit in the surface and centers it final float scale = Math.min(mWidth / (float) view.getMeasuredWidth(), Loading @@ -107,14 +117,14 @@ public class PreviewSurfaceRenderer implements IBinder.DeathRecipient { .setInterpolator(new AccelerateDecelerateInterpolator()) .setDuration(FADE_IN_ANIMATION_DURATION) .start(); mSurfaceControlViewHost.setView(view, view.getMeasuredWidth(), host.setView(view, view.getMeasuredWidth(), view.getMeasuredHeight()); }); Bundle result = new Bundle(); result.putParcelable(KEY_SURFACE_PACKAGE, mSurfaceControlViewHost.getSurfacePackage()); result.putParcelable(KEY_SURFACE_PACKAGE, surfacePackage); Handler handler = new Handler(Looper.getMainLooper(), Loopermessage -> { Handler handler = new Handler(Looper.getMainLooper(), message -> { binderDied(); return true; }); Loading @@ -128,8 +138,10 @@ public class PreviewSurfaceRenderer implements IBinder.DeathRecipient { @Override public void binderDied() { if (mSurfaceControlViewHost != null) { MAIN_EXECUTOR.execute(() -> { mSurfaceControlViewHost.release(); mSurfaceControlViewHost = null; }); } mHostToken.unlinkToDeath(this, 0); } Loading Loading
src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java +17 −5 Original line number Diff line number Diff line Loading @@ -81,10 +81,12 @@ public class PreviewSurfaceRenderer implements IBinder.DeathRecipient { binderDied(); } SurfaceControlViewHost.SurfacePackage surfacePackage; try { mSurfaceControlViewHost = MAIN_EXECUTOR .submit(() -> new SurfaceControlViewHost(mContext, mDisplay, mHostToken)) .get(5, TimeUnit.SECONDS); surfacePackage = mSurfaceControlViewHost.getSurfacePackage(); mHostToken.linkToDeath(this, 0); } catch (Exception e) { e.printStackTrace(); Loading @@ -92,6 +94,14 @@ public class PreviewSurfaceRenderer implements IBinder.DeathRecipient { } MAIN_EXECUTOR.execute(() -> { // If mSurfaceControlViewHost is null due to any reason (e.g. binder died, // happening when user leaves the preview screen before preview rendering finishes), // we should return here. SurfaceControlViewHost host = mSurfaceControlViewHost; if (host == null) { return; } View view = new LauncherPreviewRenderer(mContext, mIdp).getRenderedView(); // This aspect scales the view to fit in the surface and centers it final float scale = Math.min(mWidth / (float) view.getMeasuredWidth(), Loading @@ -107,14 +117,14 @@ public class PreviewSurfaceRenderer implements IBinder.DeathRecipient { .setInterpolator(new AccelerateDecelerateInterpolator()) .setDuration(FADE_IN_ANIMATION_DURATION) .start(); mSurfaceControlViewHost.setView(view, view.getMeasuredWidth(), host.setView(view, view.getMeasuredWidth(), view.getMeasuredHeight()); }); Bundle result = new Bundle(); result.putParcelable(KEY_SURFACE_PACKAGE, mSurfaceControlViewHost.getSurfacePackage()); result.putParcelable(KEY_SURFACE_PACKAGE, surfacePackage); Handler handler = new Handler(Looper.getMainLooper(), Loopermessage -> { Handler handler = new Handler(Looper.getMainLooper(), message -> { binderDied(); return true; }); Loading @@ -128,8 +138,10 @@ public class PreviewSurfaceRenderer implements IBinder.DeathRecipient { @Override public void binderDied() { if (mSurfaceControlViewHost != null) { MAIN_EXECUTOR.execute(() -> { mSurfaceControlViewHost.release(); mSurfaceControlViewHost = null; }); } mHostToken.unlinkToDeath(this, 0); } Loading