Commit Graph

84677 Commits

Author SHA1 Message Date
Jeff Sharkey
a58d6e3405 Execute "strict" queries with extra parentheses.
SQLiteQueryBuilder has a setStrict() mode which can be used to
detect SQL attacks from untrusted sources, which it does by running
each query twice: once with an extra set of parentheses, and if that
succeeds, it runs the original query verbatim.

This sadly doesn't catch inputs of the type "1=1) OR (1=1", which
creates valid statements for both tests above, but the final executed
query ends up leaking data due to SQLite operator precedence.

Instead, we need to continue compiling both variants, but we need
to execute the query with the additional parentheses to ensure
data won't be leaked.

Test: atest cts/tests/tests/database/src/android/database/sqlite/cts/SQLiteQueryBuilderTest.java
Bug: 111085900
Change-Id: Ie85a95003ae134eef2fdfbf074c2f82d0a6a9f26
2018-07-16 17:21:50 -06:00
Jeff Sharkey
99cc118423 Add support for appending standalone phrases.
When users are building queries, they often need to append several
standalone SQL clauses, and it's tedious to track their first clause
so they can manually append " AND " to each subsequent clause.

So add new appendWherePhrase() API which appends a standalone phrase
which is AND'ed together with any existing WHERE query.

Also fix bug in update() which would turn null values into the
string literal "null" instead of passing them through as SQL NULL.

Test: atest cts/tests/tests/database/src/android/database/sqlite/cts/SQLiteQueryBuilderTest.java
Bug: 111085900
Change-Id: Ia280dd864895654239503e080eaef925f5620d37
2018-07-16 14:56:03 -06:00
Jeff Sharkey
bba22006d6 GROUP BY and HAVING aren't ready to be strict.
Despite SQLite documentation saying these clauses follow the "expr"
syntax, queries will fail with obscure "row value misused" errors,
so remove the strict enforcement for now.

Test: manual
Bug: 111480817
Change-Id: Ib8cdcb4e6456110589203189fcfa14e75cd68718
2018-07-16 10:44:15 -06:00
Jeff Sharkey
162d771709 Merge "Extend SQLiteQueryBuilder for update and delete." 2018-07-14 21:35:29 +00:00
TreeHugger Robot
8abf777389 Merge "Better Handling of Battery Stats History Overflow" 2018-07-14 03:07:29 +00:00
TreeHugger Robot
672dbd5b3a Merge "Make ENABLE_COPY_OPTIMIZATIONS non final." 2018-07-14 02:08:40 +00:00
Hui Yu
0ed84f1263 Better Handling of Battery Stats History Overflow
Previously battery history is kept in the in-memory mHistoryBuffer
with size of 512KB (96KB on low memory device). When the buffer is
close to full we drop certain types of history. When the buffer is
full the whole buffer is reset and we lost elder history. On a
device with long battery life this problem is more frequent.

This CL changes mHistoryBuffer to 128KB (64KB on low memory device).
When the buffer is full, it is saved to history file on file system.
By default we allow 32 history files (64 history files on low-memory
device) which gives us 4MB history (compare to 512KB today).

The MAX_HISTORY_BUFFER and MAX_HISTORY_FILES can be remote configured
through GServices or P/H.

In case of history exceeding 4MB, the oldest history file is deleted
and new history file is open.

This change increases battery history by using disk file and the
chance of losing history is greatly reduced.

Bug: 67297625
Test: adb shell dumpsys batterystats --history
Change-Id: Id9aafea761649d7323b97d1e44135f7880a95414
2018-07-13 17:31:19 -07:00
Jeff Sharkey
6adc98c09c Extend SQLiteQueryBuilder for update and delete.
Developers often accept selection clauses from untrusted code, and
SQLiteQueryBuilder already supports a "strict" mode to help catch
SQL injection attacks.  This change extends the builder to support
update() and delete() calls, so that we can help secure those
selection clauses too.

