Skip to content

Commit dd0c371

Browse files
author
Alex Ames
committed
Integrate Latest @ 120135726
Changes to admob/testapp ... - Fixed runtime link errors when building for Android devices running < M. - Fixed compilation of Firebase C++ AdMob test app when building with blaze. - Removed AdMob specific methods from testapp platform abstraction layer. - Apply Proguard stripping rules to Firebase C++ test apps. - Updates AdMob Podfile to pull v3.1.1 for Firebase/Core pod. - Refactors the state-polling interface for the AdMob C++ API by adding virtuallistener classes and corresponding setter methods, removing the public lifecycle stateenumerations, and renaming the other enums. Also updates the testapp to make use of the same. - Fixes two bugs, refactors the banner and interstitial helper properties to ivars, and removes void* and __bridge casting. - Add Firebase C++ testapp builds to TAP test suite. - Updates the AdMob C++ API implementation to include Futures for interstial ads Changes to analytics/testapp ... - Fixed runtime link errors when building for Android devices running < M. - Fixed Firebase Analytics test application to build with stlport and gnustl. - Apply Proguard stripping rules to Firebase C++ test apps. - Fixed build of Android testapps with blaze. - Pins sample podfile dependencies to M7 firebase packages. Fixes mac build for Auth and Analytics samples. - Cleans up creation of android log-window, through the use of a java class. (In place of lots of messy JNI invocations.) - Add Firebase C++ testapp builds to TAP test suite. - Remote Config C++ test application. Changes to auth/testapp ... - Fixed runtime link errors when building for Android devices running < M. - Fixed use of algorithm in Firebase C++ testapps which doesn't work with stlport. - Apply Proguard stripping rules to Firebase C++ test apps. - Fixed build of Android testapps with blaze. - Pins sample podfile dependencies to M7 firebase packages. Fixes mac build for Auth and Analytics samples. - Cleans up creation of android log-window, through the use of a java class. (In place of lots of messy JNI invocations.) - Modified the firebase auth readme to tell the user to enable anonymous sign-in in the test app. Previously this was enabled by default, but no longer. - Add Firebase C++ testapp builds to TAP test suite. - Added a text window to the ios sample, to mirror log outputs on the device. Changes to invites/testapp ... - Pin firebase dependencies in podfile to a specific release. This fixes the linker errors when building the ios version of the invites test app. - Fixed runtime link errors when building for Android devices running < M. - Fixed use of algorithm in Firebase C++ testapps which doesn't work with stlport. - Apply Proguard stripping rules to Firebase C++ test apps. - Fixed build of Android testapps with blaze. - Cleans up creation of android log-window, through the use of a java class. (In place of lots of messy JNI invocations.) - Implement method swizzling to install the ios_startup functions in Invites, moving and consolidating most of the code to Firebase App. - Add Firebase C++ testapp builds to TAP test suite. - Added a text view in the background which mirrors log output. Changes to messaging/testapp ... - Fixed runtime link errors when building for Android devices running < M. - Fixed use of algorithm in Firebase C++ testapps which doesn't work with stlport. - Apply Proguard stripping rules to Firebase C++ test apps. - Add missing gradle build files to Messaging testapp. - Fixed build of Android testapps with blaze. - Pins sample podfile dependencies to M7 firebase packages. Fixes mac build for Auth and Analytics samples. - Cleans up creation of android log-window, through the use of a java class. (In place of lots of messy JNI invocations.) - Add Firebase C++ testapp builds to TAP test suite. - Added a textview to messaging testapp, which mirrors log output. CL: 120135726
1 parent da7610f commit dd0c371

File tree

41 files changed

+1185
-404
lines changed

Some content is hidden

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

41 files changed

+1185
-404
lines changed

admob/testapp/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ source 'https://github.com/CocoaPods/Specs.git'
33
platform :ios, '7.0'
44
# AdMob test application.
55
target 'testapp' do
6-
pod 'Firebase/Core'
6+
pod 'Firebase/Core', '3.1.1'
77
pod 'Google-Mobile-Ads-SDK', '~> 7.7
88
end

admob/testapp/build.gradle

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,43 +19,6 @@ allprojects {
1919

2020
apply plugin: 'com.android.application'
2121

22-
android {
23-
compileSdkVersion 23
24-
buildToolsVersion '23.0.1'
25-
26-
sourceSets {
27-
main {
28-
jniLibs.srcDirs = ['libs']
29-
manifest.srcFile 'AndroidManifest.xml'
30-
java.srcDirs = ['src/android/java']
31-
res.srcDirs = ['res']
32-
}
33-
}
34-
35-
defaultConfig {
36-
applicationId 'com.google.android.admob.testapp'
37-
minSdkVersion 14
38-
targetSdkVersion 23
39-
versionCode 1
40-
versionName '1.0'
41-
}
42-
buildTypes {
43-
release {
44-
// Proguard temporarily disabled until we have a template for
45-
// classes referenced from JNI that shouldn't be stripped.
46-
//minifyEnabled true
47-
//proguardFiles getDefaultProguardFile('proguard-android.txt')
48-
}
49-
}
50-
}
51-
52-
dependencies {
53-
compile fileTree(dir: 'libs', include: ['*.jar'])
54-
compile 'com.google.android.gms:play-services-ads:8.5.4'
55-
}
56-
57-
apply plugin: 'com.google.gms.google-services'
58-
5922
// Pre-experimental Gradle plug-in NDK boilerplate below.
6023
// Right now the Firebase plug-in does not work with the experimental
6124
// Gradle plug-in so we're using ndk-build for the moment.
@@ -94,6 +57,43 @@ project.ext {
9457
}
9558
}
9659

60+
android {
61+
compileSdkVersion 23
62+
buildToolsVersion '23.0.1'
63+
64+
sourceSets {
65+
main {
66+
jniLibs.srcDirs = ['libs']
67+
manifest.srcFile 'AndroidManifest.xml'
68+
java.srcDirs = ['src/android/java']
69+
res.srcDirs = ['res']
70+
}
71+
}
72+
73+
defaultConfig {
74+
applicationId 'com.google.android.admob.testapp'
75+
minSdkVersion 14
76+
targetSdkVersion 23
77+
versionCode 1
78+
versionName '1.0'
79+
}
80+
buildTypes {
81+
release {
82+
minifyEnabled true
83+
proguardFile getDefaultProguardFile('proguard-android.txt')
84+
proguardFile file(project.ext.firebase_cpp_sdk_dir + "/libs/android/app.pro")
85+
proguardFile file(project.ext.firebase_cpp_sdk_dir + "/libs/android/admob.pro")
86+
}
87+
}
88+
}
89+
90+
dependencies {
91+
compile fileTree(dir: 'libs', include: ['*.jar'])
92+
compile 'com.google.android.gms:play-services-ads:8.5.4'
93+
}
94+
95+
apply plugin: 'com.google.gms.google-services'
96+
9797
task ndkBuildCompile(type:Exec) {
9898
description 'Use ndk-build to compile the C++ application.'
9999
commandLine("${project.ext.ndk_dir}${File.separator}ndk-build",

admob/testapp/src/android/android_main.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
#include <stdarg.h>
16+
1517
#include <android/log.h>
1618
#include <android_native_app_glue.h>
17-
#include <stdarg.h>
1819

1920
#include "main.h" // NOLINT
2021

admob/testapp/src/common_main.cc

Lines changed: 65 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,39 @@
2222
// Thin OS abstraction layer.
2323
#include "main.h" // NOLINT
2424

25+
// A simple listener that logs changes to a BannerView.
26+
class LoggingBannerViewListener : public firebase::admob::BannerView::Listener {
27+
public:
28+
LoggingBannerViewListener() {}
29+
void OnPresentationStateChanged(
30+
firebase::admob::BannerView* banner_view,
31+
firebase::admob::BannerView::PresentationState new_state) {
32+
::LogMessage("BannerView PresentationState has changed to %d.", new_state);
33+
}
34+
35+
void OnBoundingBoxChanged(firebase::admob::BannerView* banner_view,
36+
firebase::admob::BoundingBox new_box) {
37+
::LogMessage(
38+
"BannerView BoundingBox has changed to (x: %d, y: %d, width: %d, "
39+
"height "
40+
"%d)",
41+
new_box.x, new_box.y, new_box.width, new_box.height);
42+
}
43+
};
44+
45+
// A simple listener that logs changes to an InterstitialAd.
46+
class LoggingInterstitialAdListener
47+
: public firebase::admob::InterstitialAd::Listener {
48+
public:
49+
LoggingInterstitialAdListener() {}
50+
void OnPresentationStateChanged(
51+
firebase::admob::InterstitialAd* interstitial_ad,
52+
firebase::admob::InterstitialAd::PresentationState new_state) {
53+
::LogMessage("InterstitialAd PresentationState has changed to %d.",
54+
new_state);
55+
}
56+
};
57+
2558
// These ad units are configured to always serve test ads.
2659
#if defined(__ANDROID__)
2760
const char* kBannerAdUnit = "ca-app-pub-3940256099942544/6300978111";
@@ -56,13 +89,27 @@ ::firebase::App* g_app;
5689
::firebase::admob::BannerView* g_banner;
5790
::firebase::admob::InterstitialAd* g_int;
5891
::firebase::admob::AdRequest g_request;
92+
LoggingBannerViewListener g_banner_listener;
93+
LoggingInterstitialAdListener g_int_listener;
5994

6095
// Extras to use later
6196
::firebase::admob::KeyValuePair g_extra;
6297
::firebase::admob::KeyValuePair* g_extras_array[] = {&g_extra};
6398

99+
static void WaitForFutureCompletion(firebase::FutureBase future) {
100+
#if defined(__ANDROID__)
101+
while (!ProcessAndroidEvents(1000)) {
102+
#else
103+
while (true) {
104+
#endif // defined(__ANDROID__)
105+
if (future.Status() != ::firebase::kFutureStatus_Pending) {
106+
break;
107+
}
108+
}
109+
}
110+
64111
// Execute all methods of the C++ admob API.
65-
extern "C" int common_main(void* ad_parent) {
112+
extern "C" int common_main(::firebase::admob::AdParent ad_parent) {
66113
namespace admob = ::firebase::admob;
67114

68115
LogMessage("Initializing the AdMob library");
@@ -127,6 +174,7 @@ extern "C" int common_main(void* ad_parent) {
127174

128175
LogMessage("Creating the BannerView.");
129176
g_banner = new admob::BannerView();
177+
g_banner->SetListener(&g_banner_listener);
130178
g_banner->Initialize(static_cast<admob::AdParent>(ad_parent), kBannerAdUnit,
131179
ad_size);
132180

@@ -142,8 +190,23 @@ extern "C" int common_main(void* ad_parent) {
142190
LogMessage("Showing the banner.");
143191
g_banner->Show();
144192

193+
WaitForFutureCompletion(g_banner->ShowLastResult());
194+
195+
// When the BannerView has shown, move it.
196+
LogMessage("Moving the banner to top-center.");
197+
g_banner->MoveTo(admob::BannerView::kPositionTop);
198+
199+
WaitForFutureCompletion(g_banner->MoveToLastResult());
200+
201+
// When the BannerView has moved, move it again!
202+
LogMessage("Moving the banner to (100, 200).");
203+
g_banner->MoveTo(100, 200);
204+
205+
WaitForFutureCompletion(g_banner->MoveToLastResult());
206+
145207
LogMessage("Creating the InterstitialAd.");
146208
g_int = new admob::InterstitialAd();
209+
g_int->SetListener(&g_int_listener);
147210
g_int->Initialize(static_cast<admob::AdParent>(ad_parent),
148211
kInterstitialAdUnit);
149212

@@ -159,23 +222,11 @@ extern "C" int common_main(void* ad_parent) {
159222
LogMessage("Showing the interstitial.");
160223
g_int->Show();
161224

162-
// Wait until the user kills the app.
225+
// Wait until the user kills the app.
163226
#if defined(__ANDROID__)
164227
while (!ProcessAndroidEvents(1000)) {
165228
}
166229
#endif // defined(__ANDROID__)
167230

168231
return 0;
169232
}
170-
171-
void WaitForFutureCompletion(firebase::FutureBase future) {
172-
#if defined(__ANDROID__)
173-
while (!ProcessAndroidEvents(1000)) {
174-
#else
175-
while (true) {
176-
#endif // defined(__ANDROID__)
177-
if (future.Status() != ::firebase::kFutureStatus_Pending) {
178-
break;
179-
}
180-
}
181-
}

admob/testapp/src/ios/ios_main.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ @interface FBAViewController : UIViewController
2323

2424
@end
2525

26-
extern "C" int common_main(void* ad_parent);
26+
extern "C" int common_main(firebase::admob::AdParent ad_parent);
2727

2828
@implementation FBAViewController
2929

3030
- (void)viewDidLoad {
3131
[super viewDidLoad];
3232
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
33-
common_main((__bridge void*)self.view);
33+
common_main(self.view);
3434
});
3535
}
3636

3737
@end
3838

3939
static int exit_status = 0;
4040

41-
// Log a message that can be viewed in "adb logcat".
41+
// Log a message that can be viewed in the console.
4242
int LogMessage(const char* format, ...) {
4343
va_list list;
4444
int rc = 0;

admob/testapp/src/main.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
#include <jni.h>
2121
#endif // defined(__ANDROID__)
2222

23-
#include "firebase/admob.h"
24-
#include "firebase/admob/types.h"
25-
#include "firebase/future.h"
26-
2723
// Defined using -DANDROID_MAIN_APP_NAME=some_app_name when compiling this
2824
// file.
2925
#ifndef FIREBASE_TESTAPP_NAME
@@ -43,6 +39,4 @@ JNIEnv* GetJniEnv();
4339
jobject GetActivity();
4440
#endif // defined(__ANDROID__)
4541

46-
void WaitForFutureCompletion(firebase::FutureBase future);
47-
4842
#endif // FIREBASE_TESTAPP_MAIN_H_ // NOLINT

analytics/testapp/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ source 'https://github.com/CocoaPods/Specs.git'
33
platform :ios, '8.0'
44
# Analytics test application.
55
target 'testapp' do
6-
pod 'Firebase/Core'
6+
pod 'Firebase/Core', '3.1.1'
77
end

analytics/testapp/build.gradle

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,43 +19,6 @@ allprojects {
1919

2020
apply plugin: 'com.android.application'
2121

22-
android {
23-
compileSdkVersion 23
24-
buildToolsVersion '23.0.1'
25-
26-
sourceSets {
27-
main {
28-
jniLibs.srcDirs = ['libs']
29-
manifest.srcFile 'AndroidManifest.xml'
30-
java.srcDirs = ['src/android/java']
31-
res.srcDirs = ['res']
32-
}
33-
}
34-
35-
defaultConfig {
36-
applicationId 'com.google.android.analytics.testapp'
37-
minSdkVersion 14
38-
targetSdkVersion 23
39-
versionCode 1
40-
versionName '1.0'
41-
}
42-
buildTypes {
43-
release {
44-
// Proguard temporarily disabled until we have a template for
45-
// classes referenced from JNI that shouldn't be stripped.
46-
//minifyEnabled true
47-
//proguardFiles getDefaultProguardFile('proguard-android.txt')
48-
}
49-
}
50-
}
51-
52-
dependencies {
53-
compile fileTree(dir: 'libs', include: ['*.jar'])
54-
compile 'com.google.android.gms:firebase-measurement:8.5.4'
55-
}
56-
57-
apply plugin: 'com.google.gms.google-services'
58-
5922
// Pre-experimental Gradle plug-in NDK boilerplate below.
6023
// Right now the Firebase plug-in does not work with the experimental
6124
// Gradle plug-in so we're using ndk-build for the moment.
@@ -94,6 +57,44 @@ project.ext {
9457
}
9558
}
9659

60+
android {
61+
compileSdkVersion 23
62+
buildToolsVersion '23.0.1'
63+
64+
sourceSets {
65+
main {
66+
jniLibs.srcDirs = ['libs']
67+
manifest.srcFile 'AndroidManifest.xml'
68+
java.srcDirs = ['src/android/java']
69+
res.srcDirs = ['res']
70+
}
71+
}
72+
73+
defaultConfig {
74+
applicationId 'com.google.android.analytics.testapp'
75+
minSdkVersion 14
76+
targetSdkVersion 23
77+
versionCode 1
78+
versionName '1.0'
79+
}
80+
buildTypes {
81+
release {
82+
minifyEnabled true
83+
proguardFile getDefaultProguardFile('proguard-android.txt')
84+
proguardFile file(project.ext.firebase_cpp_sdk_dir + "/libs/android/app.pro")
85+
proguardFile file(project.ext.firebase_cpp_sdk_dir + "/libs/android/analytics.pro")
86+
proguardFile file('proguard.pro')
87+
}
88+
}
89+
}
90+
91+
dependencies {
92+
compile fileTree(dir: 'libs', include: ['*.jar'])
93+
compile 'com.google.android.gms:firebase-measurement:8.5.4'
94+
}
95+
96+
apply plugin: 'com.google.gms.google-services'
97+
9798
task ndkBuildCompile(type:Exec) {
9899
description 'Use ndk-build to compile the C++ application.'
99100
commandLine("${project.ext.ndk_dir}${File.separator}ndk-build",

analytics/testapp/proguard.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-keep,includedescriptorclasses public class com.google.firebase.example.LoggingUtils { *; }

analytics/testapp/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Building and Running the testapp
4242
to the Firebase backend.
4343
- Add the following frameworks from the Firebase C++ SDK to the project:
4444
- frameworks/ios/universal/firebase.framework
45-
- frameworks/ios/universal/firebase_analytics.framework
45+
- frameworks/ios/universal/firebase\_analytics.framework
4646
- You will need to either,
4747
1. Check "Copy items if needed" when adding the frameworks, or
4848
2. Add the framework path in "Framework Search Paths"

0 commit comments

Comments
 (0)