Commit Graph

503 Commits

Author SHA1 Message Date
Mathew Inwood
45d2c252b1 Move some members to the "Q blacklist".
Based on some analysis, these fields/methods are likely false positives.
Set maxTargetSdk=P so that any apps using them are required to migrate off
them in future. See the bug for more details.

Exempted-From-Owner-Approval: Automatic changes to the codebase
affecting only @UnsupportedAppUsage annotations, themselves added
without requiring owners approval earlier.

Bug: 115609023
Test: m
Merged-In: I719b5c94e5b1f4fa562dd5d655953422958ad37e
Change-Id: I719b5c94e5b1f4fa562dd5d655953422958ad37e
(cherry picked from commit 8c854f86a4)
2018-10-22 17:28:24 -07:00
Makoto Onuki
1fda56bbda Fix OWNERS (change google.com to android.com)
Bug: N/A
Test: N/A
Change-Id: I9a9eecfff1a72d7da55be0df73f29985b19c1e38
2018-08-24 14:58:42 -07:00
Makoto Onuki
83c1a68491 Actually make OWNERS in sync with the internal version
Bug: N/A
Test: N/A
Change-Id: Idc1dcc7753a5cf731475ae0f8f01ccd54ac0e3b3
2018-08-24 12:47:20 -07:00
Makoto Onuki
5b3c10cb28 Update OWNERS for database code
Test: N/A

Change-Id: If657f1ac87d9a9e77162816c7ac6abb719b834d4
Merged-in: If657f1ac87d9a9e77162816c7ac6abb719b834d4
2018-08-22 15:43:13 -04:00
Makoto Onuki
962f78649f Default to FULL synchronous mode for sqlite DBs in system server
Test: change pin and immediately crash the kernel with
adb shell 'su root sh -c "echo c >/proc/sysrq-trigger"' and boot
Bug: 112175067

Change-Id: Ia5f43f3118e2297fbea43c805ef2f4577bf8a9bf
(cherry picked from commit 50e00c8dc4)

Merged-in: Ia5f43f3118e2297fbea43c805ef2f4577bf8a9bf
2018-08-17 16:35:46 -07:00
Nan Zhang
eb973c97da Merge "Make SQLiteDebug @TestApi" 2018-08-17 16:53:11 +00:00
Fyodor Kupolov
6a82990b5f Make SQLiteDebug @TestApi
Otherwise, Metalava based android_test_current.jar doesn't contain
SQLiteDebug.class which caused build failure on:
out/target/common/obj/APPS/CtsDatabaseTestCases_intermediates/classes-full-debug.jar

Test: CtsDatabaseTestCases
Bug: 77543575
Change-Id: Ied9948e962fb7a81e56be0360cb94b0c318ad14d
Merged-In: Ied9948e962fb7a81e56be0360cb94b0c318ad14d
(cherry-picked from 6fe565e441)
Exempt-From-Owner-Approval: Cherry-picked a CL from git_master, and owner just agreed to use Exempt-From tag.
2018-08-17 16:32:17 +00:00
Mathew Inwood
f86bea9b42 Add @UnsupportedAppUsage annotations
For packages:
  android.database.sqlite
  android.database

This is an automatically generated CL. See go/UnsupportedAppUsage
for more details.

Exempted-From-Owner-Approval: Mechanical changes to the codebase
which have been approved by Android API council and announced on
android-eng@

Bug: 110868826
Test: m
Change-Id: I0da613d00611e89e49bf73c9ffe35700818efc6b
Merged-In: I2bcc7f0eee31a1775dd7a5dd0f291d0d37bc1292
2018-08-10 16:10:20 +01:00
Fyodor Kupolov
8ba2089165 New behavior of setSynchronousMode
setSynchronousMode is now applicable to any journal mode.
This can be useful for apps that want to use stricter durability
settings for their database.

Test: android.database.sqlite.cts.SQLiteDatabaseTest
Bug: 86953240
Change-Id: I7dbaa6d0bc0975da8067e87b402f63f51b4add10
2018-06-01 12:11:42 -07:00
Joshua Baxter
b3c20232f1 docs: fixed typo
am: 3639e2f929

Change-Id: I6f7381045bb25fdcc9f86e3e2dd0d7b8c4eda853
2018-03-27 17:34:53 +00:00
Joshua Baxter
3639e2f929 docs: fixed typo
Test: make ds-docs

Bug: 36941741

