Commit Graph

3771 Commits

Author SHA1 Message Date
Makoto Onuki
452ae34af5 Merge "Add auto battery saver suggestion notification/dialog" into pi-dev 2018-03-27 21:20:13 +00:00
Makoto Onuki
52c6295e22 Add auto battery saver suggestion notification/dialog
Spec: go/ebs-low-battery-mode-flow

- Basically when the user manually enables battery saver 4 times,
we show this notification to suggest turning on "scheduled"
(i.e. auto) battery saver.

- We show it through 8th time. If the user hits "no thanks",
or if auto-saver is enabled already, we will not show it.

- Introduced a new notification channel "HINTS" with
IMPORTANCE_DEFAULT.

Bug: 74120126
Test: Manual test with ll development/scripts/battery_simulator.py

Change-Id: I713abc59dc7caee6882ba848c3e3aabaf778c2bd
2018-03-27 10:42:05 -07:00
TreeHugger Robot
a1ff74c68d Merge "Stop using DynamicLayout in case of non selectable PrecomputedText" into pi-dev 2018-03-27 00:10:11 +00:00
TreeHugger Robot
110a7c20f4 Merge "Sticky battery saver" into pi-dev 2018-03-26 21:41:09 +00:00
Seigo Nonaka
0c5daa19e3 Stop using DynamicLayout in case of non selectable PrecomputedText
DynamicLayout is required when
- The text is Editable.
- The selection is enabled on TextView.

This CL stops using DynamicLayout when the TextView is not selectable
TextView and the input text is PrecomputedText.

Bug: 72998298
Test: atest CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
    CtsWidgetTestCases:TextViewPrecomputedTextTest

Change-Id: Ic4a66ad3ed8868570735e3199879b74132a8c4aa
2018-03-26 14:01:04 -07:00
Makoto Onuki
a3cd7b9d53 Sticky battery saver
- When battery saver is enabled manually (i.e. via PM.setPowerSaveMode()),
it'll stick, and we'll re-enable battery saver even after a reboot
or a charge.

- Extracted all battery saver state transition logic into a separate
class.

Fix: 75033216
Bug: 74120126
Test: Manual test with "dumpsys battery set ...."
Test: atest $ANDROID_BUILD_TOP/frameworks/base/services/tests/servicestests/src/com/android/server/power/batterysaver/BatterySaverStateMachineTest.java
Change-Id: If020cd48f341b339783fe09dd35bc7199e737a52
Test: dumpsys power
Test: incident_report power
Test: atest CtsBatterySavingTestCases
2018-03-26 10:27:56 -07:00
TreeHugger Robot
6da53af9c5 Merge "Guarding collisions in TimeSparseArray" into pi-dev 2018-03-24 22:36:21 +00:00
Suprabh Shukla
2811d92483 Guarding collisions in TimeSparseArray
TimeSparseArray - used to store UsageEvents - can keep at most one event
per millisecond, which can result in an event being replaced by another
event that occurred close enough that the system records it at the same
millisecond.

Test: atest android.app.usage.TimeSparseArrayTest

Fixes: 73832306
Change-Id: I860a101ab098f65d5c5832758832f43572865690
2018-03-23 17:51:20 -07:00
Alice Sheng
7384995cf8 Merge "Add setting for disabling swap." into pi-dev 2018-03-23 18:11:12 +00:00
Kurt Marcinkiewicz
991b971acb Merge "Allow specifying a network for SNTP time sync" into pi-dev 2018-03-23 18:02:19 +00:00
Ricky Wai
651ac4d119 Merge "Use sha256 of a string as seed in RapporEncoder.insecureEncoder" into pi-dev 2018-03-23 15:55:28 +00:00
TreeHugger Robot
e9a7cb8158 Merge "Fix smart_linkify_enabled flag." into pi-dev 2018-03-22 22:56:58 +00:00
TreeHugger Robot
7fd2abdf41 Merge "PhoneWindowTest: promote to presubmit" into pi-dev 2018-03-22 22:41:40 +00:00
TreeHugger Robot
827a06d4b4 Merge "Record Bluetooth Cumulative Stats Properly" into pi-dev 2018-03-22 21:39:03 +00:00
Kurt Marcinkiewicz
dfdd82e84f Allow specifying a network for SNTP time sync
Permits syncing over a specific network instead of the default for
the process. This was causing an issue with Android Wear devices
paired with iOS where the default network is bluetooth
(see b/32663274).

