Commit Graph

578 Commits

Author SHA1 Message Date
Jeff Sharkey
0ab6feb7c8 People might want GROUP_CONCAT.
Bug: 129890881
Test: none
Change-Id: I24b6cc3c65e7a25b34c57f17584ba75c40be38ab
2019-04-10 10:27:19 -06:00
Makoto Onuki
58d5470580 Change ISE to AssertException, which is more suitable.
Bug: 129139241
Bug: 129721058
Test: Treehugger
Change-Id: I12e97f37a58e1d88731a9bddd933abeb8c1169c1
2019-04-04 13:42:47 -07:00
Makoto Onuki
2276ceacb3 Improve CursorWindow failure message
Bug: 129139241
Bug: 129721058
Test: atest CursorWindowTest
Change-Id: Iac1c5ec6f999dadd638fc5ab47c69d13f60ea467
2019-04-03 16:01:33 +00:00
Jeff Sharkey
82d783c417 Support optional use of aggregation functions.
As long as the column being aggregated is valid with respect to
all existing projection checks, then we're willing to apply an
aggregation function on it.

Bug: 129220616
Test: atest --test-mapping packages/providers/MediaProvider
Change-Id: I8e4b665f5abd6553939a35d9f46247cc63c4c25f
2019-03-29 15:46:38 -06:00
Anton Hansson
a04d81ef47 Make TranslatingCursor deal with dupe column names
TranslatingCursor previously assumed each column name appeared
only once in the base cursor and used getColumIndex(String) to
find the index of it. It would then translate only that single
index.

Instead, maintain a set of column indices that need translating.

Also add a unit test.

Bug: 125467331
Test: atest FrameworksCoreTests:TranslatingCursorTest
Test: verified broken app in bug report is working correctly
Change-Id: I33a24bf6474338210ec7b9c6b54912ed49f23cb3
2019-03-27 17:29:59 +00:00
Jeff Sharkey
aa28dff4cb Respond to API council feedback.
Naming tweaks and hide API that should move to androidx.

Bug: 128427993
Test: none
Change-Id: Ic54452fdedbe72e5fa71897cc2b22e9598664c02
2019-03-25 18:01:10 -06:00
Makoto Onuki
55e9970511 Disable DB wipe check
We stopped using WAL, so let's just disable it

Change-Id: I14f4f3ca6521db12a2fbde8c20122bb4b2cc8186
Fix: 118613196
Test: Manual test with removing DB files
2019-03-19 14:04:56 -07:00
Makoto Onuki
42f353eb28 Merge "Update the deprecation description per API review" 2019-03-01 23:56:57 +00:00
Makoto Onuki
1a904797b9 Update the deprecation description per API review
Change-Id: If79ed1263aae5fc7db6e951051ebb6db20d971f5
Fix: 124882352
Test: build (tree hugger)
2019-03-01 13:34:30 -08:00
Jeff Sharkey
9e8f83db6d All Parcelable CREATOR fields are @NonNull.
If they were null, then the Parcelable would fail to work.

Bug: 126726802
Test: manual
Change-Id: I7929ffa2f20e5de1c8e68e8263cca99496e9d014
Exempt-From-Owner-Approval: Trivial API annotations
2019-02-28 23:29:04 -07:00
Jeff Sharkey
a30e5c389f To be @Nullable or @NonNull, that is the question.
Bug: 126699288, 126699496, 126700389
Bug: 126700085, 126701638, 126702005, 126700497
Test: manual
Change-Id: Idcbc2722ddcf014a9e5cef14321b4e2ce30adf9c
2019-03-01 06:26:39 +00:00
Sudheer Shanka
d5f4165e97 Merge "Address API feedback." 2019-02-28 23:24:45 +00:00
Sudheer Shanka
0f6069e666 Address API feedback.
Fixes: 126699828
Fixes: 126700458
Fixes: 126702364
Test: n/a
Change-Id: I20d415ee4fdcce97054f3b68986a65500e64fb2d
2019-02-28 12:18:11 -08:00
Andrei-Valentin Onea
94bd7aac42 Merge "Add @UnsupportedAppUsage annotations" 2019-02-28 15:21:13 +00:00
Andrei Onea
da6e570f1e Add @UnsupportedAppUsage annotations
For packages:
  android.database
  android.hardware
  android.hardware.display
  android.hardware.input
  android.hardware.location
  android.location
  android.media
  android.media.tv
  android.media.projection

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: I570c08292f8a9f512c96f9dce13f5337718f112c
2019-02-27 13:31:11 +00:00
Narayan Kamath
b8280438d8 Drop support for device configurable "compatibility WAL".
WAL as a journaling mode is no longer configurable on a
per-device basis. We preserve support for changing this value
via phenotype for now, but this will likely be removed in a
follow up once this change has been vetted.

