Skip to content

Commit 691b85c

Browse files
Merge
2 parents 0679f5e + da62838 commit 691b85c

File tree

67 files changed

+6302
-1162
lines changed

Some content is hidden

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

67 files changed

+6302
-1162
lines changed

firebase-app-distribution/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@
4444

4545
<provider
4646
android:name="androidx.core.content.FileProvider"
47-
android:authorities="${applicationId}.provider"
47+
android:authorities="${applicationId}.appdistro.fileprovider"
4848
android:exported="false"
4949
android:grantUriPermissions="true">
5050
<meta-data
5151
android:name="android.support.FILE_PROVIDER_PATHS"
52-
android:resource="@xml/provider_paths" />
52+
android:resource="@xml/appdistro_provider_paths" />
5353
</provider>
5454
</application>
5555
</manifest>

firebase-app-distribution/src/main/java/com/google/firebase/appdistribution/InstallActivity.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,22 @@ protected void onCreate(@NonNull Bundle savedInstanceState) {
4545
String path = originalIntent.getStringExtra("INSTALL_PATH");
4646
Intent intent = new Intent(Intent.ACTION_VIEW);
4747
intent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
48-
Uri apkUri =
49-
FileProvider.getUriForFile(
50-
getApplicationContext(),
51-
getApplicationContext().getPackageName() + ".provider",
52-
new File(path));
48+
File apkFile = new File(path);
5349
String APK_MIME_TYPE = "application/vnd.android.package-archive";
54-
intent.setDataAndType(apkUri, APK_MIME_TYPE);
55-
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
50+
51+
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
52+
Uri apkUri =
53+
FileProvider.getUriForFile(
54+
getApplicationContext(),
55+
getApplicationContext().getPackageName() + ".appdistro.fileprovider",
56+
apkFile);
57+
intent.setDataAndType(apkUri, APK_MIME_TYPE);
58+
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
59+
} else {
60+
LogWrapper.getInstance().d("Requesting a vanilla URI");
61+
intent.setDataAndType(Uri.fromFile(apkFile), APK_MIME_TYPE);
62+
}
63+
5664
mStartForResult.launch(intent);
5765
}
5866