This CL is in support of ag/3776564

Bug: 32663274

Test: adb shell am instrument -e class android.net.SntpClientTest -w \
com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner

Change-Id: Ic9fc169cf75457810d4992121d85d7642e350b90
2018-03-22 13:43:25 -07:00
Ricky Wai
b70d84a68b Use sha256 of a string as seed in RapporEncoder.insecureEncoder
Test: atest android.privacy.LongitudinalReportingEncoderTest
Test: atest android.privacy.RapporEncoderTest
Test: atest android.server.net.watchlist.PrivacyUtilsTests

Bug: 76001602
Change-Id: I42d569f34d29125e7adf898b9553053a42149bd4
2018-03-22 20:12:51 +00:00
Alice Sheng
b32b1ad373 Add setting for disabling swap.
Bug: 73089999
Change-Id: I89c50ae2badcb75c52652acaeb181a3161233375
2018-03-22 13:00:13 -07:00
Abodunrinwa Toki
6563833cf3 Fix smart_linkify_enabled flag.
The flag should only ensure that smart linkify calls behave in the
legacy way instead of totally disabling linkify.
Also, to keep the flag consistent with smart_selection_enabled and
smart_text_share_enabled flags, the flag should only disable the
SmartLinkify (i.e. Linkify.addLinksAsync) feature not TextClassifier
APIs (i.e. TextClassifier.generateLinks).

Also fixes issue with non-focusable TextViews by firing the primary
action instead of showing the floating toolbar. (b/73156794)

Bug: 75967597
Bug: 73156794
Test: bit FrameworksCoreTests:android.text.util.LinkifyTest
Test: bit CtsTextTestCases:android.text.util.cts.LinkifyTest
Test: bit FrameworksCoreTests:android.view.textclassifier.TextClassificationManagerTest
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest
Test: manual - checked behaviour turning flag on/off
Test: manual - checked behaviour with TextView.setFocusableInTouchMode(true/false)
Change-Id: I541f60161b9cd63ce7e57235607500f2fb0841e7
2018-03-22 19:25:14 +00:00
Robert Berry
c6bd185565 Merge "Unhide RecoveryController#getRootCertificates()" into pi-dev 2018-03-22 17:23:05 +00:00
Adrian Roos
cff1544d4a PhoneWindowTest: promote to presubmit
Bug: 73807928
Test: atest PhoneWindowTest
Change-Id: I1204f7049b6e182c5dd1f9f236e285ee7b9405ca
2018-03-22 17:38:07 +01:00
Felipe Leme
4e561f83cb Merge "Renamed AUTOFILL_COMPAT_MODE_ALLOWED_PACKAGES." into pi-dev 2018-03-22 16:24:53 +00:00
Michael Plass
dddd69ef3e Merge "Add Settings.Global.WIFI_SCORE_PARAMS" into pi-dev 2018-03-22 15:03:51 +00:00
Robert Berry
93d002ca5f Unhide RecoveryController#getRootCertificates()
This is so we can add a GTS test to affirm that GMS devices include the
Google Cloud Key Vault root certificate.

Test: runtest frameworks-core -p android.security.keystore.recovery
Bug: 74621045
Change-Id: Ib6431f5739f3dff066832e6aa300dd9da5bc0727
2018-03-22 13:49:20 +00:00
TreeHugger Robot
245f8e5ab5 Merge "Make sure at least one non-aux IME is enabled" into pi-dev 2018-03-22 03:08:38 +00:00
Felipe Leme
fd4003bf09 Renamed AUTOFILL_COMPAT_MODE_ALLOWED_PACKAGES.
The syntax of that setting changed from P Developer Preview1 to the final P, so
it's safer to use a new name than risk breaking devices during the update.

Bug: 74458004
Test: atest CtsAutoFillServiceTestCases:VirtualContainerActivityCompatModeTest\
FrameworksCoreTests:SettingsBackupTest