Change-Id: I451d8095bcc5d30dbefe3503441d718a69d821ca
2018-03-26 18:17:08 -07:00
Fyodor Kupolov
681ec3128e Include additional information in the dumpsys
Test: adb shell dumpsys dbinfo system
Bug: 64262688
Change-Id: I43d76e505e4d5598994c9af3e615c572017f120c
2018-03-20 18:50:07 -07:00
Fyodor Kupolov
692573b1b2 Introduced DISABLE_COMPATIBILITY_WAL flag
If set, Compatibility WAL will not be used.
Currently this flag is set if SQLiteOpenHelper.setWriteAheadLogging(false)
is called before opening the database. Previously this call was ignored
since ENABLE_WRITE_AHEAD_LOGGING flag is only set when setWriteAheadLogging(true)

Test: CtsDatabaseTestCases
Bug: 74116447
Change-Id: Ic486e178b9da5d747840be739303a2685b91f35b
2018-03-06 13:31:30 -08:00
Fyodor Kupolov
ab05b143ba Added SQLiteOpenHelper.setOpenParams
Using the new constructor can be difficult as it requires an app to
make a decision which version of constructor to use before instantiating
the object. By adding setOpenParams method, apps can keep the old
structure of the code and only add API level check after instantiating
a helper object.

Test: SQLiteOpenHelperTest
Bug: 70863722
Change-Id: I1705dd790e3549d0d8e75eb33b1d9b5bdadcb3c9
2018-02-12 15:33:13 -08:00
Andreas Gampe
3f24e69dbe Frameworks: Annotate trivial @GuardedBy in core/java
Add @GuardedBy for simple functions that require a single lock
and are named XYZLocked.

Bug: 73000847
Test: m
Test: m javac-check-framework RUN_ERROR_PRONE=true
Change-Id: Icb5114fea2ff2385e1cc7511121026099e05c0ee
2018-02-08 02:19:42 -08:00
Fyodor Kupolov
a17858d072 Merge "Fix JavaDoc for enableWriteAheadLogging" 2018-02-07 01:51:57 +00:00
Jeff Sharkey
ad357d1839 Pass in the user defined by Context.
The majority of Manager-style classes already use Context.getUserId()
when making calls into the OS, so clean up the remaining callers to
unify behind this strategy.

This gives @SystemApi developers a nice clean interface to interact
across user boundaries, instead of manually adding "AsUser" or
"ForUser" method variants, which would quickly become unsustainable.

Test: builds, boots
Bug: 72863821
Exempt-From-Owner-Approval: trivial changes
Change-Id: Ib772ec4438e57a2ad4950821b9432f9842998451
2018-02-03 02:11:45 +00:00
Fyodor Kupolov
4b5c35984c Fix JavaDoc for enableWriteAheadLogging
Test: build
Bug: 65206410
Bug: 64262688
Change-Id: I92e27b048ae8717c5007ac39d6a6de7b59dc7072
2018-02-02 14:57:50 -08:00
Chris Craik
0834e3561e @FastNative for CursorWindow
Test: adb install -r $OUT/data/app/CorePerfTests/CorePerfTests.apk && adb shell cmd package compile -m speed -f com.android.perftests.core && adb shell am instrument -w -e class android.database.CursorWindowPerfTest com.android.perftests.core/android.support.test.runner.AndroidJUnitRunner

Change-Id: I4d2f8846592426b993ca44a187ac0e2de7313170
2018-01-26 15:03:49 -08:00
Fyodor Kupolov
2abd2a4976 Clarify usage of context in the JavaDoc
The context is only used for resolving database paths.

Test: build
Bug: 70863722
Change-Id: I675dcd35da9d73b57dbd0bf3e357bfffdf485168
2018-01-18 01:39:10 +00:00
Fyodor Kupolov
7fcd659705 Enabled SQLiteCompatibilityWalFlags class
In system_server, it should be deactivated until InstallSystemProviders
is finished.

Test: SQLiteCompatibilityWalFlagsTest
Test: setting put global ... + verify that dumpsys dbinfo has the new flag
Bug: 70226732
Bug: 70517616
Change-Id: Iec6a5e61a5d7e4cc0ac602f2b630357c54bb4456
2017-12-15 17:34:52 -08:00
Fyodor Kupolov
ee90c03fe7 Added compatibility WAL flags for Global.Settings
Added Settings.Global.SQLITE_COMPATIBILITY_WAL_FLAGS -
configuration flags for SQLite Compatibility WAL. Encoded as a key-value
list, separated by commas. E.g.:
compatibility_wal_supported=true, wal_syncmode=OFF

SQLiteCompatibilityWalFlags caches the value of
SQLITE_COMPATIBILITY_WAL_FLAGS on first access and keeps it through
the lifetime of the process for consistent behavior across all
connections.

