Skip to content

Commit 18e361d

Browse files
committed
Merge branch 'master' into wuandy/OverlayOfflineFix
# Conflicts: # firebase-firestore/CHANGELOG.md
2 parents 910748d + f5845b2 commit 18e361d

File tree

87 files changed

+1249
-472
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1249
-472
lines changed

alternative-root-project.gradle

Lines changed: 0 additions & 60 deletions
This file was deleted.

appcheck/firebase-appcheck-debug-testing/firebase-appcheck-debug-testing.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ dependencies {
5252
implementation 'com.google.android.gms:play-services-tasks:18.0.1'
5353
implementation 'androidx.test:core:1.2.0'
5454

55+
javadocClasspath 'com.google.auto.value:auto-value-annotations:1.6.6'
56+
5557
testImplementation 'junit:junit:4.13-beta-2'
5658
testImplementation 'org.mockito:mockito-core:2.25.0'
5759
testImplementation "org.robolectric:robolectric:$robolectricVersion"

appcheck/firebase-appcheck-safetynet/firebase-appcheck-safetynet.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ dependencies {
4949
implementation 'com.google.android.gms:play-services-safetynet:18.0.0'
5050

5151
javadocClasspath 'com.google.auto.value:auto-value-annotations:1.6.6'
52+
javadocClasspath 'org.checkerframework:checker-qual:2.5.2'
5253

5354
testImplementation 'junit:junit:4.13-beta-2'
5455
testImplementation 'org.mockito:mockito-core:2.25.0'

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.google.firebase.components.Component;
2222
import com.google.firebase.components.ComponentRegistrar;
2323
import com.google.firebase.components.Dependency;
24+
import com.google.firebase.heartbeatinfo.HeartBeatConsumerComponent;
2425
import com.google.firebase.heartbeatinfo.HeartBeatController;
2526
import com.google.firebase.platforminfo.LibraryVersionComponent;
2627
import java.util.Arrays;
@@ -48,6 +49,7 @@ public List<Component<?>> getComponents() {
4849
container.getProvider(HeartBeatController.class)))
4950
.alwaysEager()
5051
.build(),
52+
HeartBeatConsumerComponent.create(),
5153
LibraryVersionComponent.create("fire-app-check", BuildConfig.VERSION_NAME));
5254
}
5355
}

