Try to detect if we’re testing, so that we prevent the wizard to show up.

Also prevent the remote push to show up
This commit is contained in:
Guillaume BIENKOWSKI 2015-01-17 23:00:34 +01:00
parent 7d127f126c
commit 2f25d70bf2
4 changed files with 30 additions and 15 deletions

View file

@ -172,24 +172,29 @@
UIApplication* app= [UIApplication sharedApplication];
UIApplicationState state = app.applicationState;
if( [app respondsToSelector:@selector(registerUserNotificationSettings:)] ){
/* iOS8 notifications can be actioned! Awesome: */
UIUserNotificationType notifTypes = UIUserNotificationTypeBadge|UIUserNotificationTypeSound|UIUserNotificationTypeAlert;
NSSet* categories = [NSSet setWithObjects:[self getCallNotificationCategory], [self getMessageNotificationCategory], nil];
UIUserNotificationSettings* userSettings = [UIUserNotificationSettings settingsForTypes:notifTypes categories:categories];
[app registerUserNotificationSettings:userSettings];
[app registerForRemoteNotifications];
} else {
NSUInteger notifTypes = UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeNewsstandContentAvailability;
[app registerForRemoteNotificationTypes:notifTypes];
}
LinphoneManager* instance = [LinphoneManager instance];
BOOL background_mode = [instance lpConfigBoolForKey:@"backgroundmode_preference"];
BOOL start_at_boot = [instance lpConfigBoolForKey:@"start_at_boot_preference"];
if( !instance.isTesting ){
if( [app respondsToSelector:@selector(registerUserNotificationSettings:)] ){
/* iOS8 notifications can be actioned! Awesome: */
UIUserNotificationType notifTypes = UIUserNotificationTypeBadge|UIUserNotificationTypeSound|UIUserNotificationTypeAlert;
NSSet* categories = [NSSet setWithObjects:[self getCallNotificationCategory], [self getMessageNotificationCategory], nil];
UIUserNotificationSettings* userSettings = [UIUserNotificationSettings settingsForTypes:notifTypes categories:categories];
[app registerUserNotificationSettings:userSettings];
[app registerForRemoteNotifications];
} else {
NSUInteger notifTypes = UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeNewsstandContentAvailability;
[app registerForRemoteNotificationTypes:notifTypes];
}
} else {
NSLog(@"No remote push for testing");
}
if (state == UIApplicationStateBackground)
{

View file

@ -180,6 +180,7 @@ typedef struct _LinphoneManagerSounds {
- (BOOL)lpConfigBoolForKey:(NSString*)key forSection:(NSString*)section;
- (void)silentPushFailed:(NSTimer*)timer;
@property (readonly) BOOL isTesting;
@property (readonly) FastAddressBook* fastAddressBook;
@property Connectivity connectivity;
@property (readonly) NetworkType network;

View file

@ -200,6 +200,12 @@ struct codec_name_pref_table codec_pref_table[]={
#endif
}
+ (BOOL)isRunningTests {
NSDictionary *environment = [[NSProcessInfo processInfo] environment];
NSString *injectBundle = environment[@"XCInjectBundle"];
return [[injectBundle pathExtension] isEqualToString:@"xctest"];
}
+ (BOOL)isNotIphone3G
{
static BOOL done=FALSE;
@ -278,6 +284,7 @@ struct codec_name_pref_table codec_pref_table[]={
[self copyDefaultSettings];
pushCallIDs = [[NSMutableArray alloc] init ];
photoLibrary = [[ALAssetsLibrary alloc] init];
self->_isTesting = [LinphoneManager isRunningTests];
NSString* factoryConfig = [LinphoneManager bundleFile:[LinphoneManager runningOnIpad]?@"linphonerc-factory~ipad":@"linphonerc-factory"];
NSString *confiFileName = [LinphoneManager documentFile:@".linphonerc"];

View file

@ -407,15 +407,17 @@ static RootViewManager* rootViewManagerInstance = nil;
LinphoneCore* core = nil;
@try {
core = [LinphoneManager getLc];
LinphoneManager* lm = [LinphoneManager instance];
if( linphone_core_get_global_state(core) != LinphoneGlobalOn ){
[self changeCurrentView: [DialerViewController compositeViewDescription]];
} else if ([[LinphoneManager instance] lpConfigBoolForKey:@"enable_first_login_view_preference"] == true) {
// Change to fist login view
[self changeCurrentView: [FirstLoginViewController compositeViewDescription]];
} else {
// always start to dialer when testing
// Change to default view
const MSList *list = linphone_core_get_proxy_config_list(core);
if(list != NULL || ([[LinphoneManager instance] lpConfigBoolForKey:@"hide_wizard_preference"] == true)) {
if(list != NULL || ([lm lpConfigBoolForKey:@"hide_wizard_preference"] == true) || lm.isTesting) {
[self changeCurrentView: [DialerViewController compositeViewDescription]];
} else {
WizardViewController *controller = DYNAMIC_CAST([[PhoneMainView instance] changeCurrentView:[WizardViewController compositeViewDescription]], WizardViewController);