Test: SQLiteCompatibilityWalFlagsTest
Test: setting put global ... + verify that dumpsys dbinfo has the new flag
Bug: 70226732
Bug: 70517616
Change-Id: Ifacbf5908c83351ebe5dea676eeb716af039fb14
2017-12-14 12:21:27 -08:00
Fyodor Kupolov
f0d4810026 Added database package OWNERS
Test: N/A
Change-Id: I30993e7e20265b88d2cda246155fde50081866cb
2017-11-28 14:14:37 -08:00
Fyodor Kupolov
25095c0802 Close available secondary connections if schema changes
If DDL statement is executed on one connection, the schema change is
not always visible to other connections due to sqlite3_column_count()
API limitation. We have to close secondary connections to prevent the
issue.

Test: cts/SQLiteOpenHelperTest
Bug: 33695159
Change-Id: I862da71ecec5b1edc880dbfadf22efb2274ca10a
2017-11-17 15:22:20 -08:00
TreeHugger Robot
3c31b2f32a Merge "Allow null context in the constructor" 2017-11-16 02:52:31 +00:00
Fyodor Kupolov
9d4c3d9a50 Allow null context in the constructor
Legacy apps can use it for in-memory databases.

Test: manual
Bug:69379861
Change-Id: I989524c38d6e2ea3b2637bbe6534f2906c5b7bb6
2017-11-15 16:04:24 -08:00
TreeHugger Robot
b0ce0a8209 Merge "Fixed typo in MergeCursor" 2017-11-15 19:45:37 +00:00
Fyodor Kupolov
5c4b623d54 Fixed typo in MergeCursor
Test: n/a
Bug: 68247902
Change-Id: I484d3aa23415769b205635908f7d73d8113d866b
2017-11-15 00:05:04 +00:00
Fyodor Kupolov
d3fe8f09c8 Merge "Apps can now specify journal/synchronous mode" 2017-11-14 17:53:06 +00:00
Kevin Hufnagle
0dd496b455 Merge "Merge "docs: Added SQLite versions used on API levels 26 and 27." into oc-mr1-dev am: 9e628b60ba" into oc-mr1-dev-plus-aosp
am: be8f36d844

Change-Id: I1f64688b30ce70b66a2f07bc47fd199dc1e3dcb0
2017-11-10 17:32:10 +00:00
Kevin Hufnagle
5dfdfa0a14 docs: Added SQLite versions used on API levels 26 and 27.
The android.database.sqlite package summary page now mentions the
versions of SQLite that are available on Android devices running Oreo
(API level 26) and API level 27.

Test: make ds-docs -j16

Bug: 69106585
Change-Id: I77a323c58343fa978ade5397d613566ba25f00c2
2017-11-09 10:12:50 -08:00
Fyodor Kupolov
13a4b37e87 Apps can now specify journal/synchronous mode
Added setJournalMode/setSynchronousMode. These methods control
journal/syncrhonous mode when ENABLE_WRITE_AHEAD_LOGGING flag is not set

Bug: 33044236
Test: manual + CtsDatabaseTestCases
Change-Id: Iffef75f6941030aae5ab3e239cd65550515f5fe0
2017-11-08 16:13:40 -08:00
Fyodor Kupolov
fd22a196a6 Update wal mode of the connection when disabling WAL
Previously calling disableWriteAheadLogging wasn't updating
journal mode of the primary connection.

Test: manual + SQLiteDatabaseTest cts
Bug: 33044236
Change-Id: Ifd105dacdd10ef59b10a023aba0cc43fbb1bba97
2017-11-06 15:08:59 -08:00
TreeHugger Robot
01f5db7240 Merge "Added setFillWindowForwardOnly" 2017-11-02 02:10:46 +00:00
Fyodor Kupolov
41cadb7d31 Added setFillWindowForwardOnly
It controls fetching of rows relative to requested position

Test: SQLiteCursorTest
Bug: 62550963
Change-Id: Iab651d8e3d689710b0436650c58dab86b119e296
2017-11-01 14:38:15 -07:00
Fyodor Kupolov
5bd43ad2e7 Initial version of compatibility WAL
In this mode, only database journal mode will be changed, connection pool
size will still be limited to a single connection.

If enabled, compatibility WAL mode will be used if an app hasn't explicitly
 requested journal mode, by calling disable/enableWriteAheadLogging.

Compatibility WAL mode is controlled by debug.sqlite.use_compatibility_wal
property and db_use_compatibility_wal config resource.

Impact on write performance:
On ext4, with WAL, there is approx 300% increase in speed of update operations
On f2fs, with WAL, there is approx 5% increase in speed of update operations

Impact on number of writes:
On ext4, switching to WAL reduces the number of writes by approx 50%.
On f2fs, switching to WAL increases the number of writes by approx 15%.

Test: CtsDatabaseTestCases
Test: manual, running device
Bug: 33044236
Change-Id: Iaffb5651df39d8c9f710d7dbbe174f9c0d8a3186
2017-10-26 11:21:19 -07:00
Fyodor Kupolov
6bb32a9a8b Allow creating CursorWindow of custom size
The default size is controlled by config_cursorWindowSize.

