Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 18c1a834 authored by Stefan Andonian's avatar Stefan Andonian Committed by Android (Google) Code Review
Browse files

Merge changes I662d3edb,Iaa5faec2 into main

* changes:
  Fix NPE in ViewCapture test helper
  Disable ViewCapture in Release builds
parents 54d3d486 9be4403d
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
package com.android.app.viewcapture

import android.media.permission.SafeCloseable
import android.os.HandlerThread
import android.view.View
import android.view.Window

/**
 * We don't want to enable the ViewCapture for release builds, since it currently only serves
 * 1p apps, and has memory / cpu load that we don't want to risk negatively impacting release builds
 */
class NoOpViewCapture: ViewCapture(0, 0,
        createAndStartNewLooperExecutor("NoOpViewCapture", HandlerThread.MIN_PRIORITY)) {
    override fun startCapture(view: View?, name: String?): SafeCloseable {
        return SafeCloseable { }
    }

    override fun startCapture(window: Window?): SafeCloseable {
        return SafeCloseable { }
    }
}
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ internal constructor(private val context: Context, executor: Executor)
        @JvmStatic
        fun getInstance(context: Context): ViewCapture = when {
            INSTANCE != null -> INSTANCE!!
            !android.os.Build.IS_DEBUGGABLE -> NoOpViewCapture()
            Looper.myLooper() == Looper.getMainLooper() -> SettingsAwareViewCapture(
                    context.applicationContext,
                    createAndStartNewLooperExecutor("SAViewCapture",
+2 −1
Original line number Diff line number Diff line
@@ -173,7 +173,7 @@ public abstract class ViewCapture {
    }

    @AnyThread
    public void dumpTo(OutputStream os, Context context)
    protected void dumpTo(OutputStream os, Context context)
            throws InterruptedException, ExecutionException, IOException {
        if (mIsEnabled) getExportedData(context).writeTo(os);
    }
@@ -382,6 +382,7 @@ public abstract class ViewCapture {
        }

        void attachToRoot() {
            if (mRoot == null) return;
            mIsActive = true;
            if (mRoot.isAttachedToWindow()) {
                safelyEnableOnDrawListener();