Skip to content

Migrate common from SharedPreferences to DataStore #6801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

daymxn
Copy link
Member

@daymxn daymxn commented Mar 24, 2025

Per b/423592727,

This adds a DataStore class that wraps around androidx.datastore.core.DataStore, and provides more Java friendly methods for creation and interop. This should make migrations from SharedPreferences in existing Java code much easier.

Note that usages of SharedPreferences in Kotlin should just use androidx.datastore.core.DataStore directly instead, as they have no need for the interop features. Furthermore, it would make it easier in the future to remove our DataStore wrapper once more SDKs have been migrated to Kotlin.

This wrapper class comes with full documentation detailing how it should be used, and quirks to keep in mind.

Since firebase-common has been migrated to use this wrapper, and common has tests with their SharedPreferences usages, our wrapper already has implicit testing.

This PR also fixes the following:

  • b/423592231 -> Migrate common from SharedPreferences to DataStore

@daymxn daymxn self-assigned this Mar 24, 2025
Copy link
Contributor

github-actions bot commented Mar 24, 2025

Javadoc Changes:
--- /home/runner/diff/original/firebase-kotlindoc/android/client/firebase-common/_toc.yaml	2025-06-09 15:52:18.614894518 +0000
+++ /home/runner/diff/modified/firebase-kotlindoc/android/client/firebase-common/_toc.yaml	2025-06-09 15:48:47.817515308 +0000
@@ -27,6 +27,16 @@
     - title: "FirebaseTooManyRequestsException"
       path: "/docs/reference/android/com/google/firebase/FirebaseTooManyRequestsException.html"
 
+- title: "firebase.datastore"
+  path: "/docs/reference/android/com/google/firebase/datastore/package-summary.html"
+
+  section:
+  - title: "Classes"
+
+    section:
+    - title: "DataStoreKt"
+      path: "/docs/reference/android/com/google/firebase/datastore/DataStoreKt.html"
+
 - title: "firebase.ktx"
   status: deprecated
   path: "/docs/reference/android/com/google/firebase/ktx/package-summary.html"