Change-Id: I1c507e8eae20f598dfe259178667ae6c2bc892ff
2018-03-21 16:36:25 -07:00
Mike Ma
561a8d9d60 Record Bluetooth Cumulative Stats Properly
updateBluetoothStateLocked does not check for null values, causing
NPE. This patch reverts part of the change in 3445570. Instead, an
update method is added to LongSamplingCounter, which accepts
cumulative values.
Fixes: 75963520
Test: LongSamplingCounterTest

Change-Id: I89eba8e20f8f055c60f4ff250653345a22536189
2018-03-21 13:09:28 -07:00
Makoto Onuki
16a0dd2d5e Implement new BS warning / notification flow (1/2)
- Show the battery saver confirmation dialog only for the first time.
- Start counting # of manual activations, which will be used in a
follow-up CL.

Bug: 74120126
Test: Manual tests with ./vendor/google_experimental/users/omakoto/android-battery-tester
Test: m -j ROBOTEST_FILTER=BatterySaverUtilsTest RunSettingsLibRoboTests
Test: cd frameworks/base/packages/SystemUI/tests && \
        atest src/com/android/systemui/power/PowerUITest.java src/com/android/systemui/power/PowerNotificationWarningsTest.java
Change-Id: If6a081a6222e6a87c4cd332364c89856e7648a36
2018-03-21 12:15:51 -07:00
Yohei Yukawa
9c372194f8 Make sure at least one non-aux IME is enabled
Imagine the scenario where three IMEs are installed, and only the last
two are enabled:

 IME A:
  * a pre-installed IME
  * has a subtype [mode="keyboard" && isAuxiliary=false]
  * disabled by user (hence not included in ENABLED_INPUT_METHODS)
 IME B:
  * a pre-installed IME
  * has a subtype [isAuxiliary=true]
  * currently enabled (included in ENABLED_INPUT_METHODS)
 IME X:
  * not a pre-installed IME
  * has a subtype [mode="keyboard" && isAuxiliary=false]
  * currently enabled (included in ENABLED_INPUT_METHODS)

In this scenario, when the IME X is uninstalled, the current
implementation of InputMethodManagerService (IMMS) does not try to
hard reset enabled IMEs because there is still one enabled IME, even
though it is an auxiliary IME.

This can, however, be problematic because an auxiliary IME is just a
supplemental IME and user may not be able to easily access the UI to
re-enable non-auxiliary IME such as IME A.  For instance, on the lock
screen there is no way to manually re-enable the IME A.

With this CL, every time the available IME list is updated, IMMS
ensures that at least one non-auxiliary IME is enabled.  If no
non-auxiliary IME is enabled, then IMMS tries to pick up one from the
pre-installed IME by using the same logic when choosing the default
enabled IMEs for the hard-reset scenario.

Bug: 71509065
Fix: 71509065
Test: atest FrameworksCoreTests:com.android.internal.inputmethod.InputMethodUtilsTest
Test: Manually verified in the above scenario
Change-Id: I88c69f548526b35f0e4ba37489365b2433373b04
2018-03-20 22:54:56 -07:00
TreeHugger Robot
6ed6340e3c Merge changes from topic "SoundTriggerJobService-steps" into pi-dev
* changes:
  Throttle number of sound trigger operations / day
  Add SoundTriggerDetectionService
  Expose SoundTriggerManager and SoundTrigger APIs
2018-03-21 03:27:56 +00:00
TreeHugger Robot
62fa81f7b4 Merge "Move the trusted root CA certs for RecoverableKeyStore to our own folder" into pi-dev 2018-03-21 00:38:35 +00:00
TreeHugger Robot
54ff524a2b Merge "Introduce new constructor for not copying NoCopySpan" into pi-dev 2018-03-21 00:06:40 +00:00
Michael Plass
f1510fbe7a Add Settings.Global.WIFI_SCORE_PARAMS
For experimentally varying parameters of the framework's various wifi
scoring methods.

