Parcourir la source

remove os check for major update (#13197)

themiswang il y a 1 an
Parent
commit
0afe0cd98e

+ 2 - 6
FirebaseCore/Internal/Sources/HeartbeatLogging/HeartbeatsPayload.swift

@@ -93,12 +93,8 @@ extension HeartbeatsPayload: HTTPHeaderRepresentable {
     let encoder = JSONEncoder()
     encoder.dateEncodingStrategy = .formatted(Self.dateFormatter)
     #if DEBUG
-      // TODO: Remove the following #available check when FirebaseCore's minimum deployment target
-      // is iOS 11+; all other supported platforms already meet the minimum for `.sortedKeys`.
-      if #available(iOS 11, *) {
-        // Sort keys in debug builds to simplify output comparisons in unit tests.
-        encoder.outputFormatting = .sortedKeys
-      }
+      // Sort keys in debug builds to simplify output comparisons in unit tests.
+      encoder.outputFormatting = .sortedKeys
     #endif // DEBUG
 
     guard let data = try? encoder.encode(self) else {

+ 23 - 33
FirebasePerformance/Sources/AppActivity/FPRAppActivityTracker.m

@@ -163,30 +163,28 @@ NSString *const kFPRAppCounterNameActivePrewarm = @"_fsapc";
 - (void)startTrackingNetwork {
   self.networkType = firebase_perf_v1_NetworkConnectionInfo_NetworkType_NONE;
 
-  if (@available(iOS 12, tvOS 12, *)) {
-    dispatch_queue_attr_t attrs = dispatch_queue_attr_make_with_qos_class(
-        DISPATCH_QUEUE_SERIAL, QOS_CLASS_UTILITY, DISPATCH_QUEUE_PRIORITY_DEFAULT);
-    self.monitorQueue = dispatch_queue_create("com.google.firebase.perf.network.monitor", attrs);
-
-    self.monitor = nw_path_monitor_create();
-    nw_path_monitor_set_queue(self.monitor, self.monitorQueue);
-    __weak FPRAppActivityTracker *weakSelf = self;
-    nw_path_monitor_set_update_handler(self.monitor, ^(nw_path_t _Nonnull path) {
-      BOOL isWiFi = nw_path_uses_interface_type(path, nw_interface_type_wifi);
-      BOOL isCellular = nw_path_uses_interface_type(path, nw_interface_type_cellular);
-      BOOL isEthernet = nw_path_uses_interface_type(path, nw_interface_type_wired);
-
-      if (isWiFi) {
-        weakSelf.networkType = firebase_perf_v1_NetworkConnectionInfo_NetworkType_WIFI;
-      } else if (isCellular) {
-        weakSelf.networkType = firebase_perf_v1_NetworkConnectionInfo_NetworkType_MOBILE;
-      } else if (isEthernet) {
-        weakSelf.networkType = firebase_perf_v1_NetworkConnectionInfo_NetworkType_ETHERNET;
-      }
-    });
+  dispatch_queue_attr_t attrs = dispatch_queue_attr_make_with_qos_class(
+      DISPATCH_QUEUE_SERIAL, QOS_CLASS_UTILITY, DISPATCH_QUEUE_PRIORITY_DEFAULT);
+  self.monitorQueue = dispatch_queue_create("com.google.firebase.perf.network.monitor", attrs);
+
+  self.monitor = nw_path_monitor_create();
+  nw_path_monitor_set_queue(self.monitor, self.monitorQueue);
+  __weak FPRAppActivityTracker *weakSelf = self;
+  nw_path_monitor_set_update_handler(self.monitor, ^(nw_path_t _Nonnull path) {
+    BOOL isWiFi = nw_path_uses_interface_type(path, nw_interface_type_wifi);
+    BOOL isCellular = nw_path_uses_interface_type(path, nw_interface_type_cellular);
+    BOOL isEthernet = nw_path_uses_interface_type(path, nw_interface_type_wired);
+
+    if (isWiFi) {
+      weakSelf.networkType = firebase_perf_v1_NetworkConnectionInfo_NetworkType_WIFI;
+    } else if (isCellular) {
+      weakSelf.networkType = firebase_perf_v1_NetworkConnectionInfo_NetworkType_MOBILE;
+    } else if (isEthernet) {
+      weakSelf.networkType = firebase_perf_v1_NetworkConnectionInfo_NetworkType_ETHERNET;
+    }
+  });
 
-    nw_path_monitor_start(self.monitor);
-  }
+  nw_path_monitor_start(self.monitor);
 }
 
 /**
@@ -195,13 +193,7 @@ NSString *const kFPRAppCounterNameActivePrewarm = @"_fsapc";
  * @return true if the OS could prewarm apps on the current device
  */
 - (BOOL)isPrewarmAvailable {
-  BOOL canPrewarm = NO;
-  // Guarding for double dispatch which does not work below iOS 13, and 0.1% of app start also show
-  // signs of prewarming on iOS 14 go/paste/5533761933410304
-  if (@available(iOS 13, *)) {
-    canPrewarm = YES;
-  }
-  return canPrewarm;
+  return YES;
 }
 
 /**
@@ -328,9 +320,7 @@ NSString *const kFPRAppCounterNameActivePrewarm = @"_fsapc";
 }
 
 - (void)dealloc {
-  if (@available(iOS 12, tvOS 12, *)) {
-    nw_path_monitor_cancel(self.monitor);
-  }
+  nw_path_monitor_cancel(self.monitor);
 
   [[NSNotificationCenter defaultCenter] removeObserver:self
                                                   name:UIApplicationDidBecomeActiveNotification

+ 4 - 17
FirebasePerformance/Sources/FPRNanoPbUtils.m

@@ -98,23 +98,10 @@ static firebase_perf_v1_NetworkConnectionInfo_MobileSubtype FPRCellularNetworkTy
     };
   });
 
-  // Use recent APIs for iOS 12 and above and older APIs for before.
-  if (@available(iOS 12, *)) {
-    NSDictionary<NSString *, NSString *> *radioAccessors =
-        FPRNetworkInfo().serviceCurrentRadioAccessTechnology;
-    if (radioAccessors.count > 0) {
-      NSString *networkString = [radioAccessors.allValues objectAtIndex:0];
-      NSNumber *cellularNetworkType = cellularNetworkToMobileSubtype[networkString];
-      return cellularNetworkType.intValue;
-    }
-  } else {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
-
-    NSString *networkString = FPRNetworkInfo().currentRadioAccessTechnology;
-
-#pragma clang diagnostic pop
-
+  NSDictionary<NSString *, NSString *> *radioAccessors =
+      FPRNetworkInfo().serviceCurrentRadioAccessTechnology;
+  if (radioAccessors.count > 0) {
+    NSString *networkString = [radioAccessors.allValues objectAtIndex:0];
     NSNumber *cellularNetworkType = cellularNetworkToMobileSubtype[networkString];
     return cellularNetworkType.intValue;
   }