Test: atest FrameworksCoreTests:android.database
Test: atest CtsDatabaseTestCases
Bug: 123352172
Change-Id: I163bad836b71770946ce12a8bfd19f362033ea83
2019-02-25 13:00:14 +00:00
Jeff Sharkey
b91eaa54a8 Respond to various API council feedback.
Handle many simple, smaller changes in a single CL.  Hide
CPC.closeQuietly(), now that it implements AutoCloseable.  Add more
details to CR.set/getCache() docs.  Add many @Nullable/@NonNull
annotations.

Bug: 124507578, 124447751, 124302519, 123697622
Bug: 123661322, 122887179, 122528742, 122527812, 116224797
Test: manual
Change-Id: Icee556a6ed76bbdf4c8e42b59d69d5580d461b95
2019-02-19 11:09:22 -07:00
Jeff Sharkey
0ec586b9d5 Add accessor methods to aid testing.
If you can set things, you should be able to read them back.

Bug: 123601452
Test: manual
Change-Id: I3a842aa873f96872581ec49523e9a3cc1d7dbb50
2019-02-14 15:29:28 -07:00
Makoto Onuki
7a8261dce2 Better handling of DB corruption in SQLiteDatabase.open()
Bug: 123750718
Test: manual test with test code
Change-Id: I80a9d35f7ad6589b3de0a506780cfe956295dcda
2019-02-01 12:54:55 -08:00
Makoto Onuki
b15186c35f Deprecate SQLite connection timeout
Fix: 121151846
Test: build
Change-Id: I85766d90857f2f9c2459a60d6ba714e39ce12bda
2019-01-28 14:50:50 -08:00
Sudheer Shanka
a07b052eb4 Add Cursor.{set,get}NotificationUris.
Bug: 120879205
Test: manual
Test: atest cts/tests/tests/database/src/android/database/cts/AbstractCursorTest.java
Change-Id: If3be228dc6b08ea58d24c9209822f9d8c2348082
2019-01-26 11:19:34 -08:00
Sudheer Shanka
a35e36d5e6 Query MediaProvider for possibly stale columns in DownloadProvider.
Some of the downloads columns data in DownloadProvider could possibly stale.
When these columns gets queried from DownloadProvider, DownloadProvider
will query internally query MediaProvider and serve those values.

Bug: 120876251
Test: atest DownloadProviderTests
Test: atest cts/tests/app/src/android/app/cts/DownloadManagerTest.java
Test: atest MediaProviderTests
Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore*

Change-Id: I4f8823e75c3a5c737ebe571ea930e5d4c578197f
2019-01-07 15:04:55 -08:00
Mathew Inwood
31755f94e1 Limit access to suspected false positives.
Members modified herein are suspected to be false positives: i.e. things
that were added to the greylist in P, but subsequent data analysis
suggests that they are not, in fact, used after all.

Add a maxTargetSdk=P to these APIs. This is lower-risk that simply
removing these things from the greylist, as none of out data sources are
perfect nor complete.

For APIs that are not supported yet by annotations, move them to
hiddenapi-greylist-max-p.txt instead which has the same effect.

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

Bug: 115609023
Test: m
Change-Id: I020a9c09672ebcae64c5357abc4993e07e744687
2018-12-28 11:50:04 +00:00
Adrian Roos
66f859135b API: Clean up redundant and ineffective usages of SystemApi and TestApi
Everything that is marked SystemApi or TestApi, but not @hide is still
part of the public SDK, it is therefore not sound to have that combination.

In the future, specifing such a combination will be considered an error
to prevent inadvertently exposing SystemApi and TestApi as public API.

Bug: 115333477
Change-Id: Ibd5d6a22862fdbc1e20a1cb3925280f5a682edea
Test: METALAVA_PREPEND_ARGS="--error UnhiddenSystemApi" m checkapi
Exempt-From-Owner-Approval: API cleanup
2018-12-11 20:38:02 +01:00
Sudheer Shanka
d5db03df1f Move TranslatingCursor to frameworks/base.
so that it can be used by DownloadProvider as well.

Also, override getColumnNames() as well since this is
what is effectively used for getting the column count.

Bug: 111890351
Test: atest MediaProviderTests
Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore*
Change-Id: I336729c321614d923a31521379896ce1b88ad6b0
2018-11-16 14:37:41 -08:00
Makoto Onuki
ee93ad28ff DB Wipe detection
- Create a check file for each database in order to detect
1) an unexpected DB file removal
2) DB wipe caused by a DB corruption.

- Either case, do a WTF to collect information on APR.

- Also print file timestamps in "dumpsys dbinfo". Example:

=====================
Database files in /data/system:
  locksettings.db                            20480b ctime=2018-10-23T22:48:35Z mtime=2018-10-23T22:48:35Z atime=2018-10-23T18:54:12Z
  locksettings.db-wipecheck                      0b ctime=2018-10-23T18:54:12Z mtime=2018-10-23T18:54:12Z atime=2018-10-23T18:54:12Z
  notification_log.db                        45056b ctime=2018-10-23T22:48:08Z mtime=2018-10-23T22:48:08Z atime=2018-10-23T18:54:13Z
    :
=====================

Change-Id: I77fbeb0bb635c787aba797412f116475fecbe41c
Fixes: 117886381
Test: manual test

Test 1: corruption
1. Stop CP2 process (adb shell killall android.process.acore)
2. shell 'echo abc > /data/user/0/com.android.providers.contacts/databases/contacts2.db'
3. Launch the contacts app.

Test 2: Unexpected file removal
1. Stop CP2 process (adb shell killall android.process.acore)
2. shell 'rm -f /data/user/0/com.android.providers.contacts/databases/contacts2.db'
3. Launch the contacts app.

In both cases, logcat shows a client side stacktrace and also a WTF. (am_wtf)
2018-10-24 08:34:04 -07:00
kopriva
b0353c56e0 docs: fixing errors found with lint checker am: 219f7dcb66
am: 003587b9a4

Change-Id: I056261f069ed679ed8a03bfc0791bfe59a405361
2018-10-10 19:41:15 -07:00
kopriva
003587b9a4 docs: fixing errors found with lint checker
am: 219f7dcb66

Change-Id: Id38a4b2e21285d5d5e2a2124d76885febd3441c6
2018-10-09 18:30:57 -07:00
kopriva
219f7dcb66 docs: fixing errors found with lint checker
through /bluetooth directory

amending through /content directory

Test: make ds-docs

Bug: 117494359

Change-Id: I751e15d60f0b9cc441998b27560050bf62994fef
Exempt-From-Owner-Approval: Docs-only change
2018-10-09 16:01:04 -07:00
kopriva
5b866cfd2a Merge "docs: fix bug 37054309, becuase typo" into pi-dev am: 9359f3683c
am: e052af447d

Change-Id: Iac54fec0d8cd2729ea31ea1a2d139d74d1a78cb0
2018-09-27 13:34:02 -07:00
kopriva
e052af447d Merge "docs: fix bug 37054309, becuase typo" into pi-dev
am: 9359f3683c

Change-Id: I8ba3e3bd1d6aa296f216343d78cc252385ba64ba
2018-09-27 13:24:29 -07:00
TreeHugger Robot
9359f3683c Merge "docs: fix bug 37054309, becuase typo" into pi-dev 2018-09-27 20:03:29 +00:00
kopriva
7364c11185 docs: fix bug 37054309, becuase typo
Test: make ds-docs

Bug: 37054309

Change-Id: I726ed84d62df4036cc274c48ae2f6968f2b7cc3f
Exempt-From-Owner-Approval: Docs-only change
2018-09-27 11:02:07 -07:00
Makoto Onuki
dd5e4bac40 Merge "Truncate(*1) it if WAL file is too big when opening DB" into pi-dev
am: 0f88f865bd

Change-Id: Ie14cea16f9cf89793a499a1b7c491ebc2f8a8829
2018-09-25 08:27:48 -07:00
Makoto Onuki
0939c5a2b3 Truncate(*1) it if WAL file is too big when opening DB
*1 -- not truncate(2) but "PRAGMA wal_checkpoint(TRUNCATE)"

Otherwise, depending on how an app operate on a DB, SQLite may not
have a chance to "shrink" the WAL file.

Fixes: 112777941
Bug: 111939259
Test: atest /android/master/frameworks/base/core/tests/coretests/src/android/database/sqlite/SQLiteCompatibilityWalFlagsTest.java
Test: Manual test with google dailer:
1. With normalized_spam.db-wal > 100MB and receive a phone call
-> WAL file gets truncated to 0 bytes.

2. Restart the dialer process and receive a phone call again
-> WAL file is already 0 bytes; won't be truncated.

3. Restart with the WAL file deleted
Same as #2. WAL file will be created before the added logic, but is 0 bytes,
so it won't be truncated.

4. Test with settings put global sqlite_compatibility_wal_flags truncate_size=1024
-> make sure the threshold is overridden

