Before N, when MTP device is connected to Android, it opened the
activity selector for applications that could handle the MTP device.
For N, we updated the behavior to make it consistent with other storage
devices like USB mass storage. In N, the system showed the notification
first, then showed the activity selector after a user taps the
notification.
The N behavior causes a problem that the user always needs to tap the
MTP notification even after the user select a default application for
the MTP device.
The CLs tweaks the behavior for O so that the system can skip the MTP
notification if the system has the default app for the connected MTP
device.
The default app is one of them:
* App selected by a user by clicking "Always use" in the activity
selector
* System app that is an only application which can handle the MTP
device in the system
* App that is an only application which can handle the MTP device in
the system where config_disableUsbPermissionDialogs=true.
Bug: 32119378
Test: Connecting MTP device to Android, which automatically opens system
app. Connecting PTP device to Android, which shows a notification.
Tapping the notifiction opens the acitivity selector.
Change-Id: I51f1d55e8c7d1db87d91ddf966631d275a171546
Adapts all notifications used by system services to use channels.
Channels are initialized by SystemServer after the NotificationService
has started.
Test: runtest systemui-notification
Change-Id: I25c45293b786adb57787aeab4c2613c9d7c89dab
The getService() and registerAsService() methods of interface objects
now have default parameters of "default" for the service name. HALs
will not have to use any service name unless they want to register
more than one service.
Test: boots
Test: hidl_test
Bug: 33844934
Change-Id: I5774469712d70de4b2629258fe54d7f8c280d9d0
Type-c ports can quickly toggle between connected/disconnected
states. Introduce debounce to prevent sending spurious notifications.
Bug: 34972898
Test: notification should not be queued for a pixel-c charger not connected
to the power outlet.
Change-Id: I4aa19f9f864fe5b77e65f6a07a3184d8aba1f5fc
UsbPort.POWER_ROLE_SINK is orthogonal to the type of the charger
attached. POWER_ROLE_SINK would be the case for AC charging and
USB charging. Therefore query BatteryManager for the charger
type.
Bug: 34972898
Test: Charging notification should not show for pixel-c chargers.
Change-Id: I8dddcd7727b6af973bd173d2c6e325aa4be2ca3a
Type-c ports can quickly toggle between connected/disconnected
states. Introduce debounce to prevent sending spurious notifications.
Bug: 34972898
Test: notification should not be queued for a pixel-c charger not connected
to the power outlet.
Change-Id: I4aa19f9f864fe5b77e65f6a07a3184d8aba1f5fc
UsbPort.POWER_ROLE_SINK is orthogonal to the type of the charger
attached. POWER_ROLE_SINK would be the case for AC charging and
USB charging. Therefore query BatteryManager for the charger
type.
Bug: 34972898
Test: Charging notification should not show for pixel-c chargers.
Change-Id: I8dddcd7727b6af973bd173d2c6e325aa4be2ca3a
Broadcasts are not sent until BOOT_COMPLETED is received.
When the device boots with usb plugged, the UPDATE_STATE
for connted and configured would be received way before
BOOT_COMPLETED is received. Since, devices can continue
to stay in same usb configuration(set through persistent
property trigger), check and send a usb state broadcast
if needed.
BUG: 34451258
Test: Manually checked to verify the broadcasts sent.
Change-Id: I8eca5f241ad758f5c4f1afa6c9807868dfd6195a
This prevents cases where the device starts up and attempts
to change the config, but intents cannot yet be sent.
A patch to resend this skipped intent is necessary to
finish fixing the bug.
Bug: 34451258
Test: Check that usb state is properly handled on boot
Change-Id: I9d79c67ce8982fd5b43fa40781b66bb9ae820694
This gets rid of an extraneous configuration change when going from
adb to adb + file transfer as previously the config would have been
reset once for functions and once for data unlocked.
It also simplifies some of the code.
Bug: 31814300
Test: manually changing usb configurations
Change-Id: Ica10a195338b2189db13113f44657393db110bee
(cherry picked from commit 7a396be6d5ba8914933a54b5bfac25e118db0e9f)
Move to a USB HAL to handle type-c ports as upstream is
considering in merging a generic type-c interface to mainline
kernel. However, the new sysfs interface can see minor changes
in the future as the sysfs interface is sitll going to land
in testing and it is still under review.
Bug: 31015010
Test: Manually tested on Angler and sailfish for type-c role switches.
Change-Id: I26771074c4b4f79a133e519bc6d35a4864a696d8
Apps that target O+ are always subject to background restrictions.
Legacy apps' background restriction is subject to the OP_RUN_IN_BACKGROUND
app op.
Apps with these properties are exempted from background restrictions:
- persistent process
- currently on the idle battery whitelist
- global whitelist for things like bluetooth services
Bug 30953212
Change-Id: Icc19b2fbc05f40dcf8c3fc4abf718c373dc8d4f6
Apps that target O+ are always subject to background restrictions.
Legacy apps' background restriction is subject to the OP_RUN_IN_BACKGROUND
app op.
Apps with these properties are exempted from background restrictions:
- persistent process
- currently on the idle battery whitelist
- global whitelist for things like bluetooth services
Bug 30953212
Change-Id: Ib444829a2d222125f64ff19e8218823fa78373f9
b/31814300 was fixed, but mtp can still stick around in the
persistent config even after flashing. This block of code
will only run once, but will ensure that mtp is not in
the config after the update.
Bug: 31814300
Test: Manual
Change-Id: Icf02be38c9e1f769412ac963ed6afc14e6092bfb
(cherry-picked from commit a45dac0e83f4f907b6b42f453181a7d5c01f65f3)
When changing state to adb from mtp (charging), we want to disable
the old mtp function. Similarly when change to away from adb to
charging, enable the mtp function.
Also the mtp function should never be persisted.
Bug: 31818377
Bug: 31814300
Test: Manually verify that the correct usb configuration is displayed.
Test: Manually verify that logcat is not kicked during boot.
Change-Id: Idcb7f53be39ea38712d5de45b323d8daeb552129
(cherry-picked from commit 58018d01a3c384b954275d15bee7f9c52a1c7c0a)
The debouncing of USB disconnects means that the disconnect caused
by resetting the connection without unplugging the device does not make
it to the handler, and thus doesn't exit accessory mode. Therefore we
must exit accessory mode even for connect events after we have left the
entering accessory mode state.
Test: Manual testing with desktop head unit
Change-Id: Ia028ff28783fa777a9f8bcd86b523d01f633a140
Functionfs requires MtpServer to write descriptors before the device can be
configured. This adds a new configure call that will occur only when
functions are changed (new argument added to updateUsbStateBroadcast for this)
and be called after sys.usb.config is changed but before the waitForState
call to ensure compatibility with configfs devices.
Bug: 30976142
Change-Id: I7e94a5847d3b19c0fd75139e1b15a3f2a1cea01d
Test: Manual
If there are differnet priorities only consider the acitities with the
highest priorities. Esp, if there is only one app with the highest
priority launch it directly.
This enables an interesting use case:
If a priviledged app wants to always be launched for a device it can
just set the priority to >0. As it is also on system/ the user
_will_not_ get a confirmation dialog and the app will always be directly
launched.
Test: Added app with higher priority to device and saw it to get
auto-selected.
Fixes: 28595282
Change-Id: Ia2c9afa00b5a6e8a00b30a01442da62dd0e33961
This gets rid of an extraneous configuration change when going from
adb to adb + file transfer as previously the config would have been
reset once for functions and once for data unlocked.
It also simplifies some of the code.
Test: manually changing usb configurations
Change-Id: Ica10a195338b2189db13113f44657393db110bee
(cherry picked from commit 7a396be6d5ba8914933a54b5bfac25e118db0e9f)
b/31814300 was fixed, but mtp can still stick around in the
persistent config even after flashing. This block of code
will only run once, but will ensure that mtp is not in
the config after the update.
Bug: 31814300
Test: Manual
Change-Id: Icf02be38c9e1f769412ac963ed6afc14e6092bfb
(cherry-picked from commit a45dac0e83f4f907b6b42f453181a7d5c01f65f3)
When changing state to adb from mtp (charging), we want to disable
the old mtp function. Similarly when change to away from adb to
charging, enable the mtp function.
Also the mtp function should never be persisted.
Bug: 31818377
Bug: 31814300
Test: Manually verify that the correct usb configuration is displayed.
Test: Manually verify that logcat is not kicked during boot.
Change-Id: Idcb7f53be39ea38712d5de45b323d8daeb552129
(cherry-picked from commit 58018d01a3c384b954275d15bee7f9c52a1c7c0a)
b/31814300 was fixed, but mtp can still stick around in the
persistent config even after flashing. This block of code
will only run once, but will ensure that mtp is not in
the config after the update.
Bug: 31814300
Test: Manual
Change-Id: Icf02be38c9e1f769412ac963ed6afc14e6092bfb
When changing state to adb from mtp (charging), we want to disable
the old mtp function. Similarly when change to away from adb to
charging, enable the mtp function.
Also the mtp function should never be persisted.
Bug: 31818377
Bug: 31814300
Test: Manually verify that the correct usb configuration is displayed.
Test: Manually verify that logcat is not kicked during boot.
Change-Id: Idcb7f53be39ea38712d5de45b323d8daeb552129