Extend it to support selection arguments being provided when
appending appendWhere() clauses, meaning developers no longer need
to manually track their local selection arguments along with
remote arguments.

Extend it to support newer ContentProvider.query() variant that
accepts "Bundle queryArgs", and have all query() callers flow
through that common code path.  (This paves the way for a future
CL that will offer to gracefully extract non-WHERE clauses that
callers have tried smashing into their selections.)

Updates ContentValues to internally use more efficient ArrayMap.

Bug: 111268862
Test: atest frameworks/base/core/tests/utiltests/src/com/android/internal/util/ArrayUtilsTest.java
Test: atest cts/tests/tests/database/src/android/database/sqlite/cts/SQLiteQueryBuilderTest.java
Change-Id: I60b6f69045766bb28d2f21a32c120ec8c383b917
2018-07-13 18:11:37 -06:00
Shrijana Ghimire
8e63b746ba Merge "Merge "docs: Fixed typos in AdapterView Javadoc." into pi-dev am: 9ef41ccf42" into pi-dev-plus-aosp
am: 74ecab8a44

Change-Id: I676fa766b26ecfc145ed4d5dd60b1af70dc99529
2018-07-13 12:48:15 -07:00
Shrijana Ghimire
a58f9d550d Merge "docs: Fixed typos in AdapterView Javadoc." into pi-dev
am: 9ef41ccf42

Change-Id: I03291b3758127de3bfef480a6561930f5901014c
2018-07-13 12:29:55 -07:00
Shrijana Ghimire
9ef41ccf42 Merge "docs: Fixed typos in AdapterView Javadoc." into pi-dev 2018-07-13 19:03:24 +00:00
TreeHugger Robot
141d67c3a7 Merge "Pin compiled code of HOME app" 2018-07-13 15:47:19 +00:00
Julia Reynolds
b992c34510 Merge "Add notification settings to backup&restore" 2018-07-13 14:17:07 +00:00
Jorim Jaggi
402d78ebb7 Pin compiled code of HOME app
Keeping the code in memory of the currently set home app is
important for latency as we don't have any kind of starting
window/splash screen when pressing the home app to hide any latency.

Memory impact:

Pinning dex/vdex:

In practical scenarios, this should be < 500kb.
The home app is usually profile-speed compiled, for which the
resulting dex/vdex files are about 2 mb. However, during regular
use, at least 1.5 MB of it is referenced in memory. This makes
sense: By definition profile-speed only compiles the things that
is usually frequently executed during regular execution.

Pinning apk:
With Launcher 3 in practical scenarios this should be about 3.7 MB,
as the APK is about 5.7 MB but 2 MB are usually referenced in any
case.

Bug: 111132016
Bug: 78585335
Test: Inspect "adb shell dumpsys pinner" after boot.
Test: Check for pinned files after updating camera/home.
Test: Check for pinned files after user switch with different
default apps.
Test: Check for pinned files after bg-dexopt.
Test: Check for pinned files after bg-dexopt + kill pid.

Change-Id: I6cdbc06d089efeb1c72a51216879ba0573502009
2018-07-13 15:16:48 +02:00
TreeHugger Robot
f97fa4d77b Merge "Skip execution of transactions on a destroyed activity" 2018-07-13 03:38:16 +00:00
Lucas Dupin
401ea1647a Merge "Dark Notification Shade" 2018-07-13 02:09:31 +00:00
Lucas Dupin
f03e752407 Dark Notification Shade
Test: adb shell service call uimode 4 i32 1 # day
Test: adb shell service call uimode 4 i32 2 # night
Bug: 110758454
Change-Id: Ib6fce91d1aeff7e1fbfe8a7a528095487fbdb3f8
2018-07-12 17:30:34 -07:00
Jorim Jaggi
bdc73423c6 Merge "DO NOT MERGE Remove WTF spam" into pi-dev
am: 650ead619e