Bug: 65216267
Test: atest SettingsBackupTest
Change-Id: I6b1476aff8c18e4dd2b5ae8d41b5a48d2b4de283
2018-03-20 16:20:14 -07:00
Bo Zhu
c5c4a0e948 Move the trusted root CA certs for RecoverableKeyStore to our own folder
Bug: 74621071
Test: runtest frameworks-core -p android.security.keystore.recovery
Change-Id: I3668594b29f56832f2a1fe78b01f585c897bf952
2018-03-20 15:17:30 -07:00
Alice Sheng
0b08926fcb Merge "Revert "Revert "Add setting for enabling CPU frequency scaling.""" into pi-dev 2018-03-20 21:56:40 +00:00
Seigo Nonaka
3483bc7d64 Introduce new constructor for not copying NoCopySpan
To hold the original text in PrecomputedText, need to create
SpannableString, but copying NoCopySpan causes some side effect.
This CL introduces a way of copying SpannableString/SpannedString
with all spans other than NoCopySpan.

Bug: 72998298
Bug: 35638900
Test: atest CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
    CtsWidgetTestCases:TextViewPrecomputedTextTest

Change-Id: I20dea2114ccaa54b16ff679c97682a5003f9a4c1
2018-03-20 14:33:35 -07:00
Andrii Kulian
002e0ef06e Merge "Don't throw exception for duplicate stop" into pi-dev 2018-03-20 21:11:09 +00:00
Philip P. Moltmann
7e25b3d915 Throttle number of sound trigger operations / day
It is not clear when the day should start. Further a day might have
25 hours in the case of daylight savings time.
Hence a day in this case is the last 24 hours, not a calendar day.

Keeping track of the time of each operation might waste memory as we
don't need that much precision.

Hence keep track how many operations were performed in the last 24
hours in buckets of hours. If the total count reaches a maximum suppress
any further operations.

The maximum is configurable via global settings. It can be updated
by apps that have the appropriate permissions. Hence if the default
value turns out to be incorrect, it can be adjusted after release.

This does not throttle based on battery state as it is better to
completely unload the sound model to not even have a detection event.

Test: atest SoundTriggerDetectionServiceTests (separate CL)
      atest android.provider.SettingsBackupTest
Bug: 73829108
Change-Id: Ied8570b60b61b6a055bd2576d1502c1b36424efa
2018-03-20 13:57:14 -07:00
Philip P. Moltmann
18e3eb8168 Add SoundTriggerDetectionService
The service is meant to replace the PendingIntent based API. Once all
users of the PendingIntent based API switched the PendingIntent based API
will be removed.

To have as little as possible impact on the whole SoundTrigger framework
the RemoteSoundTriggerDetectionService class implements the same
interface as the PendingIntent based class. Hence the exising code has
very little change. Further once the old code can be removed the amount
of changed (and added) code is limited.

The RemoteSoundTriggerDetectionService -> SoundTriggerDetectionService
is a vanilla as possible service implementation. The special behaviors
are:
- The system holds a wakelock while service operations are in progress
and the service is bound as foreground. Hence the service can e.g.
listen to the microphone.
- Service operations have a certain amount of time they are allowed to
run. Once every operation is either finished or the the operation
exceeded the allotted time, the system calls onStopOperation for each
still pending operation. This is a similar model as for the commonly
used JobService.
  Please note that if the time allowed for an operation is 15s and
op1 was run as 0si, and op1 was run at 5s, the service is allowed to run
until 20s. Hence _both_ onStopOperations will happen at 20s. This is
done for ease of implementation but should not give the service more
power than calling onStopOperation exactly 15s after each operation is
triggered.
- If an operation is done before the allotted time is reached, the
service can declare the operation as finished manually by calling
onOperationFinished. This is a call back into the system, hence a
'client' binder is sent to the service. If the operation is finished
by calling this method onStopOperation will not be called.
- As the service instance might be killed and restored between
operations we add a opaque bundle 'params' to each operations. The users
of the API can use this to send data from the start command to the
operations. It can also just be set to null. The params are not meant to
store changing state in between operations. Such state needs to be
persisted using the regular methods (e.g. write it to disk)
- A service can be used for multiple recognition sessions. Each
recognition is uniquelity defined by its sound model UUID. Hence each
operation gets at least tree arguments: Operation ID, sound mode UUID, params
- As a small optimization the params are cached inside of the service
instance.

