<lambda>null1 package com.android.launcher3.model
2
3 import android.content.Context
4 import android.database.Cursor
5 import android.database.sqlite.SQLiteDatabase
6 import androidx.test.platform.app.InstrumentationRegistry
7 import java.io.BufferedReader
8 import java.io.InputStreamReader
9
10 private val All_COLUMNS =
11 arrayOf(
12 "_id",
13 "title",
14 "intent",
15 "container",
16 "screen",
17 "cellX",
18 "cellY",
19 "spanX",
20 "spanY",
21 "itemType",
22 "appWidgetId",
23 "icon",
24 "appWidgetProvider",
25 "modified",
26 "restored",
27 "profileId",
28 "rank",
29 "options",
30 "appWidgetSource"
31 )
32
33 class FactitiousDbController(context: Context, insertFile: String) : ModelDbController(context) {
34
35 val inMemoryDb: SQLiteDatabase by lazy {
36 SQLiteDatabase.createInMemory(SQLiteDatabase.OpenParams.Builder().build()).also { db ->
37 BufferedReader(
38 InputStreamReader(
39 InstrumentationRegistry.getInstrumentation().context.assets.open(insertFile)
40 )
41 )
42 .lines()
43 .forEach { sqlStatement -> db.execSQL(sqlStatement) }
44 }
45 }
46
47 override fun query(
48 table: String,
49 projection: Array<out String>?,
50 selection: String?,
51 selectionArgs: Array<out String>?,
52 sortOrder: String?
53 ): Cursor {
54 return inMemoryDb.query(table, All_COLUMNS, selection, selectionArgs, null, null, sortOrder)
55 }
56
57 override fun loadDefaultFavoritesIfNecessary() {
58 // No-Op
59 }
60 }
61