Change-Id: I6d4300530516c25a5eb9af8ea8f924591eff3b95
2018-07-12 15:09:20 -07:00
Tomasz Wasilczyk
5f6ba52f59 Export BandDescriptor for AIDL.
Bug: 73950974
Test: it builds
Change-Id: I96321c24c96a848ab01cca47f563d70e4ff99b89
2018-07-12 21:51:01 +00:00
Jorim Jaggi
650ead619e Merge "DO NOT MERGE Remove WTF spam" into pi-dev 2018-07-12 21:32:53 +00:00
TreeHugger Robot
aa29832a8b Merge "Make IAutofillManager fully oneway." 2018-07-12 20:31:25 +00:00
TreeHugger Robot
a741f5dca4 Merge "Depecrate flags, and try to match them to actions" 2018-07-12 19:34:40 +00:00
Neil Fuller
a57acd367c Merge "Move XML object factory logic to libcore" am: 8176fb99e1
am: 7add22db60

Change-Id: If395891203fae0a8b55f8f58430adc979b758db2
2018-07-12 11:42:14 -07:00
Neil Fuller
7add22db60 Merge "Move XML object factory logic to libcore"
am: 8176fb99e1

Change-Id: Ib0940ecb89eaf11841bbd66cdaf1c5379466496c
2018-07-12 11:26:03 -07:00
Donghui Han
ebc6cb38a0 Merge "camera2: Treat face detect mode larger than FULL as FULL" into pi-dev am: 2fca393cc1
am: d05d630060

Change-Id: I3947264d88d0c558f8c7fb5ee22160af934e411e
2018-07-12 11:19:07 -07:00
Donghui Han
d05d630060 Merge "camera2: Treat face detect mode larger than FULL as FULL" into pi-dev
am: 2fca393cc1

Change-Id: I77b6b8e6d469a9e28478ddd7975f9c065caef20b
2018-07-12 10:47:53 -07:00
Felipe Leme
d4e52285ed Make IAutofillManager fully oneway.
The critical methods on this interface - like updateSession() - were already
void, so all we had to do were to "onewaywize" the other methods. We could
either refactor them to be truly async, or implement a blocking mechanism that
let them still be sync *and* oneway - because these methods are not in the
critical path, we opted for the latter, which is simpler and less risky.

Fixes: 73536867

Test: mmma -j ./frameworks/base/apct-tests/perftests/autofill/ && \
      adb install -r $OUT/data/app/AutofillPerfTests/AutofillPerfTests.apk && \
      adb shell am instrument -w -e class android.view.autofill.LoginTest \
      com.android.perftests.autofill/android.support.test.runner.AndroidJUnitRunner
Test: CtsAutoFillServiceTestCases

Change-Id: I380430aa2a7805aed6f629afb360566fc5402abb
2018-07-12 10:37:05 -07:00
Brett Chabot
968a5322b9 Make ENABLE_COPY_OPTIMIZATIONS non final.
Test: make -j56 Run_robolectric_robolectric_tests
Change-Id: I6ef235fef5a2daf55fab059b4d1b3a9afce09c8d
2018-07-12 10:33:43 -07:00
Donghui Han
2fca393cc1 Merge "camera2: Treat face detect mode larger than FULL as FULL" into pi-dev 2018-07-12 17:19:36 +00:00
Julia Reynolds
afc94d724c Add notification settings to backup&restore
Change-Id: I421c7487955ee339f88e3957c973375d0f87e2ff
Fixes: 35655737
Test: presubmit unit tests
2018-07-12 12:41:34 -04:00
Treehugger Robot
8176fb99e1 Merge "Move XML object factory logic to libcore" 2018-07-12 13:46:56 +00:00
Jorim Jaggi
511ac80149 DO NOT MERGE Remove WTF spam
Root cause has been identified, but fix is too risky. Instead, we
remove the WTF for now and readd the fix as well as the WTF
in master.

Note that due to defensive programming, in case we land in the WTF
case, it doesn't cause any real bug.

