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

Commit 80b12fca authored by Romain Guy's avatar Romain Guy
Browse files

Disable the AssetAtlas when running under valgrind

Bug #9191438

When running under valgrind, the ppid will be different from the ppid
of the system server (which always gets forked from zygote.)

Change-Id: I42cbf99fd0084aeab76c30de9beb7c49ed1fc7d8
parent 3bf4fa4b
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -649,6 +649,12 @@ public class Process {
     */
    public static final native int myPid();

    /**
     * Returns the identifier of this process' parent.
     * @hide
     */
    public static native int myPpid();

    /**
     * Returns the identifier of the calling thread, which be used with
     * {@link #setThreadPriority(int, int)}.
+7 −5
Original line number Diff line number Diff line
@@ -1931,6 +1931,7 @@ public abstract class HardwareRenderer {

            IAssetAtlas atlas = IAssetAtlas.Stub.asInterface(binder);
            try {
                if (atlas.isCompatible(android.os.Process.myPpid())) {
                    GraphicBuffer buffer = atlas.getBuffer();
                    if (buffer != null) {
                        int[] map = atlas.getMap();
@@ -1938,6 +1939,7 @@ public abstract class HardwareRenderer {
                            GLES20Canvas.initAtlas(buffer, map);
                        }
                    }
                }
            } catch (RemoteException e) {
                Log.w(LOG_TAG, "Could not acquire atlas", e);
            }
+7 −0
Original line number Diff line number Diff line
@@ -27,6 +27,13 @@ import android.view.GraphicBuffer;
 * @hide
 */
interface IAssetAtlas {
    /**
     * Indicates whether the atlas is compatible with the specified
     * parent process id. If the atlas' ppid does not match, this
     * method will return false.
     */
    boolean isCompatible(int ppid);

    /**
     * Returns the atlas buffer (texture) or null if the atlas is
     * not available yet.
+6 −0
Original line number Diff line number Diff line
@@ -99,6 +99,11 @@ jint android_os_Process_myPid(JNIEnv* env, jobject clazz)
    return getpid();
}

jint android_os_Process_myPpid(JNIEnv* env, jobject clazz)
{
    return getppid();
}

jint android_os_Process_myUid(JNIEnv* env, jobject clazz)
{
    return getuid();
@@ -990,6 +995,7 @@ jintArray android_os_Process_getPidsForCommands(JNIEnv* env, jobject clazz,

static const JNINativeMethod methods[] = {
    {"myPid",       "()I", (void*)android_os_Process_myPid},
    {"myPpid",      "()I", (void*)android_os_Process_myPpid},
    {"myTid",       "()I", (void*)android_os_Process_myTid},
    {"myUid",       "()I", (void*)android_os_Process_myUid},
    {"getUidForName",       "(Ljava/lang/String;)I", (void*)android_os_Process_getUidForName},
+5 −0
Original line number Diff line number Diff line
@@ -369,6 +369,11 @@ public class AssetAtlasService extends IAssetAtlas.Stub {
    private static native void nReleaseAtlasCanvas(Canvas canvas, int bitmap);
    private static native boolean nUploadAtlas(GraphicBuffer buffer, int bitmap);

    @Override
    public boolean isCompatible(int ppid) {
        return ppid == android.os.Process.myPpid();
    }

    @Override
    public GraphicBuffer getBuffer() throws RemoteException {
        return mAtlasReady.get() ? mBuffer : null;