summaryrefslogtreecommitdiff
path: root/graphics/java/android/renderscript/RenderScript.java
diff options
context:
space:
mode:
authorDan Morrill <morrildl@google.com>2013-03-28 18:10:43 -0700
committerDan Morrill <morrildl@google.com>2013-04-04 09:49:22 -0700
commite4d9a01bfc7451afff1ed399a5801c7aa2af2831 (patch)
treeb30444a0b1a12eed9ad08bda1eff549453076a00 /graphics/java/android/renderscript/RenderScript.java
parent9bd94043837d40efe874df1f9b3ca66e192ed3d1 (diff)
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
Diffstat (limited to 'graphics/java/android/renderscript/RenderScript.java')
-rw-r--r--graphics/java/android/renderscript/RenderScript.java29
1 files changed, 21 insertions, 8 deletions
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();