Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions OsmAnd.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@
32EAF9FF2AE15A3C00646807 /* AFNetworkReachabilityManagerWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 32EAF9FE2AE15A3C00646807 /* AFNetworkReachabilityManagerWrapper.m */; };
32EAFA012AE17F3100646807 /* TravelGuidesSettingsDownloadViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32EAFA002AE17F3100646807 /* TravelGuidesSettingsDownloadViewController.swift */; };
32EB3DF12AC325780018D9B8 /* OATravelLocalDataDbHelper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 32EB3DF02AC325780018D9B8 /* OATravelLocalDataDbHelper.mm */; };
32F184A32CF8CC78002396E1 /* OALogWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32F184A22CF8CC2C002396E1 /* OALogWrapper.swift */; };
32F6225D29A7AE080069EE04 /* OAAmenityExtendedNameFilter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 320EADAB29A77AAB002F9883 /* OAAmenityExtendedNameFilter.mm */; };
32FE7AA72B65138800F82728 /* OAGPXImportUIHelper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 32FE7AA62B65138800F82728 /* OAGPXImportUIHelper.mm */; };
32FF4C292C183B1D00246B36 /* SegmentTableHeaderView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 32FF4C252C183A6400246B36 /* SegmentTableHeaderView.xib */; };
Expand Down Expand Up @@ -3859,6 +3860,7 @@
32EB3DEF2AC3256B0018D9B8 /* OATravelLocalDataDbHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OATravelLocalDataDbHelper.h; sourceTree = "<group>"; };
32EB3DF02AC325780018D9B8 /* OATravelLocalDataDbHelper.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = OATravelLocalDataDbHelper.mm; sourceTree = "<group>"; };
32ECBEAD2657AD7F005D33BD /* fi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fi; path = fi.lproj/Localizable.strings; sourceTree = "<group>"; };
32F184A22CF8CC2C002396E1 /* OALogWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OALogWrapper.swift; sourceTree = "<group>"; };
32FE7AA52B65136D00F82728 /* OAGPXImportUIHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OAGPXImportUIHelper.h; sourceTree = "<group>"; };
32FE7AA62B65138800F82728 /* OAGPXImportUIHelper.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = OAGPXImportUIHelper.mm; sourceTree = "<group>"; };
32FF4C252C183A6400246B36 /* SegmentTableHeaderView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SegmentTableHeaderView.xib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -10723,6 +10725,7 @@
DA5A79BF26C563A000F274C7 /* main.m */,
DA5A79BB26C563A000F274C7 /* OALog.h */,
DA5A79C226C563A000F274C7 /* OALog.mm */,
32F184A22CF8CC2C002396E1 /* OALogWrapper.swift */,
DA5A79B726C563A000F274C7 /* OsmAndApp.h */,
DA5A79C026C563A000F274C7 /* OsmAndApp.mm */,
DA5A79B926C563A000F274C7 /* OsmAndAppCppProtocol.h */,
Expand Down Expand Up @@ -16780,6 +16783,7 @@
DA5A818326C563A700F274C7 /* OASwitchableAction.m in Sources */,
DA5A844A26C563A900F274C7 /* OAHudButton.m in Sources */,
46FB65BA2A8BBC2000A21850 /* CoordinatesMapCenterWidget.swift in Sources */,
32F184A32CF8CC78002396E1 /* OALogWrapper.swift in Sources */,
32BC95732CC021CE00FEEAB8 /* UIFont+Extension.swift in Sources */,
DA5A845526C563A900F274C7 /* OAOsmEditsLayer.mm in Sources */,
DA5A815526C563A700F274C7 /* OACarPlayActiveViewController.m in Sources */,
Expand Down
16 changes: 8 additions & 8 deletions Sources/AppHost/CarPlayDelegate/CarPlaySceneDelegates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ final class CarPlaySceneDelegate: UIResponder {
private var isForegroundScene = false

func sceneWillEnterForeground(_ scene: UIScene) {
NSLog("[CarPlay] CarPlaySceneDelegate sceneWillEnterForeground")
OALog("[CarPlay] CarPlaySceneDelegate sceneWillEnterForeground")
isForegroundScene = true
configureScene()
}

func sceneWillResignActive(_ scene: UIScene) {
NSLog("[CarPlay] CarPlaySceneDelegate sceneWillResignActive")
OALog("[CarPlay] CarPlaySceneDelegate sceneWillResignActive")
NotificationCenter.default.removeObserver(self)
isForegroundScene = false
}
Expand Down Expand Up @@ -113,29 +113,29 @@ final class CarPlaySceneDelegate: UIResponder {
}

@objc private func appInitEventConfigureScene(notification: Notification) {
NSLog("[CarPlay] CarPlaySceneDelegate appInitEventConfigureScene")
OALog("[CarPlay] CarPlaySceneDelegate appInitEventConfigureScene")
guard let userInfo = notification.userInfo,
let item = userInfo["event"] as? Int,
let event = AppLaunchEvent(rawValue: item) else { return }
if case .setupRoot = event {
guard isForegroundScene else { return }
NSLog("[CarPlay] CarPlaySceneDelegate appInitEventConfigureScene success")
OALog("[CarPlay] CarPlaySceneDelegate appInitEventConfigureScene success")
configureScene()
}
}
}

