Skip to content

Commit d74ab41

Browse files
committed
Merge remote-tracking branch 'origin/master' into ExpectedExceptionEqualsTrueToAssertThrows
2 parents 163ba01 + e3ae02d commit d74ab41

File tree

7 files changed

+59
-48
lines changed

7 files changed

+59
-48
lines changed

firebase-dynamic-links/src/main/java/com/google/firebase/dynamiclinks/PendingDynamicLinkData.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ protected PendingDynamicLinkData(
7171
}
7272

7373
/**
74-
* Return the {@link Bundle} so that 1P dynamic links extensions can access extension data. The
74+
* Returns the {@link Bundle} so that 1P dynamic links extensions can access extension data. The
7575
* data is stored bundle with keys defined by the extension. The bundle is shared with all
7676
* extensions, so the keys should be unique using the package name of the extension to define the
7777
* namespace.
7878
*
79-
* @return A bundle will all extension data.
79+
* @return A bundle with all extensions data.
8080
* @hide
8181
*/
8282
@KeepForSdk
@@ -89,7 +89,7 @@ public Bundle getExtensions() {
8989
}
9090

9191
/**
92-
* Return the link parameter of the dynamic link.
92+
* Returns the link parameter of the Firebase Dynamic Link.
9393
*
9494
* <p>This link will be set as data in the launch Intent, see {@link Intent#setData(Uri)}, which
9595
* will match {@link android.content.IntentFilter} to deep link into the app.
@@ -109,8 +109,8 @@ public Uri getLink() {
109109
}
110110

111111
/**
112-
* Return the {@link Bundle} which contains utm parameters associated with the firebase dynamic
113-
* link.
112+
* Returns the {@link Bundle} which contains utm parameters associated with the Firebase Dynamic
113+
* Link.
114114
*
115115
* @return Bundle of utm parameters associated with firebase dynamic link.
116116
*/
@@ -124,9 +124,9 @@ public Bundle getUtmParameters() {
124124
}
125125

126126
/**
127-
* The minimum app version requested to process the dynamic link that can be compared directly
128-
* with {@link android.content.pm.PackageInfo#versionCode}. If the minimum version code is higher
129-
* than the installed app version code, the app can upgrade using {@link
127+
* Gets the minimum app version requested to process the Firebase Dynamic Link that can be
128+
* compared directly with {@link android.content.pm.PackageInfo#versionCode}. If the minimum
129+
* version code is higher than the installed app version code, the app can upgrade using {@link
130130
* #getUpdateAppIntent(Context)}.
131131
*
132132
* @return minimum version code set on the dynamic link, or 0 if not specified.
@@ -139,8 +139,8 @@ public int getMinimumAppVersion() {
139139
}
140140

141141
/**
142-
* The time that the user clicked on the dynamic link. This can be used to determine the amount of
143-
* time that has passed since the user selected the link until the app is launched.
142+
* Gets the time that the user clicked on the Firebase Dynamic Link. This can be used to determine
143+
* the amount of time that has passed since the user selected the link until the app is launched.
144144
*
145145
* @return The number of milliseconds that have elapsed since January 1, 1970.
146146
*/
@@ -152,7 +152,7 @@ public long getClickTimestamp() {
152152
}
153153