Test: SQLiteCursorTest
Bug: 62550963
Change-Id: Ic5c6550b2dd53401afc039ec257524a98bf2950e
2017-10-17 15:22:11 -07:00
Fyodor Kupolov
76dd22ff1e Dump total execution time per connection pool
Test: dumpsys dbinfo system
Bug: 64262688
Change-Id: I3e094240a2fdb27089b90a78a0dc26822e3c66e8
2017-09-18 14:33:16 -07:00
Fyodor Kupolov
28e49b7eed Merge "Allow using SQLiteGlobal for testing" into oc-mr1-dev am: 347eaf21fa
am: ac6d9d3173

Change-Id: I0819f276018c9c9d50fe51c834c6356dad02c87e
2017-09-08 00:43:44 +00:00
Fyodor Kupolov
347eaf21fa Merge "Allow using SQLiteGlobal for testing" into oc-mr1-dev 2017-09-08 00:13:51 +00:00
Fyodor Kupolov
5d53e4477f Allow using SQLiteGlobal for testing
Test: android.database.sqlite.cts.SQLiteOpenHelperTest
Bug: 63398887
Change-Id: Ic636d672a78c7b770a964bdf17c19c8ccfb6c7eb
2017-09-01 18:33:37 -07:00
Fyodor Kupolov
a816016de4 Merge "Do not close idle connections by default" into oc-mr1-dev am: 6f8afdc501
am: eb952ab3d0

Change-Id: I5b4583fc8d663afe87cdc79b32536e85a29756cd
2017-09-01 18:01:07 +00:00
Fyodor Kupolov
5356729953 Do not close idle connections by default
Otherwise it can cause issues in apps depending on transient state.

Test: manual
Bug: 63398887
Bug: 65220630
Change-Id: I0806693e05e2e61035aee0b108e31f8bcc8b1a0b
2017-08-30 18:16:31 -07:00
Fyodor Kupolov
24929cd4e4 Distinguish ROLLBACK from ROLLBACK TO
The former aborts the current transaction, the latter restores the
state to a specified savepoint.

Test: CtsDatabaseTestCases
Test: DatabaseGeneralTest
Bug: 36957161
Change-Id: Ia0b189e8aac4687f10d8fbc07143a452f5f719c9
2017-08-28 17:02:37 -07:00
Fyodor Kupolov
2c7e249b84 Keep close_idle_connections optimization for all devices
Internal compatibility testing didn't reveal any issues related to it.

Rationale to not make it specific to low-ram:
1) Consistent behavior from app perspective. close_idle_connections
   is a behavioural change and may affect apps relying on undocumented
   behavior of connection pooling. Developers can detect problems
   without testing on low-ram device
2) Closing idle connections is especially important in WAL mode.
   Disabling this feature would become an issue if more apps are
   switching to WAL and we would need to re-enable this optimization.

Test: n/a
Bug: 63398887
Change-Id: I1b431f44daa2d337aad7f12f8e1409ae3143ded0
2017-08-23 16:36:15 -07:00
Fyodor Kupolov
45be5633e9 Make SQLiteDirectCursorDriver @TestApi
Test: cts/SQLiteDatabaseTest+SQLiteOpenHelperTest
Bug: 64228388
Change-Id: Ic711069cfdc7df1affaecf26a3d01539f1a8e821
2017-08-08 16:55:03 -07:00
Fyodor Kupolov
76436c04a4 API Review update for SQLiteDatabase
SQLiteDatabase openDatabase -- should take File for first parameter
  instead of a String path

SQLiteDatabase.OpenParams.Builder -- make sure the javadocs says what
  the default openFlags is and default idle connection timeout

SQLiteDatabase createInMemory -- throw if it has trouble instead of
  returning null.

Test: cts/SQLiteDatabaseTest
Bug: 64331777
Bug: 64331778
Bug: 64330914

Change-Id: Ibecf4f4a6498795f9a5d12b94b77481e5745b523
2017-08-07 11:12:38 -07:00
TreeHugger Robot
2729912a35 Merge "List column names in the error message" into oc-mr1-dev 2017-08-01 00:36:49 +00:00
Fyodor Kupolov
82f289a4b4 Merge "Added setIdleConnectionTimeout method" into oc-mr1-dev 2017-07-31 23:56:02 +00:00
Fyodor Kupolov
cf97b6b7f7 Added setIdleConnectionTimeout method
It allows apps to set time SQLite connection is allowed to be idle
before it is closed and removed from the pool.

Test: manual + DatabaseGeneralTest
Bug: 63398887
Change-Id: Ie09eeb4dc2b9e52ba67d9355b1f9bd869b148613
2017-07-31 11:05:57 -07:00