__pDeviceManager = _DeviceManager::GetInstance();
SysTryReturn(NID_SYS, __pDeviceManager, E_SYSTEM, E_SYSTEM,"It is failed to create DeviceManager instance.");
- if (__IsInitializedDevice == false)
- {
- r = __pDeviceManager->InitializeDevice();
- SysTryReturn(NID_SYS, !IsFailed(r), false, E_SYSTEM, "It is failed to init device");
- __IsInitializedDevice = true;
- }
-
__pRegistry = new (std::nothrow) Registry();
SysTryReturn(NID_SYS, __pRegistry, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,"Memory is insufficient.");
void
_DeviceManagerStub::AddInterestedApp(AppId appId, int pid)
{
- result r = __pRegistry->AddValue(DEVICE_MANAGER_REGISTRY_SECTION, (String) appId, pid);
+ result r = E_SUCCESS;
+
+ if (__IsInitializedDevice == false)
+ {
+ r = __pDeviceManager->InitializeDevice();
+ SysTryReturn(NID_SYS, !IsFailed(r), , E_SYSTEM, "It is failed to init device");
+ __IsInitializedDevice = true;
+ SysLog(NID_SYS, "InitializeDevice for BT");
+ }
+ r = __pRegistry->AddValue(DEVICE_MANAGER_REGISTRY_SECTION, (String) appId, pid);
SysLog(NID_SYS, "The result of adding pid is [%s]", GetErrorMessage(r));
__pRegistry->Flush();
}
void
_DeviceManagerStub::RemoveInterestedApp(AppId appId, int pid)
{
+ if (__IsInitializedDevice == false)
+ {
+ return;
+ }
result r = __pRegistry->RemoveValue(DEVICE_MANAGER_REGISTRY_SECTION, (String) appId);
SysLog(NID_SYS, "The result of removing pid is [%s]", GetErrorMessage(r));
__pRegistry->Flush();
+
+ IList* pInterestList = __pRegistry->GetAllEntryNamesN(DEVICE_MANAGER_REGISTRY_SECTION);
+ SysTryReturn(NID_SYS, pInterestList, , E_SYSTEM, "It is failed to get registry.");
+
+ if (pInterestList->GetCount() == 0)
+ {
+ __pDeviceManager->DeinitializeDevice();
+ __IsInitializedDevice = false;
+ SysLog(NID_SYS, "DeinitializeDevice for BT");
+ }
+ delete pInterestList;
}
_DeviceManagerStub::OnRequestOccured(const ArrayList& request, ArrayList* response)
{
int cmp = 0;
- result r = E_SUCCESS;
- bool isSuccess = false;
StringComparer strComparer;
__command = *(String*)request.GetAt(1);
}
}
- isSuccess = true;
-CATCH:
ArrayList* temp = const_cast<ArrayList*>(&request);
temp->RemoveAll(true);
- return isSuccess;
+ return true;
}
void
_DeviceManagerStub::OnApplicationTerminated(const AppId& appId, int pid)
{
- //SysLog(NID_SYS, "OnApplicationTerminated %ls, %d", appId.GetPointer(), pid);
RemoveInterestedApp(appId, pid);
}