Merged-in: I2b193603e5dfa493ccccb8123db592f0e9c0e7ae
Change-Id: I2b193603e5dfa493ccccb8123db592f0e9c0e7ae
(cherry picked from commit 96e06002ed)
2018-09-24 22:47:02 +00:00
Jeff Sharkey
34e3e68375 Merge "Mark deprecated APIs, support column greylisting." 2018-09-14 18:38:15 +00:00
Mathew Inwood
db0657a4f4 Merge "Move some members to the "Q blacklist"." 2018-09-14 13:54:28 +00:00
Mathew Inwood
8c854f86a4 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
Change-Id: I719b5c94e5b1f4fa562dd5d655953422958ad37e
2018-09-14 13:18:34 +01:00
Jeff Sharkey
7049e651fa Mark deprecated APIs, support column greylisting.
Update MediaStore APIs that are effectively no-ops, including
MiniThumbFile which is no longer used.

Add support for "greylisted" columns to SQLiteQueryBuilder, so that
we can support abusive columns that match specific regex patterns
while in "strict" mode, such as COUNT(*).

Bug: 111268862
Test: atest MediaProviderTests
Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore*
Change-Id: I364ef5bfa338ef8492b0b29c2a5c13c4189467ee
2018-09-13 17:14:27 -06:00
Jeff Sharkey
ec5f7d1625 Support more createPackageContextAsUser() users.
We created this API to make it easy to pass a given UserHandle into
all Managers obtained from a given Context, which works great for
"normal" users, but we should also support special users like ALL
and CURRENT.

Also add an AutoCloseable marker to make try-with-resources easier.

Bug: 112153259
Test: atest android.content.cts.ContextTest
Change-Id: I261dfcc5cfdfc76bda5d70181785e11c2715a558
2018-09-12 14:02:11 -06:00
Makoto Onuki
eb932592ad Add test API for sqlite CTS
Test: CtsDatabaseTestCases
Bug: 112777941
Bug: 111939259
Change-Id: Ibd394aa801ddfbb383acb9ae73c2029b47965f83
2018-08-27 12:14:05 -07:00
Makoto Onuki
efa01c37b7 Merge "Fix OWNERS (change google.com to android.com)" am: 7a8e363c0b am: 906a31f49f
am: 8fd96af2b1

Change-Id: Ibe5b3d6bf9d11fce9d091eb3e3872b6cd9e66afc
2018-08-25 23:33:02 -07:00
Makoto Onuki
8fd96af2b1 Merge "Fix OWNERS (change google.com to android.com)" am: 7a8e363c0b
am: 906a31f49f

Change-Id: Ie5089669974c9e9e9c99525c50eddaef6f479874
2018-08-25 23:23:37 -07:00
Makoto Onuki
d52f363924 Merge "Actually make OWNERS in sync with the internal version" am: 7e54042f9c
am: 83c37379da

Change-Id: I1bbd7ccc7b610d9cbdcf9f7f8f52b734679766cd
2018-08-24 15:17:22 -07:00
Makoto Onuki
96e06002ed Truncate(*1) it if WAL file is too big when opening DB
*1 -- not truncate(2) but "PRAGMA wal_checkpoint(TRUNCATE)"

Otherwise, depending on how an app operate on a DB, SQLite may not
have a chance to "shrink" the WAL file.

Fixes: 112777941
Bug: 111939259
Test: atest /android/master/frameworks/base/core/tests/coretests/src/android/database/sqlite/SQLiteCompatibilityWalFlagsTest.java
Test: Manual test with google dailer:
1. With normalized_spam.db-wal > 100MB and receive a phone call
-> WAL file gets truncated to 0 bytes.

2. Restart the dialer process and receive a phone call again
-> WAL file is already 0 bytes; won't be truncated.

3. Restart with the WAL file deleted
Same as #2. WAL file will be created before the added logic, but is 0 bytes,
so it won't be truncated.

4. Test with settings put global sqlite_compatibility_wal_flags truncate_size=1024
-> make sure the threshold is overridden

Change-Id: I2b193603e5dfa493ccccb8123db592f0e9c0e7ae
2018-08-24 15:07:21 -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
49a46611ef Merge "Update OWNERS for database code" am: aea74ff62a
am: 92732c2a25

Change-Id: I43a02b809a275df2ddbc2987f811a5f40c2a8461
2018-08-24 11:29:37 -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
2132e0814c Merge "Default to FULL synchronous mode for sqlite DBs in system server" into pi-dev
am: 30fdcbad94

Change-Id: I0f4b5f91cf0a877bc518b555abb8380487c68d31
2018-08-17 16:48:09 -07:00