diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index 65e996b48..9b6984e75 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -253,7 +253,7 @@ LOGW(@"[VFS] Can not active for simulators."); [VFSUtil setVfsEnabbledWithEnabled:false groupName:kLinphoneMsgNotificationAppGroupId]; } else if (!VFSUtil.activateVFS) { - [VFSUtil oslogWithLog:@"[VFS] Error unable to activate." level:OS_LOG_TYPE_ERROR]; + [VFSUtil log:@"[VFS] Error unable to activate." :OS_LOG_TYPE_ERROR]; [VFSUtil setVfsEnabbledWithEnabled:false groupName:kLinphoneMsgNotificationAppGroupId]; } } diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m index 4b7128750..cde3750cc 100644 --- a/Classes/LinphoneCoreSettingsStore.m +++ b/Classes/LinphoneCoreSettingsStore.m @@ -798,7 +798,7 @@ [VFSUtil setVfsEnabbledWithEnabled:false groupName:kLinphoneMsgNotificationAppGroupId]; [self setBool:FALSE forKey:@"vfs_enabled_mode"]; } else if (!VFSUtil.activateVFS) { - [VFSUtil oslogWithLog:@"[VFS] Error unable to activate." level:OS_LOG_TYPE_ERROR]; + [VFSUtil log:@"[VFS] Error unable to activate ! Warning disabling VFS enabled preference." :OS_LOG_TYPE_ERROR]; [VFSUtil setVfsEnabbledWithEnabled:false groupName:kLinphoneMsgNotificationAppGroupId]; [self setBool:FALSE forKey:@"vfs_enabled_mode"]; } else { diff --git a/Classes/VFSUtil.swift b/Classes/VFSUtil.swift index 787ca5c7b..36a859fbc 100644 --- a/Classes/VFSUtil.swift +++ b/Classes/VFSUtil.swift @@ -1,21 +1,21 @@ /* - * Copyright (c) 2010-2020 Belledonne Communications SARL. - * - * This file is part of linphone-iphone - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ +* Copyright (c) 2010-2020 Belledonne Communications SARL. +* +* This file is part of linphone-iphone +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ import UIKit import Foundation @@ -116,7 +116,7 @@ import os kSecAttrAccount as String: key.data(using: .utf8)!, kSecAttrAccessGroup as String : accessGroup] SecItemDelete(delQuery as CFDictionary) - + let insertQUery: [String: Any] = [kSecClass as String: kSecClassGenericPassword, kSecAttrAccessGroup as String : accessGroup, @@ -156,46 +156,55 @@ import os @objc static func activateVFS() -> Bool { do { if (getSecuredPreference(key: prefName) == nil) { - oslog(log: "[VFS] no secret key set, building one.", level: .info) + log("[VFS] no secret key set, building one.", .info) try generateKey(requiresBiometry: false) guard let encryptedHash = encrypt(clearText: randomSha512()) else { return false } if (!addSecuredPreference(key: prefName, value: encryptedHash)) { - oslog(log: "[VFS] Unable to save encrypted key in secured defaults.", level: .error) + log("[VFS] Unable to save encrypted key in secured defaults.", .error) } } guard let encryptedKey = getSecuredPreference(key: prefName) else { - oslog(log: "[VFS] Unable to retrieve encrypted key.", level: .error) + log("[VFS] Unable to retrieve encrypted key.", .error) return false } let secret = decrypt(encryptedText: encryptedKey) Factory.Instance.setVfsEncryption(encryptionModule: 2, secret: secret, secretSize: 32) - oslog(log: "[VFS] activated", level: .info) + log("[VFS] activated", .info) return true } catch { - oslog(log: "[VFS] Error setting up VFS: \(error)", level: .info) + log("[VFS] Error setting up VFS: \(error)", .info) return false } } @objc static func vfsEnabled(groupName: String) -> Bool { let defaults = UserDefaults.init(suiteName: groupName) + if (defaults == nil) { + log("Unable to get VFS enabled preference userDefaults is null",.error); + } return defaults?.bool(forKey: "vfs_enabled_preference") == true } @objc static func setVfsEnabbled(enabled: Bool, groupName: String) { let defaults = UserDefaults.init(suiteName: groupName) + if (defaults == nil) { + log("Unable to set VFS enabled preferece userDefaults is null",.error); + } defaults?.setValue(enabled, forKey: "vfs_enabled_preference") } - @objc static func oslog(log:String, level: OSLogType) { - if #available(iOS 10.0, *) { - os_log("%{public}@", type: level,log) - } else { - NSLog(log) + @objc static func log(_ log:String, _ level: OSLogType) { + switch (level) { + case.info:LoggingService.Instance.message(message: log) + case.debug:LoggingService.Instance.debug(message: log) + case.error:LoggingService.Instance.error(message: log) + case.fault:LoggingService.Instance.fatal(message: log) + default:LoggingService.Instance.message(message: log) } + } - + } diff --git a/msgNotificationContent/NotificationViewController.swift b/msgNotificationContent/NotificationViewController.swift index 5bad22ba4..28dbc7053 100644 --- a/msgNotificationContent/NotificationViewController.swift +++ b/msgNotificationContent/NotificationViewController.swift @@ -21,6 +21,7 @@ import UIKit import UserNotifications import UserNotificationsUI import linphonesw +import os #if USE_CRASHLYTICS import Firebase #endif @@ -133,7 +134,7 @@ class NotificationViewController: UIViewController, UNNotificationContentExtensi func startCore() throws { if (VFSUtil.vfsEnabled(groupName: APP_GROUP_ID) && !VFSUtil.activateVFS()) { - VFSUtil.oslog(log: "[VFS] Error unable to activate.", level: .error) + VFSUtil.log("[VFS] Error unable to activate.", .error) } config = Config.newForSharedCore(appGroupId: APP_GROUP_ID, configFilename: "linphonerc", factoryConfigFilename: "") log = LoggingService.Instance /*enable liblinphone logs.*/ diff --git a/msgNotificationService/NotificationService.swift b/msgNotificationService/NotificationService.swift index 83858998d..c657f797c 100644 --- a/msgNotificationService/NotificationService.swift +++ b/msgNotificationService/NotificationService.swift @@ -57,7 +57,7 @@ class NotificationService: UNNotificationServiceExtension { NSLog("[msgNotificationService] start msgNotificationService extension") if (VFSUtil.vfsEnabled(groupName: APP_GROUP_ID) && !VFSUtil.activateVFS()) { - VFSUtil.oslog(log: "[VFS] Error unable to activate.", level: .error) + VFSUtil.log("[VFS] Error unable to activate.", .error) } if let bestAttemptContent = bestAttemptContent {