diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2017-02-21 09:52:09 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-21 09:52:09 -0500 |
commit | a284bdfc1e92ef7e5048fb8d5b1364885bd6ee01 (patch) | |
tree | a50ab912d2665e9a4ac11a905d783e030802f92e | |
parent | 8fda95124154dcb6fe17af5d527f0a630d7ad9c4 (diff) | |
parent | 74f9a4316da627d6cea6b843250e1870214dc43a (diff) | |
download | sdl_ios-a284bdfc1e92ef7e5048fb8d5b1364885bd6ee01.tar.gz |
Merge pull request #541 from smartdevicelink/hotfix/issue_539
Fix lock screen showing when HMI is backgrounded
-rw-r--r-- | SmartDeviceLink/SDLLockScreenStatusManager.m | 11 | ||||
-rw-r--r-- | SmartDeviceLinkTests/ProxySpecs/SDLLockScreenStatusManagerSpec.m | 28 |
2 files changed, 34 insertions, 5 deletions
diff --git a/SmartDeviceLink/SDLLockScreenStatusManager.m b/SmartDeviceLink/SDLLockScreenStatusManager.m index 86350b0d0..956da2dcf 100644 --- a/SmartDeviceLink/SDLLockScreenStatusManager.m +++ b/SmartDeviceLink/SDLLockScreenStatusManager.m @@ -71,10 +71,17 @@ return [SDLLockScreenStatus OFF]; } else if ([self.hmiLevel isEqualToEnum:[SDLHMILevel BACKGROUND]]) { // App is in the background on the car - // The lockscreen depends entirely on if the user selected the app if (self.userSelected) { - return [SDLLockScreenStatus REQUIRED]; + // It was user selected + if (self.haveDriverDistractionStatus && !self.driverDistracted) { + // We have the distraction status, and the driver is not distracted + return [SDLLockScreenStatus OPTIONAL]; + } else { + // We don't have the distraction status, and/or the driver is distracted + return [SDLLockScreenStatus REQUIRED]; + } } else { + // It wasn't user selected return [SDLLockScreenStatus OFF]; } } else if ([self.hmiLevel isEqualToEnum:[SDLHMILevel FULL]] || [self.hmiLevel isEqualToEnum:[SDLHMILevel LIMITED]]) { diff --git a/SmartDeviceLinkTests/ProxySpecs/SDLLockScreenStatusManagerSpec.m b/SmartDeviceLinkTests/ProxySpecs/SDLLockScreenStatusManagerSpec.m index 546380367..8a61980fe 100644 --- a/SmartDeviceLinkTests/ProxySpecs/SDLLockScreenStatusManagerSpec.m +++ b/SmartDeviceLinkTests/ProxySpecs/SDLLockScreenStatusManagerSpec.m @@ -122,9 +122,31 @@ describe(@"the lockscreen status manager", ^{ beforeEach(^{ lockScreenManager.userSelected = YES; }); - - it(@"should return lock screen required", ^{ - expect(lockScreenManager.lockScreenStatus).to(equal([SDLLockScreenStatus REQUIRED])); + + context(@"if we do not set the driver distraction state", ^{ + it(@"should return lock screen required", ^{ + expect(lockScreenManager.lockScreenStatus).to(equal([SDLLockScreenStatus REQUIRED])); + }); + }); + + context(@"if we set the driver distraction state to false", ^{ + beforeEach(^{ + lockScreenManager.driverDistracted = NO; + }); + + it(@"should return lock screen optional", ^{ + expect(lockScreenManager.lockScreenStatus).to(equal([SDLLockScreenStatus OPTIONAL])); + }); + }); + + context(@"if we set the driver distraction state to true", ^{ + beforeEach(^{ + lockScreenManager.driverDistracted = YES; + }); + + it(@"should return lock screen required", ^{ + expect(lockScreenManager.lockScreenStatus).to(equal([SDLLockScreenStatus REQUIRED])); + }); }); }); |