extension CarPlaySceneDelegate: CPTemplateApplicationSceneDelegate {
func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene, didConnect interfaceController: CPInterfaceController, to window: CPWindow) {
NSLog("[CarPlay] CarPlaySceneDelegate didConnect")
OALog("[CarPlay] CarPlaySceneDelegate didConnect")

OsmAndApp.swiftInstance().carPlayActive = true
windowToAttach = window
carPlayInterfaceController = interfaceController
}

func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene, didDisconnect interfaceController: CPInterfaceController, from window: CPWindow) {
NSLog("[CarPlay] CarPlaySceneDelegate didDisconnect")
OALog("[CarPlay] CarPlaySceneDelegate didDisconnect")

OsmAndApp.swiftInstance().carPlayActive = false
if defaultAppMode != nil && !isRoutingActive() {
Expand All @@ -144,13 +144,13 @@ extension CarPlaySceneDelegate: CPTemplateApplicationSceneDelegate {

defaultAppMode = nil
guard let mapPanel = OARootViewController.instance()?.mapPanel else {
NSLog("[CarPlay] CarPlaySceneDelegate rootViewController mapPanel is nil")
OALog("[CarPlay] CarPlaySceneDelegate rootViewController mapPanel is nil")
return
}

mapPanel.onCarPlayDisconnected { [weak self] in
guard let self else { return }
NSLog("[CarPlay] CarPlaySceneDelegate onCarPlayDisconnected")
OALog("[CarPlay] CarPlaySceneDelegate onCarPlayDisconnected")
carPlayMapController?.detachFromCarPlayWindow()
carPlayDashboardController = nil
carPlayMapController?.navigationController?.popViewController(animated: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ final class DashboardCarPlaySceneDelegate: UIResponder {
private var isForegroundScene = false

func sceneWillEnterForeground(_ scene: UIScene) {
NSLog("[CarPlay] DashboardCarPlaySceneDelegate sceneWillEnterForeground")
OALog("[CarPlay] DashboardCarPlaySceneDelegate sceneWillEnterForeground")
isForegroundScene = true
configureScene()
}

func sceneWillResignActive(_ scene: UIScene) {
NSLog("[CarPlay] DashboardCarPlaySceneDelegate sceneWillResignActive")
OALog("[CarPlay] DashboardCarPlaySceneDelegate sceneWillResignActive")
NotificationCenter.default.removeObserver(self)
isForegroundScene = false
mapVC?.isCarPlayDashboardActive = false
Expand Down Expand Up @@ -68,13 +68,13 @@ final class DashboardCarPlaySceneDelegate: UIResponder {
}

@objc private func appInitEventConfigureScene(notification: Notification) {
NSLog("[CarPlay] DashboardCarPlaySceneDelegate appInitEventConfigureScene")
OALog("[CarPlay] DashboardCarPlaySceneDelegate appInitEventConfigureScene")
guard let userInfo = notification.userInfo,
let item = userInfo["event"] as? Int,
let event = AppLaunchEvent(rawValue: item) else { return }
if case .setupRoot = event {
guard isForegroundScene else { return }
NSLog("[CarPlay] DashboardCarPlaySceneDelegate appInitEventConfigureScene success")
OALog("[CarPlay] DashboardCarPlaySceneDelegate appInitEventConfigureScene success")
configureScene()
}
}
Expand All @@ -83,7 +83,7 @@ final class DashboardCarPlaySceneDelegate: UIResponder {
extension DashboardCarPlaySceneDelegate: CPTemplateApplicationDashboardSceneDelegate {

func templateApplicationDashboardScene(_ templateApplicationDashboardScene: CPTemplateApplicationDashboardScene, didConnect dashboardController: CPDashboardController, to window: UIWindow) {
NSLog("[CarPlay] DashboardCarPlaySceneDelegate didConnect")
OALog("[CarPlay] DashboardCarPlaySceneDelegate didConnect")
self.window = window
dashboardController.shortcutButtons = [
CPDashboardButton(titleVariants: [localizedString("shared_string_navigation")], subtitleVariants: [""], image: UIImage(named: "ic_carplay_navigation")!, handler: { _ in
Expand All @@ -97,7 +97,7 @@ extension DashboardCarPlaySceneDelegate: CPTemplateApplicationDashboardSceneDele
}

func templateApplicationDashboardScene(_ templateApplicationDashboardScene: CPTemplateApplicationDashboardScene, didDisconnect dashboardController: CPDashboardController, from window: UIWindow) {
NSLog("[CarPlay] DashboardCarPlaySceneDelegate didDisconnect")
OALog("[CarPlay] DashboardCarPlaySceneDelegate didDisconnect")
dashboardVC?.detachFromCarPlayWindow()
mapVC = nil
self.window = nil
Expand Down
42 changes: 21 additions & 21 deletions Sources/AppHost/OAAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ - (instancetype)init
self = [super init];
if (self)
{
NSLog(@"AppDelegate initialized");
OALog(@"AppDelegate initialized");
initializeQueue = dispatch_queue_create("OAAppDelegateInitializeQueue", dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_CONCURRENT, QOS_CLASS_USER_INTERACTIVE, 0));
}
return self;
Expand Down Expand Up @@ -105,7 +105,7 @@ - (BOOL)initialize

[self configureAppLaunchEvent:AppLaunchEventStart];

NSLog(@"OAAppDelegate initialize start");
OALog(@"OAAppDelegate initialize start");

// Configure device
UIDevice* device = [UIDevice currentDevice];
Expand Down Expand Up @@ -133,19 +133,19 @@ - (BOOL)initialize

dispatch_async(initializeQueue, ^{

NSLog(@"OAAppDelegate beginBackgroundTask");
OALog(@"OAAppDelegate beginBackgroundTask");

// Initialize OsmAnd core
if (![_app initializeCore])
{
NSLog(@"OAAppDelegate failed to initialize core");
OALog(@"OAAppDelegate failed to initialize core");
return;
}

// Initialize application in background
if (![_app initialize])
{
NSLog(@"OAAppDelegate failed to initialize app");
OALog(@"OAAppDelegate failed to initialize app");
return;
}

Expand Down Expand Up @@ -199,14 +199,14 @@ - (BOOL)initialize
[[UIApplication sharedApplication] endBackgroundTask:_appInitTask];
_appInitTask = UIBackgroundTaskInvalid;

NSLog(@"OAAppDelegate endBackgroundTask");
OALog(@"OAAppDelegate endBackgroundTask");

// Check for updates every hour when the app is in the foreground
[self initCheckUpdatesTimer];
});
});

NSLog(@"OAAppDelegate initialize finish");
OALog(@"OAAppDelegate initialize finish");
return YES;
}

Expand Down Expand Up @@ -284,14 +284,14 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
_dataFetchQueue = [[NSOperationQueue alloc] init];
@try
{
NSLog(@"BGTaskScheduler registerForTaskWithIdentifier");
OALog(@"BGTaskScheduler registerForTaskWithIdentifier");
[BGTaskScheduler.sharedScheduler registerForTaskWithIdentifier:kFetchDataUpdatesId usingQueue:nil launchHandler:^(__kindof BGTask * _Nonnull task) {
[self handleBackgroundDataFetch:(BGProcessingTask *)task];
}];
}
@catch (NSException *e)
{
NSLog(@"Failed to schedule background fetch. Reason: %@", e.reason);
OALog(@"Failed to schedule background fetch. Reason: %@", e.reason);
}
}

Expand Down Expand Up @@ -322,14 +322,14 @@ - (void)scheduleBackgroundDataFetch
request.earliestBeginDate = [NSDate dateWithTimeIntervalSinceNow:kCheckUpdatesInterval];
@try
{
NSLog(@"BGTaskScheduler submitTaskRequest");
OALog(@"BGTaskScheduler submitTaskRequest");
NSError *error = nil;
// e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"net.osmand.fetchDataUpdates"]
[BGTaskScheduler.sharedScheduler submitTaskRequest:request error:&error];
if (error)
NSLog(@"Could not schedule app refresh: %@", error.description);
OALog(@"Could not schedule app refresh: %@", error.description);
} @catch (NSException *e) {
NSLog(@"Could not schedule app refresh: %@", e.reason);
OALog(@"Could not schedule app refresh: %@", e.reason);
}
}

Expand All @@ -340,14 +340,14 @@ - (void)application:(UIApplication *)application handleEventsForBackgroundURLSes

- (void)applicationWillResignActive
{
NSLog(@"OAAppDelegate applicationWillResignActive %d", _appInitDone);
OALog(@"OAAppDelegate applicationWillResignActive %d", _appInitDone);
if (_appInitDone)
[_app onApplicationWillResignActive];
}

- (void)applicationDidEnterBackground
{
NSLog(@"OAAppDelegate applicationDidEnterBackground %d", _appInitDone);
OALog(@"OAAppDelegate applicationDidEnterBackground %d", _appInitDone);
[self invalidateIfNeededCheckUpdatesTimer];
if (_appInitDone)
[_app onApplicationDidEnterBackground];
Expand All @@ -358,7 +358,7 @@ - (void)applicationDidEnterBackground

- (void)applicationWillEnterForeground
{
NSLog(@"OAAppDelegate applicationWillEnterForeground %d", _appInitDone);
OALog(@"OAAppDelegate applicationWillEnterForeground %d", _appInitDone);
if (_appInitDone)
{
[_app onApplicationWillEnterForeground];
Expand All @@ -369,7 +369,7 @@ - (void)applicationWillEnterForeground
id<OADownloadTask> nextTask = [_app.downloadsManager firstDownloadTasksWithKey:[_app.downloadsManager.keysOfDownloadTasks objectAtIndex:0]];
if (nextTask)
{
NSLog(@"Resume suspended download %@", nextTask.key);
OALog(@"Resume suspended download %@", nextTask.key);
[nextTask resume];
}
}
Expand All @@ -378,7 +378,7 @@ - (void)applicationWillEnterForeground

- (void)applicationDidBecomeActive
{
NSLog(@"OAAppDelegate applicationDidBecomeActive %d", _appInitDone);
OALog(@"OAAppDelegate applicationDidBecomeActive %d", _appInitDone);
if (_appInitDone)
{
[self initCheckUpdatesTimer];
Expand All @@ -394,7 +394,7 @@ - (void)initCheckUpdatesTimer

- (void)applicationWillTerminate:(UIApplication *)application
{
NSLog(@"OAAppDelegate applicationWillTerminate");
OALog(@"OAAppDelegate applicationWillTerminate");
[_app shutdown];
OAMapViewController *mapVc = OARootViewController.instance.mapPanel.mapViewController;
[mapVc onApplicationDestroyed];
Expand All @@ -409,17 +409,17 @@ - (void)applicationWillTerminate:(UIApplication *)application

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
{
NSLog(@"OAAppDelegate applicationDidReceiveMemoryWarning");
OALog(@"OAAppDelegate applicationDidReceiveMemoryWarning");
}

- (void)applicationProtectedDataWillBecomeUnavailable:(UIApplication *)application
{
NSLog(@"OAAppDelegate applicationProtectedDataWillBecomeUnavailable");
OALog(@"OAAppDelegate applicationProtectedDataWillBecomeUnavailable");
}

- (void)applicationProtectedDataDidBecomeAvailable:(UIApplication *)application
{
NSLog(@"OAAppDelegate applicationProtectedDataDidBecomeAvailable");
OALog(@"OAAppDelegate applicationProtectedDataDidBecomeAvailable");
}

#pragma mark - UISceneSession Lifecycle
Expand Down
21 changes: 11 additions & 10 deletions Sources/AppHost/OAFetchBackgroundDataOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import "OAAutoObserverProxy.h"
#import "OAObservable.h"
#import "OADownloadTask.h"
#import "OALog.h"
#import <AFNetworking/AFNetworkReachabilityManager.h>

@implementation OAFetchBackgroundDataOperation
Expand Down Expand Up @@ -58,11 +59,11 @@ - (void) onBackgroundDownloadCanceled

- (void) performUpdatesCheck
{
NSLog(@"OAFetchBackgroundDataOperation start");
OALog(@"OAFetchBackgroundDataOperation start");

[_app checkAndDownloadOsmAndLiveUpdates:NO];

NSLog(@"OAFetchBackgroundDataOperation LiveUpdates checked");
OALog(@"OAFetchBackgroundDataOperation LiveUpdates checked");

OADownloadsManager *downloadManager = _app.downloadsManager;
BOOL hasNetworkConnection = NO;
Expand All @@ -73,46 +74,46 @@ - (void) performUpdatesCheck
hasNetworkConnection = AFNetworkReachabilityManager.sharedManager.isReachable;
hasTasks = [downloadManager numberOfDownloadTasksWithKeySuffix:@".live.obf"] > 0;

NSLog(@"OAFetchBackgroundDataOperation processing live tasks %d", [downloadManager numberOfDownloadTasksWithKeySuffix:@".live.obf"]);
OALog(@"OAFetchBackgroundDataOperation processing live tasks %d", [downloadManager numberOfDownloadTasksWithKeySuffix:@".live.obf"]);

} while (hasNetworkConnection && hasTasks && !self.cancelled);

if (self.cancelled && hasTasks)
{
NSLog(@"OAFetchBackgroundDataOperation LiveUpdates cancel tasks %d", [downloadManager numberOfDownloadTasksWithKeySuffix:@".live.obf"]);
OALog(@"OAFetchBackgroundDataOperation LiveUpdates cancel tasks %d", [downloadManager numberOfDownloadTasksWithKeySuffix:@".live.obf"]);
NSArray *tasks = [downloadManager downloadTasksWithKeySuffix:@".live.obf"];
for (id<OADownloadTask> task in tasks)
[task cancel];
}

NSLog(@"OAFetchBackgroundDataOperation LiveUpdates done");
OALog(@"OAFetchBackgroundDataOperation LiveUpdates done");

if (!self.cancelled && hasNetworkConnection)
{
[_app checkAndDownloadWeatherForecastsUpdates];
NSLog(@"OAFetchBackgroundDataOperation ForecastsUpdates checked");
OALog(@"OAFetchBackgroundDataOperation ForecastsUpdates checked");
do {
[NSThread sleepForTimeInterval:0.5];

hasNetworkConnection = AFNetworkReachabilityManager.sharedManager.isReachable;
hasTasks = [downloadManager numberOfDownloadTasksWithKeySuffix:@"tifsqlite"] > 0;

NSLog(@"OAFetchBackgroundDataOperation processing forecasts tasks %d", [downloadManager numberOfDownloadTasksWithKeySuffix:@"tifsqlite"]);
OALog(@"OAFetchBackgroundDataOperation processing forecasts tasks %d", [downloadManager numberOfDownloadTasksWithKeySuffix:@"tifsqlite"]);

} while (hasNetworkConnection && hasTasks && !self.cancelled);

if (self.cancelled && hasTasks)
{
NSLog(@"OAFetchBackgroundDataOperation ForecastsUpdates cancel tasks %d", [downloadManager numberOfDownloadTasksWithKeySuffix:@"tifsqlite"]);
OALog(@"OAFetchBackgroundDataOperation ForecastsUpdates cancel tasks %d", [downloadManager numberOfDownloadTasksWithKeySuffix:@"tifsqlite"]);
NSArray *tasks = [downloadManager downloadTasksWithKeySuffix:@"tifsqlite"];
for (id<OADownloadTask> task in tasks)
[task cancel];
}

NSLog(@"OAFetchBackgroundDataOperation ForecastsUpdates done");
OALog(@"OAFetchBackgroundDataOperation ForecastsUpdates done");
}

NSLog(@"OAFetchBackgroundDataOperation finish");
OALog(@"OAFetchBackgroundDataOperation finish");
}

@end
Loading