{
result r = _AccessController::CheckUserPrivilege(_PRV_LOCATION);
r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
- SysTryReturnResult(NID_LOC, r == E_SUCCESS, r, "[%s] The application is not permitted to call this method.",GetErrorMessage(r));
+ SysTryReturnResult(NID_LOC, r == E_SUCCESS, r, "The application is not permitted to call this method.");
SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
r = __pImpl->StartLocationUpdatesByInterval(interval);
{
result r = _AccessController::CheckUserPrivilege(_PRV_LOCATION);
r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
- SysTryReturnResult(NID_LOC, r == E_SUCCESS, r, "[%s] The application is not permitted to call this method.",GetErrorMessage(r));
+ SysTryReturnResult(NID_LOC, r == E_SUCCESS, r, "The application is not permitted to call this method.");
SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
r = __pImpl->StartLocationUpdatesByDistance(distance);
}
}
-bool
-_LocationManager::IsAppEnabled(void)
-{
- SysTryReturn(NID_LOC, __waitLoopListener.GetValue(), false, E_SYSTEM, "[%s] Location manager is not initialized.", GetErrorMessage(E_SYSTEM));
-
- Boolean enable(false);
- Monitor synchronizer;
- result r = synchronizer.Construct();
- SysTryReturn(NID_LOC, r == E_SUCCESS, false, r, "[%s] Propogating.", GetErrorMessage(r));
-
- std::unique_ptr< Tizen::Base::Collection::ArrayList > pArgList(new (std::nothrow) ArrayList());
- SysTryReturn(NID_LOC, pArgList, false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- r = pArgList->Construct();
- SysTryReturn(NID_LOC, r == E_SUCCESS, false, r, "[%s] Propogating.", GetErrorMessage(r));
-
- r = pArgList->Add(enable);
- SysTryCatch(NID_LOC, r == E_SUCCESS, , r, "[%s] Propogating", GetErrorMessage(r));
- r = pArgList->Add(synchronizer);
- SysTryCatch(NID_LOC, r == E_SUCCESS, , r, "[%s] Propogating", GetErrorMessage(r));
-
- r = synchronizer.Enter();
- SysTryCatch(NID_LOC, r == E_SUCCESS, , r, "[%s] Propogating", GetErrorMessage(r));
-
- r = SendUserEvent(REQ_ID_GET_APP_ACCESSIBILITY, pArgList.get());
- SysTryCatch(NID_LOC, r == E_SUCCESS, synchronizer.Exit(), r, "[%s] Propogating", GetErrorMessage(r));
- pArgList.release();
-
- SysLog(NID_LOC, "Wait till location manager checks if the app is allowed to use location.");
- r = synchronizer.Wait();
- SysTryCatch(NID_LOC, r == E_SUCCESS, synchronizer.Exit(), r, "[%s] Propogating", GetErrorMessage(r));
- SysLog(NID_LOC, "Application setting state is '%ls'.", enable.ToString().GetPointer());
- synchronizer.Exit();
-
- return enable.ToBool();
-
-CATCH:
- return false;
-}
-
_LocationManager*
_LocationManager::GetInstance(void)
{
void
_LocationManager::SendLocationCallbacks(void)
{
- bool isAllowed = GetAppAccessibility();
const Location* pBestLocation = FindBestLocation();
- SysLog(NID_LOC, "Send location(validity: %x) and accessibility(%x) through the callback.", pBestLocation->IsValid(), isAllowed);
+ SysLog(NID_LOC, "Send location(validity: %x) through the callback.", pBestLocation->IsValid());
unique_ptr< Location > pLocation(new (std::nothrow) Location(*pBestLocation));
SysTryReturnVoidResult(NID_LOC, pLocation != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
const _LocationRequestInfo* pLocRequestInfo = static_cast< const _LocationRequestInfo* >(__pLocRequestInfoList->GetAt(i));
if (interval % pLocRequestInfo->GetInterval() == 0 && pLocRequestInfo->GetListener() != null)
{
- if (!isAllowed)
- {
- _LocationImpl::GetInstance(*pLocation)->TurnOnDeniedFlag();
- }
pLocRequestInfo->GetListener()->OnLocationUpdated(pLocRequestInfo->GetRequestId(), *pLocation.get());
}
}
long long gpsTimestamp = 0;
long long wpsTimestamp = 0;
- if (__gpsHandler.pLocation->IsValid() && !_LocationImpl::GetInstance(*__gpsHandler.pLocation)->IsDenied())
+ if (__gpsHandler.pLocation->IsValid())
{
gpsTimestamp = _LocationImpl::GetInstance(*__gpsHandler.pLocation)->GetTimestampInMs();
}
- if (__wpsHandler.pLocation->IsValid() && !_LocationImpl::GetInstance(*__wpsHandler.pLocation)->IsDenied())
+ if (__wpsHandler.pLocation->IsValid())
{
wpsTimestamp = _LocationImpl::GetInstance(*__wpsHandler.pLocation)->GetTimestampInMs();
}
}
break;
- case REQ_ID_GET_APP_ACCESSIBILITY:
- {
- SysLog(NID_LOC, "REQ_ID_GET_APP_ACCESSIBILITY");
- SysTryReturnVoidResult(NID_LOC, pArgs, E_INVALID_ARG, "[E_INVALID_ARG] Null argument encountered. Ignored.");
-
- Boolean* pEnabled = static_cast< Boolean* >(pArgs->GetAt(0));
- Monitor* pMonitor = static_cast< Monitor* >(pArgs->GetAt(1));
- SysAssertf(pEnabled != null && pMonitor != null, "Invalid request has been made on the location manager.");
- if (pMonitor != null)
- {
- pMonitor->Enter();
- if (pEnabled != null)
- {
- pEnabled->value = GetAppAccessibility();
- }
- pMonitor->Notify();
- pMonitor->Exit();
- }
- pArgs->RemoveAt(1);
- pArgs->RemoveAt(0);
- }
- break;
-
case REQ_ID_GET_LAST_LOCATION:
{
SysLog(NID_LOC, "REQ_ID_GET_LAST_LOCATION");
delete __pUniqueInstance;
}
-bool
-_LocationManager::GetAppAccessibility(void)
-{
- int res = 0;
- static bool appRegistered = false;
- if (!appRegistered)
- {
- static const char COMMAND_REGISTER_APP[] = "ADD_APPLIST";
- if (location_manager_send_command(COMMAND_REGISTER_APP) == LOCATIONS_ERROR_NONE)
- {
- static const char COMMAND_ENABLE_APP[] = "ACCESSIBILITY:1";
- res = location_manager_send_command(COMMAND_ENABLE_APP);
- SysTryReturn(NID_LOC, res == 0, false, E_SYSTEM,
- "[%s] Failed to register the application.", GetErrorMessage(E_SYSTEM));
- appRegistered = true;
- }
- }
-
- location_accessibility_state_e accessState;
- res = location_manager_get_accessibility_state(&accessState);
- SysTryReturn(NID_LOC, res == 0, false, E_SYSTEM,
- "[%s] Failed to get the application location setting.", GetErrorMessage(E_SYSTEM));
-
- return (accessState == LOCATIONS_ACCESS_STATE_ALLOWED) ? true : false;
-}
}}
//
LocationAccuracy GetAccuracyLevel(double horAcc) const;
- // This method gets the location setting information of this particular application.
- //
- // @since 2.0
- //
- bool IsAppEnabled(void);
-
// This method returns the wait loop listener of this class.
//
// @since 2.0
//
static void DestroyLocationManager(void);
- // This method gets app's accessibility from native side, adding the app into the location
- // setting, if it is not registerd.
- //
- // @since 2.0
- //
- static bool GetAppAccessibility(void);
-
private:
const static RequestId REQ_ID_START_LOC_UPDATES = 1;
const static RequestId REQ_ID_STOP_LOC_UPDATES = 2;
const static RequestId REQ_ID_SUSTAIN_GPS = 4;
const static RequestId REQ_ID_SUSTAIN_WPS = 5;
const static RequestId REQ_ID_SYNC_LOC_RETRIEVAL = 6;
- const static RequestId REQ_ID_GET_APP_ACCESSIBILITY = 7;
- const static RequestId REQ_ID_GET_LAST_LOCATION = 8;
- const static RequestId REQ_ID_UPDATE_INTERVAL = 9;
+ const static RequestId REQ_ID_GET_LAST_LOCATION = 7;
+ const static RequestId REQ_ID_UPDATE_INTERVAL = 8;
enum _LocationMethodRequested
{