154154
/**
155-
* Provides the redirect url, which is used as the alternative to opening the app. This url may
155+
* Gets the redirect url, which is used as the alternative to opening the app. This url may
156156
* install the app or go to an app specific website.
157157
*
158158
* @return Url that can be used to create an intent to launch an activity.
@@ -168,7 +168,7 @@ public Uri getRedirectUrl() {
168168
}
169169

170170
/**
171-
* Provide an intent to update the app to the version in the Play Store.
171+
* Gets the intent to update the app to the version in the Play Store.
172172
*
173173
* <p>An intent is returned to be used as a parameter to {@link
174174
* android.app.Activity#startActivity(Intent)} to launch the Play Store update flow for the app.

firebase-messaging/src/main/java/com/google/firebase/messaging/FcmLifecycleCallbacks.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
// limitations under the License.
1414
package com.google.firebase.messaging;
1515

16+
import static com.google.firebase.messaging.Constants.TAG;
17+
1618
import android.app.Activity;
1719
import android.app.Application;
1820
import android.content.Intent;
@@ -21,6 +23,7 @@
2123
import android.os.Bundle;
2224
import android.os.Handler;
2325
import android.os.Looper;
26+
import android.util.Log;
2427
import java.util.Collections;
2528
import java.util.Set;
2629
import java.util.WeakHashMap;
@@ -74,12 +77,19 @@ public void onActivityResumed(Activity activity) {}
7477
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {}
7578

7679
private void logNotificationOpen(Intent startingIntent) {
77-
Bundle extras = startingIntent.getExtras();
78-
if (extras != null) {
79-
Bundle analyticsData = extras.getBundle(Constants.MessageNotificationKeys.ANALYTICS_DATA);
80-
if (MessagingAnalytics.shouldUploadScionMetrics(analyticsData)) {
81-
MessagingAnalytics.logNotificationOpen(analyticsData);
80+
Bundle analyticsData = null;
81+
try {
82+
Bundle extras = startingIntent.getExtras();
83+
if (extras != null) {
84+
analyticsData = extras.getBundle(Constants.MessageNotificationKeys.ANALYTICS_DATA);
8285
}
86+
} catch (RuntimeException e) {
87+
// Don't crash if there was a problem trying to get the analytics data Bundle since the
88+
// Intent could be coming from anywhere and could be incorrectly formatted.
89+
Log.w(TAG, "Failed trying to get analytics data from Intent extras.", e);
90+
}
91+
if (MessagingAnalytics.shouldUploadScionMetrics(analyticsData)) {
92+
MessagingAnalytics.logNotificationOpen(analyticsData);
8393
}
8494
}
8595
}

firebase-perf/src/main/java/com/google/firebase/perf/application/AppStateMonitor.java

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,7 @@ public void onActivityCreated(Activity activity, Bundle savedInstanceState) {}
146146
public void onActivityDestroyed(Activity activity) {}
147147

148148
@Override
149-
public synchronized void onActivityStarted(Activity activity) {
150-
if (isScreenTraceSupported(activity) && configResolver.isPerformanceMonitoringEnabled()) {
151-
// Starts recording frame metrics for this activity.
152-
/**
153-
* TODO: Only add activities that are hardware acceleration enabled so that calling {@link
154-
* FrameMetricsAggregator#remove(Activity)} will not throw exceptions.
155-
*/
156-
frameMetricsAggregator.add(activity);
157-
// Start the Trace
158-
Trace screenTrace = new Trace(getScreenTraceName(activity), transportManager, clock, this);
159-
screenTrace.start();
160-
activityToScreenTraceMap.put(activity, screenTrace);
161-
}
162-
}
149+
public synchronized void onActivityStarted(Activity activity) {}
163150