Test: boots
Bug: 110834518
Change-Id: I0da1e48e420c3fcde0e818b7fe0527da9155a159
2018-07-12 12:01:48 +00:00
TreeHugger Robot
f8585dcb50 Merge "Move XML object factory logic to libcore" 2018-07-12 11:20:37 +00:00
Riddle Hsu
d3062cbf41 Skip execution of transactions on a destroyed activity
An Activity may not yet create on client side, there is another
launch request with flags to clear task, then a destroy transaction
is scheduled. If client side keeps blocking until destroy timeout,
the token on server side will be removed. When client begins to
handle the first creation, it will report its activity token to
server that causes IllegalArgumentException because there is no
matched ActivityRecord.

Bug: 32375307
Test: atest FrameworksCoreTests:TransactionExecutorTests
Change-Id: I1b7e0c2863b13091c3fd50df602ff31ae02ff38d
2018-07-12 11:54:47 +08:00
TreeHugger Robot
daf0e11ca5 Merge "Make sure checking for accessibility pane is consistent" 2018-07-12 02:33:30 +00:00
Jeff Sharkey
b5a3117fe9 Merge "Utility methods useful for working with files." 2018-07-12 01:19:39 +00:00
Arthur Ishiguro
78c1e790b3 [automerger] Resolve inconsistent parcel read in NanoAppFilter am: abe5a73a4a am: 2895b320b4 am: 77e6e34644 am: 49e97ea1dc am: c2cfe453f2 am: cab2fa779e am: bf8733b162 am: e9b67d2b22 am: 267b960dab
am: b9912a254a

Change-Id: Ic85c323a3b706808616e1cf9d3e30a95ca2c37f6
2018-07-11 15:44:51 -07:00
Arthur Ishiguro
b9912a254a [automerger] Resolve inconsistent parcel read in NanoAppFilter am: abe5a73a4a am: 2895b320b4 am: 77e6e34644 am: 49e97ea1dc am: c2cfe453f2 am: cab2fa779e am: bf8733b162 am: e9b67d2b22
am: 267b960dab

Change-Id: I78fff5a76a8e1215e3a4235cbe65cc95d0fb8653
2018-07-11 15:07:23 -07:00
Arthur Ishiguro
267b960dab [automerger] Resolve inconsistent parcel read in NanoAppFilter am: abe5a73a4a am: 2895b320b4 am: 77e6e34644 am: 49e97ea1dc am: c2cfe453f2 am: cab2fa779e am: bf8733b162
am: e9b67d2b22

Change-Id: Ia3222d7b97b2d1083404d607738fc15d2646999c
2018-07-11 14:40:57 -07:00
Arthur Ishiguro
e9b67d2b22 [automerger] Resolve inconsistent parcel read in NanoAppFilter am: abe5a73a4a am: 2895b320b4 am: 77e6e34644 am: 49e97ea1dc am: c2cfe453f2 am: cab2fa779e
am: bf8733b162

Change-Id: I4fe6469031d7ef6fcc6d9b46da4dbc5845ea62d2
2018-07-11 14:27:45 -07:00
Arthur Ishiguro
bf8733b162 [automerger] Resolve inconsistent parcel read in NanoAppFilter am: abe5a73a4a am: 2895b320b4 am: 77e6e34644 am: 49e97ea1dc am: c2cfe453f2
am: cab2fa779e

Change-Id: Ifdd69396d202951f8b9ed5fe6e5766133955a5e5
2018-07-11 14:13:30 -07:00
Jeff Sharkey
5aae0c9df7 Utility methods useful for working with files.
Part of getting DocumentsUI ready for building against public API.

Test: builds
Bug: 110959821
Change-Id: I7cc0acd5ac3bcc89790cb49f34291ae523e44019
2018-07-11 14:41:24 -06:00
Tony Mak
09db2ea924 Suggest smart actions in ExtServices
By using text textclassifier API, we classify entities like
email, phone, address in the notification and suggest the corresponding
actions.

