OSDN Git Service

Merge "Fix the RIL-to-HIDL conversion for Cell Lat and Long" am: 988cd1f5d3 am: 799ca...
[android-x86/hardware-ril.git] / libril / RilSocket.h
index 619401a..53b00c9 100644 (file)
 #include "rilSocketQueue.h"
 #include <ril_event.h>
 
-using namespace std;
-
-extern "C" void *ril_socket_process_requests_loop(void *arg);
-
 /**
  * Abstract socket class representing sockets in rild.
  * <p>
@@ -46,81 +42,6 @@ class RilSocket {
          */
         RIL_SOCKET_ID id;
 
-       /**
-        * Listen socket file descriptor.
-        */
-        int listenFd = -1;
-
-       /**
-        * Commands socket file descriptor.
-        */
-        int commandFd = -1;
-
-       /**
-        * Socket request loop thread id.
-        */
-        pthread_t socketThreadId;
-
-       /**
-        * Listen event callack. Callback called when the other ends does accept.
-        */
-        ril_event_cb listenCb;
-
-       /**
-        * Commands event callack.Callback called when there are requests from the other side.
-        */
-        ril_event_cb commandCb;
-
-        /**
-         * Listen event to be added to eventloop after socket listen.
-         */
-        struct ril_event listenEvent;
-
-        /**
-         * Commands event to be added to eventloop after accept.
-         */
-        struct ril_event callbackEvent;
-
-        /**
-         * Static socket listen handler. Chooses the socket to call the listen callback
-         * from ril.cpp.
-         *
-         * @param Listen fd.
-         * @param flags.
-         * @param Parameter for the listen handler.
-         */
-        static void sSocketListener(int fd, short flags, void *param);
-
-        /**
-         * Static socket request handler. Chooses the socket to call the request handler on.
-         *
-         * @param Commands fd.
-         * @param flags.
-         * @param Parameter for the request handler.
-         */
-        static void sSocketRequestsHandler(int fd, short flags, void *param);
-
-        /**
-         * Process record from the record stream and push the requests onto the queue.
-         *
-         * @param record data.
-         * @param record length.
-         */
-        virtual void pushRecord(void *record, size_t recordlen) = 0;
-
-        /**
-         * Socket lock for writing data on the socket.
-         */
-        pthread_mutex_t write_lock = PTHREAD_MUTEX_INITIALIZER;
-
-        /**
-         * The loop to process the incoming requests.
-         */
-        virtual void *processRequestsLoop(void) = 0;
-
-    private:
-        friend void *::ril_socket_process_requests_loop(void *arg);
-
     public:
 
         /**
@@ -135,138 +56,15 @@ class RilSocket {
         }
 
         /**
-         * Clean up function on commands socket close.
-         */
-        virtual void onCommandsSocketClosed(void) = 0;
-
-        /**
-         * Function called on new commands socket connect. Request loop thread is started here.
-         */
-        void onNewCommandConnect(void);
-
-        /**
-         * Set listen socket fd.
-         *
-         * @param Input fd.
-         */
-        void setListenFd(int listenFd);
-
-        /**
-         * Set commands socket fd.
-         *
-         * @param Input fd.
-         */
-        void setCommandFd(int commandFd);
-
-        /**
-         * Get listen socket fd.
-         *
-         * @return Listen fd.
-         */
-        int getListenFd(void);
-
-        /**
-         * Get commands socket fd.
+         * Get socket id.
          *
-         * @return Commands fd.
+         * @return RIL_SOCKET_ID socket id.
          */
-        int getCommandFd(void);
-
-        /**
-         * Set listen event callback.
-         *
-         * @param Input event callback.
-         */
-        void setListenCb(ril_event_cb listenCb);
-
-        /**
-         * Set command event callback.
-         *
-         * @param Input event callback.
-         */
-        void setCommandCb(ril_event_cb commandCb);
-
-        /**
-         * Get listen event callback.
-         *
-         * @return Listen event callback.
-         */
-        ril_event_cb getListenCb(void);
-
-        /**
-         * Gey command event callback.
-         *
-         * @return Command event callback.
-         */
-        ril_event_cb getCommandCb(void);
-
-        /**
-         * Set listen event.
-         *
-         * @param Input event.
-         */
-        void setListenEvent(ril_event listenEvent);
-
-        /**
-         * Set command callback event.
-         *
-         * @param Input event.
-         */
-        void setCallbackEvent(ril_event commandEvent);
-
-        /**
-         * Get listen event.
-         *
-         * @return Listen event.
-         */
-        ril_event* getListenEvent(void);
-
-        /**
-         * Get commands callback event.
-         *
-         * @return Commands callback event.
-         */
-        ril_event* getCallbackEvent(void);
+        RIL_SOCKET_ID getSocketId(void) {
+            return id;
+        }
 
         virtual ~RilSocket(){}
-
-    protected:
-
-        /**
-         * Start listening on the socket and add the socket listen callback event.
-         *
-         * @return Result of the socket listen.
-         */
-        int socketInit(void);
-
-        /**
-         * Socket request handler
-         *
-         * @param Commands fd.
-         * @param flags.
-         * @param Record stream.
-         */
-        void socketRequestsHandler(int fd, short flags, RecordStream *rs);
-};
-
-class socketClient {
-    public:
-        RilSocket *socketPtr;
-        RecordStream *rs;
-
-        socketClient(RilSocket *socketPtr, RecordStream *rs) {
-            this->socketPtr = socketPtr;
-            this->rs = rs;
-        }
 };
 
-typedef struct MySocketListenParam {
-    SocketListenParam sListenParam;
-    RilSocket *socket;
-} MySocketListenParam;
-
-typedef void* (RilSocket::*RilSocketFuncPtr)(void);
-typedef void (RilSocket::*RilSocketEventPtr)(int fd,short flags, void *param);
-typedef void* (*PthreadPtr)(void*);
-
 #endif