--- /home/runner/diff/original/firebase-kotlindoc/android/com/google/firebase/datastore/DataStoreKt.html	1970-01-01 00:00:00.000000000 +0000
+++ /home/runner/diff/modified/firebase-kotlindoc/android/com/google/firebase/datastore/DataStoreKt.html	2025-06-09 15:48:47.824515390 +0000
@@ -0,0 +1,81 @@
+<html devsite="true">
+  <head>
+    <title>DataStoreKt</title>
+{% setvar book_path %}/_book.yaml{% endsetvar %}
+{% include "docs/reference/android/_reference-head-tags.html" %}
+  </head>
+  <body>
+    <h1>DataStoreKt</h1>
+    <p>
+      <pre>public final class <a href="/docs/reference/android/com/google/firebase/datastore/DataStoreKt.html">DataStoreKt</a></pre>
+    </p>
+    <hr>
+    <h2>Summary</h2>
+    <div class="devsite-table-wrapper">
+      <table class="responsive">
+        <colgroup>
+          <col width="40%">
+          <col>
+        </colgroup>
+        <thead>
+          <tr>
+            <th colspan="100%"><h3>Public methods</h3></th>
+          </tr>
+        </thead>
+        <tbody class="list">
+          <tr>
+            <td><code>static&nbsp;final @<a href="https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html">NonNull</a> T</code></td>
+            <td>
+              <div><code>&lt;T&nbsp;extends&nbsp;<a href="https://developer.android.com/reference/kotlin/java/lang/Object.html">Object</a>&gt; <a href="/docs/reference/android/com/google/firebase/datastore/DataStoreKt.html">DataStoreKt</a>.<a href="/docs/reference/android/com/google/firebase/datastore/DataStoreKt.html#(androidx.datastore.preferences.core.Preferences).getOrDefault(androidx.datastore.preferences.core.Preferences.Key,kotlin.Any)">getOrDefault</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences.html">Preferences</a>&nbsp;receiver,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences.Key.html">Preferences.Key</a>&lt;@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html">NonNull</a> T&gt;&nbsp;key,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html">NonNull</a> T&nbsp;defaultValue<br>)</code></div>
+              <p>Helper method for getting the value out of a <code><a href="https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences.html">Preferences</a></code> object if it exists, else falling back to the default value.</p>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="list">
+      <h2>Public methods</h2>
+      <div class="api-item"><a name="(androidx.datastore.preferences.core.Preferences).getOrDefault(androidx.datastore.preferences.core.Preferences.Key, kotlin.Any)"></a><a name="-androidx.datastore.preferences.core.Preferences-.getOrDefault-androidx.datastore.preferences.core.Preferences.Key-kotlin.Any-"></a><a name="getordefault"></a>
+        <h3 class="api-name" id="(androidx.datastore.preferences.core.Preferences).getOrDefault(androidx.datastore.preferences.core.Preferences.Key,kotlin.Any)">DataStoreKt.getOrDefault</h3>
+        <pre class="api-signature no-pretty-print">public&nbsp;static&nbsp;final&nbsp;@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html">NonNull</a> T&nbsp;&lt;T&nbsp;extends&nbsp;<a href="https://developer.android.com/reference/kotlin/java/lang/Object.html">Object</a>&gt; <a href="/docs/reference/android/com/google/firebase/datastore/DataStoreKt.html">DataStoreKt</a>.<a href="/docs/reference/android/com/google/firebase/datastore/DataStoreKt.html#(androidx.datastore.preferences.core.Preferences).getOrDefault(androidx.datastore.preferences.core.Preferences.Key,kotlin.Any)">getOrDefault</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences.html">Preferences</a>&nbsp;receiver,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences.Key.html">Preferences.Key</a>&lt;@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html">NonNull</a> T&gt;&nbsp;key,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html">NonNull</a> T&nbsp;defaultValue<br>)</pre>
+        <p>Helper method for getting the value out of a <code><a href="https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences.html">Preferences</a></code> object if it exists, else falling back to the default value.</p>
+        <p>This is primarily useful when working with an instance of <code><a href="https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/MutablePreferences.html">MutablePreferences</a></code></p>
+        <ul>
+          <li>
+            <p>like when working within an <code><a href="/docs/reference/android/com/google/firebase/datastore/DataStorage.html#editSync(kotlin.Function1)">DataStorage.editSync</a></code> callback.</p>
+          </li>
+        </ul>
+        <p>Example:</p>
+        <pre class="prettyprint">dataStore.editSync((pref) -&gt; {<br> long heartBeatCount = DataStoreKt.getOrDefault(pref, HEART_BEAT_COUNT_TAG, 0L);<br> heartBeatCount+=1;<br> pref.set(HEART_BEAT_COUNT_TAG, heartBeatCount);<br><br> return null;<br>});</pre>
+        <div class="devsite-table-wrapper">
+          <table class="responsive">
+            <colgroup>
+              <col width="40%">
+              <col>
+            </colgroup>
+            <thead>
+              <tr>
+                <th colspan="100%">Parameters</th>
+              </tr>
+            </thead>
+            <tbody class="list">
+              <tr>
+                <td><code>@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences.Key.html">Preferences.Key</a>&lt;@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html">NonNull</a> T&gt;&nbsp;key</code></td>
+                <td>
+                  <p>The typed key of the entry to get data for.</p>
+                </td>
+              </tr>
+              <tr>
+                <td><code>@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html">NonNull</a> T&nbsp;defaultValue</code></td>
+                <td>
+                  <p>A value to default to, if the key isn't found.</p>
+                </td>
+              </tr>
+            </tbody>
+          </table>
+        </div>
+      </div>
+    </div>
+  </body>
+</html>
+
--- /home/runner/diff/original/firebase-kotlindoc/android/com/google/firebase/datastore/package-summary.html	1970-01-01 00:00:00.000000000 +0000
+++ /home/runner/diff/modified/firebase-kotlindoc/android/com/google/firebase/datastore/package-summary.html	2025-06-09 15:48:47.824515390 +0000
@@ -0,0 +1,26 @@
+<html devsite="true">
+  <head>
+    <title>com.google.firebase.datastore</title>
+{% setvar book_path %}/_book.yaml{% endsetvar %}
+{% include "docs/reference/android/_reference-head-tags.html" %}
+  </head>
+  <body>
+    <h1>com.google.firebase.datastore</h1>
+    <h2>Classes</h2>
+    <div class="devsite-table-wrapper">
+      <table class="responsive">
+        <colgroup>
+          <col width="40%">
+          <col>
+        </colgroup>
+        <tbody class="list">
+          <tr>
+            <td><code><a href="/docs/reference/android/com/google/firebase/datastore/DataStoreKt.html">DataStoreKt</a></code></td>
+            <td></td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+  </body>
+</html>
+
--- /home/runner/diff/original/firebase-kotlindoc/kotlin/client/firebase-common/_toc.yaml	2025-06-09 15:52:18.617894552 +0000
+++ /home/runner/diff/modified/firebase-kotlindoc/kotlin/client/firebase-common/_toc.yaml	2025-06-09 15:48:47.825515402 +0000
@@ -29,6 +29,9 @@
     - title: "Firebase"
       path: "/docs/reference/kotlin/com/google/firebase/Firebase.html"
 
