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

Commit fb8f4d8c authored by Jean-François Geyelin's avatar Jean-François Geyelin Committed by Gerrit Code Review
Browse files

Revert "Throw an exception when using RenderScript ScriptC with an API level above 34"

This reverts commit f55efb8a.

Reason for revert: b/303246133

atest CtsRsBlasTestCases:android.cts.rsblas.IntrinsicBLAS#test_L3_SGEMM_API -- --abi x86_64

Change-Id: I0860fa2ec00174d3d3974a2f886c71dabff3823c
parent f55efb8a
Loading
Loading
Loading
Loading
+2 −28
Original line number Original line Diff line number Diff line
@@ -16,12 +16,9 @@


package android.renderscript;
package android.renderscript;


import android.app.compat.CompatChanges;
import android.compat.annotation.ChangeId;
import android.compat.annotation.EnabledAfter;
import android.content.res.Resources;
import android.content.res.Resources;
import android.util.Slog;


import java.io.File;
import java.io.IOException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStream;


@@ -37,15 +34,6 @@ import java.io.InputStream;
public class ScriptC extends Script {
public class ScriptC extends Script {
    private static final String TAG = "ScriptC";
    private static final String TAG = "ScriptC";


    /**
     * In targetSdkVersion 35 and above, Renderscript's ScriptC stops being supported
     * and an exception is thrown when the class is instantiated.
     * In targetSdkVersion 34 and below, Renderscript's ScriptC still works.
     */
    @ChangeId
    @EnabledAfter(targetSdkVersion = 35)
    private static final long RENDERSCRIPT_SCRIPTC_DEPRECATION_CHANGE_ID = 297019750L;

    /**
    /**
     * Only intended for use by the generated derived classes.
     * Only intended for use by the generated derived classes.
     *
     *
@@ -101,20 +89,7 @@ public class ScriptC extends Script {
        setID(id);
        setID(id);
    }
    }


    private static void throwExceptionIfSDKTooHigh() {
    private static synchronized long internalCreate(RenderScript rs, Resources resources, int resourceID) {
        String message =
                "ScriptC scripts are not supported when targeting an API Level >= 35. Please refer "
                    + "to https://developer.android.com/guide/topics/renderscript/migration-guide "
                    + "for proposed alternatives.";
        Slog.w(TAG, message);
        if (CompatChanges.isChangeEnabled(RENDERSCRIPT_SCRIPTC_DEPRECATION_CHANGE_ID)) {
            throw new UnsupportedOperationException(message);
        }
    }

    private static synchronized long internalCreate(
            RenderScript rs, Resources resources, int resourceID) {
        throwExceptionIfSDKTooHigh();
        byte[] pgm;
        byte[] pgm;
        int pgmLength;
        int pgmLength;
        InputStream is = resources.openRawResource(resourceID);
        InputStream is = resources.openRawResource(resourceID);
@@ -150,7 +125,6 @@ public class ScriptC extends Script {
    }
    }


    private static synchronized long internalStringCreate(RenderScript rs, String resName, byte[] bitcode) {
    private static synchronized long internalStringCreate(RenderScript rs, String resName, byte[] bitcode) {
        throwExceptionIfSDKTooHigh();
        //        Log.v(TAG, "Create script for resource = " + resName);
        //        Log.v(TAG, "Create script for resource = " + resName);
        return rs.nScriptCCreate(resName, RenderScript.getCachePath(), bitcode, bitcode.length);
        return rs.nScriptCCreate(resName, RenderScript.getCachePath(), bitcode, bitcode.length);
    }
    }