323 Commits

Author SHA1 Message Date
Jeff Brown
0a19d001c4 Fix a segfault when there is no power module.
This can happen in the emulator.

Bug: 7315152
Change-Id: I4a3f547127419fcd4dc4fc1c6f7ee869706cf12e
2012-10-09 14:47:05 -07:00
Jeff Brown
9e316a1a2a Blank or unblank all displays as need.
Ensures that both the internal display and HDMI are blanked
or unblanked in tandem.

Bug: 7309812
Change-Id: Ie8b96d393e8bb20d23c92f3320142d9f7cf42aff
2012-10-08 19:23:15 -07:00
Andy McFadden
94ffe8739e Merge "Pass display arg to blank/unblank" into jb-mr1-dev 2012-09-28 13:06:45 -07:00
Jeff Brown
bcc046af4e Bundle correlated switch changes atomically.
This is a prerequisite for headset jack detection on Manta.

Bug: 6548391
Change-Id: I549a194344511c0cee578b00f6a9ab5fdbdfb99c
2012-09-27 21:42:57 -07:00
Andy McFadden
1081eed9b7 Pass display arg to blank/unblank
blank() and unblank() now take a display argument.  For now,
just pass the default display in.

Bug: 7240511

Change-Id: I7747732471c9116cb6b3686bd95d5f32a63279a6
2012-09-27 16:03:01 -07:00
Jeff Brown
80cd819a04 Use more reasonable warning thresholds for power on/off.
To encourage vendors to make power on/off as efficient
and responsive as possible, we log some warnings whenever it
is too slow.  The previous thresholds were a little
unreasonable mainly because we wanted to understand
how long the process tends to take even when it's fast.

Raise the warning limit while still being aggressive about
timings.  Ideally we want the screen to turn on/off within
no more than a few frames.

Bug: 7167820
Change-Id: Id28dbf8c91cefa7ae7544b72887104af7aabccff
2012-09-25 16:59:58 -07:00
Jeff Brown
83d616a9c7 Make input system aware of multiple displays.
The input system needs to know about the window that has
focus, even if it is on a secondary display.  So now we
send it the list of all windows and indicate which display
they are on.  We filter the list of windows as necessary
when delivering touch events.

To keep things simple, monitor input channels and input
filters are not supported except on the main display.
We also do not pass the display id to applications; it is
only used inside the input system for now.

Properly scale touch coordinates based on the viewport.
This will be needed to ensure that touch works on external
display as well as when the internal display is being used
to simulate a different resolution.

Change-Id: I1815579a52fcc852c519b5391fc7ab8767c2dc59
2012-09-10 15:48:47 -07:00
Jeff Brown
d728bf514f Make display manager tell input system about viewports.
The window manager is no longer responsible for telling the
input system about the display viewport.

Change-Id: I932882bae55decef55f25093bb2a7ebac1620bb1
2012-09-08 18:12:57 -07:00
Jeff Brown
64a55af0ac Add plumbing for new surface flinger display API.
Cleaned up the implementation of Surface and SurfaceSession
to use more consistent naming and structure.

Added JNI for all of the new surface flinger display API calls.

Enforced the requirement that all Surfaces created by
the window manager be named.

Updated the display manager service to use the new methods.

Change-Id: I2a658f1bfd0437e1c6f9d22df8d4ffcce7284ca2
2012-08-27 14:34:54 -07:00
Jeff Brown
0b722fe9ce Use new surface flinger API.
Change-Id: Ic888577408a59a36481a48010e19c5e77c24e211
2012-08-27 14:34:53 -07:00
Scott Anderson
5ad9fc2182 BatteryService: Fix comment to match code
Change-Id: Ib4e30e7808ff3a2a8a49c000eac719a3a4273fdd
Signed-off-by: Scott Anderson <saa@android.com>
2012-08-21 13:11:26 -07:00
Jeff Brown
256237c99f Merge "Plumb the switch code into Dalvik." into jb-mr1-dev 2012-08-20 20:26:11 -07:00
Jeff Brown
5338428ddb Plumb the switch code into Dalvik.
Bug: 6548391
Change-Id: If0e918669ba27ca0e6561930d4abc427c34de42d
2012-08-20 20:16:01 -07:00
Brian Muramatsu
37a37f445c add wireless charger support
bug: 6879638