+- title: "firebase.datastore"
+  path: "/docs/reference/kotlin/com/google/firebase/datastore/package-summary.html"
+
 - title: "firebase.ktx"
   status: deprecated
   path: "/docs/reference/kotlin/com/google/firebase/ktx/package-summary.html"
--- /home/runner/diff/original/firebase-kotlindoc/kotlin/com/google/firebase/datastore/package-summary.html	1970-01-01 00:00:00.000000000 +0000
+++ /home/runner/diff/modified/firebase-kotlindoc/kotlin/com/google/firebase/datastore/package-summary.html	2025-06-09 15:48:47.832515484 +0000
@@ -0,0 +1,70 @@
+<html devsite="true">
+  <head>
+    <title>com.google.firebase.datastore</title>
+{% setvar book_path %}/_book.yaml{% endsetvar %}
+{% include "docs/reference/kotlin/_reference-head-tags.html" %}
+  </head>
+  <body>
+    <h1>com.google.firebase.datastore</h1>
+    <h2>Extension functions summary</h2>
+    <div class="devsite-table-wrapper">
+      <table class="responsive">
+        <colgroup>
+          <col width="40%">
+          <col>
+        </colgroup>
+        <tbody class="list">
+          <tr>
+            <td><code>T</code></td>
+            <td>
+              <div><code>&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>?&gt; <a href="https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences.html">Preferences</a>.<a href="/docs/reference/kotlin/com/google/firebase/datastore/package-summary.html#(androidx.datastore.preferences.core.Preferences).getOrDefault(androidx.datastore.preferences.core.Preferences.Key,kotlin.Any)">getOrDefault</a>(key:&nbsp;<a href="https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences.Key.html">Preferences.Key</a>&lt;T&gt;,&nbsp;defaultValue:&nbsp;T)</code></div>
+              <p>Helper method for getting the value out of a <code><a href="https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences.html">Preferences</a></code> object if it exists, else falling back to the default value.</p>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <h2>Extension functions</h2>
+    <div class="api-item"><a name="(androidx.datastore.preferences.core.Preferences).getOrDefault(androidx.datastore.preferences.core.Preferences.Key, kotlin.Any)"></a><a name="-androidx.datastore.preferences.core.Preferences-.getOrDefault-androidx.datastore.preferences.core.Preferences.Key-kotlin.Any-"></a><a name="getordefault"></a>
+      <h3 class="api-name" id="(androidx.datastore.preferences.core.Preferences).getOrDefault(androidx.datastore.preferences.core.Preferences.Key,kotlin.Any)">getOrDefault</h3>
+      <pre class="api-signature no-pretty-print">fun&nbsp;&lt;T&nbsp;:&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html">Any</a>?&gt; <a href="https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences.html">Preferences</a>.<a href="/docs/reference/kotlin/com/google/firebase/datastore/package-summary.html#(androidx.datastore.preferences.core.Preferences).getOrDefault(androidx.datastore.preferences.core.Preferences.Key,kotlin.Any)">getOrDefault</a>(key:&nbsp;<a href="https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences.Key.html">Preferences.Key</a>&lt;T&gt;,&nbsp;defaultValue:&nbsp;T):&nbsp;T</pre>
+      <p>Helper method for getting the value out of a <code><a href="https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences.html">Preferences</a></code> object if it exists, else falling back to the default value.</p>
+      <p>This is primarily useful when working with an instance of <code><a href="https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/MutablePreferences.html">MutablePreferences</a></code></p>
+      <ul>
+        <li>
+          <p>like when working within an <code><a href="/docs/reference/kotlin/com/google/firebase/datastore/DataStorage.html#editSync(kotlin.Function1)">DataStorage.editSync</a></code> callback.</p>
+        </li>
+      </ul>
+      <p>Example:</p>
+      <pre class="prettyprint">dataStore.editSync((pref) -&gt; {<br> long heartBeatCount = DataStoreKt.getOrDefault(pref, HEART_BEAT_COUNT_TAG, 0L);<br> heartBeatCount+=1;<br> pref.set(HEART_BEAT_COUNT_TAG, heartBeatCount);<br><br> return null;<br>});</pre>
+      <div class="devsite-table-wrapper">
+        <table class="responsive">
+          <colgroup>
+            <col width="40%">
+            <col>
+          </colgroup>
+          <thead>
+            <tr>
+              <th colspan="100%">Parameters</th>
+            </tr>
+          </thead>
+          <tbody class="list">
+            <tr>
+              <td><code>key:&nbsp;<a href="https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences.Key.html">Preferences.Key</a>&lt;T&gt;</code></td>
+              <td>
+                <p>The typed key of the entry to get data for.</p>
+              </td>
+            </tr>
+            <tr>
+              <td><code>defaultValue:&nbsp;T</code></td>
+              <td>
+                <p>A value to default to, if the key isn't found.</p>
+              </td>
+            </tr>
+          </tbody>
+        </table>
+      </div>
+    </div>
+  </body>
+</html>
+

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Mar 24, 2025

