Remove DeviceManagerService.
authorHokwon Song <hokwon.song@samsung.com>
Fri, 14 Jun 2013 05:27:38 +0000 (14:27 +0900)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Thu, 20 Jun 2013 06:53:21 +0000 (06:53 +0000)
Change-Id: Ib5f3edd7d8a557a87ab0f06f573662518a02b428
Signed-off-by: Hokwon Song <hokwon.song@samsung.com>
CMakeLists.txt
inc/AppService.h
inc/FSys_DeviceManagerService.h [deleted file]
src/AppService.cpp
src/FSys_DeviceManagerService.cpp [deleted file]

index acbb84f..92850ce 100644 (file)
@@ -69,7 +69,6 @@ SET (${this_target}_SOURCE_FILES
        src/FApp_ContextManager.cpp
        src/FApp_CommunicationDispatcher.cpp
        src/FApp_PackageManagerStub.cpp
-       src/FSys_DeviceManagerService.cpp
        src/FSys_SystemService.cpp
        src/FSys_AccessoryManagerService.cpp
        src/AppService.cpp
index 606bf06..55d4ba0 100755 (executable)
@@ -43,7 +43,6 @@ namespace Tizen { namespace System
 {
 class _AlarmService;
 class _AccessoryManagerService;
-class _DeviceManagerService;
 class _SettingService;
 class _SystemService;
 }}
@@ -127,7 +126,6 @@ private:
        Tizen::App::_AppManagerStub* __pAppManagerStub;
        Tizen::App::_ConditionManagerStub* __pConditionManagerStub;
        _TaskHandlerThread      __handlerThread;
-       Tizen::System::_DeviceManagerService* __pDeviceManagerService;
        Tizen::System::_SystemService* __pSystemService;
        Tizen::System::_SettingService* __pSettingService;
        Tizen::System::_AccessoryManagerService* __pAccessoryManagerService;
diff --git a/inc/FSys_DeviceManagerService.h b/inc/FSys_DeviceManagerService.h
deleted file mode 100644 (file)
index ced994e..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-//
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-/**
- * @file        FSys_DeviceManagerService.h
- * @brief      This is the header file of the _DeviceManagerService class.
- *
- * This header file contains the declarations of the _DeviceManagerService class.
- */
-#include <FApp.h>
-#include <FBase.h>
-#include <FSys_IDeviceManagerEventListener.h>
-#include "FApp_ICommunicationRequestListener.h"
-
-#ifndef _FSYS_INTERNAL_DEVICE_MANAGER_SERVICE_H_
-#define _FSYS_INTERNAL_DEVICE_MANAGER_SERVICE_H_
-
-namespace Tizen { namespace System {
-
-/**
- * @class      _DeviceManagerService
- * @brief      This class contains implementaion of device control.
- * @since 2.1
- */
-class _DeviceManagerService
-       : public Tizen::App::_ICommunicationRequestListener
-{
-private:
-       _DeviceManagerService(void);
-       virtual ~_DeviceManagerService(void);
-public:
-       virtual Tizen::Base::String GetId(void);
-       void OnRequestOccured(Tizen::App::AppId appId, int pid, Tizen::Base::Collection::ArrayList* request, Tizen::Base::Collection::ArrayList* response);
-       void OnApplicationTerminated(const Tizen::App::AppId& appId, int pid);
-       void SendEvent(Tizen::Base::String event);
-       void SetBluetoothStatus(bool status);
-       bool GetBluetoothStatus(void);
-       static _DeviceManagerService* GetInstance(void);
-
-private:
-       static _DeviceManagerService* __pDeviceManagerService;
-       Tizen::App::_CommunicationDispatcher* __pCommunicationDispatcher;
-       bool isBluetoothHeadSetConnected;
-       bool isInitBluetooth;
-       Tizen::Base::Collection::ArrayList __interestedPidList;
-
-private:
-       void AddInterestedApp(int pid);
-       void RemoveInterestedApp(int pid);
-
-};     //_DeviceManagerService
-
-}} //Tizen::System
-#endif /* _FSYS_INTERNAL_DEVICE_MANAGER_SERVICE_H_ */
index b3e8037..d02b17e 100755 (executable)
@@ -40,7 +40,6 @@
 #include "FApp_ContextManager.h"
 #include "FApp_AppManagerStub.h"
 #include "FApp_ConditionManagerStub.h"
-#include "FSys_DeviceManagerService.h"
 #include "FSys_SystemService.h"
 #include "FSys_SettingService.h"
 #include "FSys_AccessoryManagerService.h"
@@ -84,7 +83,6 @@ AppService::AppService()
 , __pAppManagerStub(null)
 , __pConditionManagerStub(null)
 , __handlerThread(*this)
-, __pDeviceManagerService(null)
 , __pSystemService(null)
 , __pSettingService(null)
 , __pAccessoryManagerService(null)
@@ -263,10 +261,6 @@ CATCH:
 void
 AppService::ReadySystemServices(void)
 {
-       __pDeviceManagerService = _DeviceManagerService::GetInstance();
-       SysAssert( __pDeviceManagerService != null);
-       SysTryReturnVoidResult(NID_APP, __pDeviceManagerService != null, E_OUT_OF_MEMORY, "It is failed to _DeviceManagerService creation.");
-
        __pSystemService = _SystemService::GetInstance();
        SysAssert( __pSystemService != null);
        SysTryReturnVoidResult(NID_APP, __pSystemService != null, E_OUT_OF_MEMORY, "It is failed to _SystemService creation.");
diff --git a/src/FSys_DeviceManagerService.cpp b/src/FSys_DeviceManagerService.cpp
deleted file mode 100644 (file)
index 85a822a..0000000
+++ /dev/null
@@ -1,378 +0,0 @@
-//
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-/**
- * @file               FSys_DeviceManagerService.cpp
- * @brief              This is the implementation file for _DeviceManagerService class.
- */
-
-#include <new>
-#include <system/media_key.h>
-#include <bluetooth.h>
-
-#include <FBaseSysLog.h>
-#include <FSys_DeviceManagerEventProvider.h>
-
-#include "FApp_CommunicationDispatcher.h"
-#include "FSys_DeviceManagerService.h"
-
-using namespace Tizen::App;
-using namespace Tizen::Io;
-using namespace Tizen::System;
-using namespace Tizen::Base;
-using namespace Tizen::Base::Collection;
-
-namespace {
-       const String DEVICE_MANAGER_SERVICE_ID = L"osp.devicemanager.service";
-       const String DEVICE_MANAGER_COMMAND_OPEN = L"osp.devicemanager.command.open";
-       const String DEVICE_MANAGER_COMMAND_CLOSE = L"osp.devicemanager.command.close";
-       const String DEVICE_MANAGER_COMMAND_STATUS= L"osp.devicemanager.command.status";
-       const String DEVICE_MANAGER_COMMAND_EVENT = L"osp.devicemanager.command.event";
-       const String DEVICE_MANAGER_BLUETOOTH = L"osp.devicemanager.bluetooth";
-
-       const String BLUETOOTH_A2DP_CONNECTED = L"Connected";
-       const String BLUETOOTH_A2DP_DISCONNECTED = L"Disconnected";
-       const String BLUETOOTH_A2DP_PLAY = L"Play";
-       const String BLUETOOTH_A2DP_STOP = L"Stop";
-       const String BLUETOOTH_A2DP_PAUSE = L"Pause";
-       const String BLUETOOTH_A2DP_RESUME = L"Resume";
-       const String BLUETOOTH_A2DP_FORWARD = L"Forward";
-       const String BLUETOOTH_A2DP_FASTFORWARD = L"FastForward";
-       const String BLUETOOTH_A2DP_BACKWARD = L"Backward";
-       const String BLUETOOTH_A2DP_REWIND = L"Rewind";
-}
-
-Tizen::System::_DeviceManagerService* Tizen::System::_DeviceManagerService::__pDeviceManagerService = null;
-
-void bluetooth_connection_state_changed(int result, bool connected, const char* remote_address, bt_audio_profile_type_e type, void* user_data)
-{
-       SysLog(NID_SYS, "Bluetooth headset[%s] connection[%d] event", remote_address, connected);
-       String bt_event;
-       _DeviceManagerService* pDeviceManagerService = _DeviceManagerService::GetInstance();
-
-       if(pDeviceManagerService != null)
-       {
-               if(pDeviceManagerService->GetBluetoothStatus() != connected)
-               {
-                       if(connected == true)
-                       {
-                               bt_event = BLUETOOTH_A2DP_CONNECTED;
-                       }
-                       else
-                       {
-                               bt_event = BLUETOOTH_A2DP_DISCONNECTED;
-                       }
-                       pDeviceManagerService->SendEvent(bt_event);
-               }
-               pDeviceManagerService->SetBluetoothStatus(connected);
-       }
-}
-
-void app_media_key_handler(media_key_e key, media_key_event_e status, void* pUserData)
-{
-       String event;
-       SysLog(NID_SYS, "Bluetooth headset event is occured %d, %d", (int)key, (int)status);
-       _DeviceManagerService* pDeviceManagerService = _DeviceManagerService::GetInstance();
-       if(pDeviceManagerService != null)
-       {
-               if(status == MEDIA_KEY_STATUS_RELEASED)
-               {
-                       switch(key)
-                       {
-                       case MEDIA_KEY_PLAY:
-                               event = BLUETOOTH_A2DP_PLAY;
-                               break;
-                       case MEDIA_KEY_STOP:
-                               event = BLUETOOTH_A2DP_STOP;
-                               break;
-                       case MEDIA_KEY_PAUSE:
-                               event = BLUETOOTH_A2DP_PAUSE;
-                               break;
-                       case MEDIA_KEY_PREVIOUS:
-                               event = BLUETOOTH_A2DP_BACKWARD;
-                               break;
-                       case MEDIA_KEY_NEXT:
-                               event = BLUETOOTH_A2DP_FORWARD;
-                               break;
-                       case MEDIA_KEY_FASTFORWARD:
-                               event = BLUETOOTH_A2DP_FASTFORWARD;
-                               break;
-                       case MEDIA_KEY_REWIND:
-                               event = BLUETOOTH_A2DP_REWIND;
-                               break;
-                       case MEDIA_KEY_UNKNOWN:
-                       default:
-                               SysLog(NID_SYS, "Unsupported key[%d] is occured.", key);
-                               return;
-                       }
-                       pDeviceManagerService->SendEvent(event);
-               }
-       }
-}
-
-_DeviceManagerService::_DeviceManagerService()
-       : _ICommunicationRequestListener()
-       , __pCommunicationDispatcher(null)
-       , isBluetoothHeadSetConnected(false)
-       , isInitBluetooth(false)
-{
-       result r = E_SUCCESS;
-
-       __pCommunicationDispatcher = _CommunicationDispatcher::GetInstance();
-       SysTryCatch(NID_SYS, __pCommunicationDispatcher != null, r = E_SYSTEM, E_SYSTEM, "_CommunicationDispatcher initiate is failed.");
-
-       r = __pCommunicationDispatcher->AddCommunicationEventListener(*this);
-       SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "It is failed to add event listener.");
-
-       r = __interestedPidList.Construct();
-       SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "It is failed to initiate bluetooth headset application list.");
-CATCH:
-       SetLastResult(r);
-}
-
-_DeviceManagerService::~_DeviceManagerService()
-{
-       result r = E_SUCCESS;
-
-
-       if(isInitBluetooth == true)
-       {
-               int btResult = 0;
-               SysLog(NID_SYS, "Bluetooth headset event is released.");
-               media_key_release();
-               btResult = bt_audio_unset_connection_state_changed_cb();
-               SysTryReturnVoidResult(NID_SYS, btResult == BT_ERROR_NONE, E_SYSTEM, "It is failed to unregister bluetooth headset connection event");
-
-               btResult = bt_audio_deinitialize();
-               SysTryReturnVoidResult(NID_SYS, btResult == BT_ERROR_NONE, E_SYSTEM, "It is failed to close bluetooth");
-
-               btResult = bt_deinitialize();
-               SysTryReturnVoidResult(NID_SYS, btResult == BT_ERROR_NONE, E_SYSTEM, "It is failed to init bluetooth module");
-               isInitBluetooth = false;
-       }
-
-       SysTryCatch(NID_SYS, __pCommunicationDispatcher != null, r = E_SYSTEM, E_SYSTEM, "_CommunicationDispatcher is not ready");
-
-       r = __pCommunicationDispatcher->RemoveCommunicationEventListener(*this);
-       SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "It is failed to remove event listener");
-
-CATCH:
-       SetLastResult(r);
-}
-
-_DeviceManagerService*
-_DeviceManagerService::GetInstance(void)
-{
-       if(__pDeviceManagerService == null)
-       {
-               __pDeviceManagerService = new (std::nothrow) _DeviceManagerService();
-       }
-       return __pDeviceManagerService;
-}
-
-String
-_DeviceManagerService::GetId(void)
-{
-       return DEVICE_MANAGER_SERVICE_ID;
-}
-
-void
-_DeviceManagerService::SendEvent(String event)
-{
-       if(__interestedPidList.GetCount() > 0)
-       {
-               int count = 0;
-               Integer* pPid = null;
-               ArrayList* data = null;
-
-               for(count = 0 ; count < __interestedPidList.GetCount() ; count++)
-               {
-                       pPid = (Integer*)__interestedPidList.GetAt(count);
-                       if(pPid == null)
-                       {
-                               SysLogException(NID_SYS, E_SYSTEM, "It is failed to get appid from bluetooth headset app list");
-                       }
-                       else
-                       {
-                               data = new (std::nothrow) ArrayList(SingleObjectDeleter);
-                               data->Construct();
-                               data->Add(new (std::nothrow) String(DEVICE_MANAGER_SERVICE_ID));
-                               data->Add(new (std::nothrow) String(DEVICE_MANAGER_COMMAND_EVENT));
-                               data->Add(new (std::nothrow) String(DEVICE_MANAGER_BLUETOOTH));
-                               data->Add(new (std::nothrow) String(event));
-
-                               __pCommunicationDispatcher->SendData(pPid->value, data);
-                               SysLog(NID_SYS, "Bluetooth headset event is sended to %d.", pPid->value);
-                       }
-               }
-       }
-       else
-       {
-               SysLog(NID_SYS, "Bluetooth Headset Event is not required by any application.");
-       }
-}
-
-void
-_DeviceManagerService::AddInterestedApp(int pid)
-{
-       int count = 0;
-       for(count = 0; count < __interestedPidList.GetCount(); count++)
-       {
-               Integer* pPid = (Integer*)__interestedPidList.GetAt(count);
-               if(pPid->value == pid)
-               {
-                       return;
-               }
-       }
-
-       if(isInitBluetooth == false)
-       {
-               SysLog(NID_SYS, "Bluetooth headset event is reserved.");
-
-               int btResult = 0;
-               btResult = bt_initialize();
-
-               SysTryReturnVoidResult(NID_SYS, btResult == BT_ERROR_NONE, E_SYSTEM, "It is failed to init bluetooth module");
-
-               btResult = bt_audio_initialize();
-               SysTryReturnVoidResult(NID_SYS, btResult == BT_ERROR_NONE, E_SYSTEM, "It is failed to init bluetooth audio module");
-
-               btResult = bt_audio_set_connection_state_changed_cb(bluetooth_connection_state_changed, null);
-               SysTryReturnVoidResult(NID_SYS, btResult == BT_ERROR_NONE, E_SYSTEM, "It is failed to register bluetooth audio event");
-
-               isInitBluetooth = true;
-       }
-
-       Integer* pPid = new (std::nothrow) Integer(pid);
-       __interestedPidList.Add(*pPid);
-
-       if(__interestedPidList.GetCount() > 0)
-       {
-               media_key_reserve(app_media_key_handler, null);
-       }
-}
-
-void
-_DeviceManagerService::RemoveInterestedApp(int pid)
-{
-       int count = 0;
-       for(count = 0; count < __interestedPidList.GetCount(); count++)
-       {
-               Integer* pPid = (Integer*)__interestedPidList.GetAt(count);
-               SysTryReturnVoidResult(NID_SYS, pPid != null, E_SYSTEM, "It is failed to get integerested PID.");
-               if(pPid->value == pid)
-               {
-                       __interestedPidList.RemoveAt(count, true);
-                       break;
-               }
-       }
-
-       if(__interestedPidList.GetCount() == 0)
-       {
-               media_key_release();
-       }
-}
-
-void
-_DeviceManagerService::OnRequestOccured(AppId appId, int pid, ArrayList* request, ArrayList* response)
-{
-       StringComparer strComparer;
-       int cmp = 0;
-       result r = E_SUCCESS;
-       String* command = null;
-       String* device = null;
-
-       SysLog(NID_APP, "Request is forwarded to _DeviceManagerService");
-       SysTryCatch(NID_SYS, request != null && response != null, r = E_INVALID_ARG, E_INVALID_ARG, "Parameters are null");
-
-       command = (String*)request->GetAt(1);
-       device = (String*)request->GetAt(2);
-       SysTryCatch(NID_SYS, command!= null && device != null, r = E_INVALID_ARG, E_INVALID_ARG, "Parameters has no command %x, %x", command, device);
-
-       SysLog(NID_SYS, "command is %ls, device is %ls", command->GetPointer(), device->GetPointer());
-
-       strComparer.Compare(*command, DEVICE_MANAGER_COMMAND_OPEN, cmp);
-       if(cmp == 0)
-       {
-               strComparer.Compare(*device, DEVICE_MANAGER_BLUETOOTH, cmp);
-               if(cmp == 0)
-               {
-                       SysLog(NID_SYS, "Bluetooth headset event is required");
-                       AddInterestedApp(pid);
-               }
-       }
-
-       strComparer.Compare(*command, DEVICE_MANAGER_COMMAND_CLOSE, cmp);
-       if(cmp == 0)
-       {
-               strComparer.Compare(*device, DEVICE_MANAGER_BLUETOOTH, cmp);
-               if(cmp == 0)
-               {
-                       RemoveInterestedApp(pid);
-               }
-       }
-
-       strComparer.Compare(*command, DEVICE_MANAGER_COMMAND_STATUS, cmp);
-       if(cmp == 0)
-       {
-               strComparer.Compare(*device, DEVICE_MANAGER_BLUETOOTH, cmp);
-               if(cmp == 0)
-               {
-
-                       SysLog(NID_SYS, "Bluetooth headset status is %d", isBluetoothHeadSetConnected);
-                       if(response != null)
-                       {
-                               String* serviceId = new (std::nothrow) String(DEVICE_MANAGER_SERVICE_ID);
-                               String* commandId = new (std::nothrow) String(DEVICE_MANAGER_COMMAND_STATUS);
-                               String* deviceId = new (std::nothrow) String(DEVICE_MANAGER_BLUETOOTH);
-                               String* status = null;
-                               if(isBluetoothHeadSetConnected == true)
-                               {
-                                       status = new (std::nothrow) String(BLUETOOTH_A2DP_CONNECTED);
-                               }
-                               else
-                               {
-                                       status = new (std::nothrow) String(BLUETOOTH_A2DP_DISCONNECTED);
-                               }
-                               response->Add(*serviceId);
-                               response->Add(*commandId);
-                               response->Add(*deviceId);
-                               response->Add(*status);
-                       }
-               }
-       }
-
-CATCH:
-       SetLastResult(r);
-}
-
-void
-_DeviceManagerService::OnApplicationTerminated(const AppId& appId, int pid)
-{
-       RemoveInterestedApp(pid);
-}
-
-bool
-_DeviceManagerService::GetBluetoothStatus(void)
-{
-       return isBluetoothHeadSetConnected;
-}
-void
-_DeviceManagerService::SetBluetoothStatus(bool status)
-{
-       isBluetoothHeadSetConnected = status;
-}
-