Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated lockscreen notification and enum #1608

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions SmartDeviceLink/SDLLockScreenManager.m
Expand Up @@ -54,7 +54,10 @@ - (instancetype)initWithConfiguration:(SDLLockScreenConfiguration *)config notif
_presenter = presenter;
_lockScreenDismissedByUser = NO;

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_lockScreenStatusDidChange:) name:SDLDidChangeLockScreenStatusNotification object:dispatcher];
#pragma clang diagnostic pop
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_lockScreenIconReceived:) name:SDLDidReceiveLockScreenIcon object:dispatcher];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_appDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_driverDistractionStateDidChange:) name:SDLDidChangeDriverDistractionStateNotification object:dispatcher];
Expand Down Expand Up @@ -194,17 +197,26 @@ - (void)sdl_updatePresentation {
if (self.canPresent) {
[self.presenter updateLockScreenToShow:YES withCompletionHandler:nil];
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
} else if ([self.lastLockNotification.lockScreenStatus isEqualToEnum:SDLLockScreenStatusRequired]) {
#pragma clang diagnostic pop
if (self.canPresent && !self.lockScreenDismissedByUser) {
[self.presenter updateLockScreenToShow:YES withCompletionHandler:nil];
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
} else if ([self.lastLockNotification.lockScreenStatus isEqualToEnum:SDLLockScreenStatusOptional]) {
#pragma clang diagnostic pop
if (self.config.displayMode == SDLLockScreenConfigurationDisplayModeOptionalOrRequired && self.canPresent && !self.lockScreenDismissedByUser) {
[self.presenter updateLockScreenToShow:YES withCompletionHandler:nil];
} else if (self.config.displayMode != SDLLockScreenConfigurationDisplayModeOptionalOrRequired) {
[self.presenter updateLockScreenToShow:NO withCompletionHandler:nil];
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
} else if ([self.lastLockNotification.lockScreenStatus isEqualToEnum:SDLLockScreenStatusOff]) {
#pragma clang diagnostic pop
[self.presenter updateLockScreenToShow:NO withCompletionHandler:nil];
}
}
Expand Down
8 changes: 4 additions & 4 deletions SmartDeviceLink/SDLLockScreenStatus.h
Expand Up @@ -11,19 +11,19 @@

Used in OnLockScreenStatus
*/
typedef SDLEnum SDLLockScreenStatus SDL_SWIFT_ENUM;
typedef SDLEnum SDLLockScreenStatus SDL_SWIFT_ENUM __deprecated;

/**
* LockScreen is Not Required
*/
extern SDLLockScreenStatus const SDLLockScreenStatusOff;
extern SDLLockScreenStatus const SDLLockScreenStatusOff __deprecated;

/**
* LockScreen is Optional
*/
extern SDLLockScreenStatus const SDLLockScreenStatusOptional;
extern SDLLockScreenStatus const SDLLockScreenStatusOptional __deprecated;

/**
* LockScreen is Required
*/
extern SDLLockScreenStatus const SDLLockScreenStatusRequired;
extern SDLLockScreenStatus const SDLLockScreenStatusRequired __deprecated;
2 changes: 1 addition & 1 deletion SmartDeviceLink/SDLLockScreenStatusManager.h
Expand Up @@ -17,9 +17,9 @@ NS_ASSUME_NONNULL_BEGIN
@property (assign, nonatomic) BOOL userSelected;
@property (assign, nonatomic) BOOL driverDistracted;
@property (nullable, strong, nonatomic) SDLHMILevel hmiLevel;
@property (strong, nonatomic, readonly) SDLLockScreenStatus lockScreenStatus;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
@property (strong, nonatomic, readonly) SDLLockScreenStatus lockScreenStatus;
@property (strong, nonatomic, readonly) SDLOnLockScreenStatus *lockScreenStatusNotification;
#pragma clang diagnostic pop

Expand Down
24 changes: 24 additions & 0 deletions SmartDeviceLink/SDLLockScreenStatusManager.m
Expand Up @@ -68,36 +68,60 @@ - (SDLOnLockScreenStatus *)lockScreenStatusNotification {
return notification;
}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (SDLLockScreenStatus)lockScreenStatus {
#pragma clang diagnostic pop
if (self.hmiLevel == nil || [self.hmiLevel isEqualToEnum:SDLHMILevelNone]) {
// App is not active on the car
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
return SDLLockScreenStatusOff;
#pragma clang diagnostic pop
} else if ([self.hmiLevel isEqualToEnum:SDLHMILevelBackground]) {
// App is in the background on the car
if (self.userSelected) {
// It was user selected
if (self.haveDriverDistractionStatus && !self.driverDistracted) {
// We have the distraction status, and the driver is not distracted
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
return SDLLockScreenStatusOptional;
#pragma clang diagnostic pop
} else {
// We don't have the distraction status, and/or the driver is distracted
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
return SDLLockScreenStatusRequired;
#pragma clang diagnostic pop
}
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
return SDLLockScreenStatusOff;
#pragma clang diagnostic pop
}
} else if ([self.hmiLevel isEqualToEnum:SDLHMILevelFull] || [self.hmiLevel isEqualToEnum:SDLHMILevelLimited]) {
// App is in the foreground on the car in some manner
if (self.haveDriverDistractionStatus && !self.driverDistracted) {
// We have the distraction status, and the driver is not distracted
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
return SDLLockScreenStatusOptional;
#pragma clang diagnostic pop
} else {
// We don't have the distraction status, and/or the driver is distracted
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
return SDLLockScreenStatusRequired;
#pragma clang diagnostic pop
}
} else {
// This shouldn't be possible.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
return SDLLockScreenStatusOff;
#pragma clang diagnostic pop
}
}

Expand Down
2 changes: 1 addition & 1 deletion SmartDeviceLink/SDLNotificationConstants.h
Expand Up @@ -560,7 +560,7 @@ extern SDLNotificationName const SDLDidReceiveKeyboardInputNotification;
extern SDLNotificationName const SDLDidChangeLanguageNotification;

/// Name for a LockScreenStatus notification RPC
extern SDLNotificationName const SDLDidChangeLockScreenStatusNotification;
extern SDLNotificationName const SDLDidChangeLockScreenStatusNotification __deprecated;

/// Name for a NewHash notification RPC
extern SDLNotificationName const SDLDidReceiveNewHashNotification;
Expand Down
6 changes: 6 additions & 0 deletions SmartDeviceLink/SDLNotificationDispatcher.m
Expand Up @@ -673,9 +673,15 @@ - (void)onOnLanguageChange:(SDLOnLanguageChange *)notification {
[self postRPCNotificationNotification:SDLDidChangeLanguageNotification notification:notification];
}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
- (void)onOnLockScreenNotification:(SDLOnLockScreenStatus *)notification {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[self postRPCNotificationNotification:SDLDidChangeLockScreenStatusNotification notification:notification];
#pragma clang diagnostic pop
}
#pragma clang diagnostic pop

- (void)onOnPermissionsChange:(SDLOnPermissionsChange *)notification {
[self postRPCNotificationNotification:SDLDidChangePermissionsNotification notification:notification];
Expand Down
2 changes: 1 addition & 1 deletion SmartDeviceLink/SDLProxyListener.h
Expand Up @@ -1178,7 +1178,7 @@ NS_ASSUME_NONNULL_BEGIN
*/
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (void)onOnLockScreenNotification:(SDLOnLockScreenStatus *)notification;
- (void)onOnLockScreenNotification:(SDLOnLockScreenStatus *)notification __deprecated;
#pragma clang diagnostic pop

/**
Expand Down
28 changes: 12 additions & 16 deletions SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m
Expand Up @@ -66,17 +66,12 @@ @interface SDLLockScreenManager ()
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
__block SDLOnLockScreenStatus *testRequiredStatus = nil;
#pragma clang diagnostic pop

beforeEach(^{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
testRequiredStatus = [[SDLOnLockScreenStatus alloc] init];
#pragma clang diagnostic pop

testRequiredStatus.lockScreenStatus = SDLLockScreenStatusRequired;

[testNotificationDispatcher postNotificationName:SDLDidChangeLockScreenStatusNotification infoObject:testRequiredStatus];
#pragma clang diagnostic pop
});

it(@"should not have presented the lock screen", ^{
Expand Down Expand Up @@ -118,10 +113,9 @@ @interface SDLLockScreenManager ()
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
testRequiredStatus = [[SDLOnLockScreenStatus alloc] init];
#pragma clang diagnostic pop
testRequiredStatus.lockScreenStatus = SDLLockScreenStatusRequired;

SDLRPCNotificationNotification *testLockStatusNotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeLockScreenStatusNotification object:nil rpcNotification:testRequiredStatus];
#pragma clang diagnostic pop
[[NSNotificationCenter defaultCenter] postNotification:testLockStatusNotification];
});

Expand Down Expand Up @@ -213,16 +207,12 @@ @interface SDLLockScreenManager ()
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
__block SDLOnLockScreenStatus *testOffStatus = nil;
#pragma clang diagnostic pop


beforeEach(^{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
testOffStatus = [[SDLOnLockScreenStatus alloc] init];
#pragma clang diagnostic pop
testOffStatus.lockScreenStatus = SDLLockScreenStatusOff;

SDLRPCNotificationNotification *testLockStatusNotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeLockScreenStatusNotification object:nil rpcNotification:testOffStatus];
#pragma clang diagnostic pop
[[NSNotificationCenter defaultCenter] postNotification:testLockStatusNotification];
});

Expand Down Expand Up @@ -332,8 +322,8 @@ @interface SDLLockScreenManager ()
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
SDLOnLockScreenStatus *status = [[SDLOnLockScreenStatus alloc] init];
#pragma clang diagnostic pop
status.lockScreenStatus = SDLLockScreenStatusRequired;
#pragma clang diagnostic pop
testManager.lastLockNotification = status;

SDLOnDriverDistraction *testDriverDistraction = [[SDLOnDriverDistraction alloc] init];
Expand Down Expand Up @@ -376,8 +366,11 @@ @interface SDLLockScreenManager ()

context(@"receiving a lock screen status of required", ^{
beforeEach(^{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
testStatus.lockScreenStatus = SDLLockScreenStatusRequired;
testLockStatusNotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeLockScreenStatusNotification object:nil rpcNotification:testStatus];
#pragma clang diagnostic pop

[[NSNotificationCenter defaultCenter] postNotification:testLockStatusNotification];
});
Expand All @@ -389,8 +382,11 @@ @interface SDLLockScreenManager ()

context(@"receiving a lock screen status of off", ^{
beforeEach(^{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
testStatus.lockScreenStatus = SDLLockScreenStatusOff;
testLockStatusNotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeLockScreenStatusNotification object:nil rpcNotification:testStatus];
#pragma clang diagnostic pop

[[NSNotificationCenter defaultCenter] postNotification:testLockStatusNotification];
});
Expand All @@ -412,9 +408,9 @@ @interface SDLLockScreenManager ()
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
SDLOnLockScreenStatus *testOptionalStatus = [[SDLOnLockScreenStatus alloc] init];
#pragma clang diagnostic pop
testOptionalStatus.lockScreenStatus = SDLLockScreenStatusOptional;
testLockStatusNotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeLockScreenStatusNotification object:nil rpcNotification:testOptionalStatus];
#pragma clang diagnostic pop
testLockScreenConfig = [SDLLockScreenConfiguration enabledConfiguration];
});

Expand Down