27536 Commits

Author SHA1 Message Date
Jeff Brown
a9be4154e8 Fix issues with reentrant SQLite triggers.
Modified SQLiteConnection and SQLiteSession to support
reentrant execution of SQLite operations, as might occur
when a custom function is invoked by a trigger.

Bug: 5884809
Change-Id: I253d828b2801bd06b1bbda7caa7da3f040a642bb
2012-01-18 18:29:20 -08:00
Adam Cohen
dc89357810 Merge "Getting rid of hack where the wallpaper offset was being deferred" 2012-01-12 16:47:00 -08:00
Svetoslav Ganov
bd2ff3666b Merge "AccessibilityService description not internationalized." 2012-01-12 15:36:58 -08:00
Jeff Brown
986f00faf4 Merge "Rewrite SQLite database wrappers." 2012-01-12 15:03:26 -08:00
Jeff Brown
156936975d Merge "Fix indentation and whitespace." 2012-01-12 14:59:30 -08:00
Jeff Brown
18c415c3c8 Merge "Clean up database tests a little bit." 2012-01-12 14:59:11 -08:00
Jeff Brown
e5360fbf3e Rewrite SQLite database wrappers.
The main theme of this change is encapsulation.  This change
preserves all existing functionality but the implementation
is now much cleaner.

Instead of a "database lock", access to the database is treated
as a resource acquisition problem.  If a thread's owns a database
connection, then it can access the database; otherwise, it must
acquire a database connection first, and potentially wait for other
threads to give up theirs.  The SQLiteConnectionPool encapsulates
the details of how connections are created, configured, acquired,
released and disposed.

One new feature is that SQLiteConnectionPool can make scheduling
decisions about which thread should next acquire a database
connection when there is contention among threads.  The factors
considered include wait queue ordering (fairness among peers),
whether the connection is needed for an interactive operation
(unfairness on behalf of the UI), and whether the primary connection
is needed or if any old connection will do.  Thus one goal of the
new SQLiteConnectionPool is to improve the utilization of
database connections.

To emulate some quirks of the old "database lock," we introduce
the concept of the primary database connection.  The primary
database connection is the one that is typically used to perform
write operations to the database.  When a thread holds the primary
database connection, it effectively prevents other threads from
modifying the database (although they can still read).  What's
more, those threads will block when they try to acquire the primary
connection, which provides the same kind of mutual exclusion
features that the old "database lock" had.  (In truth, we
probably don't need to be requiring use of the primary database
connection in as many places as we do now, but we can seek to refine
that behavior in future patches.)

Another significant change is that native sqlite3_stmt objects
(prepared statements) are fully encapsulated by the SQLiteConnection
object that owns them.  This ensures that the connection can
finalize (destroy) all extant statements that belong to a database
connection when the connection is closed.  (In the original code,
this was very complicated because the sqlite3_stmt objects were
managed by SQLiteCompiledSql objects which had different lifetime
from the original SQLiteDatabase that created them.  Worse, the
SQLiteCompiledSql finalizer method couldn't actually destroy the
sqlite3_stmt objects because it ran on the finalizer thread and
therefore could not guarantee that it could acquire the database
lock in order to do the work.  This resulted in some rather
tortured logic involving a list of pending finalizable statements
and a high change of deadlocks or leaks.)

Because sqlite3_stmt objects never escape the confines of the
SQLiteConnection that owns them, we can also greatly simplify
the design of the SQLiteProgram, SQLiteQuery and SQLiteStatement
objects.  They no longer have to wrangle a native sqlite3_stmt
object pointer and manage its lifecycle.  So now all they do
is hold bind arguments and provide a fancy API.

All of the JNI glue related to managing database connections
and performing transactions is now bound to SQLiteConnection
(rather than being scattered everywhere).  This makes sense because
SQLiteConnection owns the native sqlite3 object, so it is the
only class in the system that can interact with the native
SQLite database directly.  Encapsulation for the win.

One particularly tricky part of this change is managing the
ownership of SQLiteConnection objects.  At any given time,
a SQLiteConnection is either owned by a SQLiteConnectionPool
or by a SQLiteSession.  SQLiteConnections should never be leaked,
but we handle that case too (and yell about it with CloseGuard).