- add new enum value BATTERY_PLUGGED_WIRELESS
- check for sys online file with contents "Wireless"

Change-Id: I22dc3c40f50573c98643e7b5cbcb237d0216530d
2012-08-20 10:04:12 -07:00
Jeff Brown
9630704ed3 Power manager rewrite.
The major goal of this rewrite is to make it easier to implement
power management policies correctly.  According, the new
implementation primarily uses state-based rather than event-based
triggers for applying changes to the current power state.

For example, when an application requests that the proximity
sensor be used to manage the screen state (by way of a wake lock),
the power manager makes note of the fact that the set of
wake locks changed.  Then it executes a common update function
that recalculates the entire state, first looking at wake locks,
then considering user activity, and eventually determining whether
the screen should be turned on or off.  At this point it may
make a request to a component called the DisplayPowerController
to asynchronously update the display's powe state.  Likewise,
DisplayPowerController makes note of the updated power request
and schedules its own update function to figure out what needs
to be changed.

The big benefit of this approach is that it's easy to mutate
multiple properties of the power state simultaneously then
apply their joint effects together all at once.  Transitions
between states are detected and resolved by the update in
a consistent manner.

The new power manager service has is implemented as a set of
loosely coupled components.  For the most part, information
only flows one way through these components (by issuing a
request to that component) although some components support
sending a message back to indicate when the work has been
completed.  For example, the DisplayPowerController posts
a callback runnable asynchronously to tell the PowerManagerService
when the display is ready.  An important feature of this
approach is that each component neatly encapsulates its
state and maintains its own invariants.  Moreover, we do
not need to worry about deadlocks or awkward mutual exclusion
semantics because most of the requests are asynchronous.

The benefits of this design are especially apparent in
the implementation of the screen on / off and brightness
control animations which are able to take advantage of
framework features like properties, ObjectAnimator
and Choreographer.

The screen on / off animation is now the responsibility
of the power manager (instead of surface flinger).  This change
makes it much easier to ensure that the animation is properly
coordinated with other power state changes and eliminates
the cause of race conditions in the older implementation.

The because of the userActivity() function has been changed
so that it never wakes the device from sleep.  This change
removes ambiguity around forcing or disabling user activity
for various purposes.  To wake the device, use wakeUp().
To put it to sleep, use goToSleep().  Simple.

The power manager service interface and API has been significantly
simplified and consolidated.  Also fixed some inconsistencies
related to how the minimum and maximum screen brightness setting
was presented in brightness control widgets and enforced behind
the scenes.

At present the following features are implemented:

- Wake locks.
- User activity.
- Wake up / go to sleep.
- Power state broadcasts.
- Battery stats and event log notifications.
- Dreams.
- Proximity screen off.
- Animated screen on / off transitions.
- Auto-dimming.
- Auto-brightness control for the screen backlight with
  different timeouts for ramping up versus ramping down.
- Auto-on when plugged or unplugged.
- Stay on when plugged.
- Device administration maximum user activity timeout.
- Application controlled brightness via window manager.

The following features are not yet implemented:

- Reduced user activity timeout for the key guard.
- Reduced user activity timeout for the phone application.
- Coordinating screen on barriers with the window manager.
- Preventing auto-rotation during power state changes.
- Auto-brightness adjustment setting (feature was disabled
  in previous version of the power manager service pending
  an improved UI design so leaving it out for now).
- Interpolated brightness control (a proposed new scheme
  for more compactly specifying auto-brightness levels
  in config.xml).
- Button / keyboard backlight control.
- Change window manager to associated WorkSource with
  KEEP_SCREEN_ON_FLAG wake lock instead of talking
  directly to the battery stats service.
- Optionally support animating screen brightness when
  turning on/off instead of playing electron beam animation
  (config_animateScreenLights).

Change-Id: I1d7a52e98f0449f76d70bf421f6a7f245957d1d7
2012-08-15 03:06:24 -07:00
Mathias Agopian
187019c51f Merge "screen-off animation won't be handled by SF anymore" into jb-mr1-dev 2012-08-02 21:49:25 -07:00
Mathias Agopian
893a0e71a7 screen-off animation won't be handled by SF anymore
Change-Id: I66ad02b07b1148c1610e9c29ba80450d49c22806
2012-08-02 21:29:54 -07:00
Dianne Hackborn
908aecc3a6 Start moving away from DisplayMetrics.DENSITY_DEVICE.
This puts in most of the infrastructure needed to allow us to
switch between different densities at run time.  The main remaining
uses of the global are to initialize the Bitmap object (not sure
what to do about that since it doesn't have anything passed in
the constructor to get this information from), and being able to
load drawables if we need a different density than what was preloaded
by zygote.

