Skip to content

Commit dbc72dc

Browse files
committed
Merge branch 'crashlytics/anrs' into td/anr
2 parents 91cda29 + c81f83c commit dbc72dc

File tree

12 files changed

+100
-75
lines changed

12 files changed

+100
-75
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ https://firebase.google.com.
6161
submodules by running `git submodule update --init --recursive`.
6262
* Import the firebase-android-sdk gradle project into Android Studio using the
6363
**Import project(Gradle, Eclipse ADT, etc.)** option.
64+
* `firebase-crashlytics-ndk` must be built with NDK 21. See
65+
[firebase-crashlytics-ndk](firebase-crashlytics-ndk/README.md) for more
66+
details.
6467

6568
## Testing
6669

appcheck/firebase-appcheck-debug-testing/src/main/java/com/google/firebase/appcheck/debug/testing/DebugAppCheckTestHelper.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,31 @@
2929
*
3030
* <p>Example Usage:
3131
*
32-
* <pre>{@code
33-
* @RunWith(AndroidJunit4.class)
32+
* <pre>
33+
* &#64;RunWith(AndroidJunit4.class)
3434
* public class MyTests {
3535
* private final DebugAppCheckTestHelper debugAppCheckTestHelper =
3636
* DebugAppCheckTestHelper.fromInstrumentationArgs();
3737
*
38-
* @Test
39-
* public testWithDefaultApp() {
38+
* &#64;Test
39+
* public void testWithDefaultApp() {
4040
* debugAppCheckTestHelper.withDebugProvider(() -> {
4141
* // Test code that requires a debug AppCheckToken
4242
* });
4343
* }
4444
*
45-
* @Test
46-
* public testWithNonDefaultApp() {
45+
* &#64;Test
46+
* public void testWithNonDefaultApp() {
4747
* debugAppCheckTestHelper.withDebugProvider(
4848
* FirebaseApp.getInstance("nonDefaultApp"),
4949
* () -> {
5050
* // Test code that requires a debug AppCheckToken
5151
* });
5252
* }
5353
* }
54-
* }</pre>
54+
* </pre>
5555
*
56-
* <pre>{@code
56+
* <pre>
5757
* // In build.gradle.kts
5858
* android {
5959
* defaultConfig {
@@ -63,15 +63,15 @@
6363
* }
6464
* }
6565
* }
66-
* }</pre>
66+
* </pre>
6767
*/
6868
public final class DebugAppCheckTestHelper {
6969
private static final String DEBUG_SECRET_KEY = "firebaseAppCheckDebugSecret";
7070

7171
private final String debugSecret;
7272

7373
/**
74-
* Create a {@link DebugAppCheckTestHelper} instance with the debug secret obtained from {@link
74+
* Creates a {@link DebugAppCheckTestHelper} instance with the debug secret obtained from {@link
7575
* InstrumentationRegistry} arguments.
7676
*/
7777
@NonNull

appcheck/firebase-appcheck-safetynet/src/main/java/com/google/firebase/appcheck/safetynet/SafetyNetAppCheckProviderFactory.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
/**
2424
* Implementation of an {@link AppCheckProviderFactory} that builds {@link
25-
* SafetyNetAppCheckProvider}s. This is the default implementation
25+
* SafetyNetAppCheckProvider}s. This is the default implementation.
2626
*/
2727
public class SafetyNetAppCheckProviderFactory implements AppCheckProviderFactory {
2828

@@ -31,6 +31,10 @@ public class SafetyNetAppCheckProviderFactory implements AppCheckProviderFactory
3131

3232
private SafetyNetAppCheckProviderFactory() {}
3333

34+
/**
35+
* Gets an instance of this class for installation into a {@link
36+
* com.google.firebase.appcheck.FirebaseAppCheck} instance.
37+
*/
3438
@NonNull
3539
public static SafetyNetAppCheckProviderFactory getInstance() {
3640
return instance;

appcheck/firebase-appcheck/src/main/java/com/google/firebase/appcheck/AppCheckProvider.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@
2626
public interface AppCheckProvider {
2727

2828
/**
29-
* Returns a {@link Task} which resolves to one of three things: (1) A valid {@link
30-
* AppCheckToken}. (2) {@code null} in the event that a token is unavailable. (3) An {@link
31-
* Exception} in the case that an unexpected failure occurred while getting the token.
29+
* Returns a {@link Task} which resolves to a valid {@link AppCheckToken} or an {@link Exception}
30+
* in the case that an unexpected failure occurred while getting the token.
3231
*/
3332
@NonNull
3433
Task<AppCheckToken> getToken();

appcheck/firebase-appcheck/src/main/java/com/google/firebase/appcheck/AppCheckProviderFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
public interface AppCheckProviderFactory {
2222

2323
/**
24-
* Gets the {@link AppCheckProvider} associated with the given FirebaseApp instance, or creates
25-
* one if none already exists.
24+
* Gets the {@link AppCheckProvider} associated with the given {@link FirebaseApp} instance, or
25+
* creates one if none already exists.
2626
*/
2727
@NonNull
2828
AppCheckProvider create(@NonNull FirebaseApp firebaseApp);

appcheck/firebase-appcheck/src/main/java/com/google/firebase/appcheck/FirebaseAppCheck.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@
2222

2323
public abstract class FirebaseAppCheck implements InternalAppCheckTokenProvider {
2424

25-
/** Get the default instance of FirebaseAppCheck. */
25+
/** Gets the default instance of {@code FirebaseAppCheck}. */
2626
@NonNull
2727
public static FirebaseAppCheck getInstance() {
2828
return getInstance(FirebaseApp.getInstance());
2929
}
3030

3131
/**
32-
* Get the instance of FirebaseAppCheck associated with the given {@link FirebaseApp} instance.
32+
* Gets the instance of {@code FirebaseAppCheck} associated with the given {@link FirebaseApp}
33+
* instance.
3334
*/
3435
@NonNull
3536
public static FirebaseAppCheck getInstance(@NonNull FirebaseApp firebaseApp) {
@@ -38,9 +39,9 @@ public static FirebaseAppCheck getInstance(@NonNull FirebaseApp firebaseApp) {
3839

3940
/**
4041
* Installs the given {@link AppCheckProviderFactory}, overwriting any that were previously
41-
* associated with this FirebaseAppCheck instance. Any {@link AppCheckTokenListener}s attached to
42-
* this FirebaseAppCheck instance will be transferred from existing factories to the newly
43-
* installed one.
42+
* associated with this {@code FirebaseAppCheck} instance. Any {@link AppCheckTokenListener}s
43+
* attached to this {@code FirebaseAppCheck} instance will be transferred from existing factories
44+
* to the newly installed one.
4445
*
4546
* <p>Automatic token refreshing will only occur if the global {@code
4647
* isDataCollectionDefaultEnabled} flag is set to true. To allow automatic token refreshing for
@@ -53,14 +54,14 @@ public static FirebaseAppCheck getInstance(@NonNull FirebaseApp firebaseApp) {
5354

5455
/**
5556
* Installs the given {@link AppCheckProviderFactory}, overwriting any that were previously
56-
* associated with this FirebaseAppCheck instance. Any {@link AppCheckTokenListener}s attached to
57-
* this FirebaseAppCheck instance will be transferred from existing factories to the newly
58-
* installed one.
57+
* associated with this {@code FirebaseAppCheck} instance. Any {@link AppCheckTokenListener}s
58+
* attached to this {@code FirebaseAppCheck} instance will be transferred from existing factories
59+
* to the newly installed one.
5960
*
6061
* <p>Automatic token refreshing will only occur if the {@code isTokenAutoRefreshEnabled} field is
6162
* set to true. To use the global {@code isDataCollectionDefaultEnabled} flag for determining
62-
* automatic token refreshing, {@link #installAppCheckProviderFactory(AppCheckProviderFactory)}
63-
* should be called instead.
63+
* automatic token refreshing, call {@link
64+
* #installAppCheckProviderFactory(AppCheckProviderFactory)} instead.
6465
*/
6566
@SuppressLint("FirebaseLambdaLast")
6667
public abstract void installAppCheckProviderFactory(

ci/fireci/fireciplugins/macrobenchmark.py

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ def macrobenchmark():
4040
async def _launch_macrobenchmark_test():
4141
_logger.info('Starting macrobenchmark test...')
4242

43-
artifact_versions, config, _ = await asyncio.gather(
43+
artifact_versions, config, _, _ = await asyncio.gather(
4444
_parse_artifact_versions(),
4545
_parse_config_yaml(),
46-
_create_gradle_wrapper()
46+
_create_gradle_wrapper(),
47+
_copy_google_services(),
4748
)
4849

4950
with chdir('macrobenchmark'):
@@ -84,13 +85,21 @@ async def _create_gradle_wrapper():
8485
'./gradlew',
8586
'wrapper',
8687
'--gradle-version',
87-
'7.0',
88+
'6.9',
8889
'--project-dir',
8990
'macrobenchmark'
9091
)
9192
await proc.wait()
9293

9394

95+
async def _copy_google_services():
96+
if 'FIREBASE_CI' in os.environ:
97+
src = os.environ['FIREBASE_GOOGLE_SERVICES_PATH']
98+
dst = 'macrobenchmark/template/app/google-services.json'
99+
_logger.info(f'Running on CI. Copying "{src}" to "{dst}"...')
100+
shutil.copyfile(src, dst)
101+
102+
94103
class MacrobenchmarkTest:
95104
"""Builds the test based on configurations and runs the test on FTL."""
96105
def __init__(
@@ -117,19 +126,7 @@ async def _create_test_src(self):
117126
app_id = self.test_app_config['application-id']
118127
self.logger.info(f'Creating test app "{app_name}" with application-id "{app_id}"...')
119128

120-
mustache_context = {
121-
'application-id': app_id,
122-
'plugins': self.test_app_config['plugins'] if 'plugins' in self.test_app_config else [],
123-
'dependencies': [
124-
{
125-
'key': x,
126-
'version': self.artifact_versions[x]
127-
} for x in self.test_app_config['dependencies']
128-
] if 'dependencies' in self.test_app_config else [],
129-
}
130-
131-
if app_name != 'baseline':
132-
mustache_context['plugins'].append('com.google.gms.google-services')
129+
mustache_context = await self._prepare_mustache_context()
133130

134131
shutil.copytree('template', self.test_app_dir)
135132
with chdir(self.test_app_dir):
@@ -172,6 +169,33 @@ async def _upload_apks_to_ftl(self):
172169

173170
await self._exec_subprocess(executable, args)
174171

172+
async def _prepare_mustache_context(self):
173+
app_name = self.test_app_config['name']
174+
app_id = self.test_app_config['application-id']
175+
176+
mustache_context = {
177+
'application-id': app_id,
178+
'plugins': [],
179+
'dependencies': [],
180+
}
181+
182+
if app_name != 'baseline':
183+
mustache_context['plugins'].append('com.google.gms.google-services')
184+
185+
if 'plugins' in self.test_app_config:
186+
mustache_context['plugins'].extend(self.test_app_config['plugins'])
187+
188+
if 'dependencies' in self.test_app_config:
189+
for dep in self.test_app_config['dependencies']:
190+
if '@' in dep:
191+
key, version = dep.split('@', 1)
192+
dependency = {'key': key, 'version': version}
193+
else:
194+
dependency = {'key': dep, 'version': self.artifact_versions[dep]}
195+
mustache_context['dependencies'].append(dependency)
196+
197+
return mustache_context
198+
175199
async def _exec_subprocess(self, executable, args):
176200
command = " ".join([executable, *args])
177201
self.logger.info(f'Executing command: "{command}"...')

firebase-crashlytics-ndk/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ Initialize them by running the following commands:
1111

1212
## Building
1313

14-
All Gradle commands should be run from the root of this repository.
15-
16-
`./gradlew :firebase-crashlytics-ndk:assemble`
14+
* `firebase-crashlytics-ndk` must be built with NDK 21. Use Android Studio's
15+
SDK Manager to ensure you have the appropriate NDK version installed, and
16+
edit `../local.properties` to specify which NDK version to use when building
17+
this project. For example:
18+
`ndk.dir=$USER_HOME/Library/Android/sdk/ndk/21.4.7075529`
19+
* All Gradle commands should be run from the root of this repository:
20+
`./gradlew :firebase-crashlytics-ndk:assemble`
1721

1822
## Running Tests
1923

firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/FirebaseCrashlytics.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,8 @@ public void setCustomKey(@NonNull String key, @NonNull String value) {
349349

350350
/**
351351
* Sets multiple custom keys and values that are associated with subsequent fatal and non-fatal
352-
* reports. This method is intended as an alternative to `setCustomKey` in order to reduce the
353-
* computational load of writing out multiple key/value pairs at the same time.
352+
* reports. This method is intended as an alternative to {@code setCustomKey} in order to reduce
353+
* the computational load of writing out multiple key/value pairs at the same time.
354354
*
355355
* <p>Multiple calls to this method with the same key update the value for that key.
356356
*
@@ -425,10 +425,10 @@ public boolean didCrashOnPreviousExecution() {
425425
* disabled. Use {@link #deleteUnsentReports()} to delete any reports stored on the device without
426426
* sending them to Crashlytics.
427427
*
428-
* @param enabled whether to enable automatic data collection. When set to `false`, the new value
429-
* does not apply until the next run of the app. To disable data collection by default for all
430-
* app runs, add the `firebase_crashlytics_collection_enabled` flag to your app's
431-
* AndroidManifest.xml.
428+
* @param enabled whether to enable automatic data collection. When set to {@code false}, the new
429+
* value does not apply until the next run of the app. To disable data collection by default
430+
* for all app runs, add the {@code firebase_crashlytics_collection_enabled} flag to your
431+
* app's AndroidManifest.xml.
432432
*/
433433
public void setCrashlyticsCollectionEnabled(boolean enabled) {
434434
core.setCrashlyticsCollectionEnabled(enabled);
@@ -438,19 +438,19 @@ public void setCrashlyticsCollectionEnabled(boolean enabled) {
438438
* Enables or disables the automatic data collection configuration for Crashlytics.
439439
*
440440
* <p>If this is set, it overrides any automatic data collection settings configured in the
441-
* AndroidManifest.xml as well as any Firebase-wide settings. If set to `null`, the override is
442-
* cleared.
441+
* AndroidManifest.xml as well as any Firebase-wide settings. If set to {@code null}, the override
442+
* is cleared.
443443
*
444444
* <p>If automatic data collection is disabled for Crashlytics, crash reports are stored on the
445445
* device. To check for reports, use the {@link #checkForUnsentReports()} method. Use {@link
446446
* #sendUnsentReports()} to upload existing reports even when automatic data collection is
447447
* disabled. Use {@link #deleteUnsentReports()} to delete any reports stored on the device without
448448
* sending them to Crashlytics.
449449
*
450-
* @param enabled whether to enable or disable automatic data collection. When set to `false`, the
451-
* new value does not apply until the next run of the app. When set to `null`, the override is
452-
* cleared and automatic data collection settings are determined by the configuration in your
453-
* AndroidManifest.xml or other Firebase-wide settings.
450+
* @param enabled whether to enable or disable automatic data collection. When set to {@code
451+
* false}, the new value does not apply until the next run of the app. When set to {@code
452+
* null}, the override is cleared and automatic data collection settings are determined by the
453+
* configuration in your AndroidManifest.xml or other Firebase-wide settings.
454454
*/
455455
public void setCrashlyticsCollectionEnabled(@Nullable Boolean enabled) {
456456
core.setCrashlyticsCollectionEnabled(enabled);

macrobenchmark/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ firebase-inappmessaging-display:
4444
name: inappmessaging
4545
application-id: com.google.firebase.benchmark.inappmessaging
4646
dependencies:
47+
- com.google.firebase:[email protected]
4748
- com.google.firebase:firebase-inappmessaging-ktx
4849
- com.google.firebase:firebase-inappmessaging-display-ktx
4950

0 commit comments

Comments
 (0)