Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.79 KB | None | 0 0
  1. private void handleLocationChanged(Location location, boolean passive) {
  2. // create a working copy of the incoming Location so that the service can modify it without
  3. // disturbing the caller's copy
  4. Location myLocation = new Location(location);
  5. String provider = myLocation.getProvider();
  6.  
  7. // set "isFromMockProvider" bit if location came from a mock provider. we do not clear this
  8. // bit if location did not come from a mock provider because passive/fused providers can
  9. // forward locations from mock providers, and should not grant them legitimacy in doing so.
  10. if (!myLocation.isFromMockProvider() && isMockProvider(provider)) {
  11. myLocation.setIsFromMockProvider(true);
  12. }
  13.  
  14. synchronized (mLock) {
  15. if (isAllowedByCurrentUserSettingsLocked(provider)) {
  16. if (!passive) {
  17. // notify passive provider of the new location
  18. mPassiveProvider.updateLocation(myLocation);
  19. }
  20. handleLocationChangedLocked(myLocation, passive);
  21. }
  22. }
  23. }
  24.  
  25. private void handleLocationChanged(Location location, boolean passive) {
  26. // create a working copy of the incoming Location so that the service can modify it without
  27. // disturbing the caller's copy
  28. Location myLocation = new Location(location);
  29. String provider = myLocation.getProvider();
  30.  
  31. boolean isMocked = false;//controls that location given to the method is mocked
  32.  
  33. // set "isFromMockProvider" bit if location came from a mock provider. we do not clear this
  34. // bit if location did not come from a mock provider because passive/fused providers can
  35. // forward locations from mock providers, and should not grant them legitimacy in doing so.
  36. if (!myLocation.isFromMockProvider() && isMockProvider(provider)) {
  37. isMocked = true;
  38. myLocation.setIsFromMockProvider(false);
  39. }
  40. if (stopRealWhenMocking){// variable which I will add to LocationManagerSevices to disable and enable getting real location
  41. if(isMocked){
  42. synchronized (mLock) {
  43. if (isAllowedByCurrentUserSettingsLocked(provider)) {
  44. if (!passive) {
  45. // notify passive provider of the new location
  46. mPassiveProvider.updateLocation(myLocation);
  47. }
  48. handleLocationChangedLocked(myLocation, passive);
  49. }
  50. }
  51. }
  52. }
  53. else {
  54. synchronized (mLock) {
  55. if (isAllowedByCurrentUserSettingsLocked(provider)) {
  56. if (!passive) {
  57. // notify passive provider of the new location
  58. mPassiveProvider.updateLocation(myLocation);
  59. }
  60. handleLocationChangedLocked(myLocation, passive);
  61. }
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement