Skip to content

Commit e7363ce

Browse files
var-consta-maurice
authored andcommitted
Set the language in Cloud headers to gl-cpp/ in the C++ SDK on Android.
This is possible now that the Copybara CL cr/333174406 is submitted. This CL requires on Android functionality available starting from M80 (Firestore 21.7.0). PiperOrigin-RevId: 333356092
1 parent 61beffe commit e7363ce

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

firestore/src/android/firestore_android.cc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ const char kApiIdentifier[] = "Firestore";
7676
util::kMethodTypeStatic), \
7777
X(SetLoggingEnabled, "setLoggingEnabled", \
7878
"(Z)V", util::kMethodTypeStatic), \
79+
X(SetClientLanguage, "setClientLanguage", \
80+
"(Ljava/lang/String;)V", util::kMethodTypeStatic), \
7981
X(SetSettings, "setFirestoreSettings", \
8082
"(Lcom/google/firebase/firestore/FirebaseFirestoreSettings;)V"), \
8183
X(Batch, "batch", \
@@ -406,7 +408,7 @@ Future<void> FirestoreInternal::RunTransaction(TransactionFunction* update,
406408
auto* completion =
407409
static_cast<LambdaTransactionFunction*>(is_lambda ? update : nullptr);
408410
Promise<void, void, FirestoreFn> promise{ref_future(), this, completion};
409-
#else // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)
411+
#else // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)
410412
Promise<void, void, FirestoreFn> promise{ref_future(), this};
411413
#endif // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)
412414

@@ -606,7 +608,14 @@ void Firestore::set_log_level(LogLevel log_level) {
606608
}
607609

608610
void FirestoreInternal::SetClientLanguage(const std::string& language_token) {
609-
// TODO(varconst): implement
611+
JNIEnv* env = firebase::util::GetJNIEnvFromApp();
612+
jstring java_language_token = env->NewStringUTF(language_token.c_str());
613+
env->CallStaticVoidMethod(
614+
firebase_firestore::GetClass(),
615+
firebase_firestore::GetMethodId(firebase_firestore::kSetClientLanguage),
616+
java_language_token);
617+
618+
CheckAndClearJniExceptions(env);
610619
}
611620

612621
} // namespace firestore

0 commit comments

Comments
 (0)