Skip to content

Commit f03d2f7

Browse files
authored
Merge branch 'main' into push-rrwmqqkxlowz
2 parents ad7c4c7 + 225aacd commit f03d2f7

File tree

28 files changed

+135
-87
lines changed

28 files changed

+135
-87
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
`tracing-logging` feature and were either also using `tracing-reporting` or not handling error
2323
reporting at all.
2424

25+
### Logins
26+
* Opened count method on logins for Android. ([#7207](https://github.com/mozilla/application-services/pull/7207/))
27+
28+
### Autofill
29+
* Added count methods for credit cards and addresses. ([#7207](https://github.com/mozilla/application-services/pull/7207/))
30+
2531
## ✨ What's New ✨
2632

2733
### Ads Client
@@ -30,6 +36,7 @@
3036
* Reset cache on context ID rotation.
3137
* Enable staging environment support for all platforms (previously feature-gated)
3238
* Temporarily disable cache invalidation on click and impression recording (will be re-enabled behind Nimbus experiment)
39+
* Enable automatic context_id rotation every 3 days
3340

3441
### Android
3542
* Upgraded Kotlin compiler from 2.2.21 to 2.3.0 ([#7183](https://github.com/mozilla/application-services/pull/7183))

Cargo.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

automation/kotlin-components-docs/generate_docs.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ echo "Generating Kotlin bindings with uniffi-bindgen..."
3131

3232
cd "$REPO_ROOT"
3333

34+
$CARGO build -p megazord
3435
$CARGO uniffi-bindgen generate --language kotlin --no-format --out-dir "$KOTLIN_DIR" "target/debug/${DLL_PREFIX}megazord${DLL_SUFFIX}"
3536

3637
# Generate documentation with increased memory

components/ads-client/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = "ads-client"
33
version = "0.1.0"
44
edition = "2021"
55
license = "MPL-2.0"
6+
exclude = ["/android"]
67

78
[features]
89
dev = []

components/ads-client/src/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ where
202202
}
203203

204204
pub fn get_context_id(&self) -> context_id::ApiResult<String> {
205-
self.context_id_component.request(0)
205+
self.context_id_component.request(3)
206206
}
207207

208208
pub fn cycle_context_id(&mut self) -> context_id::ApiResult<String> {

components/autofill/src/autofill.udl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ interface Store {
103103
[Throws=AutofillApiError]
104104
sequence<CreditCard> get_all_credit_cards();
105105

106+
[Throws=AutofillApiError]
107+
i64 count_all_credit_cards();
108+
106109
[Throws=AutofillApiError]
107110
void update_credit_card(string guid, UpdatableCreditCardFields cc);
108111

@@ -121,6 +124,9 @@ interface Store {
121124
[Throws=AutofillApiError]
122125
sequence<Address> get_all_addresses();
123126

127+
[Throws=AutofillApiError]
128+
i64 count_all_addresses();
129+
124130
[Throws=AutofillApiError]
125131
void update_address(string guid, UpdatableAddressFields a);
126132

components/autofill/src/db/addresses.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ pub(crate) fn get_all_addresses(conn: &Connection) -> Result<Vec<InternalAddress
115115
Ok(addresses)
116116
}
117117

118+
pub(crate) fn count_all_addresses(conn: &Connection) -> Result<i64> {
119+
let sql = "SELECT COUNT(*)
120+
FROM addresses_data";
121+
122+
let mut stmt = conn.prepare(sql)?;
123+
let count: i64 = stmt.query_row([], |row| row.get(0))?;
124+
Ok(count)
125+
}
126+
118127
/// Updates just the "updatable" columns - suitable for exposure as a public
119128
/// API.
120129
pub(crate) fn update_address(
@@ -404,6 +413,9 @@ mod tests {
404413
let expected_number_of_addresses = 2;
405414
assert_eq!(expected_number_of_addresses, retrieved_addresses.len());
406415

416+
let address_count = count_all_addresses(&db).expect("Should count all saved addresses");
417+
assert_eq!(expected_number_of_addresses, address_count as usize);
418+
407419
let retrieved_address_guids = [
408420
retrieved_addresses[0].guid.as_str(),
409421
retrieved_addresses[1].guid.as_str(),

components/autofill/src/db/credit_cards.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,15 @@ pub(crate) fn get_all_credit_cards(conn: &Connection) -> Result<Vec<InternalCred
119119
Ok(credit_cards)
120120
}
121121

122+
pub(crate) fn count_all_credit_cards(conn: &Connection) -> Result<i64> {
123+
let sql = "SELECT COUNT(*)
124+
FROM credit_cards_data";
125+
126+
let mut stmt = conn.prepare(sql)?;
127+
let count: i64 = stmt.query_row([], |row| row.get(0))?;
128+
Ok(count)
129+
}
130+
122131
pub fn update_credit_card(
123132
conn: &Connection,
124133
guid: &Guid,
@@ -466,6 +475,9 @@ pub(crate) mod tests {
466475
retrieved_credit_cards.len()
467476
);
468477

478+
let credit_card_count = count_all_credit_cards(&db)?;
479+
assert_eq!(expected_number_of_credit_cards, credit_card_count as usize);
480+
469481
let retrieved_credit_card_guids = [
470482
retrieved_credit_cards[0].guid.as_str(),
471483
retrieved_credit_cards[1].guid.as_str(),

components/autofill/src/db/store.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ impl Store {
9494
Ok(credit_cards)
9595
}
9696

97+
#[handle_error(Error)]
98+
pub fn count_all_credit_cards(&self) -> ApiResult<i64> {
99+
let count = credit_cards::count_all_credit_cards(&self.db.lock().unwrap().writer)?;
100+
Ok(count)
101+
}
102+
97103
#[handle_error(Error)]
98104
pub fn update_credit_card(
99105
&self,
@@ -136,6 +142,12 @@ impl Store {
136142
Ok(addresses)
137143
}
138144

145+
#[handle_error(Error)]
146+
pub fn count_all_addresses(&self) -> ApiResult<i64> {
147+
let count = addresses::count_all_addresses(&self.db.lock().unwrap().writer)?;
148+
Ok(count)
149+
}
150+
139151
#[handle_error(Error)]
140152
pub fn update_address(&self, guid: String, address: UpdatableAddressFields) -> ApiResult<()> {
141153
addresses::update_address(&self.db.lock().unwrap().writer, &Guid::new(&guid), &address)

components/logins/android/src/main/java/mozilla/appservices/logins/DatabaseLoginsStorage.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ class DatabaseLoginsStorage(dbPath: String, keyManager: KeyManager) : AutoClosea
6565
return store.list()
6666
}
6767

68+
/**
69+
* Counts the amount of logins.
70+
*
71+
* @return The number of logins.
72+
*/
73+
@Throws(LoginsApiException::class)
74+
fun count(): Long {
75+
return store.count()
76+
}
77+
6878
@Throws(LoginsApiException::class)
6979
fun hasLoginsByBaseDomain(baseDomain: String): Boolean {
7080
return store.hasLoginsByBaseDomain(baseDomain)

0 commit comments

Comments
 (0)