Test: Manual test for now. Sideload GoogleExtServices. Write a sample app
to generate notification with phone number / address, etc, and finally
observe the smart actions.

BUG: 110527159

Change-Id: I02740cb07fa25a588d9e864990f95332d6830f12
2018-07-11 19:17:16 +00:00
Tony Mak
dad5ef0d50 Merge "Allow NotificationAssistantService to suggest smart actions" 2018-07-11 17:32:39 +00:00
Donghui Han
5f967a3941 camera2: Treat face detect mode larger than FULL as FULL
This change treats any face detect mode larger than FULL mode
in the capture result as FULL mode. So in case the face detect
mode is larger than FULL, it is assumed that the FULL mode
STATISTICS_FACE is supported in the capture result.

Bug: 111131913
Test: CTS, GCA
Change-Id: I3a6a29ce8d9d8ab66918baaea3162797e18276d2
2018-07-11 15:47:44 +00:00
Neil Fuller
f4634736ca Move XML object factory logic to libcore
It makes sense to hide the details of the parser implementation
(and other similar objects) in libcore so it could be changed.

This change removes the "ExpatPerformanceTest" which appears not to have
been maintained and was comparing KxmlParser with itself. It is assumed
that android.util.Xml used to return the expat parser.

Test: build
Bug: 111055375
Merged-In: Ibad247323ba90cd949aecb2bd92f2f73306a4327
Change-Id: Ibad247323ba90cd949aecb2bd92f2f73306a4327
2018-07-11 14:02:00 +01:00
Neil Fuller
2f5a6895c5 Move XML object factory logic to libcore
It makes sense to hide the details of the parser implementation
(and other similar objects) in libcore so it could be changed.

This change removes the "ExpatPerformanceTest" which appears not to have
been maintained and was comparing KxmlParser with itself. It is assumed
that android.util.Xml used to return the expat parser.

Test: build
Bug: 111055375
Change-Id: Ibad247323ba90cd949aecb2bd92f2f73306a4327
2018-07-11 13:50:42 +01:00
Tony Mak
628cb9368c Allow NotificationAssistantService to suggest smart actions
Here is the flow:
NAS generates Adjustment -> NMS convert this to RankingUpdate ->
SystemUI.NotificationListener receives the RankingUpdate in either
onNotificationPosted / onNotificationRankingUpdate (Depend on does NAS
provides the adjustment before the notification is en-queued) ->
NotificationEntryManager determines the need of reinflation ->
NotificationInflater inflates / reinflates the view with these
extra bits like smart actions.

Note: We do re-inflation here as simply adding a button to the existing
notification view seems problematic. For example, if the original
notification does not have any action, we will need to inflate the
template with the action container.

Screenshot:
https://hsv.googleplex.com/5731489463402496

Test: atest SystemUITests
Test: atest com.android.server.notification.NotificationAdjustmentExtractorTest
Test: Modify ExtServices to provide adjustment in
      createEnqueuedNotificationAdjustment, post a notification with
      a entity in a sample app, observed the notification is updated.
      (Testing the onNotificationPosted flow)
Test: Modify ExtServices to provide adjustment in onNotificationPosted
      by calling adjustNotification. Post a notification with
      a entity in a sample app, observed the notification is updated.
      (Testing the onRankingUpdated flow)
Test: Repeat the above test, but explicitly make the RowInflaterTask
      slow by inserting Thread.sleep. This can test the onRankingUpdated
      flow when the row is not yet inflated.

BUG: 110527159

Change-Id: I98aee3ac62f60b189ea92ac9fc000127325dfead
2018-07-11 11:12:29 +01:00
Kevin Chyn
89b325a9b9 Merge changes from topic "face-settings"
* changes:
  Remove unused parameter in FaceManager
  Add face metrics constants
2018-07-11 03:27:02 +00:00
TreeHugger Robot
87fcbc18d2 Merge "Minor logging improvement." 2018-07-11 01:14:33 +00:00