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

Commit 455af7f7 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android Git Automerger
Browse files

am 67cc7f2e: am a53de062: Add callback hack to find out when to load system properties.

* commit '67cc7f2e':
  Add callback hack to find out when to load system properties.
parents 15908221 67cc7f2e
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -140,6 +140,9 @@ public interface IBinder {
     */
     */
    int LIKE_TRANSACTION   = ('_'<<24)|('L'<<16)|('I'<<8)|'K';
    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
     * Flag to {@link #transact}: this is a one-way call, meaning that the
     * caller returns immediately, without waiting for a result from the
     * caller returns immediately, without waiting for a result from the
+28 −8
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package android.os;
package android.os;


import java.util.ArrayList;



/**
/**
 * Native implementation of the service manager.  Most clients will only
 * Native implementation of the service manager.  Most clients will only
@@ -151,14 +153,32 @@ class ServiceManagerProxy implements IServiceManager {
    }
    }
    
    
    public String[] listServices() throws RemoteException {
    public String[] listServices() throws RemoteException {
        ArrayList<String> services = new ArrayList<String>();
        int n = 0;
        while (true) {
            Parcel data = Parcel.obtain();
            Parcel data = Parcel.obtain();
            Parcel reply = Parcel.obtain();
            Parcel reply = Parcel.obtain();
            data.writeInterfaceToken(IServiceManager.descriptor);
            data.writeInterfaceToken(IServiceManager.descriptor);
        mRemote.transact(LIST_SERVICES_TRANSACTION, data, reply, 0);
            data.writeInt(n);
        String[] list = reply.readStringArray();
            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();
            reply.recycle();
            data.recycle();
            data.recycle();
        return list;
        }
        String[] array = new String[services.size()];
        services.toArray(array);
        return array;
    }
    }


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


package android.os;
package android.os;


import java.util.ArrayList;

import android.util.Log;



/**
/**
 * Gives access to the system properties store.  The system properties
 * 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_NAME_MAX = 31;
    public static final int PROP_VALUE_MAX = 91;
    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);
    private static native String native_get(String key, String def);
    private static native String native_get(String key, String def);
    private static native int native_get_int(String key, int 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 long native_get_long(String key, long def);
    private static native boolean native_get_boolean(String key, boolean 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_set(String key, String def);
    private static native void native_add_change_callback();


    /**
    /**
     * Get the value for the given key.
     * Get the value for the given key.
@@ -124,4 +131,26 @@ public class SystemProperties
        }
        }
        native_set(key, val);
        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 Original line 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";
    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 long nativeGetEnabledTags();
    private static native void nativeTraceCounter(long tag, String name, int value);
    private static native void nativeTraceCounter(long tag, String name, int value);
    private static native void nativeTraceBegin(long tag, String name);
    private static native void nativeTraceBegin(long tag, String name);
    private static native void nativeTraceEnd(long tag);
    private static native void nativeTraceEnd(long tag);


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

    private Trace() {
    private Trace() {
    }
    }


+1 −1
Original line number Original line Diff line number Diff line
@@ -17210,7 +17210,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        /**
        /**
         * Show where the margins, bounds and layout bounds are for each view.
         * 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.
         * Point used to compute visible regions.
Loading