From e4d9a01bfc7451afff1ed399a5801c7aa2af2831 Mon Sep 17 00:00:00 2001 From: Dan Morrill Date: Thu, 28 Mar 2013 18:10:43 -0700 Subject: Phase 1 of refactoring SystemServer. SystemServer is currently a monolithic class that brings up key system services. This change is the first phase of refactoring it to be more configurable. Specifically, it adds a set of on/off switches used to control startup of individual services. Future plans include finer grained controls and a more explicit and consistent startup sequence for these services. Change-Id: I7299f5ce7d7b74a34eb56dffb788366fbc058532 --- .../java/android/renderscript/RenderScript.java | 29 ++++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'graphics/java/android/renderscript/RenderScript.java') diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index bef28aa89709..822ac6fedacc 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -29,6 +29,7 @@ import android.graphics.SurfaceTexture; import android.os.Process; import android.util.Log; import android.view.Surface; +import android.os.SystemProperties; @@ -56,20 +57,22 @@ public class RenderScript { * We use a class initializer to allow the native code to cache some * field offsets. */ - @SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"}) + @SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"}) // TODO: now used locally; remove? static boolean sInitialized; native static void _nInit(); static { sInitialized = false; - try { - System.loadLibrary("rs_jni"); - _nInit(); - sInitialized = true; - } catch (UnsatisfiedLinkError e) { - Log.e(LOG_TAG, "Error loading RS jni library: " + e); - throw new RSRuntimeException("Error loading RS jni library: " + e); + if (!SystemProperties.getBoolean("config.disable_renderscript", false)) { + try { + System.loadLibrary("rs_jni"); + _nInit(); + sInitialized = true; + } catch (UnsatisfiedLinkError e) { + Log.e(LOG_TAG, "Error loading RS jni library: " + e); + throw new RSRuntimeException("Error loading RS jni library: " + e); + } } } @@ -97,6 +100,11 @@ public class RenderScript { * @param cacheDir A directory the current process can write to */ public static void setupDiskCache(File cacheDir) { + if (!sInitialized) { + Log.e(LOG_TAG, "RenderScript.setupDiskCache() called when disabled"); + return; + } + File f = new File(cacheDir, CACHE_PATH); mCachePath = f.getAbsolutePath(); f.mkdirs(); @@ -1036,6 +1044,11 @@ public class RenderScript { * @return RenderScript */ public static RenderScript create(Context ctx, int sdkVersion, ContextType ct) { + if (!sInitialized) { + Log.e(LOG_TAG, "RenderScript.create() called when disabled; someone is likely to crash"); + return null; + } + RenderScript rs = new RenderScript(ctx); rs.mDev = rs.nDeviceCreate(); -- cgit v1.2.3