164151
@Override
165152
public synchronized void onActivityStopped(Activity activity) {
@@ -181,7 +168,8 @@ public synchronized void onActivityResumed(Activity activity) {
181168
// cases:
182169
// 1. At app startup, first activity comes to foreground.
183170
// 2. app switch from background to foreground.
184-
// 3. app already in foreground, current activity is replaced by another activity.
171+
// 3. app already in foreground, current activity is replaced by another activity, or the
172+
// current activity was paused then resumed without onStop, for example by an AlertDialog
185173
if (activityToResumedMap.isEmpty()) {
186174
// The first resumed activity means app comes to foreground.
187175
resumeTime = clock.getTime();
@@ -198,9 +186,24 @@ public synchronized void onActivityResumed(Activity activity) {
198186
updateAppState(ApplicationProcessState.FOREGROUND);
199187
}
200188
} else {
201-
// case 3: app already in foreground, current activity is replaced by another activity.
189+
// case 3: app already in foreground, current activity is replaced by another activity, or the
190+
// current activity was paused then resumed without onStop, for example by an AlertDialog
202191
activityToResumedMap.put(activity, true);
203192
}
193+
194+
// Screen trace is after session update so the sessionId is not added twice to the Trace
195+
if (isScreenTraceSupported(activity) && configResolver.isPerformanceMonitoringEnabled()) {
196+
// Starts recording frame metrics for this activity.
197+
/**
198+
* TODO: Only add activities that are hardware acceleration enabled so that calling {@link
199+
* FrameMetricsAggregator#remove(Activity)} will not throw exceptions.
200+
*/
201+
frameMetricsAggregator.add(activity);
202+
// Start the Trace
203+
Trace screenTrace = new Trace(getScreenTraceName(activity), transportManager, clock, this);
204+
screenTrace.start();
205+
activityToScreenTraceMap.put(activity, screenTrace);
206+
}
204207
}
205208

206209
/** Returns if this is the cold start of the app. */

firebase-perf/src/test/java/com/google/firebase/perf/application/AppStateMonitorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ public void screenTrace_twoActivities_traceStartedAndStoppedWithActivityLifecycl
366366
int startTime = i * 100;
367367
int endTime = startTime + 10;
368368
currentTime = startTime;
369-
monitor.onActivityStarted(activity);
369+
monitor.onActivityResumed(activity);
370370
assertThat(monitor.getActivity2ScreenTrace()).hasSize(1);
371371
currentTime = endTime;
372372
monitor.onActivityPostPaused(activity);
@@ -418,7 +418,7 @@ public void screenTrace_perfMonEnabledSwitchAtRuntime_traceCreationDependsOnRunt
418418

419419
// Assert that screen trace has been created.
420420
currentTime = 100;
421-
monitor.onActivityStarted(activityWithNonHardwareAcceleratedView);
421+
monitor.onActivityResumed(activityWithNonHardwareAcceleratedView);
422422
assertThat(monitor.getActivity2ScreenTrace()).hasSize(1);
423423
currentTime = 200;
424424
monitor.onActivityPostPaused(activityWithNonHardwareAcceleratedView);

firebase-storage/src/test/java/com/google/firebase/storage/StorageReferenceTest.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,11 @@ public void initWithDefaultAndCustomUriTest() throws Exception {
148148
Assert.assertEquals("gs://foo-bar.appspot.com/", customRef.toString());
149149
}
150150

151-
@Test(expected = IllegalArgumentException.class)
151+
@Test
152152
public void badInitTest() throws Exception {
153-
FirebaseStorage.getInstance().getReference("gs://fooey.appspot.com/child");
153+
assertThrows(
154+
IllegalArgumentException.class,
155+
() -> FirebaseStorage.getInstance().getReference("gs://fooey.appspot.com/child"));
154156
}
155157

156158
@Test
@@ -178,15 +180,18 @@ public void initWithApp() throws Exception {
178180
Assert.assertEquals("child", ref.getName());
179181
}
180182

181-
@Test(expected = IllegalArgumentException.class)
183+
@Test
182184
public void badInitWithApp1() throws Exception {
183-
FirebaseStorage.getInstance().getReference("gs://bucket/child");
185+
assertThrows(
186+
IllegalArgumentException.class,
187+
() -> FirebaseStorage.getInstance().getReference("gs://bucket/child"));
184188
}
185189

186190
@SuppressWarnings("ConstantConditions")
187-
@Test(expected = IllegalArgumentException.class)
191+
@Test
188192
public void badInitWithApp2() throws Exception {
189-
FirebaseStorage.getInstance().getReference(null);
193+
assertThrows(
194+
IllegalArgumentException.class, () -> FirebaseStorage.getInstance().getReference(null));
190195
}
191196

192197
@Test

smoke-tests/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ dependencies {
7171
// Firebase
7272
implementation "com.google.firebase:firebase-analytics"
7373
implementation "com.google.firebase:firebase-annotations"
74-
implementation "com.google.firebase:firebase-appdistribution"
7574
implementation "com.google.firebase:firebase-appindexing"
7675
implementation "com.google.firebase:firebase-auth"
7776
implementation "com.google.firebase:firebase-common"

smoke-tests/src/main/java/com/google/firebase/testing/BuildOnlyTest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.google.firebase.messaging.FirebaseMessaging;
2222
import com.google.firebase.ml.modeldownloader.FirebaseModelDownloader;
2323
import com.google.firebase.perf.FirebasePerformance;
24-
import com.google.firebase.appdistribution.FirebaseAppDistribution;
2524
import org.junit.Test;
2625
import org.junit.runner.RunWith;
2726
import org.junit.runners.JUnit4;
@@ -56,9 +55,4 @@ public void modelDownloader_IsNotNull() {
5655
public void performance_IsNotNull() {
5756
assertThat(FirebasePerformance.getInstance()).isNotNull();
5857
}
59-
60-
@Test
61-
public void appDistribution_IsNotNull(){
62-
assertThat(FirebaseAppDistribution.getInstance()).isNotNull();
63-
}
6458
}

0 commit comments

Comments
 (0)