A SQLiteSession object is responsible for acquiring and releasing
a SQLiteConnection object on behalf of a single thread as needed.
For example, the session acquires a connection when a transaction
begins and releases it when finished.  If the session cannot
acquire a connection immediately, then the requested operation
blocks until a connection becomes available.

SQLiteSessions are thread-local.  A SQLiteDatabase assigns a
distinct session to each thread that performs database operations.
This is very very important.  First, it prevents two threads
from trying to use the same SQLiteConnection at the same time
(because two threads can't share the same session).
Second, it prevents a single thread from trying to acquire two
SQLiteConnections simultaneously from the same database (because
a single thread can't have two sessions for the same database which,
in addition to being greedy, could result in a deadlock).

There is strict layering between the various database objects,
objects at lower layers are not aware of objects at higher layers.
Moreover, objects at higher layers generally own objects at lower
layers and are responsible for ensuring they are properly disposed
when no longer needed (good for the environment).

API layer: SQLiteDatabase, SQLiteProgram, SQLiteQuery, SQLiteStatement.
Session layer: SQLiteSession.
Connection layer: SQLiteConnectionPool, SQLiteConnection.
Native layer: JNI glue.

By avoiding cyclic dependencies between layers, we make the
architecture much more intelligible, maintainable and robust.

Finally, this change adds a great deal of new debugging information.
It is now possible to view a list of the most recent database
operations including how long they took to run using
"adb shell dumpsys dbinfo".  (Because most of the interesting
work happens in SQLiteConnection, it is easy to add debugging
instrumentation to track all database operations in one place.)

Change-Id: Iffb4ce72d8bcf20b4e087d911da6aa84d2f15297
2012-01-12 14:56:18 -08:00
Adam Cohen
791a6331e3 Getting rid of hack where the wallpaper offset was being deferred
-> This was a hack, and with all the work going into vsync etc, it
   really shouldn't be needed.

Change-Id: I59005e2644e0ba08846a6c661e8c4e22640d8e02
2012-01-12 14:38:38 -08:00
Jeff Brown
3f11f302c7 Fix indentation and whitespace.
Change-Id: Iccb954fb77f21b230eecb3f06328e11b14611f17
2012-01-12 14:37:58 -08:00
Jeff Brown
5a05c23f3d Clean up database tests a little bit.
Change-Id: Ib05c699bf59187cb51627b5f352c2a15ad2c28bb
2012-01-12 14:37:57 -08:00
Gilles Debunne
e340527eab Merge "Fixed fadingEdge documentation" 2012-01-12 14:21:58 -08:00
Matthew Xie
cf5cecd854 am 1890fa82: am 79d84930: Merge "Set Bluetooth adapter to PowerOff mode when turnoff with airplane on" into ics-mr1
* commit '1890fa822091ea700b7409ac79a57cf650b55003':
  Set Bluetooth adapter to PowerOff mode when turnoff with airplane on
2012-01-12 11:29:39 -08:00
Matthew Xie
1890fa8220 am 79d84930: Merge "Set Bluetooth adapter to PowerOff mode when turnoff with airplane on" into ics-mr1
* commit '79d84930cd776c7173330eeb13b3282b6034fc37':
  Set Bluetooth adapter to PowerOff mode when turnoff with airplane on
2012-01-12 11:27:10 -08:00
Matthew Xie
79d84930cd Merge "Set Bluetooth adapter to PowerOff mode when turnoff with airplane on" into ics-mr1 2012-01-12 11:24:06 -08:00
John Reck
6b9a41c55e am baaf136c: am 0a3fcc3e: Fix Apache stack
* commit 'baaf136cd279e22a7ae4b551ebd5fad23b84996d':
  Fix Apache stack
2012-01-12 11:03:06 -08:00
John Reck
baaf136cd2 am 0a3fcc3e: Fix Apache stack
* commit '0a3fcc3eed15ed50bcaa7808b6ccb170fb137210':
  Fix Apache stack
2012-01-12 11:00:17 -08:00
Glenn Kasten
1c66547ba2 Merge "Use audio_format_t consistently" 2012-01-12 10:30:28 -08:00
Danielle Millett
2931d8ace9 Merge "DO NOT MERGE - Cherry picking from master to MR1" into ics-mr1 2012-01-12 07:28:24 -08:00
Brian Colonna
8a1131d789 Merge "DO NOT MERGE cherry-picked FU framework tablet commits" into ics-mr1 2012-01-12 06:33:49 -08:00
satok
11299b1b8c Make public SpellChecker utilities
Bug: 5639238
Change-Id: Id7dd2263a6305cc6ba0cf8f4d8ad8fb0d39a48ff
2012-01-12 13:54:53 +09:00
Xia Wang
4acb784630 am 87badc20: am 4ac4ab4e: Merge "Remove sleep from test acitivity to avoid ANR when key event is injected bug#: 5737922" into ics-mr1
* commit '87badc20c7d5462ee27f13adf50acaf6a3232884':
  Remove sleep from test acitivity to avoid ANR when key event is injected bug#: 5737922
2012-01-11 17:57:16 -08:00
Xia Wang
4ac4ab4ef0 Merge "Remove sleep from test acitivity to avoid ANR when key event is injected bug#: 5737922" into ics-mr1 2012-01-11 17:52:06 -08:00
John Reck
b123e96059 Merge "Initial NavCache removal support" 2012-01-11 16:34:26 -08:00
Matthew Xie
f3171fb60c Set Bluetooth adapter to PowerOff mode when turnoff with airplane on
Currently, when airplane mode was on and BT was on, turning BT off
moved BT to hotoff state. This fix moves BT all the way to Poweroff
state to have better power performance.
bug 5854282

Change-Id: I7ba41797a46a81ddb3a576453f2a8303b5eed525
2012-01-11 14:46:13 -08:00
Selim Gurun
51938e2691 Merge "Do Not Merge. Move ssl callbacks to webcore thread." into ics-mr1 2012-01-11 14:18:14 -08:00
John Reck
4eda105cdb Initial NavCache removal support
Change-Id: I927005093b620a1b1b60703bc8a58de539bdf3c8
2012-01-11 13:59:41 -08:00
Glenn Kasten
a9830d430a Merge "Fix build warnings" 2012-01-11 13:42:47 -08:00
Glenn Kasten
129e19cb37 Fix build warnings
Change-Id: I334e0a6e018bb1067c90e050cf3583c1057aacd9
2012-01-11 13:40:05 -08:00
John Reck
0a3fcc3eed Fix Apache stack
Change-Id: Iec7d0d8bdaaa5594fa7412db79943ab0ccdf594c
2012-01-11 13:35:29 -08:00
Glenn Kasten
d742fa3f60 Merge "Fix build warnings" 2012-01-11 11:37:53 -08:00
Teng-Hui Zhu
f8f4b69a28 Merge "Query the native side to decide to play when going into full screen mode" 2012-01-11 10:31:24 -08:00
Selim Gurun
972b1a505c Do Not Merge. Move ssl callbacks to webcore thread.
Bug: 4586251

Cherry picking from master for ics-mr1.

Current ssl cert logic makes callbacks to webkit from the
UI thread. This is not right. Move the callbacks to proper thread.

Change-Id: I59affba47eca01b74e2bc33d88ef83a5850d6ce9
2012-01-11 10:18:54 -08:00
Glenn Kasten
ed70933d45 Fix build warnings
Change-Id: Ic82cc86ac4b63b30ab66e1b8c7fd0e998fea590e
2012-01-11 07:27:41 -08:00
Narayan Kamath
81754949e0 Merge "Write unit tests for android.speech.tts." 2012-01-11 03:39:57 -08:00
Jeff Sharkey
2cc28deb9e Merge "Move non-monotonic reporting to interface." 2012-01-10 17:41:01 -08:00
Jeff Sharkey
5a7bcf31a4 Move non-monotonic reporting to interface.
Report non-monotonic NetworkStats through an observer interface
instead of throwing, since those events are still recoverable.

Change-Id: Ic0749f4634b0ac05dbe90e95ca490957ec8b2f23
2012-01-10 17:24:44 -08:00
Teng-Hui Zhu
e4c89e321c Query the native side to decide to play when going into full screen mode
Previously we save the state in Java side, but it is better to check with
native side since the exact state is already there.
This will help to get the updated state from javascript too.

bug:5765848

Webkit side change:
https://android-git.corp.google.com/g/#/c/157866/

Change-Id: Id0316b694c1597b50a1c3b123b31efc6b0fac706
2012-01-10 17:17:02 -08:00
Ying Wang
044a0b8ae5 Merge "Build all test apks as raw resource in FrameworksCoreTests." 2012-01-10 16:37:43 -08:00
Ying Wang
24162fc52c Build all test apks as raw resource in FrameworksCoreTests.
Bug: 5848975
Change-Id: I395013ded1c29e0914f72e03d0abd60bb4a7973a
2012-01-10 15:12:10 -08:00
Steve Block
38e90751a2 Merge "Rename LOG_ASSERT to ALOG_ASSERT DO NOT MERGE" 2012-01-10 14:08:32 -08:00
Jim Miller
5437c220e2 am d3872f55: am 62fad768: Merge "Fix 4560303: Add setting to lock later when power button pressed" into ics-mr1
* commit 'd3872f55045b7ce7be7dd7ae5fff37d7988bdcb2':
  Fix 4560303: Add setting to lock later when power button pressed
2012-01-10 10:34:51 -08:00
Jim Miller
62fad76895 Merge "Fix 4560303: Add setting to lock later when power button pressed" into ics-mr1 2012-01-10 10:28:21 -08:00
Danielle Millett
de7a2f3054 DO NOT MERGE - Cherry picking from master to MR1
Fix 5783857: Device Policy Manager doesn't allow Face Unlock

This makes it so that if face unlock is enabled and then a device policy
manager that requires something more secure than face unlock is installed,
the user will be forced to choose a new acceptable lock type.

This was previously fixed for the case where the device had been reset, or
the shell was restarted after setting face unlock, but not for the case where the
device remained on between setting face unlock and setting up a device policy
manager.

Also changed the function ordering of saveLockPattern() so that the overloaded
wrapper function is next to the main function.

Change-Id: Ibed8c4ab137ebbc07fb143faef6f047bc6dc4474
2012-01-10 11:40:41 -05:00
Jim Miller
a4edd151c5 Fix 4560303: Add setting to lock later when power button pressed
This adds a feature to delay locking the device when the power button
is pressed.  This fixes a use case where the user wants to turn off
the display (e.g. to save power) but doesn't want to lock the device.

For the case of a secure device (user has a pin/password/pattern),
this will lock the device immediately or not based on the setting.

For the non-secure case, this always "locks" the device to provide easy
access to the camera while preventing unwanted input.

Change-Id: Ie328485c3f7559e26896d761cbf0e69d3f4df4e2
2012-01-09 17:30:58 -08:00
Dianne Hackborn
32313b161f am d476c8b8: am d3be0a76: Merge "Unhide Resources APIs for getting resources at specific densities." into ics-mr1
* commit 'd476c8b8a8a6fadea7e72426d3e93c4e6b00e543':
  Unhide Resources APIs for getting resources at specific densities.
2012-01-09 16:51:52 -08:00
Dianne Hackborn
d3be0a76e4 Merge "Unhide Resources APIs for getting resources at specific densities." into ics-mr1 2012-01-09 16:47:35 -08:00
Mangesh Ghiware
2ddb4c8509 Merge "Fix issue with site-specific display density getting stuck." 2012-01-09 16:02:21 -08:00
Adam Powell
45b075dd5c Fix a bug where window progress bars had the wrong default visibility
on windows with action bars.

Change-Id: I5509d9a7c5f029b0471bd63e781f4756f5a319bc
2012-01-09 15:41:40 -08:00
Mangesh Ghiware
6f2db8e755 Fix issue with site-specific display density getting stuck.
This issue was found while investigating b/5328288.

After navigating to a page that specifies target-densitydpi in the
viewport meta tag, this density value wasn't reset to the default value
for a page that didn't.

Change-Id: I1a66dab769026367224ecf4cc28bc033ee97e475
2012-01-09 13:53:01 -08:00
Elliott Hughes
64140a0770 Fix Music import for Turkish locales.
For non-localized strings like the keywords in SQL statements, we shouldn't use
locale-specific case transformations.

(Cherry pick of 03f8f84c345e7c861a6de889d434b9d82cf04c8d.)

Bug: 4284951
Change-Id: If5b7154f70a7db22837d071d1c57e929729b7d35
2012-01-09 13:36:36 -08:00