Change-Id: Ifdbfd6b7a5c59e6aa22e63b95b78d96af3d96848
2012-08-01 10:54:39 -07:00
Jeff Brown
b696de5c10 Move and rename user activity event type constants.
Change-Id: Ie565808796773b6896e71ddfac6aaaf8031de846
2012-07-27 18:14:56 -07:00
Mathias Agopian
92c6d2fc50 update to new getDisplayInfo API
Change-Id: I8051b4f9f23d3ef4791176de1bbcfafacae7d579
2012-07-25 20:38:27 -07:00
Jeff Brown
fa25bf5382 Add display manager skeleton.
The purpose of this change is to remove direct reliance on
SurfaceFlinger for describing the size and characteristics of
displays.

This patch also starts to make a distinction between logical displays
and physical display devices.  Currently, the window manager owns
the concept of a logical display whereas the new display
manager owns the concept of a physical display device.

Change-Id: I7e0761f83f033be6c06fd1041280c21500bcabc0
2012-07-25 18:56:16 -07:00
Jeff Brown
4f8ecd8029 Move power manager to a new package.
Change-Id: I5f5a6435e64354b7d6535e8e9a63934ba7a3f448
2012-06-18 19:43:44 -07:00
Colin Cross
dccb2c16e5 PowerManagerService: call surfaceflinger blank and unblank through binder
Synchronize with SurfaceFlinger during screen off and on to ensure that
a black frame has been drawn on the display, and then trigger all early
suspend handlers on devices that have early suspend, as well as PowerHAL
operations.

Change-Id: I8a5ad5a84c9e80ce5bb8f7f0b09b064e2b9ad4ef
2012-06-07 14:01:22 -07:00
Jeff Brown
d232afa003 Tolerate missing power HAL module.
Bug: 6492793
Change-Id: I092605456e734e3f91ee098a197f208c738a619c
2012-05-16 13:39:46 -07:00
Jeff Brown
30e5eb4826 Tell power HAL when user activity occurs.
Bug: 6435382
Change-Id: I78754158b057851fcba807ebbda143899da387ec
2012-05-11 19:18:56 -07:00
Jeff Brown
7304c34382 Move power HAL interactions to PowerManagerService.
This refactoring sets the stage for a follow-on change that
will make use additional functions of the power HAL.

Moved functionality from android.os.Power into PowerManagerService.
None of these functions make sense being called outside of the
system server.  Moving them to the PowerManagerService makes it
easier to ensure that the power HAL is initialized exactly once.

Similarly, moved ShutdownThread out of the policy package and into
the services package where it can tie into the PowerManagerService
as needed.

Bug: 6435382
Change-Id: I958241bb124fb4410d96f5d5eb00ed68d60b29e5
2012-05-11 18:42:42 -07:00
Jeff Brown
93de746e55 Separate the internal and external display rotations.
When attached to an HDMI touch screen, the input system needs
to know the size and rotation of the external display independent
of the internal display.  The size was already being reported
separately but not the rotation.  The inconsistency can cause problems
if the internal display's natural rotation is portrait but
the external display's natural rotation is landscape.

Change-Id: Id344f04c1ba032625f6265766be66f9ddaa2cc0b
2012-05-02 16:29:42 -07:00
Jeff Brown
daa3753a04 Improve handling of built-in keyboard.
The window manager policy made some incorrect assumptions about the
meaning of the Configuration.keyboard field.  We need to be more
careful about distinguishing between built-in and external keyboards.

Most of this change is to move the determination of the parts of
the Configuration related to input devices into the WindowManagerService
leveraging new features of the InputManagerService to good effect.

Then we plumb through the flag that indicates whether a device
is internal or external so that we can be more particular about
how the lid switch effects changes to the Configuration.