appcheck/firebase-appcheck/src/test/java/com/google/firebase/appcheck/FirebaseAppCheckRegistrarTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void testGetComponents() {
3434
FirebaseAppCheckRegistrar firebaseAppCheckRegistrar = new FirebaseAppCheckRegistrar();
3535
List<Component<?>> components = firebaseAppCheckRegistrar.getComponents();
3636
assertThat(components).isNotEmpty();
37-
assertThat(components).hasSize(2);
37+
assertThat(components).hasSize(3);
3838
Component<?> firebaseAppCheckComponent = components.get(0);
3939
assertThat(firebaseAppCheckComponent.getDependencies())
4040
.containsExactly(

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
import com.google.firebase.gradle.plugins.license.LicenseResolverPlugin
16+
import com.google.firebase.gradle.MultiProjectReleasePlugin
1617

1718
buildscript {
1819
ext.kotlinVersion = '1.3.72'
@@ -56,6 +57,8 @@ apply plugin: com.google.firebase.gradle.plugins.publish.PublishingPlugin
5657
apply plugin: com.google.firebase.gradle.plugins.ci.ContinuousIntegrationPlugin
5758
apply plugin: com.google.firebase.gradle.plugins.ci.SmokeTestsPlugin
5859

60+
apply plugin: MultiProjectReleasePlugin
61+
5962
firebaseContinuousIntegration {
6063
ignorePaths = [
6164
/.*\.gitignore$/,

firebase-abt/gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=21.0.1
2-
latestReleasedVersion=21.0.0
1+
version=21.0.2
2+
latestReleasedVersion=21.0.1
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2022 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.google.firebase.annotations;
16+
17+
import java.lang.annotation.ElementType;
18+
import java.lang.annotation.Target;
19+
20+
/**
21+
* Indicates that this object (class, method, etc) is experimental and that both its signature and
22+
* implementation are subject to change. An API marked with this annotation provides no guarantee of
23+
* API stability or backward-compatibility.
24+
*/
25+
@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
26+
public @interface PreviewApi {}

firebase-appdistribution/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
version=0.0.1
15+
version=16.0.1

firebase-appdistribution/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<category android:name="android.intent.category.DEFAULT"/>
4141
<category android:name="android.intent.category.BROWSABLE"/>
4242

43-
<data android:scheme="appdistribution-${applicationId}" android:host="authredirect" />
43+
<data android:scheme="intent" android:host="appdistribution" android:path="/${applicationId}"/>
4444

4545
</intent-filter>
4646
</activity>

firebase-appdistribution/src/main/java/com/google/firebase/appdistribution/ApkUpdater.java

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ private void installApk(File file, boolean showDownloadNotificationManager) {
128128
file.length(),
129129
file.length(),
130130
UpdateStatus.INSTALL_FAILED,
131-
showDownloadNotificationManager);
131+
showDownloadNotificationManager,
132+
R.string.install_failed);
132133
setUpdateTaskCompletionErrorWithDefault(
133134
e,
134135
FirebaseAppDistributionException.ErrorMessages.APK_INSTALLATION_FAILED,
@@ -179,7 +180,8 @@ private void makeApkDownloadRequest(
179180
}
180181

181182
long responseLength = connection.getContentLength();
182-
postUpdateProgress(responseLength, 0, UpdateStatus.PENDING, showNotification);
183+
postUpdateProgress(
184+
responseLength, 0, UpdateStatus.PENDING, showNotification, R.string.downloading_app_update);
183185
String fileName = getApkFileName();
184186
LogWrapper.getInstance().v(TAG + "Attempting to download APK to disk");
185187

@@ -188,7 +190,12 @@ private void makeApkDownloadRequest(
188190
File apkFile = context.getFileStreamPath(fileName);
189191
validateJarFile(apkFile, responseLength, showNotification, bytesDownloaded);
190192

191-
postUpdateProgress(responseLength, bytesDownloaded, UpdateStatus.DOWNLOADED, showNotification);
193+
postUpdateProgress(
194+
responseLength,
195+
bytesDownloaded,
196+
UpdateStatus.DOWNLOADED,
197+
showNotification,
198+
R.string.download_completed);
192199
safeSetTaskResult(downloadTaskCompletionSource, apkFile);
193200
}
194201

@@ -220,12 +227,20 @@ private long downloadToDisk(
220227
if (currentTimeMs - lastMsUpdated > UPDATE_INTERVAL_MS) {
221228
lastMsUpdated = currentTimeMs;
222229
postUpdateProgress(
223-
totalSize, bytesDownloaded, UpdateStatus.DOWNLOADING, showNotification);
230+
totalSize,
231+
bytesDownloaded,
232+
UpdateStatus.DOWNLOADING,
233+
showNotification,
234+
R.string.downloading_app_update);
224235
}
225236
}
226237
} catch (IOException e) {
227238
postUpdateProgress(
228-
totalSize, bytesDownloaded, UpdateStatus.DOWNLOAD_FAILED, showNotification);
239+
totalSize,
240+
bytesDownloaded,
241+
UpdateStatus.DOWNLOAD_FAILED,
242+
showNotification,
243+
R.string.download_failed);
229244
throw new FirebaseAppDistributionException("Failed to download APK", DOWNLOAD_FAILURE, e);
230245
}
231246
return bytesDownloaded;
@@ -238,7 +253,11 @@ private void validateJarFile(
238253
new JarFile(apkFile).close();
239254
} catch (IOException e) {
240255
postUpdateProgress(
241-
totalSize, bytesDownloaded, UpdateStatus.DOWNLOAD_FAILED, showNotification);
256+
totalSize,
257+
bytesDownloaded,
258+
UpdateStatus.DOWNLOAD_FAILED,
259+
showNotification,
260+
R.string.download_failed);
242261
throw new FirebaseAppDistributionException(
243262
"Downloaded APK was not a valid JAR file", DOWNLOAD_FAILURE, e);
244263
}
@@ -274,7 +293,11 @@ private void setUpdateTaskCompletionErrorWithDefault(Exception e, String message
274293
}
275294

276295
private void postUpdateProgress(
277-
long totalBytes, long downloadedBytes, UpdateStatus status, boolean showNotification) {
296+
long totalBytes,
297+
long downloadedBytes,
298+
UpdateStatus status,
299+
boolean showNotification,
300+
int stringResourceId) {
278301
synchronized (updateTaskLock) {
279302
cachedUpdateTask.updateProgress(
280303
UpdateProgress.builder()
@@ -284,7 +307,8 @@ private void postUpdateProgress(
284307
.build());
285308
}
286309
if (showNotification) {
287-
appDistributionNotificationsManager.updateNotification(totalBytes, downloadedBytes, status);
310+
appDistributionNotificationsManager.updateNotification(
311+
totalBytes, downloadedBytes, stringResourceId);
288312
}
289313
}
290314
}

firebase-appdistribution/src/main/java/com/google/firebase/appdistribution/FirebaseAppDistributionNotificationsManager.java

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ class FirebaseAppDistributionNotificationsManager {
4646
this.appIconSource = appIconSource;
4747
}
4848

49-
void updateNotification(long totalBytes, long downloadedBytes, UpdateStatus status) {
49+
void updateNotification(long totalBytes, long downloadedBytes, int stringResourceId) {
5050
NotificationManager notificationManager = createNotificationManager(context);
5151
NotificationCompat.Builder notificationBuilder =
5252
new NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID)
5353
.setOnlyAlertOnce(true)
5454
.setSmallIcon(appIconSource.getNonAdaptiveIconOrDefault(context))
55-
.setContentTitle(context.getString(getNotificationContentTitleId(status)))
55+
.setContentTitle(context.getString(stringResourceId))
5656
.setProgress(
5757
100,
5858
(int) (((float) downloadedBytes / (float) totalBytes) * 100),
@@ -64,25 +64,6 @@ void updateNotification(long totalBytes, long downloadedBytes, UpdateStatus stat
6464
notificationManager.notify(NOTIFICATION_TAG, /*id =*/ 0, notificationBuilder.build());
6565
}
6666

67-
int getNotificationContentTitleId(UpdateStatus status) {
68-
if (isErrorState(status)) {
69-
return R.string.download_failed;
70-
} else if (status.equals(UpdateStatus.DOWNLOADED)) {
71-
return R.string.download_completed;
72-
} else {
73-
return R.string.downloading_app_update;
74-
}
75-
}
76-
77-
// CHECK THIS LATER
78-
private boolean isErrorState(UpdateStatus status) {
79-
return status.equals(UpdateStatus.DOWNLOAD_FAILED)
80-
|| status.equals(UpdateStatus.INSTALL_FAILED)
81-
|| status.equals(UpdateStatus.INSTALL_CANCELED)
82-
|| status.equals(UpdateStatus.NEW_RELEASE_CHECK_FAILED)
83-
|| status.equals(UpdateStatus.UPDATE_CANCELED);
84-
}
85-
8667
private NotificationManager createNotificationManager(Context context) {
8768
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
8869
NotificationChannel channel =
@@ -110,6 +91,20 @@ private PendingIntent createAppLaunchIntent() {
11091
LogWrapper.getInstance().w(TAG + "No activity found to launch app");
11192
return null;
11293
}
113-
return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_ONE_SHOT);
94+
return PendingIntent.getActivity(
95+
context, 0, intent, getPendingIntentFlags(PendingIntent.FLAG_ONE_SHOT));
96+
}
97+
98+
/**
99+
* Adds {@link PendingIntent#FLAG_IMMUTABLE} to a PendingIntent's flags since any PendingIntents
100+
* used here don't need to be modified.
101+
*
102+
* <p>Specifying mutability is required starting at SDK level 31.
103+
*/
104+
private static int getPendingIntentFlags(int baseFlags) {
105+
// Only add on platform levels that support FLAG_IMMUTABLE.
106+
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
107+
? baseFlags | PendingIntent.FLAG_IMMUTABLE
108+
: baseFlags;
114109
}
115110
}

firebase-appdistribution/src/main/java/com/google/firebase/appdistribution/TesterSignInManager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
class TesterSignInManager {
4646
private static final String TAG = "TesterSignInManager:";
4747
private static final String SIGNIN_REDIRECT_URL =
48-
"https://appdistribution.firebase.google.com/pub/testerapps/%s/installations/%s/buildalerts?appName=%s&packageName=%s";
48+
"https://appdistribution.firebase.google.com/pub/testerapps/%s/installations/%s/buildalerts?appName=%s&packageName=%s&newRedirectScheme=true";
4949

5050
private final FirebaseApp firebaseApp;
5151
private final Provider<FirebaseInstallationsApi> firebaseInstallationsApiProvider;
@@ -83,7 +83,7 @@ class TesterSignInManager {
8383
this.lifecycleNotifier = lifecycleNotifier;
8484

8585
lifecycleNotifier.addOnActivityCreatedListener(this::onActivityCreated);
86-
lifecycleNotifier.addOnActivityStartedListener(this::onActivityStarted);
86+
lifecycleNotifier.addOnActivityResumedListener(this::onActivityResumed);
8787
}
8888

8989
@VisibleForTesting
@@ -98,7 +98,7 @@ void onActivityCreated(Activity activity) {
9898
}
9999

100100
@VisibleForTesting
101-
void onActivityStarted(Activity activity) {
101+
void onActivityResumed(Activity activity) {
102102
if (activity instanceof SignInResultActivity || activity instanceof InstallActivity) {
103103
// SignInResult and InstallActivity are internal to the SDK and should not be treated as
104104
// reentering the app

firebase-appdistribution/src/main/res/values/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
<string name="downloading_app_update">Downloading in-app update...</string>
2626
<string name="download_completed">Download completed</string>
2727
<string name="download_failed">Download failed</string>
28+
<string name="download_pending">Download pending</string>
29+
<string name="install_failed">Install failed</string>
30+
<string name="install_canceled">Install canceled</string>
31+
<string name="update_canceled">Update canceled </string>
2832
<string name="notifications_channel_name">App Distribution App Update Downloads</string>
2933
<string name="notifications_channel_description">Shows download progress of in-app updates from App Distribution SDK</string>
3034
<string name="unknown_sources_dialog_title">Enable Unknown Sources</string>

firebase-appdistribution/src/test/java/com/google/firebase/appdistribution/ApkUpdaterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public void updateApk_whenInstallFailed_setsError() {
196196
assertThat(progressEvents).hasSize(1);
197197
assertThat(progressEvents.get(0).getUpdateStatus()).isEqualTo(UpdateStatus.INSTALL_FAILED);
198198
assertThat(updateTask.isSuccessful()).isFalse();
199-
verify(mockNotificationsManager).updateNotification(1000, 1000, UpdateStatus.INSTALL_FAILED);
199+
verify(mockNotificationsManager).updateNotification(1000, 1000, R.string.install_failed);
200200
}
201201

202202
@Test

0 commit comments

Comments
 (0)