Skip to content

Commit 779acd1

Browse files
kaibolaylfkelloggvkryachkodaymxnemilypgoogle
authored
merge fad/next into fad/in-app-feedback (#4107)
* Minor updates to the App Distribution test app. (#4088) * Update various versions (#4090) * Updated various versions (dependencies and SDK to fix Android resource linking failure (AAPT: error: resource android:attr/lStar not found.) * Update compileSdk/targetSdkVersion from 31 to 33 * Update with latest changes from master (#4091) * Deflake firebase_common HeartBeat tests. (#4083) The tests relied on `TestOnCompleteListener` that was not safe to call more than once since it was based on a count down latch. So reusing it multiple times would cause await() to return immediately. This change makes it so that a new latch is created for every await() call, making all await() calls work. Fixes: http://b/245956774 * Add Javadoc support to the DackkaPlugin (#4082) * Add util method for copying directories * Add javadoc support to our dackka plugin * Remove the extension check on fromDirectory * Add a note about cache compliance and the javadoc task * Add reference to kotlin stdlib package list (#4093) Co-authored-by: Vladimir Kryachko <[email protected]> Co-authored-by: Daymon <[email protected]> * Resolve strict mode violations in firebase-appdistribution (#4092) * merge master into fad/next (#4102) * Deflake firebase_common HeartBeat tests. (#4083) The tests relied on `TestOnCompleteListener` that was not safe to call more than once since it was based on a count down latch. So reusing it multiple times would cause await() to return immediately. This change makes it so that a new latch is created for every await() call, making all await() calls work. Fixes: http://b/245956774 * Add Javadoc support to the DackkaPlugin (#4082) * Add util method for copying directories * Add javadoc support to our dackka plugin * Remove the extension check on fromDirectory * Add a note about cache compliance and the javadoc task * Add reference to kotlin stdlib package list (#4093) Co-authored-by: Vladimir Kryachko <[email protected]> Co-authored-by: Daymon <[email protected]> Co-authored-by: Lee Kellogg <[email protected]> Co-authored-by: Vladimir Kryachko <[email protected]> Co-authored-by: Daymon <[email protected]> Co-authored-by: emilypgoogle <[email protected]>
1 parent c841968 commit 779acd1

File tree

4 files changed

+91
-5
lines changed

4 files changed

+91
-5
lines changed

firebase-appdistribution/firebase-appdistribution.gradle

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ dependencies {
5454
testImplementation "org.robolectric:robolectric:4.8.1"
5555
testImplementation "com.google.truth:truth:$googleTruthVersion"
5656
testImplementation 'org.mockito:mockito-inline:3.4.0'
57-
androidTestImplementation "org.mockito:mockito-android:3.4.0"
5857
testImplementation 'androidx.test:core:1.2.0'
5958

6059
implementation 'com.google.android.gms:play-services-tasks:18.0.1'
@@ -64,4 +63,13 @@ dependencies {
6463
implementation 'androidx.appcompat:appcompat:1.5.1'
6564
implementation "androidx.browser:browser:1.3.0"
6665
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
66+
67+
androidTestImplementation project(':integ-testing')
68+
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
69+
androidTestImplementation 'androidx.test:runner:1.2.0'
70+
androidTestImplementation "com.google.truth:truth:$googleTruthVersion"
71+
androidTestImplementation 'junit:junit:4.12'
72+
androidTestImplementation "androidx.annotation:annotation:1.0.0"
73+
androidTestImplementation 'org.mockito:mockito-core:2.25.0'
74+
androidTestImplementation 'org.mockito:mockito-inline:2.25.0'
6775
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright 2022 Google LLC -->
3+
<!-- -->
4+
<!-- Licensed under the Apache License, Version 2.0 (the "License"); -->
5+
<!-- you may not use this file except in compliance with the License. -->
6+
<!-- You may obtain a copy of the License at -->
7+
<!-- -->
8+
<!-- http://www.apache.org/licenses/LICENSE-2.0 -->
9+
<!-- -->
10+
<!-- Unless required by applicable law or agreed to in writing, software -->
11+
<!-- distributed under the License is distributed on an "AS IS" BASIS, -->
12+
<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -->
13+
<!-- See the License for the specific language governing permissions and -->
14+
<!-- limitations under the License. -->
15+
16+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
17+
package="com.google.firebase.installations">
18+
19+
<application>
20+
<uses-library android:name="android.test.runner"/>
21+
</application>
22+
23+
<instrumentation
24+
android:name="androidx.test.runner.AndroidJUnitRunner"
25+
android:targetPackage="com.google.firebase.appdistribution" />
26+
</manifest>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
package com.google.firebase.appdistribution;
15+
16+
import androidx.test.core.app.ApplicationProvider;
17+
import androidx.test.ext.junit.runners.AndroidJUnit4;
18+
import com.google.firebase.FirebaseApp;
19+
import com.google.firebase.FirebaseOptions;
20+
import com.google.firebase.appdistribution.internal.FirebaseAppDistributionProxy;
21+
import com.google.firebase.testing.integ.StrictModeRule;
22+
import org.junit.Rule;
23+
import org.junit.Test;
24+
import org.junit.runner.RunWith;
25+
26+
@RunWith(AndroidJUnit4.class)
27+
public class StrictModeTest {
28+
29+
@Rule public StrictModeRule strictMode = new StrictModeRule();
30+
31+
@Test
32+
public void initializingFirebaseAppdistribution_shouldNotViolateStrictMode() {
33+
strictMode.runOnMainThread(
34+
() -> {
35+
FirebaseApp app =
36+
FirebaseApp.initializeApp(
37+
ApplicationProvider.getApplicationContext(),
38+
new FirebaseOptions.Builder()
39+
.setApiKey("api")
40+
.setProjectId("123")
41+
.setApplicationId("appId")
42+
.build(),
43+
"hello");
44+
app.get(FirebaseAppDistribution.class);
45+
app.get(FirebaseAppDistributionProxy.class);
46+
});
47+
}
48+
}

firebase-appdistribution/src/main/java/com/google/firebase/appdistribution/impl/SignInStorage.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,29 @@
1616

1717
import android.content.Context;
1818
import android.content.SharedPreferences;
19+
import com.google.firebase.components.Lazy;
1920

2021
/** Class that handles storage for App Distribution SignIn persistence. */
2122
class SignInStorage {
2223

2324
private static final String SIGNIN_PREFERENCES_NAME = "FirebaseAppDistributionSignInStorage";
2425
private static final String SIGNIN_TAG = "firebase_app_distribution_signin";
2526

26-
private final SharedPreferences signInSharedPreferences;
27+
private final Lazy<SharedPreferences> signInSharedPreferences;
2728

2829
SignInStorage(Context applicationContext) {
2930
this.signInSharedPreferences =
30-
applicationContext.getSharedPreferences(SIGNIN_PREFERENCES_NAME, Context.MODE_PRIVATE);
31+
new Lazy(
32+
() ->
33+
applicationContext.getSharedPreferences(
34+
SIGNIN_PREFERENCES_NAME, Context.MODE_PRIVATE));
3135
}
3236

3337
void setSignInStatus(boolean testerSignedIn) {
34-
this.signInSharedPreferences.edit().putBoolean(SIGNIN_TAG, testerSignedIn).apply();
38+
this.signInSharedPreferences.get().edit().putBoolean(SIGNIN_TAG, testerSignedIn).apply();
3539
}
3640

3741
boolean getSignInStatus() {
38-
return signInSharedPreferences.getBoolean(SIGNIN_TAG, false);
42+
return signInSharedPreferences.get().getBoolean(SIGNIN_TAG, false);
3943
}
4044
}

0 commit comments

Comments
 (0)