Bug: 6424373
Change-Id: I36a1c22ade35e578955465a25940a33f227b9763
2012-05-01 16:34:20 -07:00
Mike Lockwood
166b05e0ce UsbService: Add support for accessory initiating USB audio support
Change-Id: I0e468f4b841de9e1ca7b75a05fc58299dbc78222
Signed-off-by: Mike Lockwood <lockwood@google.com>
2012-04-26 15:09:35 -07:00
Jeff Brown
5bbd4b4f5f Get alias for Bluetooth devices.
Bluetooth devices can be renamed by the user.  Make the
input system aware of the user-specified name and transparently
pass it down to applications.  This enables the keyboard
layout picker Settings UI to use device names that are
consistent with what the user set in the Bluetooth UI.

Bug: 6363157
Change-Id: I8eea26ce2c69c2a3f09c8de02e9e847610e0419c
2012-04-20 20:11:12 -07:00
Jeff Brown
6ec6f79e1a Support loading keyboard layout overlays from resources.
Added the concept of a keyboard layout overlay, which is
a key character map file that has "type OVERLAY".

Added support for loading keyboard layout overlays from
resources dynamically.  The layouts are reloaded whenever they
are changed in the Settings application or an application
is installed.  This is somewhat more aggressive than necessary
so we might want to optimize it later.

Before system-ready, the input system uses just the generic
keyboard layouts that are included on the device system image.
After system-ready, it considers the user's selected keyboard
layout overlay and attempts to load it as necessary.  We need to
wait until system-ready before doing this because we need to
be in a state where it is safe to start applications or access
their resources.

Bug: 6110399
Change-Id: Iae0886d3356649b0d2440aa00910a888cedd8323
2012-04-17 17:56:32 -07:00
Jeff Brown
a47425a13c Add support for input devices that have vibrators.
Added a getVibrator() method to InputDevice which returns a Vibrator
associated with that input device.  Its uses the same API as the
system vibrator which makes it easy for applications to be modified
to use one or the other.

Bug: 6334179
Change-Id: Ifc7f13dbcb778670f3f1c07ccc562334e6109d2e
2012-04-13 17:01:15 -07:00
Jeff Brown
af9e8d3818 Notify applications when input devices change.
This change allows the InputManager to keep track of what input
devices are registered with the system and when they change.
It needs to do this so that it can properly clear its cache of
input device properties (especially the key map!) when changes
occur.

Added new API so that applications can register listeners for
input device changes.

Fixed a minor bug in EventHub where it didn't handle EPOLLHUP
properly so it would spam the log about unsupposed epoll events
until inotify noticed that the device was gone and removed it.

Change-Id: I937d8c601f7185d4299038bce6a2934fe4fdd2b3
2012-04-12 18:54:54 -07:00
Jeff Brown
9f25b7fdf2 Request key maps from input manager service.
Instead of each application loading the KeyCharacterMap from
the file system, get them from the input manager service as
part of the InputDevice object.

Refactored InputManager to be a proper singleton instead of
having a bunch of static methods.

InputManager now maintains a cache of all InputDevice objects
that it has loaded.  Currently we never invalidate the cache
which can cause InputDevice to return stale motion ranges if
the device is reconfigured.  This will be fixed in a future change.

Added a fake InputDevice with ID -1 to represent the virtual keyboard.

Change-Id: If7a695839ad0972317a5aab89e9d1e42ace28eb7
2012-04-10 18:23:58 -07:00
Jeff Brown
27fd3420ac Fix lid switch interpretation.
Also remove unnecessary permission check for method that is
only called internally.

Change-Id: I32f63fc3e96b06709d18b046ee2d3c8f310de70d
2012-04-09 11:22:12 -07:00
Jeff Brown
603b445896 Ensure that apps crash if they throw exceptions.
Previously, if an app threw an uncaught exception in an input,
vsync or native activity callback, it would log the exception then
continue limping merrily along.  In the case of input, it
could result in an ANR occurring because we had not drained
all of the pending input events and marked them as finished
(we only marked the most recent one finished).

Bug: 6304124
Change-Id: I87d76f7fd605e1a8af1237c66d8d62973080277e
2012-04-06 18:25:09 -07:00
Jeff Brown
e38fdfae91 Add a unique input device descriptor.
The purpose of the input device descriptor is to make it possible
to associate persistent settings for each input device, such as the
keyboard layout.

The descriptor is a hash of the information we have about the
device, such as its vendor id, product id, unique id, name,
or location.

