From ffd5c0c277bead5b1f6289a3424398df46ee38d1 Mon Sep 17 00:00:00 2001 From: Yann Diorcet Date: Mon, 3 Dec 2012 16:21:30 +0100 Subject: [PATCH] Improve low battery detection and test --- Classes/PhoneMainView.m | 5 ++++- Classes/SettingsViewController.m | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Classes/PhoneMainView.m b/Classes/PhoneMainView.m index e1e480293..5aa1c3fae 100644 --- a/Classes/PhoneMainView.m +++ b/Classes/PhoneMainView.m @@ -582,8 +582,8 @@ static PhoneMainView* phoneMainViewInstance=nil; if (!call || !linphone_call_params_video_enabled(linphone_call_get_current_params(call))) return; LinphoneCallAppData* appData = (LinphoneCallAppData*) linphone_call_get_user_pointer(call); + float level = [UIDevice currentDevice].batteryLevel; if ([UIDevice currentDevice].batteryState == UIDeviceBatteryStateUnplugged) { - float level = [UIDevice currentDevice].batteryLevel; [LinphoneLogger logc:LinphoneLoggerLog format:"Video call is running. Battery level: %.2f", level]; if (level < 0.1 && !appData->batteryWarningShown) { DTActionSheet *sheet = [[[DTActionSheet alloc] initWithTitle:NSLocalizedString(@"Battery is running low. Stop video ?",nil)] autorelease]; @@ -598,6 +598,9 @@ static PhoneMainView* phoneMainViewInstance=nil; appData->batteryWarningShown = TRUE; } } + if (level >= 0.1) { + appData->batteryWarningShown = FALSE; + } } diff --git a/Classes/SettingsViewController.m b/Classes/SettingsViewController.m index f84648481..02c27d79b 100644 --- a/Classes/SettingsViewController.m +++ b/Classes/SettingsViewController.m @@ -655,7 +655,7 @@ static UICompositeViewDescription *compositeDescription = nil; [[PhoneMainView instance].mainViewController clearCache:[NSArray arrayWithObject:[[PhoneMainView instance] currentView]]]; } else if([key isEqual:@"battery_alert_button"]) { [[UIDevice currentDevice] _setBatteryState:UIDeviceBatteryStateUnplugged]; - [[UIDevice currentDevice] _setBatteryLevel:0.09f]; + [[UIDevice currentDevice] _setBatteryLevel:0.01f]; [[NSNotificationCenter defaultCenter] postNotificationName:UIDeviceBatteryLevelDidChangeNotification object:self]; } #endif