Skip to content

Commit 953be74

Browse files
fredquintanadiwu-areteankitaj224ChaoqunCHENVinayGuthal
authored
Fis sdk (#1057)
* Add Firebase Segmentation SDK and some skeleton code in Firebase Android SDK (#514) * Add Firebase Segmentation SDK and some skeleton code in Firebase Android SDK * Add Firebase Segmentation SDK and some skeleton code in Firebase Android SDK * Address comments #1 * Address comments #1 * Address comments #2 * Implement Firebase segmentation SDK device local cache * [Firebase Segmentation] Add custom installation id cache layer and tests for it. * Add test for updating cache * Switch to use SQLiteOpenHelper * Switch to use SharedPreferences from SQLite. * Change the cache class to be singleton * Wrap shared pref commit in a async task. * Address comments * Google format fix * [Firebase Segmentation] Add custom installation id cache layer and tests for it. (#524) * Add type arguments in StorageTaskManager (#517) * Output artifact list during local publishing. (#515) This effort replaces #494. * Implement Firebase segmentation SDK device local cache * fix functions (#523) * fix functions * update minsdk version * remove idea * Set test type to release only in CI. (#522) * Set test type to release only in CI. This fixes Android Studio issue, where it is impossible to run integration tests in debug mode. Additionally move build type configuration to FirebaseLibraryPlugin to avoid projects.all configuration in gradle. * Add comment back. * [Firebase Segmentation] Add custom installation id cache layer and tests for it. * Add test for updating cache * Switch to use SQLiteOpenHelper * Minor fix to error message to match the admin sdk. (#525) * Minor fix to error message to match the admin sdk. In particular, it *is* allowed to have slashes, etc in field paths. * Added clean task to smoke tests. (#527) This change allows the smoke tests to clean all build variants created by the infrastructure. * Update deps to post-androidx gms versions. (#526) * Update deps to post-androidx gms versions. Additionally configure sources.jar for SDKs. * Update functions-ktx deps * Fix versions. * unbump fiam version in fiamui-app * Switch to use SharedPreferences from SQLite. * Change the cache class to be singleton * Copy firebase-firestore-ktx dependencies on firestore into its own subfolder (#528) * Wrap shared pref commit in a async task. * Address comments * Bump firestore version for release (#530) Additionally fix pom filter to exclude multidex from deps. * Google format fix * Replace some deprecated code. * Fix some deprecations (#533) * Implement Firebase segmentation SDK device local cache * [Firebase Segmentation] Add custom installation id cache layer and tests for it. * Add test for updating cache * Switch to use SQLiteOpenHelper * Switch to use SharedPreferences from SQLite. * Change the cache class to be singleton * Wrap shared pref commit in a async task. * Address comments * Google format fix * Replace some deprecated code. * Package refactor * nit * nit * package refactor (#534) * Implement Firebase segmentation SDK device local cache * [Firebase Segmentation] Add custom installation id cache layer and tests for it. * Add test for updating cache * Switch to use SQLiteOpenHelper * Switch to use SharedPreferences from SQLite. * Change the cache class to be singleton * Wrap shared pref commit in a async task. * Address comments * Google format fix * Replace some deprecated code. * Package refactor * nit * nit * Add the state machine of updating custom installation id in the local cache and update to Firebase Segmentation backend. CL also contains unit tests. (The http client is not implemented yet.) * minor format fix * Address comments #1 * Add the state machine of updating custom installation id in the local cache and update to Firebase Segmentation backend. (#545) * Implement Firebase segmentation SDK device local cache * [Firebase Segmentation] Add custom installation id cache layer and tests for it. * Add test for updating cache * Switch to use SQLiteOpenHelper * Switch to use SharedPreferences from SQLite. * Change the cache class to be singleton * Wrap shared pref commit in a async task. * Address comments * Google format fix * Replace some deprecated code. * Package refactor * nit * nit * Add the state machine of updating custom installation id in the local cache and update to Firebase Segmentation backend. CL also contains unit tests. (The http client is not implemented yet.) * minor format fix * Address comments #1 * Http client in Firebase Segmentation SDK to call backend service. * Revert unintentional change * Fix connected device test * Fix connected device test * 1. Add a few annotations to make java code Kotlin friendly 2. Some fixes for the http request format * Fix java format * Fix API version * Change the segmentation API implementation to synchronous and put the entire synchronous code block in async task. * Fix a async getResult race issue. * OkHttpClient -> HttpsUrlConnection * Use gzip for compressing content and fix ourput stream memory leak risk. * Addressed a few comments * Http client in Firebase Segmentation SDK to call backend service. (#573) * Implement Firebase segmentation SDK device local cache * [Firebase Segmentation] Add custom installation id cache layer and tests for it. * Add test for updating cache * Switch to use SQLiteOpenHelper * Switch to use SharedPreferences from SQLite. * Change the cache class to be singleton * Wrap shared pref commit in a async task. * Address comments * Google format fix * Replace some deprecated code. * Package refactor * nit * nit * Add the state machine of updating custom installation id in the local cache and update to Firebase Segmentation backend. CL also contains unit tests. (The http client is not implemented yet.) * minor format fix * Address comments #1 * Http client in Firebase Segmentation SDK to call backend service. * Revert unintentional change * Fix connected device test * Fix connected device test * 1. Add a few annotations to make java code Kotlin friendly 2. Some fixes for the http request format * Fix java format * Fix API version * Change the segmentation API implementation to synchronous and put the entire synchronous code block in async task. * Fix a async getResult race issue. * OkHttpClient -> HttpsUrlConnection * Use gzip for compressing content and fix ourput stream memory leak risk. * Addressed a few comments * Initial Code structure for FIS Android SDK (#648) * Adding an interface library for Firebase Installations SDK * Adding Firebase Installations module * Adding Firebase Installations module. * Readding .idea files that were deleted in previous commit * Revert "Adding Firebase Installations module" This reverts commit 2ec4aef. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Add firebase installations project path * Adding Firebase Installations module. * Readding .idea files that were deleted in previous commit * Revert "Adding Firebase Installations module" This reverts commit 2ec4aef. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Add firebase installations project path * Fixing formattinf issues. * Revert "Adding Firebase Installations module" with hidden files This reverts commit 2ec4aef. * Addressing review comments. * Making InstallationTokenResult an AutoValue class. * Initial Code structure for FIS Android SDK (#648) * Adding an interface library for Firebase Installations SDK * Adding Firebase Installations module * Adding Firebase Installations module. * Readding .idea files that were deleted in previous commit * Revert "Adding Firebase Installations module" This reverts commit 2ec4aef. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Add firebase installations project path * Adding Firebase Installations module. * Readding .idea files that were deleted in previous commit * Revert "Adding Firebase Installations module" This reverts commit 2ec4aef. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Add firebase installations project path * Fixing formattinf issues. * Revert "Adding Firebase Installations module" with hidden files This reverts commit 2ec4aef. * Addressing review comments. * Making InstallationTokenResult an AutoValue class. * Initial Code structure for FIS Android SDK (#648) * Adding an interface library for Firebase Installations SDK * Adding Firebase Installations module * Adding Firebase Installations module. * Readding .idea files that were deleted in previous commit * Revert "Adding Firebase Installations module" This reverts commit 2ec4aef. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Add firebase installations project path * Adding Firebase Installations module. * Readding .idea files that were deleted in previous commit * Revert "Adding Firebase Installations module" This reverts commit 2ec4aef. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Add firebase installations project path * Fixing formattinf issues. * Revert "Adding Firebase Installations module" with hidden files This reverts commit 2ec4aef. * Addressing review comments. * Making InstallationTokenResult an AutoValue class. * Adding http client to call fis backend service (#659) * Adding Firebase Installations module * Readding .idea files that were deleted in previous commit * Revert "Adding Firebase Installations module" This reverts commit 2ec4aef. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Adding Firebase Installations module. * Readding .idea files that were deleted in previous commit * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Revert "Adding Firebase Installations module" with hidden files This reverts commit 2ec4aef. * Addressing review comments. * Http client to call FIS backend service. * Http client to call FIS backend service. * Http client to call FIS backend service. * Adding Firebase Installations module * Adding Firebase Installations module. * Readding .idea files that were deleted in previous commit * Readding .idea files that were deleted in previous commit * Revert "Adding Firebase Installations module" This reverts commit 2ec4aef. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Revert "Adding Firebase Installations module" with hidden files This reverts commit 2ec4aef. * Addressing review comments. * Http client to call FIS backend service. * Http client to call FIS backend service. * Initial Code structure for FIS Android SDK (#648) * Adding an interface library for Firebase Installations SDK * Adding Firebase Installations module * Adding Firebase Installations module. * Readding .idea files that were deleted in previous commit * Revert "Adding Firebase Installations module" This reverts commit 2ec4aef. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Add firebase installations project path * Adding Firebase Installations module. * Readding .idea files that were deleted in previous commit * Revert "Adding Firebase Installations module" This reverts commit 2ec4aef. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Add firebase installations project path * Fixing formattinf issues. * Revert "Adding Firebase Installations module" with hidden files This reverts commit 2ec4aef. * Addressing review comments. * Making InstallationTokenResult an AutoValue class. * Http client to call FIS backend service. * Addresing comments and introducing new FirebaseInstallationService Exception. * FirebaseSegmentation SDK 1. Clean up http client response code. 2. When updateCustomInstallationId is called, on non-retryable server errors, the SDK should clean up the local cache. Instead, for retryable errors, SDK can keep the local cache for retrying update later. * FirebaseSegmentation SDK changes (#673) * Implement Firebase segmentation SDK device local cache * [Firebase Segmentation] Add custom installation id cache layer and tests for it. * Add test for updating cache * Switch to use SQLiteOpenHelper * Switch to use SharedPreferences from SQLite. * Change the cache class to be singleton * Wrap shared pref commit in a async task. * Address comments * Google format fix * Replace some deprecated code. * Package refactor * nit * nit * Add the state machine of updating custom installation id in the local cache and update to Firebase Segmentation backend. CL also contains unit tests. (The http client is not implemented yet.) * minor format fix * Address comments #1 * Http client in Firebase Segmentation SDK to call backend service. * Revert unintentional change * Fix connected device test * Fix connected device test * 1. Add a few annotations to make java code Kotlin friendly 2. Some fixes for the http request format * Fix java format * Fix API version * Change the segmentation API implementation to synchronous and put the entire synchronous code block in async task. * Fix a async getResult race issue. * OkHttpClient -> HttpsUrlConnection * Use gzip for compressing content and fix ourput stream memory leak risk. * Addressed a few comments * FirebaseSegmentation SDK 1. Clean up http client response code. 2. When updateCustomInstallationId is called, on non-retryable server errors, the SDK should clean up the local cache. Instead, for retryable errors, SDK can keep the local cache for retrying update later. * Restrict Firebase API key to Android app package name. * Restrict Firebase API key to Android app package name. (#690) * Implement Firebase segmentation SDK device local cache * [Firebase Segmentation] Add custom installation id cache layer and tests for it. * Add test for updating cache * Switch to use SQLiteOpenHelper * Switch to use SharedPreferences from SQLite. * Change the cache class to be singleton * Wrap shared pref commit in a async task. * Address comments * Google format fix * Replace some deprecated code. * Package refactor * nit * nit * Add the state machine of updating custom installation id in the local cache and update to Firebase Segmentation backend. CL also contains unit tests. (The http client is not implemented yet.) * minor format fix * Address comments #1 * Http client in Firebase Segmentation SDK to call backend service. * Revert unintentional change * Fix connected device test * Fix connected device test * 1. Add a few annotations to make java code Kotlin friendly 2. Some fixes for the http request format * Fix java format * Fix API version * Change the segmentation API implementation to synchronous and put the entire synchronous code block in async task. * Fix a async getResult race issue. * OkHttpClient -> HttpsUrlConnection * Use gzip for compressing content and fix ourput stream memory leak risk. * Addressed a few comments * FirebaseSegmentation SDK 1. Clean up http client response code. 2. When updateCustomInstallationId is called, on non-retryable server errors, the SDK should clean up the local cache. Instead, for retryable errors, SDK can keep the local cache for retrying update later. * Restrict Firebase API key to Android app package name. * Explicitly add internet permission * Arete floc (#691) * Implement Firebase segmentation SDK device local cache * [Firebase Segmentation] Add custom installation id cache layer and tests for it. * Add test for updating cache * Switch to use SQLiteOpenHelper * Switch to use SharedPreferences from SQLite. * Change the cache class to be singleton * Wrap shared pref commit in a async task. * Address comments * Google format fix * Replace some deprecated code. * Package refactor * nit * nit * Add the state machine of updating custom installation id in the local cache and update to Firebase Segmentation backend. CL also contains unit tests. (The http client is not implemented yet.) * minor format fix * Address comments #1 * Http client in Firebase Segmentation SDK to call backend service. * Revert unintentional change * Fix connected device test * Fix connected device test * 1. Add a few annotations to make java code Kotlin friendly 2. Some fixes for the http request format * Fix java format * Fix API version * Change the segmentation API implementation to synchronous and put the entire synchronous code block in async task. * Fix a async getResult race issue. * OkHttpClient -> HttpsUrlConnection * Use gzip for compressing content and fix ourput stream memory leak risk. * Addressed a few comments * FirebaseSegmentation SDK 1. Clean up http client response code. 2. When updateCustomInstallationId is called, on non-retryable server errors, the SDK should clean up the local cache. Instead, for retryable errors, SDK can keep the local cache for retrying update later. * Restrict Firebase API key to Android app package name. * Explicitly add internet permission * Implementing cache for FIS SDK (#694) * Implementing cache for FIS SDK * Implementing cache for FIS SDK * Addressing Di's comments. * Addressing Di's comments. * Adding Util class for FIrebaseInstallations APIs. (#676) * Adding Firebase Installations module * Readding .idea files that were deleted in previous commit * Revert "Adding Firebase Installations module" This reverts commit 2ec4aef. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Adding Firebase Installations module. * Readding .idea files that were deleted in previous commit * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Revert "Adding Firebase Installations module" with hidden files This reverts commit 2ec4aef. * Addressing review comments. * Http client to call FIS backend service. * Http client to call FIS backend service. * Http client to call FIS backend service. * Adding Firebase Installations module * Adding Firebase Installations module. * Readding .idea files that were deleted in previous commit * Readding .idea files that were deleted in previous commit * Revert "Adding Firebase Installations module" This reverts commit 2ec4aef. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Revert "Adding Firebase Installations module" with hidden files This reverts commit 2ec4aef. * Addressing review comments. * Http client to call FIS backend service. * Http client to call FIS backend service. * Initial Code structure for FIS Android SDK (#648) * Adding an interface library for Firebase Installations SDK * Adding Firebase Installations module * Adding Firebase Installations module. * Readding .idea files that were deleted in previous commit * Revert "Adding Firebase Installations module" This reverts commit 2ec4aef. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Add firebase installations project path * Adding Firebase Installations module. * Readding .idea files that were deleted in previous commit * Revert "Adding Firebase Installations module" This reverts commit 2ec4aef. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Add firebase installations project path * Fixing formattinf issues. * Revert "Adding Firebase Installations module" with hidden files This reverts commit 2ec4aef. * Addressing review comments. * Making InstallationTokenResult an AutoValue class. * Http client to call FIS backend service. * Addresing comments and introducing new FirebaseInstallationService Exception. * Implementing getId method in FirebaseInstallation to call backend. * 1. Adding instrumentation tests. 2. Introducing serviceClient level and main class exceptions. * Addressing Di's comments. * Addressing Rayo's comments * Updating parameters order in ServiceClient. * Updating createRandomFid as per Rayo's comments. * getId() implementation with instrumented tests. (#703) * getId() implementation with instrumented tests. * Addressing rayo's comments. - Detailed JavaDocs - Renaming FiidCache as PersistedFid * Addressing rayo's comments. - Detailed JavaDocs - Renaming FiidCache as PersistedFid * Addresing comments to resoleve the following: - Make registerAnsSaveFid non blocking call in getId() - PersistedFidEntry builder with default values * Addressing Ciaran and Rayo's comments. * Addressing Ciaran's comments * Addressing Ciaran's comments * Adding param comments and checking if registration status is valid. * Correcting lint warning: uses-permission should be declared before application in AndroidManifest.xml * Adding custom assertThat with more readable assertions * Correcting instrumented tests to be reliable. * Initial Code structure for FIS Android SDK (#648) * Adding an interface library for Firebase Installations SDK * Adding Firebase Installations module * Adding Firebase Installations module. * Readding .idea files that were deleted in previous commit * Revert "Adding Firebase Installations module" This reverts commit 2ec4aef. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Add firebase installations project path * Adding Firebase Installations module. * Readding .idea files that were deleted in previous commit * Revert "Adding Firebase Installations module" This reverts commit 2ec4aef. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Add firebase installations project path * Fixing formattinf issues. * Revert "Adding Firebase Installations module" with hidden files This reverts commit 2ec4aef. * Addressing review comments. * Making InstallationTokenResult an AutoValue class. * Adding http client to call fis backend service (#659) * Adding Firebase Installations module * Readding .idea files that were deleted in previous commit * Revert "Adding Firebase Installations module" This reverts commit 2ec4aef. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Adding Firebase Installations module. * Readding .idea files that were deleted in previous commit * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Revert "Adding Firebase Installations module" with hidden files This reverts commit 2ec4aef. * Addressing review comments. * Http client to call FIS backend service. * Http client to call FIS backend service. * Http client to call FIS backend service. * Adding Firebase Installations module * Adding Firebase Installations module. * Readding .idea files that were deleted in previous commit * Readding .idea files that were deleted in previous commit * Revert "Adding Firebase Installations module" This reverts commit 2ec4aef. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Revert "Adding Firebase Installations module" with hidden files This reverts commit 2ec4aef. * Addressing review comments. * Http client to call FIS backend service. * Http client to call FIS backend service. * Initial Code structure for FIS Android SDK (#648) * Adding an interface library for Firebase Installations SDK * Adding Firebase Installations module * Adding Firebase Installations module. * Readding .idea files that were deleted in previous commit * Revert "Adding Firebase Installations module" This reverts commit 2ec4aef. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Add firebase installations project path * Adding Firebase Installations module. * Readding .idea files that were deleted in previous commit * Revert "Adding Firebase Installations module" This reverts commit 2ec4aef. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Add firebase installations project path * Fixing formattinf issues. * Revert "Adding Firebase Installations module" with hidden files This reverts commit 2ec4aef. * Addressing review comments. * Making InstallationTokenResult an AutoValue class. * Http client to call FIS backend service. * Addresing comments and introducing new FirebaseInstallationService Exception. * Implementing cache for FIS SDK (#694) * Implementing cache for FIS SDK * Implementing cache for FIS SDK * Addressing Di's comments. * Addressing Di's comments. * Adding Util class for FIrebaseInstallations APIs. (#676) * Adding Firebase Installations module * Readding .idea files that were deleted in previous commit * Revert "Adding Firebase Installations module" This reverts commit 2ec4aef. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Adding Firebase Installations module. * Readding .idea files that were deleted in previous commit * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Revert "Adding Firebase Installations module" with hidden files This reverts commit 2ec4aef. * Addressing review comments. * Http client to call FIS backend service. * Http client to call FIS backend service. * Http client to call FIS backend service. * Adding Firebase Installations module * Adding Firebase Installations module. * Readding .idea files that were deleted in previous commit * Readding .idea files that were deleted in previous commit * Revert "Adding Firebase Installations module" This reverts commit 2ec4aef. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Revert "Adding Firebase Installations module" with hidden files This reverts commit 2ec4aef. * Addressing review comments. * Http client to call FIS backend service. * Http client to call FIS backend service. * Initial Code structure for FIS Android SDK (#648) * Adding an interface library for Firebase Installations SDK * Adding Firebase Installations module * Adding Firebase Installations module. * Readding .idea files that were deleted in previous commit * Revert "Adding Firebase Installations module" This reverts commit 2ec4aef. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Add firebase installations project path * Adding Firebase Installations module. * Readding .idea files that were deleted in previous commit * Revert "Adding Firebase Installations module" This reverts commit 2ec4aef. * Revert "Readding .idea files that were deleted in previous commit" This reverts commit 7b4ebcf. * Add firebase installations project path * Fixing formattinf issues. * Revert "Adding Firebase Installations module" with hidden files This reverts commit 2ec4aef. * Addressing review comments. * Making InstallationTokenResult an AutoValue class. * Http client to call FIS backend service. * Addresing comments and introducing new FirebaseInstallationService Exception. * Implementing getId method in FirebaseInstallation to call backend. * 1. Adding instrumentation tests. 2. Introducing serviceClient level and main class exceptions. * Addressing Di's comments. * Addressing Rayo's comments * Updating parameters order in ServiceClient. * Updating createRandomFid as per Rayo's comments. * getId() implementation with instrumented tests. (#703) * getId() implementation with instrumented tests. * Addressing rayo's comments. - Detailed JavaDocs - Renaming FiidCache as PersistedFid * Addressing rayo's comments. - Detailed JavaDocs - Renaming FiidCache as PersistedFid * Addresing comments to resoleve the following: - Make registerAnsSaveFid non blocking call in getId() - PersistedFidEntry builder with default values * Addressing Ciaran and Rayo's comments. * Addressing Ciaran's comments * Addressing Ciaran's comments * Adding param comments and checking if registration status is valid. * Correcting lint warning: uses-permission should be declared before application in AndroidManifest.xml * Adding custom assertThat with more readable assertions * Correcting instrumented tests to be reliable. * Updating api.txt to resolve api-information presubmit check. * Adding api.txt for fisbase-installations-interop * Updating subprojects.cfg * FIS getAuthToken implementation. (#769) * FIS getAuthToken implementation. * FIS getAuthToken implementation. * 1. Addressing Ciaran's comments 2. Renaming InstallationTokenResult TokenExpirationTimestampMillis field to TokenExpirationInSecs * 1. Addressing Ciaran's comments 2. Renaming InstallationTokenResult TokenExpirationTimestampMillis field to TokenExpirationInSecs * Updated IntDef usage in firebase-installations * Using CountDownLatch to await instead of executor.awaitTermination * Addressing Di's comments. * Addressing Di's comments. * Addressing Ciaran's comments to replace latch with a custom listener. * Adding onSuccess to AwaitListener. * Cleaning up the code as per the ciaran's comments. * Addressing Di's comments. * 1. Handling multiple calls to getAUthToken() 2. Minor code changes as per the offline discussion with Rayo * Fixing api-information presubmit check. * updating api.txt for firbase-installations-interop * Addressing Ciaran's comments. * Fixing check-changed - GoogleJavaFormat error. * Addressing ciaran`s comments * nit fixes to executor : use unblocking queue. * FID delete() implementation. (#813) * FID delete() implementation. * Addressing ciaran's comments. * Refractoring the code to be inline. * Adding headers for Chemist to check API key restriction. (#821) * Enabling FIS network call timeout. (#827) * Enabling FIS network call timeout. * Addressing Di's comments * Simplifying FirebaseInstallations class by adding listeners. (#847) * Simplifying FirebaseInstallations class by adding listeners. * Addressing ciaran's comments to return same token if multiple getAuthToken() calls are triggered simultaneously. * Cleaning doRegistration method. * Fixing FISClient to correctly parse expiration timestamp. (#848) * Updating getAuthToken to return creation timestamp (#884) * Propagating the exceptions to the clients. (#856) * Merging changes into fis_sdk (#910) * Fixing FISClient to correctly parse expiration timestamp. (#848) * Updating getAuthToken to return creation timestamp (#884) * Propagating the exceptions to the clients. (#856) * Extract FID from FIS createInstallation response (#888) * Addressing Rayo's comment: Rename PersistedFidEntry to (#899) * Implementing retry once for FIS Client. (#895) * Simplifying FirebaseInstallations class by adding listeners. (#847) * Fixing FISClient to correctly parse expiration timestamp. (#848) * Updating getAuthToken to return creation timestamp (#884) * Propagating the exceptions to the clients. (#856) * FIS error handling (#911) 1. Mark PersistedInstallationEntry status UNREGISTERED incase of 500 errors 2. Store detailed 4xx server exceptions in the local storage. In the succeeding getId calls,return these exceptions to the clients * Reuse existing Iid as Fid (#924) * Add FisError to the persisted installation entry. (#931) * touch file (#993) 1 line change on comment * getAuthToken error handling for 401 & 404 response code (#961) * getAuthToken error handling for 401 & 404 response code: - Clear the local storage & throw an exception to call getId() resulting in recreation of fid * Renaming getAuthToken to getToken. (#1026) * Add heartbeat to fis sdk (#1037) * add tests * update api * installations * Fixes for multi-process access (#1042) * Switch from using SharedPreferences to a flat file * Fixes for multi-process access - switch from shared prefs to a flat file - protect generate Fid for cross-process and cross-thread accesses - make doRegistration only read the prefs once at the beginning and clean up the flow - pass the forceRefresh flag into doRegistration rather than storing it in a global * revert the name of the FID prefs write call * fix formatting issues * Fix the cross process locking The check if a new FID was needed was not in the critical region. * some small changes from the review * fix the java format and update the api file * Remove FirebaseSegmentation from fis_sdk branch. (was added by mistake) * Add separator line back * Update api info for FIS SDK * changed the instrumentation tests into unit tests (#1053) * changed the instrumentation tests into unit tests unit tests are easier and faster to run and debug the unit tests are also included in the code coverage tests * remove the FirebaseInstallations instrumentation tests These have been moved into unit tests and so are no longer needed. Also removed constants that are no longer referenced. * fix a format error * fixed a leak when cross process locking didn't close a file An intermediate RandomAccessFile created while acquiring the lock was not closed. Also pulled the cross process locking logic out into a separate class. Co-authored-by: Di Wu <[email protected]> Co-authored-by: Ankita <[email protected]> Co-authored-by: ChaoqunCHEN <[email protected]> Co-authored-by: Vinay Guthal <[email protected]>
1 parent f1bd039 commit 953be74

File tree

9 files changed

+1096
-926
lines changed

9 files changed

+1096
-926
lines changed

firebase-installations/firebase-installations.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,14 @@ dependencies {
5353
testImplementation 'junit:junit:4.12'
5454
testImplementation "org.robolectric:robolectric:$robolectricVersion"
5555
testImplementation "com.google.truth:truth:$googleTruthVersion"
56-
56+
testImplementation 'org.mockito:mockito-core:2.25.0'
57+
testImplementation 'org.mockito:mockito-inline:2.25.0'
5758

5859
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
5960
androidTestImplementation 'androidx.test:runner:1.2.0'
6061
androidTestImplementation "com.google.truth:truth:$googleTruthVersion"
6162
androidTestImplementation 'junit:junit:4.12'
6263
androidTestImplementation "androidx.annotation:annotation:1.0.0"
6364
androidTestImplementation 'org.mockito:mockito-core:2.25.0'
64-
androidTestImplementation 'org.mockito:mockito-android:2.25.0'
65+
androidTestImplementation 'org.mockito:mockito-inline:2.25.0'
6566
}

firebase-installations/src/androidTest/java/com/google/firebase/installations/FirebaseInstallationsInstrumentedTest.java

Lines changed: 0 additions & 849 deletions
This file was deleted.

firebase-installations/src/androidTest/java/com/google/firebase/installations/FisAndroidTestConstants.java

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,11 @@
1515
package com.google.firebase.installations;
1616

1717
import com.google.firebase.installations.local.PersistedInstallationEntry;
18-
import com.google.firebase.installations.remote.InstallationResponse;
19-
import com.google.firebase.installations.remote.InstallationResponse.ResponseCode;
20-
import com.google.firebase.installations.remote.TokenResult;
2118

2219
public final class FisAndroidTestConstants {
2320
public static final String TEST_FID_1 = "cccccccccccccccccccccc";
2421

25-
public static final String TEST_PROJECT_ID = "777777777777";
26-
2722
public static final String TEST_AUTH_TOKEN = "fis.auth.token";
28-
public static final String TEST_AUTH_TOKEN_2 = "fis.auth.token2";
29-
public static final String TEST_AUTH_TOKEN_3 = "fis.auth.token3";
30-
public static final String TEST_AUTH_TOKEN_4 = "fis.auth.token4";
31-
32-
public static final String TEST_API_KEY = "apiKey";
3323

3424
public static final String TEST_REFRESH_TOKEN = "1:test-refresh-token";
3525

@@ -41,40 +31,6 @@ public final class FisAndroidTestConstants {
4131
public static final long TEST_CREATION_TIMESTAMP_1 = 2000L;
4232
public static final long TEST_CREATION_TIMESTAMP_2 = 2L;
4333

44-
public static final String TEST_INSTANCE_ID_1 = "ccccccccccc";
45-
4634
public static final PersistedInstallationEntry DEFAULT_PERSISTED_INSTALLATION_ENTRY =
4735
PersistedInstallationEntry.builder().build();
48-
public static final InstallationResponse TEST_INSTALLATION_RESPONSE =
49-
InstallationResponse.builder()
50-
.setUri("/projects/" + TEST_PROJECT_ID + "/installations/" + TEST_FID_1)
51-
.setFid(TEST_FID_1)
52-
.setRefreshToken(TEST_REFRESH_TOKEN)
53-
.setAuthToken(
54-
TokenResult.builder()
55-
.setToken(TEST_AUTH_TOKEN)
56-
.setTokenExpirationTimestamp(TEST_TOKEN_EXPIRATION_TIMESTAMP)
57-
.build())
58-
.setResponseCode(ResponseCode.OK)
59-
.build();
60-
61-
public static final InstallationResponse TEST_INSTALLATION_RESPONSE_WITH_IID =
62-
InstallationResponse.builder()
63-
.setUri("/projects/" + TEST_PROJECT_ID + "/installations/" + TEST_INSTANCE_ID_1)
64-
.setFid(TEST_INSTANCE_ID_1)
65-
.setRefreshToken(TEST_REFRESH_TOKEN)
66-
.setAuthToken(
67-
TokenResult.builder()
68-
.setToken(TEST_AUTH_TOKEN)
69-
.setTokenExpirationTimestamp(TEST_TOKEN_EXPIRATION_TIMESTAMP)
70-
.build())
71-
.setResponseCode(ResponseCode.OK)
72-
.build();
73-
74-
public static final TokenResult TEST_TOKEN_RESULT =
75-
TokenResult.builder()
76-
.setToken(TEST_AUTH_TOKEN_2)
77-
.setTokenExpirationTimestamp(TEST_TOKEN_EXPIRATION_TIMESTAMP)
78-
.setResponseCode(TokenResult.ResponseCode.OK)
79-
.build();
8036
}

firebase-installations/src/androidTest/java/com/google/firebase/installations/local/PersistedInstallationEntrySubject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static PersistedInstallationEntrySubject assertThat(
4545

4646
/**
4747
* Constructor for use by subclasses. If you want to create an instance of this class itself, call
48-
* {@link Subject#check(String, PersistedInstallationEntry ..) check(...)}{@code .that(actual)}.
48+
* {@link Subject#check(String, Object ...) check(...)}{@code .that(actual)}.
4949
*
5050
* @param metadata
5151
* @param actual
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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.firebase.installations;
16+
17+
import android.content.Context;
18+
import java.io.File;
19+
import java.io.IOException;
20+
import java.io.RandomAccessFile;
21+
import java.nio.channels.FileChannel;
22+
import java.nio.channels.FileLock;
23+
24+
/** Use file locking to acquire a lock that will also block other processes. */
25+
class CrossProcessLock {
26+
private final FileChannel channel;
27+
private final FileLock lock;
28+
29+
private CrossProcessLock(FileChannel channel, FileLock lock) {
30+
this.channel = channel;
31+
this.lock = lock;
32+
}
33+
34+
static CrossProcessLock acquire(Context appContext, String lockName) {
35+
try {
36+
File file = new File(appContext.getFilesDir(), lockName);
37+
FileChannel channel = new RandomAccessFile(file, "rw").getChannel();
38+
// Use the file channel to create a lock on the file.
39+
// This method blocks until it can retrieve the lock.
40+
FileLock lock = channel.lock();
41+
return new CrossProcessLock(channel, lock);
42+
} catch (IOException e) {
43+
throw new IllegalStateException("exception while using file locks, should never happen", e);
44+
}
45+
}
46+
47+
/** Release a previously acquired lock and free any underlying resources. */
48+
void releaseAndClose() {
49+
try {
50+
lock.release();
51+
channel.close();
52+
} catch (IOException e) {
53+
throw new IllegalStateException("exception while using file locks, should never happen", e);
54+
}
55+
}
56+
}

firebase-installations/src/main/java/com/google/firebase/installations/FirebaseInstallations.java

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@
3333
import com.google.firebase.installations.remote.InstallationResponse;
3434
import com.google.firebase.installations.remote.TokenResult;
3535
import com.google.firebase.platforminfo.UserAgentPublisher;
36-
import java.io.File;
3736
import java.io.IOException;
38-
import java.io.RandomAccessFile;
39-
import java.nio.channels.FileChannel;
40-
import java.nio.channels.FileLock;
4137
import java.util.ArrayList;
4238
import java.util.Calendar;
4339
import java.util.Iterator;
@@ -311,7 +307,8 @@ private final void doRegistrationInternal(boolean forceRefresh) {
311307
* been persisted.
312308
*/
313309
private PersistedInstallationEntry getPrefsWithGeneratedIdMultiProcessSafe() {
314-
FileLock fileLock = getCrossProcessLock();
310+
CrossProcessLock lock = CrossProcessLock
311+
.acquire(firebaseApp.getApplicationContext(), LOCKFILE_NAME_GENERATE_FID);
315312
try {
316313
synchronized (lockGenerateFid) {
317314
PersistedInstallationEntry prefs =
@@ -332,30 +329,7 @@ private PersistedInstallationEntry getPrefsWithGeneratedIdMultiProcessSafe() {
332329
}
333330

334331
} finally {
335-
releaseCrossProcessLock(fileLock);
336-
}
337-
}
338-
339-
/** Use file locking to acquire a lock that will also block other processes. */
340-
private FileLock getCrossProcessLock() {
341-
try {
342-
File file =
343-
new File(firebaseApp.getApplicationContext().getFilesDir(), LOCKFILE_NAME_GENERATE_FID);
344-
FileChannel channel = new RandomAccessFile(file, "rw").getChannel();
345-
// Use the file channel to create a lock on the file.
346-
// This method blocks until it can retrieve the lock.
347-
return channel.lock();
348-
} catch (IOException e) {
349-
throw new IllegalStateException("exception while using file locks, should never happen", e);
350-
}
351-
}
352-
353-
/** Release a previously acquired lock. */
354-
private void releaseCrossProcessLock(FileLock fileLock) {
355-
try {
356-
fileLock.release();
357-
} catch (IOException e) {
358-
throw new IllegalStateException("exception while using file locks, should never happen", e);
332+
lock.releaseAndClose();
359333
}
360334
}
361335

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ public FakeCalendar(long initialTimeInMillis) {
2323
timeInMillis = initialTimeInMillis;
2424
}
2525

26+
@Override
2627
public long getTimeInMillis() {
2728
return timeInMillis;
2829
}
2930

31+
@Override
3032
public void setTimeInMillis(long timeInMillis) {
3133
this.timeInMillis = timeInMillis;
3234
}

0 commit comments

Comments
 (0)