Bug: 6110399
Change-Id: Idb80f946819b3f0dbf4e661bb0a753dbc2b60981
2012-04-06 14:57:19 -07:00
Jeff Brown
4532e61584 Refactor input system into its own service.
Extracted the input system from the window manager service into
a new input manager service.  This will make it easier to
offer new input-related features to applications.

Cleaned up the input manager service JNI layer somewhat to get rid
of all of the unnecessary checks for whether the input manager
had been initialized.  Simplified the callback layer as well.

Change-Id: I3175d01307aed1420780d3c093d2694b41edf66e
2012-04-05 14:42:11 -07:00
Mathias Agopian
8335f1cccc fix libgui header location
Change-Id: Iec71706cdd4f29c6904993648ce873e83ef9cafe
2012-02-27 13:03:08 -08:00
Mathias Agopian
83c64e6b62 frameworks/base refactoring
create the new libandroidfw from parts of libui and libutils

Change-Id: I1584995616fff5d527a2aba63921b682a6194d58
2012-02-20 22:38:43 -08:00
Mathias Agopian
b93a03f841 frameworks/base refactoring.
First step. Move libui includes to their new home: androidfw.

Change-Id: Ic042b52fdba72f30edc3cc6339bf30b4c1b99662
2012-02-17 15:36:10 -08:00
Jeff Brown
62d1058cc9 Merge "Remove the input dispatcher throttle." 2012-02-13 10:26:33 -08:00
Mike Lockwood
a21e945502 BatteryService: Don't fail to register native methods if kernel power supply driver is missing
Signed-off-by: Mike Lockwood <lockwood@android.com>
2012-02-10 12:00:32 -08:00
Mike Lockwood
b01e8bf57b New Serial Manager API:
SerialManager: provides access to serial ports
SerialPort: for reading and writing data to and from serial ports

IO with both array based and direct ByteBuffers is supported.

Accessing serial ports requires android.permission.SERIAL_PORT permission

Each platform must configure list of supported serial ports in the
config_serialPorts resource overlay
(this is needed to prevent apps from accidentally accessing the bluetooth
or other system UARTs).

In addition, the platform uevent.rc file must set the owner to the
/dev/tty* files to "system" so the framework can access the port.

Signed-off-by: Mike Lockwood <lockwood@android.com>
2012-02-10 10:51:19 -08:00
Jeff Brown
308028049a Remove the input dispatcher throttle.
This is part of a series of changes to improve input system pipelining.

Bug: 5963420
Change-Id: Iab33594bc5df8aa05232ef64c64e98fc61c5bf52
2012-02-07 18:38:11 -08:00
Steve Block
ec193dec4d Rename LOG_ASSERT to ALOG_ASSERT DO NOT MERGE
See https://android-git.corp.google.com/g/157519

Bug: 5449033
Change-Id: I8ceb2dba1b031a0fd68d15d146960d9ced62bbf3
2012-01-09 21:36:22 +00:00
Steve Block
3762c31172 Rename (IF_)LOGE(_IF) to (IF_)ALOGE(_IF) DO NOT MERGE
See https://android-git.corp.google.com/g/#/c/157220

Bug: 5449033
Change-Id: Ic9c19d30693bd56755f55906127cd6bd7126096c
2012-01-08 13:19:13 +00:00
Steve Block
8564c8da81 Rename (IF_)LOGW(_IF) to (IF_)ALOGW(_IF) DO NOT MERGE
See https://android-git.corp.google.com/g/157065

Bug: 5449033
Change-Id: I00a4b904f9449e6f93b7fd35eac28640d7929e69
2012-01-06 10:07:54 +00:00
Steve Block
6215d3ff4b Rename (IF_)LOGI(_IF) to (IF_)ALOGI(_IF) DO NOT MERGE
See https://android-git.corp.google.com/g/156801

Bug: 5449033
Change-Id: Ib08fe86d23db91ee153e9f91a99a35c42b9208ea
2012-01-04 20:05:49 +00:00
Steve Block
5baa3a62a9 Rename (IF_)LOGD(_IF) to (IF_)ALOGD(_IF) DO NOT MERGE
See https://android-git.corp.google.com/g/156016

Bug: 5449033
Change-Id: I4c4e33bb9df3e39e11cd985e193e6fbab4635298
2012-01-03 22:38:27 +00:00