Coverage Report 1

Affected Products

  • firebase-common

    Overall coverage changed from 52.66% (f61a649) to 53.44% (f56224c) by +0.78%.

    FilenameBase (f61a649)Merge (f56224c)Diff
    DataStore.kt?83.33%?
    HeartBeatInfoStorage.java93.23%93.98%+0.75%

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/ueYHOsuvyY.html

Copy link
Contributor

github-actions bot commented Mar 24, 2025

Test Results

 50 files   -  1 008   50 suites   - 1 008   1m 16s ⏱️ - 34m 30s
 76 tests  -  5 909   76 ✅  -  5 887  0 💤  - 22  0 ❌ ±0 
168 runs   - 11 865  168 ✅  - 11 821  0 💤  - 44  0 ❌ ±0 

Results for commit 5619a56. ± Comparison against base commit f61a649.

This pull request removes 5909 tests.
com.google.android.datatransport.cct.CctBackendFactoryTest ‑ create_returnCCTBackend_WhenBackendNameIsCCT
com.google.android.datatransport.cct.CctDestinationTest ‑ cctDestination_shouldOnlySupportProtoAndJson
com.google.android.datatransport.cct.CctDestinationTest ‑ cctDestination_shouldSupportProtoAndJson
com.google.android.datatransport.cct.CctTransportBackendTest ‑ decorate_whenOffline_shouldProperlyPopulateNetworkInfo
com.google.android.datatransport.cct.CctTransportBackendTest ‑ decorate_whenOnline_shouldProperlyPopulateNetworkInfo
com.google.android.datatransport.cct.CctTransportBackendTest ‑ schedule_shouldAddCookieOnPseudonymousIds
com.google.android.datatransport.cct.CctTransportBackendTest ‑ schedule_shouldDropCookieOnMixedPseudonymousIds
com.google.android.datatransport.cct.CctTransportBackendTest ‑ send_CompressedResponseIsUncompressed
com.google.android.datatransport.cct.CctTransportBackendTest ‑ send_whenBackendRedirectsMoreThan5Times_shouldOnlyRedirect4Times
com.google.android.datatransport.cct.CctTransportBackendTest ‑ send_whenBackendRedirects_shouldCorrectlyFollowTheRedirectViaPost
…

♻️ This comment has been updated with latest results.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Mar 24, 2025

