Loading rs/java/android/renderscript/ScriptC.java +26 −1 Original line number Diff line number Diff line Loading @@ -16,9 +16,12 @@ 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.util.Slog; import java.io.File; import java.io.IOException; import java.io.InputStream; Loading @@ -34,6 +37,15 @@ import java.io.InputStream; public class ScriptC extends Script { 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. * Loading Loading @@ -89,7 +101,19 @@ public class ScriptC extends Script { setID(id); } private static void throwExceptionIfSDKTooHigh() { 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; int pgmLength; InputStream is = resources.openRawResource(resourceID); Loading Loading @@ -126,6 +150,7 @@ public class ScriptC extends Script { private static synchronized long internalStringCreate(RenderScript rs, String resName, byte[] bitcode) { // Log.v(TAG, "Create script for resource = " + resName); throwExceptionIfSDKTooHigh(); return rs.nScriptCCreate(resName, RenderScript.getCachePath(), bitcode, bitcode.length); } } Loading
rs/java/android/renderscript/ScriptC.java +26 −1 Original line number Diff line number Diff line Loading @@ -16,9 +16,12 @@ 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.util.Slog; import java.io.File; import java.io.IOException; import java.io.InputStream; Loading @@ -34,6 +37,15 @@ import java.io.InputStream; public class ScriptC extends Script { 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. * Loading Loading @@ -89,7 +101,19 @@ public class ScriptC extends Script { setID(id); } private static void throwExceptionIfSDKTooHigh() { 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; int pgmLength; InputStream is = resources.openRawResource(resourceID); Loading Loading @@ -126,6 +150,7 @@ public class ScriptC extends Script { private static synchronized long internalStringCreate(RenderScript rs, String resName, byte[] bitcode) { // Log.v(TAG, "Create script for resource = " + resName); throwExceptionIfSDKTooHigh(); return rs.nScriptCCreate(resName, RenderScript.getCachePath(), bitcode, bitcode.length); } }