Skip to content

Commit c73cd30

Browse files
Googlercynthiajiang
authored andcommitted
Initial import of the Firebase Unity SDK - 373178197 Add a release workflow to the Firebase Unity copybara by amaurice <[email protected]>
- 372237546 Make exceptions propagate from C++ to Unity. by Googler <[email protected]> - 372234555 Remove a leftover reference to InstanceID by amaurice <[email protected]> - 371325946 Removed the deprecated RemoteConfig constructs for the 8.... by drsanta <[email protected]> - 371324215 Remove the Unity Instance ID client as it's no longer sup... by drsanta <[email protected]> - 371156989 Implement automatic extended metadata collection for Cras... by Googler <[email protected]> - 371003179 Bump up Firebase deps to EDM4U to 1.2.165 by chkuang <[email protected]> - 370954303 Update Android dependencies for Unity M94 release by amaurice <[email protected]> - 370945386 Update Unity version to 7.2.0 by amaurice <[email protected]> - 367691107 Change the Unity build to point at the new third_party lo... by amaurice <[email protected]> PiperOrigin-RevId: 373178197
1 parent 5a6e152 commit c73cd30

File tree

24 files changed

+264
-587
lines changed

24 files changed

+264
-587
lines changed

app/src/swig/app.i

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -651,10 +651,6 @@ static firebase::AppOptions* AppOptionsLoadFromJsonConfig(const char* config) {
651651
"Firebase.Installations.FirebaseInstallations, Firebase.Installations",
652652
"installations"
653653
),
654-
new EnableModuleParams(
655-
"Firebase.InstanceId.FirebaseInstanceId, Firebase.InstanceId",
656-
"instance_id"
657-
),
658654
new EnableModuleParams(
659655
"Firebase.Invites.FirebaseInvites, Firebase.Invites",
660656
"invites"

app/src/swig/future.i

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,15 @@ namespace firebase {
181181
System.Threading.Tasks.TaskCompletionSource<CSTYPE> tcs =
182182
new System.Threading.Tasks.TaskCompletionSource<CSTYPE>();
183183
#endif // TYPE_## %mangle(CTYPE)
184+
185+
// Check if an exception has occurred previously and propagate it if it has.
186+
// This has to be done before accessing the future because the future object
187+
// might be invalid.
188+
if ($imclassname.SWIGPendingException.Pending) {
189+
tcs.SetException($imclassname.SWIGPendingException.Retrieve());
190+
return tcs.Task;
191+
}
192+
184193
if (fu.status() == FutureStatus.Invalid) {
185194
tcs.SetException(
186195
new FirebaseException(0, "Asynchronous operation was not started."));

app/src/unity_main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
// the C++ module.
2121

2222
#include <jni.h>
23+
2324
#include "app/src/util.h"
2425
#include "app/src/util_android.h"
2526

@@ -110,7 +111,6 @@ jint JNI_OnLoad(JavaVM *jvm, void *reserved) {
110111
{"com/google/firebase/dynamiclinks/FirebaseDynamicLinks",
111112
"dynamic_links"},
112113
{"com/google/firebase/functions/FirebaseFunctions", "functions"},
113-
{"com/google/firebase/iid/FirebaseInstanceId", "instance_id"},
114114
{"com/google/firebase/installations/FirebaseInstallations",
115115
"installations"},
116116
{"com/google/android/gms/appinvite/AppInvite", "invites"},

auth/src/swig/auth.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ static CppInstanceManager<Auth> g_auth_instances;
956956
%typemap(csclassmodifiers) firebase::auth::FederatedOAuthProvider
957957
"public sealed class";
958958

959-
// Provider classes declared in auth/client/cpp/src/included/credential.h
959+
// Provider classes declared in third_party/firebase/cpp/auth/src/included/credential.h
960960
// Rename the kProviderId string constant for all of our AuthProviders.
961961
%rename(ProviderId) firebase::auth::EmailAuthProvider::kProviderId;
962962
%rename(ProviderId) firebase::auth::FacebookAuthProvider::kProviderId;

cmake/android_dependencies.cmake

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,49 +16,49 @@
1616

1717
set(FIREBASE_APP_ANDROID_DEPS
1818
"com.google.firebase:firebase-common:19.5.0"
19-
"com.google.firebase:firebase-analytics:18.0.2"
19+
"com.google.firebase:firebase-analytics:18.0.3"
2020
)
2121

2222
set(FIREBASE_ANALYTICS_ANDROID_DEPS
23-
"com.google.firebase:firebase-analytics:18.0.2"
23+
"com.google.firebase:firebase-analytics:18.0.3"
2424
)
2525

2626
set(FIREBASE_AUTH_ANDROID_DEPS
27-
"com.google.firebase:firebase-auth:20.0.2"
28-
"com.google.firebase:firebase-analytics:18.0.2"
27+
"com.google.firebase:firebase-auth:20.0.4"
28+
"com.google.firebase:firebase-analytics:18.0.3"
2929
)
3030

3131
set(FIREBASE_DATABASE_ANDROID_DEPS
32-
"com.google.firebase:firebase-database:19.6.0"
33-
"com.google.firebase:firebase-analytics:18.0.2"
32+
"com.google.firebase:firebase-database:19.7.0"
33+
"com.google.firebase:firebase-analytics:18.0.3"
3434
)
3535

3636
set(FIREBASE_DYNAMIC_LINKS_ANDROID_DEPS
3737
"com.google.android.gms:play-services-appinvite:18.0.0"
38-
"com.google.firebase:firebase-analytics:18.0.2"
38+
"com.google.firebase:firebase-analytics:18.0.3"
3939
)
4040

4141
set(FIREBASE_FUNCTIONS_ANDROID_DEPS
4242
"com.google.firebase:firebase-functions:19.2.0"
43-
"com.google.firebase:firebase-analytics:18.0.2"
43+
"com.google.firebase:firebase-analytics:18.0.3"
4444
)
4545

4646
set(FIREBASE_INSTANCE_ID_ANDROID_DEPS
47-
"com.google.firebase:firebase-iid:21.0.1"
48-
"com.google.firebase:firebase-analytics:18.0.2"
47+
"com.google.firebase:firebase-iid:21.1.0"
48+
"com.google.firebase:firebase-analytics:18.0.3"
4949
)
5050

5151
set(FIREBASE_MESSAGING_ANDROID_DEPS
52-
"com.google.firebase:firebase-messaging:21.0.1"
53-
"com.google.firebase:firebase-analytics:18.0.2"
52+
"com.google.firebase:firebase-messaging:21.1.0"
53+
"com.google.firebase:firebase-analytics:18.0.3"
5454
)
5555

5656
set(FIREBASE_REMOTE_CONFIG_ANDROID_DEPS
57-
"com.google.firebase:firebase-config:20.0.3"
58-
"com.google.firebase:firebase-analytics:18.0.2"
57+
"com.google.firebase:firebase-config:20.0.4"
58+
"com.google.firebase:firebase-analytics:18.0.3"
5959
)
6060

6161
set(FIREBASE_STORAGE_ANDROID_DEPS
62-
"com.google.firebase:firebase-storage:19.2.1"
63-
"com.google.firebase:firebase-analytics:18.0.2"
62+
"com.google.firebase:firebase-storage:19.2.2"
63+
"com.google.firebase:firebase-analytics:18.0.3"
6464
)

cmake/swig_fix.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ def get_transformations(namespace):
139139
'csharp': [
140140
swig_post_process.SWIGEnumPostProcessing(),
141141
NamespaceCMethodsCMake(namespace),
142-
swig_post_process.ReplaceExceptionChecks('AppUtil'),
142+
swig_post_process.ReplaceExceptionChecks(
143+
'AppUtil', ['firebase/firestore/client/unity']),
143144
swig_post_process.FixSealedClasses(),
144145
swig_post_process.InternalMethodsToInternalVisibility(),
145146
swig_post_process.RenameAsyncMethods(),

crashlytics/src/AndroidImpl.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ internal AndroidImpl() {
5555
"Unable to create FirebaseCrashlytics instance.");
5656
return;
5757
}
58+
59+
SetCustomKey(MetadataBuilder.METADATA_KEY, MetadataBuilder.GenerateMetadataJSON());
5860
}
5961

6062
~AndroidImpl() {

crashlytics/src/IOSImpl.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ internal class IOSImpl : Impl
4949
[DllImport("__Internal")]
5050
private static extern void CLUSetKeyValue(string key, string value);
5151

52+
[DllImport("__Internal")]
53+
private static extern void CLUSetInternalKeyValue(string key, string value);
54+
5255
[DllImport("__Internal")]
5356
private static extern void CLUSetUserIdentifier(string identifier);
5457

@@ -68,6 +71,7 @@ private static extern void CLURecordCustomException(string name, string reason,
6871

6972
public IOSImpl() {
7073
CLUSetDevelopmentPlatform("Unity", Application.unityVersion);
74+
CLUSetInternalKeyValue(MetadataBuilder.METADATA_KEY, MetadataBuilder.GenerateMetadataJSON());
7175
}
7276

7377
public override bool IsSDKInitialized() {

crashlytics/src/Metadata.cs

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/*
2+
* Copyright 2021 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
namespace Firebase.Crashlytics {
18+
using System;
19+
using System;
20+
using UnityEngine;
21+
22+
/// <summary>
23+
/// Represents the Unity-specific metadata object that is transformed into JSON.
24+
///
25+
/// Metadata keys are acronyms to save space as there are limits to the maximum size of Keys in
26+
/// the Android and iOS SDK.
27+
/// </summary>
28+
internal class Metadata {
29+
// unityVersion: Version of Unity Engine
30+
public string uv;
31+
// isDebugBuild: Whether "Development Build" is checked
32+
public bool idb;
33+
34+
// processorType
35+
public string pt;
36+
// processorCount: Number of cores
37+
public int pc;
38+
// processorFrequency
39+
public int pf;
40+
41+
// systemMemorySize: RAM size
42+
public int sms;
43+
44+
// graphicsMemorySize
45+
public int gms;
46+
// graphicsDeviceID
47+
public int gdid;
48+
// graphicsDeviceVendorID
49+
public int gdvid;
50+
// graphicsDeviceName
51+
public string gdn;
52+
// graphicsDeviceVendor
53+
public string gdv;
54+
// graphicsDeviceVersion
55+
public string gdver;
56+
// graphicsDeviceType
57+
public UnityEngine.Rendering.GraphicsDeviceType gdt;
58+
59+
// graphicsShaderLevel
60+
// https://docs.unity3d.com/540/Documentation/ScriptReference/SystemInfo-graphicsShaderLevel.html
61+
public int gsl;
62+
// graphicsRenderTargetCount
63+
public int grtc;
64+
// graphicsCopyTextureSupport
65+
public UnityEngine.Rendering.CopyTextureSupport gcts;
66+
// graphicsMaxTextureSize
67+
public int gmts;
68+
69+
// screenSize
70+
public string ss;
71+
// screenDPI
72+
public float sdpi;
73+
// screenRefreshRate
74+
public int srr;
75+
76+
public Metadata() {
77+
uv = Application.unityVersion;
78+
idb = Debug.isDebugBuild;
79+
80+
pt = SystemInfo.processorType;
81+
pc = SystemInfo.processorCount;
82+
pf = SystemInfo.processorFrequency;
83+
84+
sms = SystemInfo.systemMemorySize;
85+
86+
gms = SystemInfo.graphicsMemorySize;
87+
gdid = SystemInfo.graphicsDeviceID;
88+
gdvid = SystemInfo.graphicsDeviceVendorID;
89+
gdn = SystemInfo.graphicsDeviceName;
90+
gdv = SystemInfo.graphicsDeviceVendor;
91+
gdver = SystemInfo.graphicsDeviceVersion;
92+
gdt = SystemInfo.graphicsDeviceType;
93+
94+
gsl = SystemInfo.graphicsShaderLevel;
95+
grtc = SystemInfo.supportedRenderTargetCount;
96+
gcts = SystemInfo.copyTextureSupport;
97+
gmts = SystemInfo.maxTextureSize;
98+
99+
ss = String.Format("{0}x{1}", Screen.width, Screen.height);
100+
sdpi = Screen.dpi;
101+
srr = Screen.currentResolution.refreshRate;
102+
}
103+
}
104+
}

crashlytics/src/MetadataBuilder.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2021 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
namespace Firebase.Crashlytics {
18+
using System;
19+
using UnityEngine;
20+
21+
/// <summary>
22+
/// Automatically collects metadata and serializes to JSON in a space-efficient way.
23+
/// </summary>
24+
internal class MetadataBuilder {
25+
public static string METADATA_KEY = "com.crashlytics.metadata.unity";
26+
27+
public static string GenerateMetadataJSON() {
28+
try {
29+
Metadata metadata = new Metadata();
30+
return JsonUtility.ToJson(metadata);
31+
} catch (Exception e) {
32+
UnityEngine.Debug.LogError(
33+
"Failed to generate Unity-specific metadata for Crashlytics due to: " + e.ToString());
34+
return "";
35+
}
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)