Size Report 1

Affected Products

  • firebase-common

    TypeBase (f61a649)Merge (f56224c)Diff
    aar116 kB134 kB+17.9 kB (+15.5%)
    apk (aggressive)140 kB189 kB+49.2 kB (+35.1%)
    apk (release)4.45 MB5.91 MB+1.46 MB (+32.8%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/x3wEaPqBL8.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Mar 27, 2025

Startup Time Report 1

Note: Layout is sometimes suboptimal due to limited formatting support on GitHub. Please check this report on GCS.

Notes

Startup Times

  • ComponentDiscovery

    DeviceStatisticsDistributions
    oriole-32
    Percentilef61a649f56224cDiffSignificant (?)
    p10975 ±43 μs997 ±50 μs+21.9 μs (+2.2%)NO
    p251.06 ±0.04 ms1.09 ±0.05 ms+24.1 μs (+2.3%)NO
    p501.19 ±0.05 ms1.21 ±0.05 ms+14.8 μs (+1.2%)NO
    p751.40 ±0.07 ms1.42 ±0.07 ms+15.3 μs (+1.1%)NO
    p901.69 ±0.1 ms1.75 ±0.2 ms+57.8 μs (+3.4%)NO

    20 test runs in comparison
    CommitTest Runs
    f61a649
    • 2025-06-06_23:51:26.181833_nqzo
    • 2025-06-06_23:51:26.183463_ZfAi
    • 2025-06-06_23:51:26.183478_rEmy
    • 2025-06-06_23:51:26.183485_Akjy
    • 2025-06-06_23:51:26.183489_jspl
    • 2025-06-06_23:51:26.183493_iBEg
    • 2025-06-06_23:51:26.183497_npqR
    • 2025-06-06_23:51:26.183501_kfJO
    • 2025-06-06_23:51:26.183505_uoMq
    • 2025-06-06_23:51:26.183509_YpKC
    f56224c
    • 2025-06-09_16:06:22.853157_RGnd
    • 2025-06-09_16:06:22.853196_UvWm
    • 2025-06-09_16:06:22.853219_WMsU
    • 2025-06-09_16:06:22.853230_pzyC
    • 2025-06-09_16:06:22.853238_SlRy
    • 2025-06-09_16:06:22.853246_qDfL
    • 2025-06-09_16:06:22.853253_JjQx
    • 2025-06-09_16:06:22.853261_vzDa
    • 2025-06-09_16:06:22.853268_hPMb
    • 2025-06-09_16:06:22.853275_Iovc
    redfin-30
    Percentilef61a649f56224cDiffSignificant (?)
    p10812 ±16 μs832 ±46 μs+20.0 μs (+2.5%)NO
    p25847 ±20 μs872 ±43 μs+25.3 μs (+3.0%)NO
    p50916 ±29 μs934 ±46 μs+18.3 μs (+2.0%)NO
    p751.12 ±0.09 ms1.17 ±0.1 ms+47.1 μs (+4.2%)NO
    p901.52 ±0.2 ms1.65 ±0.2 ms+130 μs (+8.5%)NO

    20 test runs in comparison
    CommitTest Runs
    f61a649
    • 2025-06-06_23:51:26.181833_nqzo
    • 2025-06-06_23:51:26.183463_ZfAi
    • 2025-06-06_23:51:26.183478_rEmy
    • 2025-06-06_23:51:26.183485_Akjy
    • 2025-06-06_23:51:26.183489_jspl
    • 2025-06-06_23:51:26.183493_iBEg
    • 2025-06-06_23:51:26.183497_npqR
    • 2025-06-06_23:51:26.183501_kfJO
    • 2025-06-06_23:51:26.183505_uoMq
    • 2025-06-06_23:51:26.183509_YpKC
    f56224c
    • 2025-06-09_16:06:22.853157_RGnd
    • 2025-06-09_16:06:22.853196_UvWm
    • 2025-06-09_16:06:22.853219_WMsU
    • 2025-06-09_16:06:22.853230_pzyC
    • 2025-06-09_16:06:22.853238_SlRy
    • 2025-06-09_16:06:22.853246_qDfL
    • 2025-06-09_16:06:22.853253_JjQx
    • 2025-06-09_16:06:22.853261_vzDa
    • 2025-06-09_16:06:22.853268_hPMb
    • 2025-06-09_16:06:22.853275_Iovc
  • Firebase

    DeviceStatisticsDistributions
    oriole-32
    Percentilef61a649f56224cDiffSignificant (?)
    p105.46 ±0.1 ms5.44 ±0.1 ms-23.9 μs (-0.4%)NO
    p255.69 ±0.2 ms5.67 ±0.1 ms-20.7 μs (-0.4%)NO
    p506.05 ±0.2 ms6.08 ±0.1 ms+23.9 μs (+0.4%)NO
    p756.66 ±0.2 ms6.58 ±0.1 ms-81.4 μs (-1.2%)NO
    p907.37 ±0.2 ms7.35 ±0.3 ms-17.1 μs (-0.2%)NO

    20 test runs in comparison
    CommitTest Runs
    f61a649
    • 2025-06-06_23:51:26.181833_nqzo
    • 2025-06-06_23:51:26.183463_ZfAi
    • 2025-06-06_23:51:26.183478_rEmy
    • 2025-06-06_23:51:26.183485_Akjy
    • 2025-06-06_23:51:26.183489_jspl
    • 2025-06-06_23:51:26.183493_iBEg
    • 2025-06-06_23:51:26.183497_npqR
    • 2025-06-06_23:51:26.183501_kfJO
    • 2025-06-06_23:51:26.183505_uoMq
    • 2025-06-06_23:51:26.183509_YpKC
    f56224c
    • 2025-06-09_16:06:22.853157_RGnd
    • 2025-06-09_16:06:22.853196_UvWm
    • 2025-06-09_16:06:22.853219_WMsU
    • 2025-06-09_16:06:22.853230_pzyC
    • 2025-06-09_16:06:22.853238_SlRy
    • 2025-06-09_16:06:22.853246_qDfL
    • 2025-06-09_16:06:22.853253_JjQx
    • 2025-06-09_16:06:22.853261_vzDa
    • 2025-06-09_16:06:22.853268_hPMb
    • 2025-06-09_16:06:22.853275_Iovc
    redfin-30
    Percentilef61a649f56224cDiffSignificant (?)
    p108.41 ±0.1 ms8.54 ±0.4 ms+130 μs (+1.6%)NO
    p258.65 ±0.2 ms8.84 ±0.5 ms+193 μs (+2.2%)NO
    p509.07 ±0.2 ms9.28 ±0.5 ms+207 μs (+2.3%)NO
    p759.78 ±0.3 ms10.1 ±0.6 ms+301 μs (+3.1%)NO
    p9011.0 ±0.4 ms11.6 ±1 ms+612 μs (+5.5%)NO

    20 test runs in comparison
    CommitTest Runs
    f61a649
    • 2025-06-06_23:51:26.181833_nqzo
    • 2025-06-06_23:51:26.183463_ZfAi
    • 2025-06-06_23:51:26.183478_rEmy
    • 2025-06-06_23:51:26.183485_Akjy
    • 2025-06-06_23:51:26.183489_jspl
    • 2025-06-06_23:51:26.183493_iBEg
    • 2025-06-06_23:51:26.183497_npqR
    • 2025-06-06_23:51:26.183501_kfJO
    • 2025-06-06_23:51:26.183505_uoMq
    • 2025-06-06_23:51:26.183509_YpKC
    f56224c
    • 2025-06-09_16:06:22.853157_RGnd
    • 2025-06-09_16:06:22.853196_UvWm
    • 2025-06-09_16:06:22.853219_WMsU
    • 2025-06-09_16:06:22.853230_pzyC
    • 2025-06-09_16:06:22.853238_SlRy
    • 2025-06-09_16:06:22.853246_qDfL
    • 2025-06-09_16:06:22.853253_JjQx
    • 2025-06-09_16:06:22.853261_vzDa
    • 2025-06-09_16:06:22.853268_hPMb
    • 2025-06-09_16:06:22.853275_Iovc
  • Runtime

    DeviceStatisticsDistributions
    oriole-32
    Percentilef61a649f56224cDiffSignificant (?)
    p104.35 ±0.09 ms4.31 ±0.07 ms-42.1 μs (-1.0%)NO
    p254.50 ±0.1 ms4.46 ±0.08 ms-39.0 μs (-0.9%)NO
    p504.75 ±0.2 ms4.73 ±0.09 ms-19.8 μs (-0.4%)NO
    p755.21 ±0.2 ms5.17 ±0.1 ms-38.3 μs (-0.7%)NO
    p905.76 ±0.2 ms5.78 ±0.1 ms+22.3 μs (+0.4%)NO

    20 test runs in comparison
    CommitTest Runs
    f61a649
    • 2025-06-06_23:51:26.181833_nqzo
    • 2025-06-06_23:51:26.183463_ZfAi
    • 2025-06-06_23:51:26.183478_rEmy
    • 2025-06-06_23:51:26.183485_Akjy
    • 2025-06-06_23:51:26.183489_jspl
    • 2025-06-06_23:51:26.183493_iBEg
    • 2025-06-06_23:51:26.183497_npqR
    • 2025-06-06_23:51:26.183501_kfJO
    • 2025-06-06_23:51:26.183505_uoMq
    • 2025-06-06_23:51:26.183509_YpKC
    f56224c
    • 2025-06-09_16:06:22.853157_RGnd
    • 2025-06-09_16:06:22.853196_UvWm
    • 2025-06-09_16:06:22.853219_WMsU
    • 2025-06-09_16:06:22.853230_pzyC
    • 2025-06-09_16:06:22.853238_SlRy
    • 2025-06-09_16:06:22.853246_qDfL
    • 2025-06-09_16:06:22.853253_JjQx
    • 2025-06-09_16:06:22.853261_vzDa
    • 2025-06-09_16:06:22.853268_hPMb
    • 2025-06-09_16:06:22.853275_Iovc
    redfin-30
    Percentilef61a649f56224cDiffSignificant (?)
    p107.43 ±0.1 ms7.57 ±0.4 ms+135 μs (+1.8%)NO
    p257.64 ±0.1 ms7.81 ±0.4 ms+173 μs (+2.3%)NO
    p507.97 ±0.1 ms8.17 ±0.5 ms+204 μs (+2.6%)NO
    p758.48 ±0.3 ms8.71 ±0.5 ms+227 μs (+2.7%)NO
    p909.36 ±0.4 ms9.89 ±1 ms+534 μs (+5.7%)NO

    20 test runs in comparison
    CommitTest Runs
    f61a649
    • 2025-06-06_23:51:26.181833_nqzo
    • 2025-06-06_23:51:26.183463_ZfAi
    • 2025-06-06_23:51:26.183478_rEmy
    • 2025-06-06_23:51:26.183485_Akjy
    • 2025-06-06_23:51:26.183489_jspl
    • 2025-06-06_23:51:26.183493_iBEg
    • 2025-06-06_23:51:26.183497_npqR
    • 2025-06-06_23:51:26.183501_kfJO
    • 2025-06-06_23:51:26.183505_uoMq
    • 2025-06-06_23:51:26.183509_YpKC
    f56224c
    • 2025-06-09_16:06:22.853157_RGnd
    • 2025-06-09_16:06:22.853196_UvWm
    • 2025-06-09_16:06:22.853219_WMsU
    • 2025-06-09_16:06:22.853230_pzyC
    • 2025-06-09_16:06:22.853238_SlRy
    • 2025-06-09_16:06:22.853246_qDfL
    • 2025-06-09_16:06:22.853253_JjQx
    • 2025-06-09_16:06:22.853261_vzDa
    • 2025-06-09_16:06:22.853268_hPMb
    • 2025-06-09_16:06:22.853275_Iovc
  • timeToInitialDisplay

    DeviceStatisticsDistributions
    oriole-32
    Percentilef61a649f56224cDiffSignificant (?)
    p10197 ±5 ms201 ±4 ms+4.22 ms (+2.1%)NO
    p25202 ±5 ms207 ±3 ms+4.68 ms (+2.3%)NO
    p50210 ±4 ms214 ±4 ms+4.29 ms (+2.0%)NO
    p75217 ±5 ms222 ±5 ms+5.29 ms (+2.4%)NO
    p90224 ±5 ms231 ±6 ms+6.80 ms (+3.0%)NO

    20 test runs in comparison
    CommitTest Runs
    f61a649
    • 2025-06-06_23:51:26.181833_nqzo
    • 2025-06-06_23:51:26.183463_ZfAi
    • 2025-06-06_23:51:26.183478_rEmy
    • 2025-06-06_23:51:26.183485_Akjy
    • 2025-06-06_23:51:26.183489_jspl
    • 2025-06-06_23:51:26.183493_iBEg
    • 2025-06-06_23:51:26.183497_npqR
    • 2025-06-06_23:51:26.183501_kfJO
    • 2025-06-06_23:51:26.183505_uoMq
    • 2025-06-06_23:51:26.183509_YpKC
    f56224c
    • 2025-06-09_16:06:22.853157_RGnd
    • 2025-06-09_16:06:22.853196_UvWm
    • 2025-06-09_16:06:22.853219_WMsU
    • 2025-06-09_16:06:22.853230_pzyC
    • 2025-06-09_16:06:22.853238_SlRy
    • 2025-06-09_16:06:22.853246_qDfL
    • 2025-06-09_16:06:22.853253_JjQx
    • 2025-06-09_16:06:22.853261_vzDa
    • 2025-06-09_16:06:22.853268_hPMb
    • 2025-06-09_16:06:22.853275_Iovc
    redfin-30
    Percentilef61a649f56224cDiffSignificant (?)
    p10225 ±4 ms251 ±7 ms+25.9 ms (+11.5%)MAYBE
    p25231 ±4 ms257 ±9 ms+26.4 ms (+11.4%)MAYBE
    p50238 ±4 ms266 ±12 ms+28.0 ms (+11.8%)NO
    p75245 ±4 ms275 ±13 ms+30.1 ms (+12.3%)NO
    p90253 ±4 ms287 ±13 ms+34.0 ms (+13.5%)MAYBE

    20 test runs in comparison
    CommitTest Runs
    f61a649
    • 2025-06-06_23:51:26.181833_nqzo
    • 2025-06-06_23:51:26.183463_ZfAi
    • 2025-06-06_23:51:26.183478_rEmy
    • 2025-06-06_23:51:26.183485_Akjy
    • 2025-06-06_23:51:26.183489_jspl
    • 2025-06-06_23:51:26.183493_iBEg
    • 2025-06-06_23:51:26.183497_npqR
    • 2025-06-06_23:51:26.183501_kfJO
    • 2025-06-06_23:51:26.183505_uoMq
    • 2025-06-06_23:51:26.183509_YpKC
    f56224c
    • 2025-06-09_16:06:22.853157_RGnd
    • 2025-06-09_16:06:22.853196_UvWm
    • 2025-06-09_16:06:22.853219_WMsU
    • 2025-06-09_16:06:22.853230_pzyC
    • 2025-06-09_16:06:22.853238_SlRy
    • 2025-06-09_16:06:22.853246_qDfL
    • 2025-06-09_16:06:22.853253_JjQx
    • 2025-06-09_16:06:22.853261_vzDa
    • 2025-06-09_16:06:22.853268_hPMb
    • 2025-06-09_16:06:22.853275_Iovc

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/tHreu4Ov2h/index.html

Copy link
Contributor

github-actions bot commented Jun 9, 2025

Firebase AI Mock Responses Check ⚠️

A newer major version of the mock responses for Firebase AI unit tests is available. update_responses.sh should be updated to clone the latest version of the responses: v14.0

@daymxn daymxn requested a review from rlazo June 9, 2025 15:42
@daymxn daymxn enabled auto-merge (squash) June 9, 2025 15:46
*
* @hide
*/
class DataStorage(val context: Context, val name: String) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use a name like DataStorageForJava, JavaDataStorage, DataStorageJavaAdapter, or the like to make it even more clear that this is intended for Java only? Since this is not meant to be part of the public API we can go with ugly but clearer naming

*
* Automatically migrates data from any `SharedPreferences` that share the same context and name.
*
* There should only ever be _one_ instance of this class per context and name variant.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something we should try to enforce through code?

import android.os.Build;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.datastore.preferences.core.*;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No star imports

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants