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

Commit a53de062 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Add callback hack to find out when to load system properties.

Use this to reload the trace and layout bounds properties.

This is ONLY for debugging.

Change-Id: I1c4bdb52c823520c352c5bac45fa9ee31160793c
parent 8b2e37e5
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -140,6 +140,9 @@ public interface IBinder {
     */
    int LIKE_TRANSACTION   = ('_'<<24)|('L'<<16)|('I'<<8)|'K';

    /** @hide */
    int SYSPROPS_TRANSACTION = ('_'<<24)|('S'<<16)|('P'<<8)|'R';

    /**
     * Flag to {@link #transact}: this is a one-way call, meaning that the
     * caller returns immediately, without waiting for a result from the
+28 −8
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.os;

import java.util.ArrayList;


/**
 * Native implementation of the service manager.  Most clients will only
@@ -151,14 +153,32 @@ class ServiceManagerProxy implements IServiceManager {
    }
    
    public String[] listServices() throws RemoteException {
        ArrayList<String> services = new ArrayList<String>();
        int n = 0;
        while (true) {
            Parcel data = Parcel.obtain();
            Parcel reply = Parcel.obtain();
            data.writeInterfaceToken(IServiceManager.descriptor);
        mRemote.transact(LIST_SERVICES_TRANSACTION, data, reply, 0);
        String[] list = reply.readStringArray();
            data.writeInt(n);
            n++;
            try {
                boolean res = mRemote.transact(LIST_SERVICES_TRANSACTION, data, reply, 0);
                if (!res) {
                    break;
                }
            } catch (RuntimeException e) {
                // The result code that is returned by the C++ code can
                // cause the call to throw an exception back instead of
                // returning a nice result...  so eat it here and go on.
                break;
            }
            services.add(reply.readString());
            reply.recycle();
            data.recycle();
        return list;
        }
        String[] array = new String[services.size()];
        services.toArray(array);
        return array;
    }

    public void setPermissionController(IPermissionController controller)
+29 −0
Original line number Diff line number Diff line
@@ -16,6 +16,10 @@

package android.os;

import java.util.ArrayList;

import android.util.Log;


/**
 * Gives access to the system properties store.  The system properties
@@ -28,12 +32,15 @@ public class SystemProperties
    public static final int PROP_NAME_MAX = 31;
    public static final int PROP_VALUE_MAX = 91;

    private static final ArrayList<Runnable> sChangeCallbacks = new ArrayList<Runnable>();

    private static native String native_get(String key);
    private static native String native_get(String key, String def);
    private static native int native_get_int(String key, int def);
    private static native long native_get_long(String key, long def);
    private static native boolean native_get_boolean(String key, boolean def);
    private static native void native_set(String key, String def);
    private static native void native_add_change_callback();

    /**
     * Get the value for the given key.
@@ -124,4 +131,26 @@ public class SystemProperties
        }
        native_set(key, val);
    }

    public static void addChangeCallback(Runnable callback) {
        synchronized (sChangeCallbacks) {
            if (sChangeCallbacks.size() == 0) {
                native_add_change_callback();
            }
            sChangeCallbacks.add(callback);
        }
    }

    static void callChangeCallbacks() {
        synchronized (sChangeCallbacks) {
            //Log.i("foo", "Calling " + sChangeCallbacks.size() + " change callbacks!");
            if (sChangeCallbacks.size() == 0) {
                return;
            }
            ArrayList<Runnable> callbacks = new ArrayList<Runnable>(sChangeCallbacks);
            for (int i=0; i<callbacks.size(); i++) {
                callbacks.get(i).run();
            }
        }
    }
}
+9 −1
Original line number Diff line number Diff line
@@ -47,13 +47,21 @@ public final class Trace {

    public static final String PROPERTY_TRACE_TAG_ENABLEFLAGS = "debug.atrace.tags.enableflags";

    private static final long sEnabledTags = nativeGetEnabledTags();
    private static long sEnabledTags = nativeGetEnabledTags();

    private static native long nativeGetEnabledTags();
    private static native void nativeTraceCounter(long tag, String name, int value);
    private static native void nativeTraceBegin(long tag, String name);
    private static native void nativeTraceEnd(long tag);

    static {
        SystemProperties.addChangeCallback(new Runnable() {
            @Override public void run() {
                sEnabledTags = nativeGetEnabledTags();
            }
        });
    }

    private Trace() {
    }

+1 −1
Original line number Diff line number Diff line
@@ -17250,7 +17250,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        /**
         * Show where the margins, bounds and layout bounds are for each view.
         */
        final boolean mDebugLayout = SystemProperties.getBoolean(DEBUG_LAYOUT_PROPERTY, false);
        boolean mDebugLayout = SystemProperties.getBoolean(DEBUG_LAYOUT_PROPERTY, false);
        /**
         * Point used to compute visible regions.
Loading