The time allowed for each operation is in a @SystemAPI global setting,
so the service can make sure it finishes the operations before they are
stopped. It might take some time to deliver the operations via the
binder, hence it is not recommended to try to use every last ms of
allotted time.

Test: atest SoundTriggerDetectionServiceTest (added in separate CL)
      atest android.provider.SettingsBackupTest
Change-Id: I47f813b7a5138a6f24732197813a605d29f85a93
Fixes: 73829108
2018-03-20 13:57:14 -07:00
Anthony Stange
c97870a91a DO NOT MERGE Add scan background mode to Settings.Global.
This enables us to mess with the different scan intervals and shift
clients to a different scan mode in the background based on what scan
interval values we choose for the different power modes.

Bug: 71765044
Test: None. Just adding a key.
Change-Id: Id48ebc521dd3fe8a68c9c4c0bdb1018ea5b3743e
2018-03-20 10:51:54 +00:00
Andreas Gampe
92fc065cf6 Frameworks: Handle exceptions in SystemProperties callbacks
When notifying callbacks, catch thrown exceptions.

(cherry picked from commit 7074e6fd4c)

Bug: 73058952
Test: m
Test: atest SystemPropertiesTest
Merged-In: I1c61e11b833e8ddd30d80b9859b20a9fb3185a33
Change-Id: I1c61e11b833e8ddd30d80b9859b20a9fb3185a33
2018-03-19 20:33:49 -07:00
Andrii Kulian
829829ca2c Don't throw exception for duplicate stop
A double stop request is possible when display is being locked.
An activity may receive a "sleep" message followed by "stop",
both of which try to move it to stopped state.

An example when this happens: a keyguard is set up and the screen
is being locked. The keyguard will occlude the activity, which
causes a transition to paused state and, eventually, to stopped
state. A "sleep" message can be sent sometime before "stop" message
and will ignore that activity is in the process of becoming stopped.

Change-Id: I09e2c26004664b6e73ac5c2b6fe88bdf8271cf34
Fixes: 74967786
Test: FrameworksCoreTests:ActivityThreadTest
2018-03-19 18:41:15 -07:00
Alice Sheng
59a9488f50 Revert "Revert "Add setting for enabling CPU frequency scaling.""
This reverts commit 6750352248.

Reason for revert: Added SElinux policy to allow the service to be started. Verified by local testing on the latest pi-wear-dev.

Bug: 74018496
Bug: 75974893
Change-Id: I9bd8939f6292be9c160e19ebdf934023792059ba
2018-03-19 23:46:56 +00:00
Alice Sheng
7723aed494 Merge "Revert "Add setting for enabling CPU frequency scaling."" into pi-dev 2018-03-19 22:38:25 +00:00
Alice Sheng
6750352248 Revert "Add setting for enabling CPU frequency scaling."
This reverts commit 2e8afd8736.

Reason for revert: SELinux Boot crash
Bug: 75974893

Change-Id: I4751530a1b460842130a495efe688aaf19b92638
2018-03-19 22:36:52 +00:00
TreeHugger Robot
f4f317798b Merge "Settings: Remove unused bg scan throttle settings" into pi-dev 2018-03-19 22:24:04 +00:00
TreeHugger Robot
f679bda843 Merge "Move trusted CA certs to core" into pi-dev 2018-03-19 21:44:23 +00:00
TreeHugger Robot
e9b60f2cd3 Merge "Add setupwizard personalisation state to Settings" into pi-dev 2018-03-19 21:26:37 +00:00
Alice Sheng
1799f2b878 Merge "Add setting for enabling CPU frequency scaling." into pi-dev 2018-03-19 18:41:40 +00:00
TreeHugger Robot
1639c330fc Merge "Resolve STATSD and batterystats race condition" into pi-dev 2018-03-19 18:00:40 +00:00
Roshan Pius
9c396677d9 Settings: Remove unused bg scan throttle settings
Bug: 68987915
Test: Compiles
Change-Id: I49b213f0d63f2a639e45c2239506787d31ae866a
Merged-In: Id878daa0f782ddc751e726ee19cdc1c8e5ea1bc2
2018-03-19 10:39:18 -07:00