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