2 // Copyright 2007 The Android Open Source Project
4 // Serve properties to the simulated runtime.
6 #ifndef _SIM_PROPERTY_SERVER_H
7 #define _SIM_PROPERTY_SERVER_H
9 #include "cutils/properties.h"
10 #include "utils/List.h"
13 * Define a thread that responds to requests from clients to get/set/list
16 class PropertyServer : public wxThread {
18 PropertyServer(void) : mListenSock(-1) {}
19 virtual ~PropertyServer(void);
21 /* start the thread running */
22 bool StartThread(void);
24 /* thread entry point */
25 virtual void* Entry(void);
27 /* clear out all properties */
28 void ClearProperties(void);
30 /* add some default values */
31 void SetDefaultProperties(void);
33 /* copy a property into valueBuf; returns false if property not found */
34 bool GetProperty(const char* key, char* valueBuf);
36 /* set the property, replacing it if it already exists */
37 bool SetProperty(const char* key, const char* value);
39 /* property name constants */
40 static const char* kPropCheckJni;
43 /* one property entry */
44 typedef struct Property {
45 char key[PROPERTY_KEY_MAX];
46 char value[PROPERTY_VALUE_MAX];
49 /* create the UNIX-domain socket we listen on */
50 bool CreateSocket(const char* fileName);
52 /* serve up properties */
53 void ServeProperties(void);
55 /* handle a client request */
56 bool HandleRequest(int fd);
58 /* listen here for new connections */
61 /* list of connected fds to scan */
62 android::List<int> mClientList;
64 /* set of known properties */
65 android::List<Property> mPropList;
68 #endif // PROPERTY_SERVER_H