Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Applications
android-components
Commits
8877e665
Commit
8877e665
authored
Oct 09, 2019
by
Michael Droettboom
Browse files
Use a single sharedPreferences object
parent
96f55389
Changes
3
Hide whitespace changes
Inline
Side-by-side
components/service/glean/src/main/java/mozilla/components/service/glean/Glean.kt
View file @
8877e665
...
...
@@ -283,7 +283,7 @@ open class GleanInternalAPI internal constructor () {
pingStorageEngine
.
clearPendingPings
()
storageEngineManager
.
clearAllStores
()
pingMaker
.
resetPing
SequenceNumbers
()
pingMaker
.
resetPing
MakerStorage
()
// This does not clear the experiments store (which isn't managed by the
// StorageEngineManager), since doing so would mean we would have to have the
...
...
components/service/glean/src/main/java/mozilla/components/service/glean/ping/PingMaker.kt
View file @
8877e665
...
...
@@ -23,18 +23,12 @@ internal class PingMaker(
)
{
private
val
logger
=
Logger
(
"glean/PingMaker"
)
private
val
objectStartTime
=
getISOTimeString
()
internal
val
sharedPreferences
Seq
:
SharedPreferences
?
by
lazy
{
internal
val
sharedPreferences
:
SharedPreferences
?
by
lazy
{
applicationContext
.
getSharedPreferences
(
this
.
javaClass
.
canonicalName
,
Context
.
MODE_PRIVATE
)
}
val
sharedPreferencesStartTimes
:
SharedPreferences
?
by
lazy
{
applicationContext
.
getSharedPreferences
(
"{this.javaClass.canonicalName}StartTimes"
,
Context
.
MODE_PRIVATE
)
}
/**
* Get the ping sequence number for a given ping. This is a
...
...
@@ -45,7 +39,7 @@ internal class PingMaker(
* @return sequence number
*/
internal
fun
getPingSeq
(
pingName
:
String
):
Int
{
sharedPreferences
Seq
?.
let
{
sharedPreferences
?.
let
{
val
key
=
"${pingName}_seq"
val
currentValue
=
it
.
getInt
(
key
,
0
)
val
editor
=
it
.
edit
()
...
...
@@ -61,10 +55,10 @@ internal class PingMaker(
}
/**
* Reset all ping sequence numbers.
* Reset all ping sequence numbers
and start times
.
*/
internal
fun
resetPing
SequenceNumbers
()
{
sharedPreferences
Seq
?.
let
{
internal
fun
resetPing
MakerStorage
()
{
sharedPreferences
?.
let
{
it
.
edit
().
clear
().
apply
()
}
}
...
...
@@ -77,7 +71,7 @@ internal class PingMaker(
* @return start time
*/
internal
fun
getPingStartTime
(
pingName
:
String
):
String
{
sharedPreferences
StartTimes
?.
let
{
sharedPreferences
?.
let
{
val
key
=
"${pingName}_start_time"
val
currentValue
=
it
.
getString
(
key
,
objectStartTime
)
!!
return
currentValue
...
...
@@ -96,7 +90,7 @@ internal class PingMaker(
* @param startTime The start time to set for the ping
*/
internal
fun
setPingStartTime
(
pingName
:
String
,
startTime
:
String
)
{
sharedPreferences
StartTimes
?.
let
{
sharedPreferences
?.
let
{
val
key
=
"${pingName}_start_time"
val
editor
=
it
.
edit
()
editor
.
putString
(
key
,
startTime
)
...
...
components/service/glean/src/test/java/mozilla/components/service/glean/ping/PingMakerTest.kt
View file @
8877e665
...
...
@@ -235,7 +235,7 @@ class PingMakerTest {
// Clear the sharedPreferences on the PingMaker so we can test that the
// numbers start at zero.
maker
.
sharedPreferences
Seq
?.
let
{
maker
.
sharedPreferences
?.
let
{
val
editor
=
it
.
edit
()
editor
.
clear
()
editor
.
apply
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment