Commit Graph

25 Commits

Author SHA1 Message Date
Treehugger Robot
f46a32f2b7 Merge "Fix ADB key file reading" 2022-06-22 19:35:22 +00:00
William Hester
efb8194ec4 Fix ADB key file reading
The "adb_temp_keys.xml" file is used to keep track of each ADB key and
when it was previously connected. It also keeps track of authorized WiFi
networks. It is written correctly, however, the parser currently is
unable to read the file that it wrote, meaning that:
1. ADB keys never properly expire
2. WiFi APs are never properly restored

Furthermore, because of complex interactions with restoring the adb_keys
file in Test Harness Mode, duplicate keys get appended repteatedly to
the adb_keys file if they're not in the key map.

This cleans up the file, making it more testable, adds tests for the
previously broken functionality, and just performs some simple
restructuring of bits of the code that were error-prone.

Now, the adb_keys file is nothing but a view of the temp keys file. When
keys are added to the temp keys file, we completely rewrite the adb_keys
file with the set of keys present in the temp keys file, meaning that
duplicates cannot be added.

This also introduces a method for other system services (primarily for
TestHarnessModeService) to notify the AdbDebuggingManager that the key
files were modified, and it should reload the state.

Bug: 236299256
Test: atest AdbDebuggingManagerTest

Change-Id: Iae955aca17e873288d58b16f184bd4d325d50d86
2022-06-21 15:51:56 -07:00
William Hester
6f06edfc85 Add OWNERS for core/java/android/debug
enh@google.com and shaju@google.com own ADB, so they should own this
code path.

Change-Id: I161af9738c16ba3f93ebd4a8cf0edd3e74af4aaf
Test: N/A
2022-06-21 15:45:02 -07:00
Bill Yi
95267eaf87 Merge SP2A.220405.004 to aosp-master - DO NOT MERGE
Merged-In: Iae1a66165221f45051be17c4d047b5bd5be3999b
Merged-In: I0c82fda5497bace30d49989b8e84ebc98250ca8c
Change-Id: I2c75988c023cec548e3a576cb0c3a1a13bb0016f
2022-04-07 18:40:59 -07:00
Joshua Duong
f238799415 Restrict AdbManager broadcasts to apps with MANAGE_DEBUGGING permission.
Bug: 205836329
Test: atest AdbDebuggingManagerTest
Change-Id: If18a874c6d6232d9131f2cc3de3614ef67a58bbd
(cherry picked from commit b139e99661)
(cherry picked from commit dc7d96c9e5)
Merged-In:If18a874c6d6232d9131f2cc3de3614ef67a58bbd
2022-02-14 23:12:49 +00:00
Yifan Hong
08fdaa25cb AdbService sends callback on adb debugging enabled / disabled.
Test: pass
Bug: 190867939
Change-Id: Ieebe78e01bec948a1475d1c74a84b95e275fa48e
2021-08-03 14:17:10 -07:00
Yifan Hong
a623e99230 IAdbManager.getPairDevices returns FingerprintAndPairDevice[].
Map is not supported in C++ backend. To compile IAdbManager in C++,
Map is translated into a list of key, value tuples.

Test: pass
Bug: 194829333
Change-Id: I92e3ad29e8a2bfbab3756d2ef5a2db76ba3cc3d9
2021-08-03 14:17:07 -07:00
Yifan Hong
882a6e20b6 PairDevice to structured Parcelable.
Bug: 194829333
Test: pass
Change-Id: I0b44555403113a7f68c865b33b87a85a6847cf21
2021-08-03 14:17:03 -07:00
Joshua Duong
b381dfaf18 Don't attach PendingIntent if settings app is hidden.
The settings app may not be available. In that case, just show the adb
notification without a PendingIntent.

Bug: 156453114

Test: atest AdbNotificationsTest
Test: With USB debugging enabled, install TestDPC, and use it to hide settings app.
Unplug and replug USB. USB debugging notification shows up and clicking
it does nothing.
Change-Id: Ie29d2c425c05bce9371600d76e4eb2eaba692fd7

Change-Id: Ie5f746cbc7b8a32fc280177bf281a9e973c8df12
2020-05-15 18:58:33 +00:00
Joshua Duong
ec1980f86b Fix PendingIntent hijacking for adb notifications.
Use an explicit intent and set PendingIntent.FLAG_IMMUTABLE to prevent
someone from modifying the intent from PendingIntent.send(...).

Bug: 153356209

Test: atest AdbNotificationsTest
Test: In bug, install and launch the PoC apk and give it notification
permissions. Then, with USB/Wifi debugging enabled, disconnect and connect
the device to create the adb notification. the PoC apk should not have
permission to display information from
content://com.android.settings.files/my_cache/NOTICE.html.

Change-Id: Ie49aa3cf9b33168cf1435fc2427e95aac7f4609b
(cherry picked from commit 2c03881459)
Exempt-From-Owner-Approval: approved in master
2020-04-17 16:08:39 +00:00
Joshua Duong
ac29885a0e Allow UsbDeviceManager to start adbd again.
There's some weird state where if persist.sys.usb.config=none,adb, then
adbd won't get started. Give back adbd start permissions to
UsbDeviceManager to see if that fixes the issue.

Bug: 150130503
Bug: 150116813

Test: adb shell su 0 setprop persist.sys.usb.config none,adb; adb reboot
adb should be online after.

Change-Id: I36c6ef4b20d58570a2d51ed70088ae5c54d6687d
Exempt-From-Owner-Approval: Fix adbd offline failure
(cherry picked from commit 7a3800993d)
2020-02-26 16:26:39 +00:00
Joshua Duong
b401e0a8bb Add AdbTransportType.aidl. Add AdbWifi internal API stubs.
Since wireless debugging can be enabled without usb debugging enabled,
we'll need to differentiate between which transport is enabled.

Also added the internal AdbManager stubs for wireless debugging. Adding
implementation in separate CL to get around merge conflict with a SysUI
CL in the stack.

BUG: b/111434128

Test: make
Exempt-From-Owner-Approval: already approved
Change-Id: I4e1ae6398f291f321e61e7eb119564ebd5e54c2e
2020-02-19 02:41:21 +00:00
Joshua Duong
a5cbda4729 Add SystemApis isAdbWifiSupported(), isAdbWifiQRSupported() to AdbManager.
Bug: 146139798, 111434128

Test: make
Change-Id: Iab20d20b39f0079418026a730cd4093de08d1db9
2020-01-17 22:08:45 -08:00
William Hester
99a7d633b3 Fix Test Harness Mode to work with new ADB file
Because the ADB keys are now stored in adb_temp_keys.xml as well, Test
Harness Mode should back up and restore that file. To resolve a comment
in the initial CL, it uses a LocalService to actually interact with the
AdbService to retrieve the file, so any future changes in file location
should be immediately propagated to Test Harness Mode.

There were also two minor bugs fixed in this CL:
1) When serializing the adb keys to the XML file, if the allowedTime was
   0, they were all removed
2) If all keys are removed, the file was only an XML header and therefore
   invalid XML

Test: adb shell cmd testharness enable
Test: adb shell settings put global adb_allowed_connection_time 1;
unplug device, plug device back in, adb shell cat
/data/misc/adb/adb_temp_keys.xml (should return 'No such file or
directory')
Change-Id: I09e2998a0b80660486502f7486d4c838219c342c
2019-02-08 12:38:08 -08:00
Kenny Root
a5964c08bc Move AdbDebuggingManager to AdbService
Also remove the "Usb" from the AIDL function since it's not really
related to USB.

Test: make
Bug: 63820489
Change-Id: Ibf23964665a115a5bc835820dcff98aaf7ba610f
2018-10-31 16:11:02 +09:00
Kenny Root
473121834b AdbService: move source of truth for enabled
This makes the AdbService the source of truth for whether ADB is enabled
on the system or not. All UsbManager checks will now query the
AdbService.

Test: make
Bug: 63820489
Change-Id: I2965a15b5fa9f747fe0ae4dc791b5e357e78253f
2018-10-31 16:11:02 +09:00
Kenny Root
a269b334d5 Add function to query ADB state
This is what the USB manager will use to query the current ADB state in
the future.

Bug: 63820489
Test: make
Change-Id: I70484f97e56af4e5104611dc3b43ef83885671d7
2018-10-31 16:11:02 +09:00
Kenny Root
61fd360f50 Add ADB transport skeleton
This adds the AIDL definition for ADB transports. For instance USB is
one type of ADB transport and the only one supported now.

Bug: 63820489
Test: make
Change-Id: Id422a814567021ab4b1097c2792a95c42bfccf74
2018-10-31 16:11:01 +09:00
Kenny Root
dc14eb700a Add empty AdbManagerInternal for system server
This will allow the call of internal-only AdbService functions from within
the system server.

Bug: 63820489
Test: make
Change-Id: Ic761b513a8c10ce0173ddb6bc761a6372799f15c
2018-10-31 16:11:01 +09:00
Kenny Root
f74bfdee01 Add empty AdbService to SystemServer
Create skeleton service to migrate functions from UsbService in later
change.

Bug: 63820489
Test: make
Change-Id: I07672fe87cfae188fe77c173fc49119e182c6b05
2018-10-31 16:11:01 +09:00
Ashok Bhat
42f06b0e22 Remove unused JNITest class
JNITest class is no longer actively used. This patch
removes the class (java and jni) files.

JNI interfaces and calls are extensively tested in
the art unit tests (art/tests) and in cts (see
CtsJniTestCases).

Change-Id: I62f7c72deb5d206fa3f545ae39a9cb9011110d0a
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
2014-02-21 14:34:35 +00:00
Kenny Root
3a084af2e9 Correct executable bit for source files
Many media files and source code files were marked as executable in Git.
Remove those.

Also a shell script and python script were not marked as executable.

Change-Id: Ieb51bafb46c895a21d2e83696f5a901ba752b2c5
2012-11-07 10:27:31 -08:00
The Android Open Source Project
9066cfe988 auto import from //depot/cupcake/@135843 2009-03-03 19:31:44 -08:00
The Android Open Source Project
d83a98f4ce auto import from //depot/cupcake/@135843 2009-03-03 18:28:45 -08:00
The Android Open Source Project
54b6cfa9a9 Initial Contribution 2008-10-21 07:00:00 -07:00