Error dialogs absorb all input to ensure that they are not missed. This can cause the screen to lock up if they are not displayed but are still absorbing touches. This was what was happening when there was an error dialog up at the same time as a phone call came in as in b/17648830.

This fix recognizes when an app is dismissing the keyguard and forces any error dialogs to be shown over such an app.

This also removes the private flags from the input system as they are no longer needed.

TvStreamConfig should do deep comparison in TvInputHardwareManager where the object gets created from binder calls. In addition to this fix, modify [aA]ddStream to [aA]ddOrUpdateStream so that the method name better reflects what it does.

We set the system_server classpath in the environment (like we do with BOOTCLASSPATH). After the zygote forks the system_server, we dexopt the classpath (if needed) and then launch the system server with the correct PathClassLoader. This needed several small / medium refactorings :

- The logic for connecting to installd is now in a separate class and belongs in the system_server. - SystemService / SystemServiceManager have now moved to classes.jar. They are only used from there, and since they use Class.forName, we want them to be loaded by the system_server classloader, and not the bootclassloader. - BootReceiver now moves to frameworks.jar, because it is used by ActivityThread and friends.

This eliminates the need for the ConnectivityService.VpnCallback class. This requires shifting VPNs to the new "network" netd API. VpnService.protect() is modified to no longer go through ConnectivityService. NetworkCapabilities is extended to add a transport type for VPNs and a capability requiring a non-VPN (so the default NetworkRequest isn't satisfied by a VPN).

Since DEVICE_AVAILABLE event fires right after initialization, it could happen before TvInputHal.mPtr is set, which causes calls to null pointer. Fix the bug by allowing TvInputHal to wait for mPtr to be set before calling native methods.

Routing control action is initiated in various cases, such as manual TV input port switching, routing change of a different CEC switch, and so on. The action determines the device to be a new active source.

Local device is in charge of handling incoming messages and for some messages such as <set menum language> or <report physical address> each device has slightly different behavior. Instread of checking destination address and local device status from service, this change leaves it to each local device. Note that some messages are still left on service and will be refactored in the following changes.

HdmiCecService will soon be deprecated and replaced with HdmiControlService. Stopped publishing the service, and turned the corresponding manager to stub so that it will do nothing but print out a warning msg instead.

Will help the app transition to the new service in the meantime. Once the migration is finished, will gut out all the HdmiCecService/ HdmiCecManager stuff.

Notification for incoming cec message can be issued from any thread but jni can call java method in the thread that jni knows like service thread. So this change delegates incoming message to jni-friendly thread, service thread by exploit looper of service thread.

Instead of storing a direct SkCanvas reference, Canvas now tracks an opaque native wrapper class. The native wrapper can be used to store additional info for emulating deprecated Skia features (at this point it only stores a canvas).

HdmiCecService will soon be deprecated and replaced with HdmiControlService. Stopped publishing the service, and turned the corresponding manager to stub so that it will do nothing but print out a warning msg instead.

Will help the app transition to the new service in the meantime. Once the migration is finished, will gut out all the HdmiCecService/ HdmiCecManager stuff.

Notification for incoming cec message can be issued from any thread but jni can call java method in the thread that jni knows like service thread. So this change delegates incoming message to jni-friendly thread, service thread by exploit looper of service thread.

This change includes native jni implementation for incoming and outgoing message of CEC. For incoming message, native layer converts it into three pieces, source address (initiator), destination address (follower) and data body which includes opcode. In Java layer, it is delegated to main io thread. For now all messages are rejected by sending <Feature Abort> to initiator. For outoging message, all messages are sent to io thread and it delegates it into native layer. Native logic converts it into cec_message and pass it to HAL so that HAL performs sending message. In order to handle <Feature Abort> message, added [Abort reason] which is defined in hdmi_cec.h.

HdmiCecService is a system service handling HDMI-CEC features and command. Recently we found out that industry has more requirements to support HDMI-CEC. Also, MHL is another standard should be in our pocket. Basically, MHL is a standard to support communication between mobile device and TV or Av device. As CEC is a control standard over HDMI cable, MHL has control channel for peer device. There behavior is very similiar. Both have commands that can change Tv's current input and can send/receive key to other device to control other deivce or TV.

In order to cover both CEC and MHL, current HdmiCecService implementation has limitation. We had several session of discussion and decided to refactor HdmiCecService into HdmiControlService. For each standard it will have separate controller instance like HdmiCecController and HdmiMhlController.

In this change I didn't touch original HdmiCecService because some component, like cast receiver, uses HdmiCecService. For a while we will keep HdmiCecService until HdmiControlService accomodates all features of HdmiCecService.

Most of the methods in the interface IHdmiCecService should be implemented based on the device type. This CL makes a change such that the HdmiCecDevice just has stub methods that should be overriden by subclasses.

Other changes: - Fixed a bug of <Inactive Source> not sending its physical address in its message body. Also the command should have been sent to TV only rather than broadcast.

- Put back sendGiveDevicePowerStatus interface method. It allows the client to keep track of the other device(like TV) power status more closely. Devices goes through the status from standby -> transient to on -> on but the CEC spec doesn't require that they broacast it actively.

The restored method can be used to let the playback device to get up-to-date power status of TV/display when it is booting up.

This method should work the same across all the device types. So it was implemented in the service, not delegated to HdmiCecDevice.

- Send <Report Physical Address> when a new logical device is registered, which is required by CEC spec: "it should report the association between its logical and physical address by broadcasting <Report Physical Address>

Previously OSD name was based on device type. This CL makes it independent of device type. CEC spec says "A device that implements more than one type of CEC functionality should respond with the same OSD name for each logical address. It is recommended that the name refers to the complete physical product rather than the individual CEC functionality".

Now the default name comes from system build property. I removed setOsdName() from aidl for now since it won't be in use.

It saves us from having to add numerous native methods to HdmiCecService. A new native method that reports physical address was added in consequence to be able to build the message in Java side.

Other changes: - Substituted more concrete type (cec_device_type_t) to int. - Fixed the issue about byte endianness in handling physical address/vendor id. The bytes of variable mPhysicalAddress in native service were being reversed previously but still worked because they were reversed again when copied out to outgoing messages. Vendor id had a bug of bytes being reversed. In order to fix the issue, the way they are copied to byte array was changed so that it becomes independent to byte endianness. - CL's for header/HAL implementation changes are: https://googleplex-android-review.git.corp.google.com/#/c/437667 https://googleplex-android-review.git.corp.google.com/#/c/437668

Use the uptime while creating the battery stats history to generate a new event indicating when the CPU is actually running. We can do this in combination with the new event reporting when the CPU comes awake, looking at the difference between the uptime and elapsed time at that point to determine when it last when to sleep.

Also use this information to generate a new set of aggregated states, the uptime caused by each wake reason.

Finally use new radio down timestamp to adjust the times we compute for radio use. Note that this information is not (yet) being used to adjust how these are recorded in the history.

b/12068020 Make kb layouts only unique to vendor/product. Do not merge

This is a cherry-pick of https://googleplex-android-review.git.corp.google.com/#/c/399886/

Instead of storing a kb layout per device descriptor (which is expected to be unique), store it for each vendor/product. This way we can keep a consistent layout between identical but physically different keyboards.

There are some corner cases this is expected to fail on, namely devices that incorrectly have the same vendor/product id. Devices that don't define a vendor/product id will continue to use the descriptor to store layout files.

Updates the format of the calibration XML to store the Surface rotation that a specific calibration applies to. Also updates the API to require a rotation value for get/set, and has the native framework supply this according to the current rotation whenever it changes.

Depends on a modification to libsuspend so that we can get a callback each time the device wakes up, to read the current wakeup reasons from the kernel. These are then stuffed in to a new field in the battery history.

Also add new dump options --history-start and --charged to better control what is dumped.

Finally the alarm manager uses a "*walarm*" tag for history item wake locks that are coming from a wakeup alarm.

The libskia target exports all of its public includes directories so redefining them here is redundant. Also this cleans up and makes it obvious where the framework is making using of private Skia headers.

When a doze component has been specified in a config.xml resource overlay, the power manager will try to start a preconfigured dream whenever it would have otherwise gone to sleep and turned the screen off. The dream should render whatever it intends to show then call startDozing() to tell the power manager to put the display into a low power "doze" state and allow the application processor to be suspended. The dream may wake up periodically using the alarm manager or other features to update the contents of the display.

Added several new config.xml resources related to dreams and dozing. In particular for dozing there are two new resources that pertain to decoupling auto-suspend mode and interactive mode from the display state. This is a requirement to enable the application processor and other components to be suspended while dozing. Most devices do not support these features today.

Consolidated the power manager's NAPPING and DREAMING states into one to simplify the logic. The NAPPING state was mostly superfluous and simply indicated that the power manager should attempt to start a new dream. This state is now tracked in the mSandmanSummoned field.

Added a new DOZING state which is analoguous to DREAMING. The normal state transition is now: AWAKE -> DREAMING -> DOZING -> ASLEEP. The PowerManager.goToSleep() method now enters the DOZING state instead of immediately going to sleep.

While in the doze state, the screen remains on. However, we actually tell the rest of the system that the screen is off. This is somewhat unfortunate but much of the system makes inappropriate assumptions about what it means for the screen to be on or off. In particular, screen on is usually taken to indicate an interactive state where the user is present but that's not at all true for dozing (and is only sometimes true while dreaming). We will probably need to add some more precise externally visible states at some point.

The DozeHardware interface encapsulates a generic microcontroller interface to allow a doze dream for off-loading rendering or other functions while dozing. If the device possesses an MCU HAL for dozing then it is exposed to the DreamService here.

Removed a number of catch blocks in DreamService that caught Throwable and attempted to cause the dream to finish itself. We actually just want to let the process crash. Cleanup will happen automatically if needed. Catching these exceptions results in mysterious undefined behavior and broken dreams.

SO_BINDTODEVICE is not needed with policy routing. SO_BINDTODEVICE was also used on the default iface which causes problems when the default iface is IPv6 only and the socket tries to connect to a IPv4 address.

Modified ActivityView to inject touch events it receives back into its activity container. The container then injects the event into the input system along with the display id of the underlying virtual display.

Add support for injecting events into ActivityContainers. (DO NOT MERGE)

Modified ActivityView to inject touch events it receives back into its activity container. The container then injects the event into the input system along with the display id of the underlying virtual display.

Enhanced the input system to support concurrent dispatch of touch events on multiple displays which is required for this to work.

Remove all of the pieces except the PointerController and SpriteController over to frameworks/native in preparation for inputflinger. Those two need to stay in frameworks/base for now because they depend on Skia currently. In the long run they should be merged into either the InputManager or the WindowManager rather than as a part of the inputservice / inputflinger.

Remove all of the pieces except the PointerController and SpriteController over to frameworks/native in preparation for inputflinger. Those two need to stay in frameworks/base for now because they depend on Skia currently. In the long run they should be merged into either the InputManager or the WindowManager rather than as a part of the inputservice / inputflinger.

Due to the very large number of internal conflicts, I have chosen to cherry-pick this change instead of letting it merge through AOSP because the merge conflict resolution would be very hard to review.

[x] Some minor changes have been done to conform with standard JNI practice (e.g. use of jint instead of int in JNI function prototypes)

[x] AssetAtlasManager is not completely 64-bit compatible yet. Specifically mAtlasMap member has to be converted to hold native pointer using long. Added a TODO to AssetAtlasManager.java to indicate the change required.

Due to the very large number of internal conflicts, I have chosen to cherry-pick this change instead of letting it merge through AOSP because the merge conflict resolution would be very hard to review.

[x] Some minor changes have been done to conform with standard JNI practice (e.g. use of jint instead of int in JNI function prototypes)

[x] AssetAtlasManager is not completely 64-bit compatible yet. Specifically mAtlasMap member has to be converted to hold native pointer using long. Added a TODO to AssetAtlasManager.java to indicate the change required.

Instead of storing a kb layout per device descriptor (which is expected to be unique), store it for each vendor/product. This way we can keep a consistent layout between identical but physically different keyboards.

There are some corner cases this is expected to fail on, namely devices that incorrectly have the same vendor/product id. Devices that don't define a vendor/product id will continue to use the descriptor to store layout files.