Skip to content

Commit d5e3888

Browse files
authored
Depend on Google Utlities for device platform + Add Model information to session events. (#10508)
1 parent a368679 commit d5e3888

File tree

9 files changed

+109
-44
lines changed

9 files changed

+109
-44
lines changed

FirebaseSessions.podspec

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@ Pod::Spec.new do |s|
3939
base_dir + 'Protogen/**/*.{c,h,m,mm}',
4040
]
4141

42-
s.ios.framework = 'CoreTelephony'
4342
s.dependency 'FirebaseCore', '~> 10.0'
4443
s.dependency 'FirebaseCoreExtension', '~> 10.0'
4544
s.dependency 'FirebaseInstallations', '~> 10.0'
4645
s.dependency 'GoogleDataTransport', '~> 9.2'
47-
s.dependency 'GoogleUtilities/Environment', '~> 7.8'
46+
s.dependency 'GoogleUtilities/Environment', '~> 7.10'
4847
s.dependency 'nanopb', '>= 2.30908.0', '< 2.30910.0'
4948

5049
s.pod_target_xcconfig = {

FirebaseSessions/Sources/ApplicationInfo.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ protocol ApplicationInfoProtocol {
3838
/// Crashlytics-specific device / OS filter values.
3939
var osName: String { get }
4040

41+
/// Model of the device
42+
var deviceModel: String { get }
43+
4144
/// Validated Mobile Country Code and Mobile Network Code
4245
var mccMNC: String { get }
4346

@@ -67,10 +70,15 @@ class ApplicationInfo: ApplicationInfoProtocol {
6770
}
6871

6972
var osName: String {
70-
// TODO: Update once https://github.com/google/GoogleUtilities/pull/89 is released
71-
// to production, update this to GULAppEnvironmentUtil.appleDevicePlatform() and update
72-
// the podfile to depend on the newest version of GoogleUtilities
73-
return GULAppEnvironmentUtil.applePlatform()
73+
return GULAppEnvironmentUtil.appleDevicePlatform()
74+
}
75+
76+
var deviceModel: String {
77+
#if targetEnvironment(simulator)
78+
return GULAppEnvironmentUtil.deviceSimulatorModel() ?? ""
79+
#else
80+
return GULAppEnvironmentUtil.deviceModel() ?? ""
81+
#endif // targetEnvironment(simulator)
7482
}
7583

7684
var mccMNC: String {

FirebaseSessions/Sources/NanoPB/FIRSESNanoPBHelpers.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,6 @@ BOOL FIRSESIsPBDataEqual(pb_bytes_array_t* _Nullable pbArray, NSData* _Nullable
8282
/// Swift does not support c-style macros.
8383
pb_size_t FIRSESGetAppleApplicationInfoTag(void);
8484

85-
/// Returns the cellular mobile country code (mnc) if CoreTelephony is supported, otherwise nil
86-
NSString* _Nullable FIRSESNetworkMobileCountryCode(void);
87-
88-
/// Returns the cellular mobile network code (mnc) if CoreTelephony is supported, otherwise nil
89-
NSString* _Nullable FIRSESNetworkMobileNetworkCode(void);
90-
9185
/// Returns the validated MccMnc if it is available, or nil if the device does not support telephone
9286
NSString* _Nullable FIRSESValidateMccMnc(NSString* _Nullable mcc, NSString* _Nullable mnc);
9387

FirebaseSessions/Sources/NanoPB/FIRSESNanoPBHelpers.m

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
#import <Foundation/Foundation.h>
1717

18+
#import <GoogleUtilities/GULNetworkInfo.h>
19+
1820
#import "FirebaseSessions/Sources/NanoPB/FIRSESNanoPBHelpers.h"
1921

2022
#import "FirebaseSessions/Protogen/nanopb/sessions.nanopb.h"
@@ -155,35 +157,6 @@ pb_size_t FIRSESGetAppleApplicationInfoTag(void) {
155157
return firebase_appquality_sessions_ApplicationInfo_apple_app_info_tag;
156158
}
157159

158-
#ifdef TARGET_HAS_MOBILE_CONNECTIVITY
159-
CTTelephonyNetworkInfo *_Nullable FIRSESNetworkInfo(void) {
160-
static CTTelephonyNetworkInfo *networkInfo;
161-
static dispatch_once_t onceToken;
162-
dispatch_once(&onceToken, ^{
163-
networkInfo = [[CTTelephonyNetworkInfo alloc] init];
164-
});
165-
return networkInfo;
166-
}
167-
#endif
168-
169-
NSString *_Nullable FIRSESNetworkMobileCountryCode(void) {
170-
#ifdef TARGET_HAS_MOBILE_CONNECTIVITY
171-
CTTelephonyNetworkInfo *networkInfo = FIRSESNetworkInfo();
172-
CTCarrier *provider = networkInfo.subscriberCellularProvider;
173-
return provider.mobileCountryCode;
174-
#endif
175-
return nil;
176-
}
177-
178-
NSString *_Nullable FIRSESNetworkMobileNetworkCode(void) {
179-
#ifdef TARGET_HAS_MOBILE_CONNECTIVITY
180-
CTTelephonyNetworkInfo *networkInfo = FIRSESNetworkInfo();
181-
CTCarrier *provider = networkInfo.subscriberCellularProvider;
182-
return provider.mobileNetworkCode;
183-
#endif
184-
return nil;
185-
}
186-
187160
NSString *_Nullable FIRSESValidateMccMnc(NSString *_Nullable mcc, NSString *_Nullable mnc) {
188161
// These are both nil if the target does not support mobile connectivity
189162
if (mcc == nil && mnc == nil) {

FirebaseSessions/Sources/NetworkInfo.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
// limitations under the License.
1515

1616
import Foundation
17+
18+
@_implementationOnly import GoogleUtilities
19+
1720
protocol NetworkInfoProtocol {
1821
var mobileCountryCode: String? { get }
1922

@@ -22,10 +25,10 @@ protocol NetworkInfoProtocol {
2225

2326
class NetworkInfo: NetworkInfoProtocol {
2427
var mobileCountryCode: String? {
25-
return FIRSESNetworkMobileCountryCode()
28+
return GULNetworkInfo.getNetworkMobileCountryCode()
2629
}
2730

2831
var mobileNetworkCode: String? {
29-
return FIRSESNetworkMobileNetworkCode()
32+
return GULNetworkInfo.getNetworkMobileNetworkCode()
3033
}
3134
}

FirebaseSessions/Sources/SessionStartEvent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class SessionStartEvent: NSObject, GDTCOREventDataObject {
3939
proto.application_info.app_id = makeProtoString(appInfo.appID)
4040
proto.application_info.session_sdk_version = makeProtoString(appInfo.sdkVersion)
4141
proto.application_info.log_environment = convertLogEnvironment(environment: appInfo.environment)
42-
// proto.application_info.device_model = makeProtoString(appInfo.deviceModel)
42+
proto.application_info.device_model = makeProtoString(appInfo.deviceModel)
4343
// proto.application_info.development_platform_name;
4444
// proto.application_info.development_platform_version;
4545

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
PODS:
2+
- FirebaseCore (10.2.0):
3+
- FirebaseCoreInternal (~> 10.0)
4+
- GoogleUtilities/Environment (~> 7.8)
5+
- GoogleUtilities/Logger (~> 7.8)
6+
- FirebaseCoreExtension (10.2.0):
7+
- FirebaseCore (~> 10.0)
8+
- FirebaseCoreInternal (10.2.0):
9+
- "GoogleUtilities/NSData+zlib (~> 7.8)"
10+
- FirebaseInstallations (10.2.0):
11+
- FirebaseCore (~> 10.0)
12+
- GoogleUtilities/Environment (~> 7.8)
13+
- GoogleUtilities/UserDefaults (~> 7.8)
14+
- PromisesObjC (~> 2.1)
15+
- FirebaseSessions (10.0.0):
16+
- FirebaseCore (~> 10.0)
17+
- FirebaseCoreExtension (~> 10.0)
18+
- FirebaseInstallations (~> 10.0)
19+
- GoogleDataTransport (~> 9.2)
20+
- GoogleUtilities/Environment (~> 7.10)
21+
- nanopb (< 2.30910.0, >= 2.30908.0)
22+
- GoogleDataTransport (9.2.0):
23+
- GoogleUtilities/Environment (~> 7.7)
24+
- nanopb (< 2.30910.0, >= 2.30908.0)
25+
- PromisesObjC (< 3.0, >= 1.2)
26+
- GoogleUtilities/Environment (7.10.0):
27+
- PromisesObjC (< 3.0, >= 1.2)
28+
- GoogleUtilities/Logger (7.10.0):
29+
- GoogleUtilities/Environment
30+
- "GoogleUtilities/NSData+zlib (7.10.0)"
31+
- GoogleUtilities/UserDefaults (7.10.0):
32+
- GoogleUtilities/Logger
33+
- nanopb (2.30909.0):
34+
- nanopb/decode (= 2.30909.0)
35+
- nanopb/encode (= 2.30909.0)
36+
- nanopb/decode (2.30909.0)
37+
- nanopb/encode (2.30909.0)
38+
- PromisesObjC (2.1.1)
39+
40+
DEPENDENCIES:
41+
- FirebaseCore (from `../../../`)
42+
- FirebaseCoreExtension (from `../../../`)
43+
- FirebaseCoreInternal (from `../../../`)
44+
- FirebaseInstallations (from `../../../`)
45+
- FirebaseSessions (from `../../../`)
46+
47+
SPEC REPOS:
48+
trunk:
49+
- GoogleDataTransport
50+
- GoogleUtilities
51+
- nanopb
52+
- PromisesObjC
53+
54+
EXTERNAL SOURCES:
55+
FirebaseCore:
56+
:path: "../../../"
57+
FirebaseCoreExtension:
58+
:path: "../../../"
59+
FirebaseCoreInternal:
60+
:path: "../../../"
61+
FirebaseInstallations:
62+
:path: "../../../"
63+
FirebaseSessions:
64+
:path: "../../../"
65+
66+
SPEC CHECKSUMS:
67+
FirebaseCore: 813838072b797b64f529f3c2ee35e696e5641dd1
68+
FirebaseCoreExtension: d08b424832917cf13612021574399afbbedffeef
69+
FirebaseCoreInternal: 091bde13e47bb1c5e9fe397634f3593dc390430f
70+
FirebaseInstallations: 004915af170935e3a583faefd5f8bc851afc220f
71+
FirebaseSessions: 154d37bbda55072f2d6b6d0013778bf69d2e2e52
72+
GoogleDataTransport: 1c8145da7117bd68bbbed00cf304edb6a24de00f
73+
GoogleUtilities: bad72cb363809015b1f7f19beb1f1cd23c589f95
74+
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
75+
PromisesObjC: ab77feca74fa2823e7af4249b8326368e61014cb
76+
77+
PODFILE CHECKSUM: 1a003bf06c05ee635d13a4c6a952942ff7e13dd0
78+
79+
COCOAPODS: 1.11.3

FirebaseSessions/Tests/Unit/Mocks/MockApplicationInfo.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class MockApplicationInfo: ApplicationInfoProtocol {
2626

2727
var osName: String = ""
2828

29+
var deviceModel: String = ""
30+
2931
var mccMNC: String = ""
3032

3133
var environment: DevEnvironment = .prod
@@ -35,6 +37,7 @@ class MockApplicationInfo: ApplicationInfoProtocol {
3537
static let testSDKVersion = "testSDKVersion"
3638
static let testOSName = "ios"
3739
static let testMCCMNC = "testMCCMNC"
40+
static let testDeviceModel = "testDeviceModel"
3841
static let testEnvironment: DevEnvironment = .prod
3942

4043
func mockAllInfo() {
@@ -43,6 +46,7 @@ class MockApplicationInfo: ApplicationInfoProtocol {
4346
sdkVersion = MockApplicationInfo.testSDKVersion
4447
osName = MockApplicationInfo.testOSName
4548
mccMNC = MockApplicationInfo.testMCCMNC
49+
deviceModel = MockApplicationInfo.testDeviceModel
4650
environment = MockApplicationInfo.testEnvironment
4751
}
4852
}

FirebaseSessions/Tests/Unit/SessionStartEventTests.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ class SessionStartEventTests: XCTestCase {
8686
expected: MockApplicationInfo.testBundleID,
8787
fieldName: "bundle_short_version"
8888
)
89+
assertEqualProtoString(
90+
proto.application_info.device_model,
91+
expected: MockApplicationInfo.testDeviceModel,
92+
fieldName: "device_model"
93+
)
8994
assertEqualProtoString(
9095
proto.application_info.apple_app_info.mcc_mnc,
9196
expected: MockApplicationInfo.testMCCMNC,

0 commit comments

Comments
 (0)