Skip to content

Merge from internal #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
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
7 changes: 0 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ option(FIREBASE_INCLUDE_DYNAMIC_LINKS
"Include the Firebase Dynamic Links library." ON)
option(FIREBASE_INCLUDE_FUNCTIONS
"Include the Cloud Functions for Firebase library." ON)
option(FIREBASE_INCLUDE_INSTANCE_ID
"Include the Firebase Instance ID library." ON)
option(FIREBASE_INCLUDE_MESSAGING
"Include the Firebase Cloud Messaging library." ON)
option(FIREBASE_INCLUDE_REMOTE_CONFIG
Expand Down Expand Up @@ -244,11 +242,6 @@ if (FIREBASE_INCLUDE_FUNCTIONS)
list(APPEND TARGET_LINK_LIB_NAMES "firebase_functions" "firebase_functions_swig")
list(APPEND PROJECT_LIST_HEADER " X(Functions)")
endif()
if (FIREBASE_INCLUDE_INSTANCE_ID)
add_subdirectory(instance_id)
list(APPEND TARGET_LINK_LIB_NAMES "firebase_instance_id" "firebase_instance_id_swig")
list(APPEND PROJECT_LIST_HEADER " X(InstanceId)")
endif()
if (FIREBASE_INCLUDE_MESSAGING)
add_subdirectory(messaging)
list(APPEND TARGET_LINK_LIB_NAMES "firebase_messaging" "firebase_messaging_swig")
Expand Down
4 changes: 0 additions & 4 deletions app/src/swig/app.i
Original file line number Diff line number Diff line change
Expand Up @@ -651,10 +651,6 @@ static firebase::AppOptions* AppOptionsLoadFromJsonConfig(const char* config) {
"Firebase.Installations.FirebaseInstallations, Firebase.Installations",
"installations"
),
new EnableModuleParams(
"Firebase.InstanceId.FirebaseInstanceId, Firebase.InstanceId",
"instance_id"
),
new EnableModuleParams(
"Firebase.Invites.FirebaseInvites, Firebase.Invites",
"invites"
Expand Down
9 changes: 9 additions & 0 deletions app/src/swig/future.i
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,15 @@ namespace firebase {
System.Threading.Tasks.TaskCompletionSource<CSTYPE> tcs =
new System.Threading.Tasks.TaskCompletionSource<CSTYPE>();
#endif // TYPE_## %mangle(CTYPE)

// Check if an exception has occurred previously and propagate it if it has.
// This has to be done before accessing the future because the future object
// might be invalid.
if ($imclassname.SWIGPendingException.Pending) {
tcs.SetException($imclassname.SWIGPendingException.Retrieve());
return tcs.Task;
}

if (fu.status() == FutureStatus.Invalid) {
tcs.SetException(
new FirebaseException(0, "Asynchronous operation was not started."));
Expand Down
2 changes: 1 addition & 1 deletion app/src/unity_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// the C++ module.

#include <jni.h>

#include "app/src/util.h"
#include "app/src/util_android.h"

Expand Down Expand Up @@ -110,7 +111,6 @@ jint JNI_OnLoad(JavaVM *jvm, void *reserved) {
{"com/google/firebase/dynamiclinks/FirebaseDynamicLinks",
"dynamic_links"},
{"com/google/firebase/functions/FirebaseFunctions", "functions"},
{"com/google/firebase/iid/FirebaseInstanceId", "instance_id"},
{"com/google/firebase/installations/FirebaseInstallations",
"installations"},
{"com/google/android/gms/appinvite/AppInvite", "invites"},
Expand Down
2 changes: 1 addition & 1 deletion auth/src/swig/auth.i
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ static CppInstanceManager<Auth> g_auth_instances;
%typemap(csclassmodifiers) firebase::auth::FederatedOAuthProvider
"public sealed class";

// Provider classes declared in auth/client/cpp/src/included/credential.h
// Provider classes declared in third_party/firebase/cpp/auth/src/included/credential.h
// Rename the kProviderId string constant for all of our AuthProviders.
%rename(ProviderId) firebase::auth::EmailAuthProvider::kProviderId;
%rename(ProviderId) firebase::auth::FacebookAuthProvider::kProviderId;
Expand Down
32 changes: 16 additions & 16 deletions cmake/android_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,49 @@

set(FIREBASE_APP_ANDROID_DEPS
"com.google.firebase:firebase-common:19.5.0"
"com.google.firebase:firebase-analytics:18.0.2"
"com.google.firebase:firebase-analytics:18.0.3"
)

set(FIREBASE_ANALYTICS_ANDROID_DEPS
"com.google.firebase:firebase-analytics:18.0.2"
"com.google.firebase:firebase-analytics:18.0.3"
)

set(FIREBASE_AUTH_ANDROID_DEPS
"com.google.firebase:firebase-auth:20.0.2"
"com.google.firebase:firebase-analytics:18.0.2"
"com.google.firebase:firebase-auth:20.0.4"
"com.google.firebase:firebase-analytics:18.0.3"
)

set(FIREBASE_DATABASE_ANDROID_DEPS
"com.google.firebase:firebase-database:19.6.0"
"com.google.firebase:firebase-analytics:18.0.2"
"com.google.firebase:firebase-database:19.7.0"
"com.google.firebase:firebase-analytics:18.0.3"
)

set(FIREBASE_DYNAMIC_LINKS_ANDROID_DEPS
"com.google.android.gms:play-services-appinvite:18.0.0"
"com.google.firebase:firebase-analytics:18.0.2"
"com.google.firebase:firebase-analytics:18.0.3"
)

set(FIREBASE_FUNCTIONS_ANDROID_DEPS
"com.google.firebase:firebase-functions:19.2.0"
"com.google.firebase:firebase-analytics:18.0.2"
"com.google.firebase:firebase-analytics:18.0.3"
)

set(FIREBASE_INSTANCE_ID_ANDROID_DEPS
"com.google.firebase:firebase-iid:21.0.1"
"com.google.firebase:firebase-analytics:18.0.2"
"com.google.firebase:firebase-iid:21.1.0"
"com.google.firebase:firebase-analytics:18.0.3"
)

set(FIREBASE_MESSAGING_ANDROID_DEPS
"com.google.firebase:firebase-messaging:21.0.1"
"com.google.firebase:firebase-analytics:18.0.2"
"com.google.firebase:firebase-messaging:21.1.0"
"com.google.firebase:firebase-analytics:18.0.3"
)

set(FIREBASE_REMOTE_CONFIG_ANDROID_DEPS
"com.google.firebase:firebase-config:20.0.3"
"com.google.firebase:firebase-analytics:18.0.2"
"com.google.firebase:firebase-config:20.0.4"
"com.google.firebase:firebase-analytics:18.0.3"
)

set(FIREBASE_STORAGE_ANDROID_DEPS
"com.google.firebase:firebase-storage:19.2.1"
"com.google.firebase:firebase-analytics:18.0.2"
"com.google.firebase:firebase-storage:19.2.2"
"com.google.firebase:firebase-analytics:18.0.3"
)
3 changes: 2 additions & 1 deletion cmake/swig_fix.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ def get_transformations(namespace):
'csharp': [
swig_post_process.SWIGEnumPostProcessing(),
NamespaceCMethodsCMake(namespace),
swig_post_process.ReplaceExceptionChecks('AppUtil'),
swig_post_process.ReplaceExceptionChecks(
'AppUtil', ['firebase/firestore/client/unity']),
swig_post_process.FixSealedClasses(),
swig_post_process.InternalMethodsToInternalVisibility(),
swig_post_process.RenameAsyncMethods(),
Expand Down
2 changes: 2 additions & 0 deletions crashlytics/src/AndroidImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ internal AndroidImpl() {
"Unable to create FirebaseCrashlytics instance.");
return;
}

SetCustomKey(MetadataBuilder.METADATA_KEY, MetadataBuilder.GenerateMetadataJSON());
}

~AndroidImpl() {
Expand Down
4 changes: 4 additions & 0 deletions crashlytics/src/IOSImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ internal class IOSImpl : Impl
[DllImport("__Internal")]
private static extern void CLUSetKeyValue(string key, string value);

[DllImport("__Internal")]
private static extern void CLUSetInternalKeyValue(string key, string value);

[DllImport("__Internal")]
private static extern void CLUSetUserIdentifier(string identifier);

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

public IOSImpl() {
CLUSetDevelopmentPlatform("Unity", Application.unityVersion);
CLUSetInternalKeyValue(MetadataBuilder.METADATA_KEY, MetadataBuilder.GenerateMetadataJSON());
}

public override bool IsSDKInitialized() {
Expand Down
104 changes: 104 additions & 0 deletions crashlytics/src/Metadata.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace Firebase.Crashlytics {
using System;
using System;
using UnityEngine;

/// <summary>
/// Represents the Unity-specific metadata object that is transformed into JSON.
///
/// Metadata keys are acronyms to save space as there are limits to the maximum size of Keys in
/// the Android and iOS SDK.
/// </summary>
internal class Metadata {
// unityVersion: Version of Unity Engine
public string uv;
// isDebugBuild: Whether "Development Build" is checked
public bool idb;

// processorType
public string pt;
// processorCount: Number of cores
public int pc;
// processorFrequency
public int pf;

// systemMemorySize: RAM size
public int sms;

// graphicsMemorySize
public int gms;
// graphicsDeviceID
public int gdid;
// graphicsDeviceVendorID
public int gdvid;
// graphicsDeviceName
public string gdn;
// graphicsDeviceVendor
public string gdv;
// graphicsDeviceVersion
public string gdver;
// graphicsDeviceType
public UnityEngine.Rendering.GraphicsDeviceType gdt;

// graphicsShaderLevel
// https://docs.unity3d.com/540/Documentation/ScriptReference/SystemInfo-graphicsShaderLevel.html
public int gsl;
// graphicsRenderTargetCount
public int grtc;
// graphicsCopyTextureSupport
public UnityEngine.Rendering.CopyTextureSupport gcts;
// graphicsMaxTextureSize
public int gmts;

// screenSize
public string ss;
// screenDPI
public float sdpi;
// screenRefreshRate
public int srr;

public Metadata() {
uv = Application.unityVersion;
idb = Debug.isDebugBuild;

pt = SystemInfo.processorType;
pc = SystemInfo.processorCount;
pf = SystemInfo.processorFrequency;

sms = SystemInfo.systemMemorySize;

gms = SystemInfo.graphicsMemorySize;
gdid = SystemInfo.graphicsDeviceID;
gdvid = SystemInfo.graphicsDeviceVendorID;
gdn = SystemInfo.graphicsDeviceName;
gdv = SystemInfo.graphicsDeviceVendor;
gdver = SystemInfo.graphicsDeviceVersion;
gdt = SystemInfo.graphicsDeviceType;

gsl = SystemInfo.graphicsShaderLevel;
grtc = SystemInfo.supportedRenderTargetCount;
gcts = SystemInfo.copyTextureSupport;
gmts = SystemInfo.maxTextureSize;

ss = String.Format("{0}x{1}", Screen.width, Screen.height);
sdpi = Screen.dpi;
srr = Screen.currentResolution.refreshRate;
}
}
}
38 changes: 38 additions & 0 deletions crashlytics/src/MetadataBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace Firebase.Crashlytics {
using System;
using UnityEngine;

/// <summary>
/// Automatically collects metadata and serializes to JSON in a space-efficient way.
/// </summary>
internal class MetadataBuilder {
public static string METADATA_KEY = "com.crashlytics.metadata.unity";

public static string GenerateMetadataJSON() {
try {
Metadata metadata = new Metadata();
return JsonUtility.ToJson(metadata);
} catch (Exception e) {
UnityEngine.Debug.LogError(
"Failed to generate Unity-specific metadata for Crashlytics due to: " + e.ToString());
return "";
}
}
}
}
4 changes: 3 additions & 1 deletion crashlytics/src/cpp/android/crashlytics_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@
#define FIREBASE_CRASHLYTICS_CLIENT_CPP_SRC_ANDROID_CRASHLYTICS_ANDROID_H_

#include <jni.h>

#include <map>
#include <set>

#include "crashlytics/src/cpp/include/firebase/crashlytics.h"
#include "app/src/future_manager.h"
#include "app/src/include/firebase/app.h"
#include "app/src/include/firebase/internal/common.h"
#include "app/src/mutex.h"
#include "app/src/util_android.h"
#include "crashlytics/src/cpp/include/firebase/crashlytics.h"

namespace firebase {
namespace crashlytics {
Expand Down
4 changes: 2 additions & 2 deletions crashlytics/src/cpp/common/crashlytics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
#include "app/src/cleanup_notifier.h"
#include "app/src/include/firebase/app.h"
#include "app/src/include/firebase/version.h"
#include "app/src/mutex.h"
#include "app/src/log.h"
#include "app/src/mutex.h"
#include "app/src/util.h"

#if defined(__ANDROID__)
#include "app/src/util_android.h"
#include "crashlytics/src/cpp/android/crashlytics_android.h"
#include "app/src/util_android.h"
#else
#include "crashlytics/src/cpp/stub/crashlytics_stub.h"
#endif // defined(__ANDROID__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@
@property(nonatomic, strong, nullable) NSString* developmentPlatformVersion;

@end

void FIRCLSUserLoggingRecordInternalKeyValue(NSString* key, id value);
4 changes: 4 additions & 0 deletions crashlytics/src/cpp/ios/CrashlyticsiOSWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ void CLUSetKeyValue(const char *key, const char *value) {
forKey:safeCharToNSString(key)];
}

void CLUSetInternalKeyValue(const char *key, const char *value) {
FIRCLSUserLoggingRecordInternalKeyValue(safeCharToNSString(key), safeCharToNSString(value));
}

void CLULog(const char *msg) { [[FIRCrashlytics crashlytics] log:safeCharToNSString(msg)]; }

void CLUSetUserIdentifier(const char *identifier) {
Expand Down
3 changes: 2 additions & 1 deletion crashlytics/src/cpp/stub/crashlytics_stub.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@

#include <map>
#include <set>

#include "crashlytics/src/cpp/include/firebase/crashlytics.h"
#include "app/src/cleanup_notifier.h"
#include "app/src/future_manager.h"
#include "app/src/include/firebase/app.h"
#include "app/src/include/firebase/internal/common.h"
#include "app/src/mutex.h"
#include "crashlytics/src/cpp/include/firebase/crashlytics.h"

namespace firebase {
namespace crashlytics {
Expand Down
Loading