firebase-app-distribution/src/main/java/com/google/firebase/appdistribution/UpdateApkClient.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,13 @@ private void downloadToDisk(
178178
long bytesDownloaded = 0;
179179
try (BufferedOutputStream outputStream =
180180
new BufferedOutputStream(
181-
firebaseApp.getApplicationContext().openFileOutput(fileName, Context.MODE_PRIVATE))) {
181+
firebaseApp
182+
.getApplicationContext()
183+
.openFileOutput(
184+
fileName,
185+
android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N
186+
? Context.MODE_PRIVATE
187+
: Context.MODE_WORLD_READABLE))) {
182188

183189
byte[] data = new byte[8 * 1024];
184190
int readSize = input.read(data);

firebase-messaging/api.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22
package com.google.firebase.messaging {
33

44
public class FirebaseMessaging {
5-
method @Deprecated public boolean deliveryMetricsExportToBigQueryEnabled();
5+
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Void> deleteToken();
6+
method @NonNull public boolean deliveryMetricsExportToBigQueryEnabled();
67
method @NonNull public static com.google.firebase.messaging.FirebaseMessaging getInstance();
8+
method @NonNull public com.google.android.gms.tasks.Task<java.lang.String> getToken();
79
method public boolean isAutoInitEnabled();
8-
method public boolean isDeliveryMetricsExportToBigQueryEnabled();
10+
method public boolean isNotificationDelegationEnabled();
911
method public void send(@NonNull com.google.firebase.messaging.RemoteMessage);
1012
method public void setAutoInitEnabled(boolean);
1113
method public void setDeliveryMetricsExportToBigQuery(boolean);
14+
method public com.google.android.gms.tasks.Task<java.lang.Void> setNotificationDelegationEnabled(boolean);
1215
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Void> subscribeToTopic(@NonNull String);
1316
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Void> unsubscribeFromTopic(@NonNull String);
14-
field public static final String INSTANCE_ID_SCOPE = "FCM";
17+
field @Deprecated public static final String INSTANCE_ID_SCOPE = "FCM";
1518
}
1619

1720
public class FirebaseMessagingService extends android.app.Service {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# code_gen_cfg.textproto
2+
# proto-file: google3/third_party/firebase/android/encoders/protoc_gen/proto/config.proto
3+
# proto-message: CodeGenConfig
4+
5+
# all types will be vendored in this package
6+
vendor_package: "com.google.firebase.messaging"
7+
8+
# marks a type as a "root" message
9+
include: "reporting.MessagingClientEventExtension"

firebase-messaging/firebase-messaging.gradle

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,40 @@
1414

1515
plugins {
1616
id 'firebase-library'
17+
id 'com.google.protobuf'
1718
}
1819

20+
configurations.create("protobuild")
21+
dependencies {
22+
protobuild project(path: ":encoders:protoc-gen-firebase-encoders", configuration: "shadow")
23+
}
24+
25+
protobuf {
26+
protoc {
27+
artifact = "com.google.protobuf:protoc:$protocVersion"
28+
}
29+
plugins {
30+
firebaseEncoders {
31+
path = configurations.protobuild.asPath
32+
}
33+
}
34+
generateProtoTasks {
35+
all().each { task ->
36+
task.dependsOn configurations.protobuild
37+
task.inputs.file 'code_gen_cfg.textproto'
38+
task.plugins {
39+
firebaseEncoders {
40+
option file('code_gen_cfg.textproto').path
41+
}
42+
}
43+
task.builtins {
44+
remove java
45+
}
46+
}
47+
}
48+
}
49+
50+
1951
firebaseLibrary {
2052
testLab.enabled = false
2153
}
@@ -25,6 +57,7 @@ android {
2557
timeOutInMs 60 * 1000
2658
}
2759

60+
2861
lintOptions {
2962
abortOnError false
3063
}
@@ -55,18 +88,18 @@ dependencies {
5588
implementation project(':transport:transport-backend-cct')
5689
implementation project(':encoders:firebase-encoders')
5790
implementation project(':encoders:firebase-encoders-json')
91+
implementation project(":encoders:firebase-encoders-proto")
92+
implementation project(":firebase-installations")
93+
annotationProcessor project(":encoders:firebase-encoders-processor")
5894

59-
implementation 'androidx.annotation:annotation:1.1.0'
60-
implementation "com.google.android.gms:play-services-tasks:17.0.2"
61-
implementation "com.google.android.gms:play-services-basement:17.2.1"
62-
implementation 'com.google.android.gms:play-services-base:17.2.1'
63-
implementation 'com.google.firebase:firebase-measurement-connector:18.0.0'
64-
implementation "com.google.firebase:firebase-iid-interop:17.0.0"
65-
implementation ("com.google.firebase:firebase-iid:20.2.3") {
66-
exclude group: "com.google.firebase", module: "firebase-common"
67-
exclude group: "com.google.firebase", module: "firebase-components"
68-
exclude group: "com.google.firebase", module: "firebase-installations-interop"
69-
}
95+
implementation 'androidx.annotation:annotation:1.2.0'
96+
implementation "com.google.android.gms:play-services-tasks:17.2.1"
97+
implementation "com.google.android.gms:play-services-basement:17.6.0"
98+
implementation 'com.google.android.gms:play-services-base:17.6.0'
99+
implementation 'com.google.android.gms:play-services-stats:17.0.1'
100+
implementation 'com.google.firebase:firebase-measurement-connector:19.0.0'
101+
implementation "com.google.firebase:firebase-iid-interop:17.1.0"
102+
implementation 'com.google.android.gms:play-services-cloud-messaging:17.0.0'
70103
implementation ("com.google.api-client:google-api-client:1.30.9") {
71104
exclude group: "org.apache.httpcomponents", module: "httpclient"
72105
}
@@ -76,13 +109,20 @@ dependencies {
76109
javadocClasspath 'com.google.auto.value:auto-value-annotations:1.6.6'
77110

78111
testImplementation 'androidx.test:core:1.2.0'
112+
testImplementation 'com.google.android.gms:play-services-cloud-messaging:17.0.0'
79113
testImplementation 'androidx.test:rules:1.2.0'
80114
testImplementation 'androidx.test:runner:1.2.0'
81115
testImplementation "org.robolectric:robolectric:$robolectricVersion"
82116
testImplementation 'junit:junit:4.13-beta-2'
83117
testImplementation 'org.mockito:mockito-core:2.25.0'
84118
testImplementation "com.google.truth:truth:$googleTruthVersion"
85119
testImplementation 'com.google.android.gms:play-services-vision:19.0.0'
120+
testImplementation ("com.google.firebase:firebase-iid:21.1.0") {
121+
exclude group: "com.google.firebase", module: "firebase-common"
122+
exclude group: "com.google.firebase", module: "firebase-components"
123+
exclude group: "com.google.firebase", module: "firebase-installations-interop"
124+
exclude group: "com.google.firebase", module: "firebase-installations"
125+
}
86126

87127
testImplementation 'com.android.support.test:runner:1.0.2'
88128
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.9.8'
@@ -91,6 +131,4 @@ dependencies {
91131
testImplementation 'androidx.test:rules:1.2.0'
92132
testImplementation 'androidx.test.ext:truth:1.2.0'
93133
testImplementation 'androidx.test.services:test-services:1.2.0'
94-
95-
96134
}

firebase-messaging/src/main/AndroidManifest.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,21 @@
1515
-->
1616
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
1717
package="com.google.firebase.messaging">
18-
<!--<uses-sdk android:minSdkVersion="16"/>-->
18+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
19+
<uses-permission android:name="android.permission.WAKE_LOCK" />
20+
<!-- Required by older versions of Google Play services to create IID tokens -->
21+
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
1922
<application>
2023

24+
<receiver
25+
android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
26+
android:exported="true"
27+
android:permission="com.google.android.c2dm.permission.SEND" >
28+
<intent-filter>
29+
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
30+
</intent-filter>
31+
</receiver>
32+
2133
<!-- FirebaseMessagingService performs security checks at runtime,
2234
but set to not exported to explicitly avoid allowing another app to call it. -->
2335
<service
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright 2020 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.iid;
16+
17+
import android.content.Context;
18+
import android.content.Intent;
19+
import android.os.Bundle;
20+
import android.util.Log;
21+
import androidx.annotation.NonNull;
22+
import androidx.annotation.WorkerThread;
23+
import com.google.android.gms.cloudmessaging.CloudMessage;
24+
import com.google.android.gms.cloudmessaging.CloudMessagingReceiver;
25+
import com.google.android.gms.cloudmessaging.CloudMessagingReceiver.IntentActionKeys;
26+
import com.google.android.gms.tasks.Tasks;
27+
import com.google.firebase.messaging.FcmBroadcastProcessor;
28+
import com.google.firebase.messaging.MessagingAnalytics;
29+
import com.google.firebase.messaging.ServiceStarter;
30+
import java.util.concurrent.ExecutionException;
31+
32+
/**
33+
* Implementation of {@code CloudMessagingReceiver} that passes Intents to the {@code
34+
* FirebaseMessagingService}.
35+
*
36+
* @hide
37+
*/
38+
public final class FirebaseInstanceIdReceiver extends CloudMessagingReceiver {
39+
40+
private static final String TAG = "FirebaseMessaging";
41+
42+
private static Intent createServiceIntent(
43+
@NonNull Context context, @NonNull String action, @NonNull Bundle data) {
44+
return new Intent(action).putExtras(data);
45+
}
46+
47+
/** @hide */
48+
@Override
49+
@WorkerThread
50+
protected int onMessageReceive(@NonNull Context context, @NonNull CloudMessage message) {
51+
try {
52+
return Tasks.await(new FcmBroadcastProcessor(context).process(message.getIntent()));
53+
} catch (ExecutionException | InterruptedException e) {
54+
Log.e(TAG, "Failed to send message to service.", e);
55+
return ServiceStarter.ERROR_UNKNOWN;
56+
}
57+
}
58+
59+
/** @hide */
60+
@Override
61+
@WorkerThread
62+
protected void onNotificationDismissed(@NonNull Context context, @NonNull Bundle data) {
63+
// Reconstruct the service intent from the data.
64+
Intent notificationDismissedIntent =
65+
createServiceIntent(context, IntentActionKeys.NOTIFICATION_DISMISS, data);
66+
if (MessagingAnalytics.shouldUploadScionMetrics(notificationDismissedIntent)) {
67+
MessagingAnalytics.logNotificationDismiss(notificationDismissedIntent);
68+
}
69+
}
70+
}

0 commit comments

Comments
 (0)