Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 16e37cba authored by Marvin W.'s avatar Marvin W. 🐿️
Browse files

Location: Various improvements, add support for local location learning

parent 470ef55c
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -152,12 +152,16 @@ object SettingsContract {

        const val WIFI_MLS = "location_wifi_mls"
        const val WIFI_MOVING = "location_wifi_moving"
        const val WIFI_LEARNING = "location_wifi_learning"
        const val CELL_MLS = "location_cell_mls"
        const val CELL_LEARNING = "location_cell_learning"

        val PROJECTION = arrayOf(
            WIFI_MLS,
            WIFI_MOVING,
            CELL_MLS
            WIFI_LEARNING,
            CELL_MLS,
            CELL_LEARNING,
        )
    }

+4 −0
Original line number Diff line number Diff line
@@ -295,7 +295,9 @@ class SettingsProvider : ContentProvider() {
        when (key) {
            Location.WIFI_MLS -> getSettingsBoolean(key, true)
            Location.WIFI_MOVING -> getSettingsBoolean(key, true)
            Location.WIFI_LEARNING -> getSettingsBoolean(key, true)
            Location.CELL_MLS -> getSettingsBoolean(key, true)
            Location.CELL_LEARNING -> getSettingsBoolean(key, true)
            else -> throw IllegalArgumentException("Unknown key: $key")
        }
    }
@@ -307,7 +309,9 @@ class SettingsProvider : ContentProvider() {
            when (key) {
                Location.WIFI_MLS -> editor.putBoolean(key, value as Boolean)
                Location.WIFI_MOVING -> editor.putBoolean(key, value as Boolean)
                Location.WIFI_LEARNING -> editor.putBoolean(key, value as Boolean)
                Location.CELL_MLS -> editor.putBoolean(key, value as Boolean)
                Location.CELL_LEARNING -> editor.putBoolean(key, value as Boolean)
                else -> throw IllegalArgumentException("Unknown key: $key")
            }
        }
+16 −0
Original line number Diff line number Diff line
@@ -25,6 +25,14 @@ class LocationSettings(private val context: Context) {
            SettingsContract.setSettings(context, SettingsContract.Location.getContentUri(context)) { put(SettingsContract.Location.WIFI_MOVING, value)}
        }

    var wifiLearning: Boolean
        get() = SettingsContract.getSettings(context, SettingsContract.Location.getContentUri(context), arrayOf(SettingsContract.Location.WIFI_LEARNING)) { c ->
            c.getInt(0) != 0
        }
        set(value) {
            SettingsContract.setSettings(context, SettingsContract.Location.getContentUri(context)) { put(SettingsContract.Location.WIFI_LEARNING, value)}
        }

    var cellMls : Boolean
        get() = SettingsContract.getSettings(context, SettingsContract.Location.getContentUri(context), arrayOf(SettingsContract.Location.CELL_MLS)) { c ->
            c.getInt(0) != 0
@@ -32,4 +40,12 @@ class LocationSettings(private val context: Context) {
        set(value) {
            SettingsContract.setSettings(context, SettingsContract.Location.getContentUri(context)) { put(SettingsContract.Location.CELL_MLS, value)}
        }

    var cellLearning: Boolean
        get() = SettingsContract.getSettings(context, SettingsContract.Location.getContentUri(context), arrayOf(SettingsContract.Location.CELL_LEARNING)) { c ->
            c.getInt(0) != 0
        }
        set(value) {
            SettingsContract.setSettings(context, SettingsContract.Location.getContentUri(context)) { put(SettingsContract.Location.CELL_LEARNING, value)}
        }
}
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ internal val FEATURES = arrayOf(
    Feature("use_safe_parcelable_in_intents", 1)
)

internal fun Long.formatRealtime(): CharSequence = DateUtils.getRelativeTimeSpanString((this - SystemClock.elapsedRealtime()) + System.currentTimeMillis(), System.currentTimeMillis(), 0)
internal fun Long.formatRealtime(): CharSequence = if (this <= 0) "n/a" else DateUtils.getRelativeTimeSpanString((this - SystemClock.elapsedRealtime()) + System.currentTimeMillis(), System.currentTimeMillis(), 0)
internal fun Long.formatDuration(): CharSequence {
    if (this == 0L) return "0ms"
    if (this > 315360000000L /* ten years */) return "\u221e"
+0 −1
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@ class LocationAppsDatabase(context: Context) : SQLiteOpenHelper(context, "geoapp

    fun noteAppLocation(packageName: String, location: Location?) {
        noteAppUsage(packageName)
        Log.d(TAG, "Note app $packageName @ $location")
        if (location == null) return
        val values = contentValuesOf(
            FIELD_PACKAGE to packageName,
Loading