Skip to content

Commit c091675

Browse files
authored
Add firebase-config sample app for SDK size test. (#624)
* Add firebase-config sample app for SDK size test.
1 parent 8152ab8 commit c091675

File tree

6 files changed

+116
-0
lines changed

6 files changed

+116
-0
lines changed

tools/measurement/apksize/apksize.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ apply from: "src/database/database.gradle"
2525
apply from: "src/storage/storage.gradle"
2626
apply from: "src/firestore/firestore.gradle"
2727
apply from: "src/functions/functions.gradle"
28+
apply from: "src/config/config.gradle"
2829

2930
/**
3031
* This task builds all supported variants (only aggressive as of writing) and writes the

tools/measurement/apksize/sdks.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ functions-aggressive:2
66
storage-aggressive:3
77
functions-release:6
88
storage-release:7
9+
config-aggressive:9
10+
config-release:10
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2018 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+
16+
android {
17+
productFlavors {
18+
config {
19+
dimension "apkSize"
20+
applicationId "com.google.apksize.config"
21+
}
22+
}
23+
sourceSets {
24+
config {
25+
java.srcDirs = [
26+
"src/config/java",
27+
]
28+
}
29+
}
30+
}
31+
dependencies {
32+
configImplementation project(":firebase-config")
33+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright 2019 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.apksize;
16+
17+
import android.content.Context;
18+
import com.google.firebase.remoteconfig.FirebaseRemoteConfig;
19+
import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings;
20+
21+
public class Config implements SampleCode {
22+
private static final String MESSAGE_TAG = "message";
23+
private static final String FLAG_TAG = "flag";
24+
private static final String NUMBER_TAG = "number";
25+
26+
@Override
27+
public void runSample(Context context) {
28+
FirebaseRemoteConfig remoteConfig = FirebaseRemoteConfig.getInstance();
29+
FirebaseRemoteConfigSettings settings =
30+
new FirebaseRemoteConfigSettings.Builder()
31+
.setDeveloperModeEnabled(BuildConfig.DEBUG)
32+
.setMinimumFetchIntervalInSeconds(3600)
33+
.build();
34+
remoteConfig.setConfigSettings(settings);
35+
remoteConfig.setDefaults(R.xml.remote_config_defaults);
36+
37+
remoteConfig.getString(MESSAGE_TAG);
38+
remoteConfig.getBoolean(FLAG_TAG);
39+
remoteConfig.getDouble(NUMBER_TAG);
40+
}
41+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2019 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.apksize;
16+
17+
import android.content.Context;
18+
19+
public class SampleCodeLoader {
20+
21+
public void runSamples(Context context) {
22+
new Config().runSample(context);
23+
}
24+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<defaultsMap>
3+
<entry>
4+
<key>message</key>
5+
<value>My custom message</value>
6+
</entry>
7+
<entry>
8+
<key>flag</key>
9+
<value>false</value>
10+
</entry>
11+
<entry>
12+
<key>number</key>
13+
<value>3.14159</value>
14+
</entry>
15+
</defaultsMap>

0 commit comments

Comments
 (0)