samsung: doze: use ExecutorService for listener registration
authorezio84 <brabus84@gmail.com>
Thu, 14 Jun 2018 13:00:19 +0000 (15:00 +0200)
committerBruno Martins <bgcngm@gmail.com>
Wed, 13 Jan 2021 14:24:41 +0000 (15:24 +0100)
commitaf08e80c2876ba3b6fe5374014c436c8ba89a1c1
tree12ff0a1f42c5aedf7930a6b3ef9a48de7b707fff
parent31c0675e728144308f38a7d06bc354d2db9e6138
samsung: doze: use ExecutorService for listener registration

Replicate what Google did for SystemUI in this commit.
https://github.com/aosp-mirror/platform_frameworks_base/commit/fabc743bcf6e6623e530545c4b31285ea642f087

Registering a sensor seems to be an expensive operation,
and we do it on each screen-on event, so moving it to
an asynchronous task looks like a good idea anyway.

By moving all non-essential binder calls of the main thread or to the
next frame, we bring this down to 5ms, such that window animation
and Keyguard animation starts about at the same time.

The interesting part about the ExecutorService:
"Memory consistency effects: Actions in a thread prior to the submission
of a Runnable or Callable task to an ExecutorService happen-before any
actions taken by that task, which in turn happen-before the result is
retrieved via Future.get()."
(from https://developer.android.com/reference/java/util/concurrent/ExecutorService)

Change-Id: I4f37bb9a7dc9d7775d587d4ebd4b6619f3b77e81
doze/src/org/lineageos/settings/doze/SamsungDozeService.java