From c5a33f83c66a7b2305b06dcb478016882bfb1714 Mon Sep 17 00:00:00 2001 From: Jack He Date: Wed, 20 Mar 2019 17:38:11 -0700 Subject: DO NOT MERGE Atoms: Add BluetoothClassicPairingEvent * Add BluetoothClassicPairingEvent to log pairing and encryption related statistics Bug: 124301137 Test: test drive with statsd Change-Id: Idca6f6d340e03af91c5a6fb4102666d44167635b (cherry picked from commit 6110c95184c6ca0265ebc39235ca81da21c0483d) --- cmds/statsd/src/atoms.proto | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto index 18aa0d06d6dc..30995d28e985 100644 --- a/cmds/statsd/src/atoms.proto +++ b/cmds/statsd/src/atoms.proto @@ -122,6 +122,8 @@ message Atom { WTFOccurred wtf_occurred = 80; LowMemReported low_mem_reported = 81; ThermalThrottlingStateChanged thermal_throttling = 86; + // 86 - 165 are not available + BluetoothClassicPairingEventReported bluetooth_classic_pairing_event_reported = 166; } // Pulled events will start at field 10000. @@ -1026,6 +1028,42 @@ message BluetoothConnectionStateChanged { optional int32 bt_profile = 3; } +/** + * Logs there is an event related Bluetooth classic pairing + * + * Logged from: + * system/bt + */ +message BluetoothClassicPairingEventReported { + // An identifier that can be used to match events for this device. + // Currently, this is a salted hash of the MAC address of this Bluetooth device. + // Salt: Randomly generated 256 bit value + // Hash algorithm: HMAC-SHA256 + // Size: 32 byte + // Default: null or empty if the device identifier is not known + // Note: string is here for backward compatibility purpose only + optional string obfuscated_id = 1; + // Connection handle of this connection if available + // Range: 0x0000 - 0x0EFF (12 bits) + // Default: 0xFFFF if the handle is unknown + optional int32 connection_handle = 2; + // HCI command associated with this event + // Default: CMD_UNKNOWN + optional int32 hci_cmd = 3; + // HCI event associated with this event + // Default: EVT_UNKNOWN + optional int32 hci_event = 4; + // HCI command status code if this is triggered by hci_cmd + // Default: STATUS_UNKNOWN + optional int32 cmd_status = 5; + // HCI reason code associated with this event + // Default: STATUS_UNKNOWN + optional int32 reason_code = 6; + // A status value related to this specific event + // Default: 0 + optional int64 event_value = 7; +} + /** * Logs when something is plugged into or removed from the USB-C connector. * -- cgit v1.2.3 From bac376dd4095c1ef930aff46e457af6a50956a31 Mon Sep 17 00:00:00 2001 From: Varun Shah Date: Wed, 20 Mar 2019 11:10:33 -0700 Subject: Added missing permission check to isPackageDeviceAdminOnAnyUser. Added a check for the MANAGE_USERS permission to PackageManagerService#isPackageDeviceAdminOnAnyUser. To test that the method is still usable: 1) Enable virtual storage via: adb shell sm set-virtual-disk true 2) Follow instructions by clicking on notification to set up virtual storage 3) Go to Settings -> Apps & notifications -> See all X apps 4) Click on any non-system app (example Instagram) 5) Tap Storage and you should see a "Change" button (if not, choose another app) 6) Tap Change and you should see Internal and Virtual storage options listed 7) The above step confirms the method is still usable by Settings Bug: 128599183 Test: SafetyNet logging (steps listed above) Change-Id: I989f1daf52a71f6c778ebd81baa6f1bf83e9a718 Merged-In: I36521fa43daab399e08869647326a7ac32d1e512 (cherry picked from commit 18e7dedf6c35f07daf8b7239d501737745ac7f43) --- services/core/java/com/android/server/pm/PackageManagerService.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 82ad46f08aed..3cde709bfeb2 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -18141,6 +18141,12 @@ public class PackageManagerService extends IPackageManager.Stub @Override public boolean isPackageDeviceAdminOnAnyUser(String packageName) { final int callingUid = Binder.getCallingUid(); + if (checkUidPermission(android.Manifest.permission.MANAGE_USERS, callingUid) + != PERMISSION_GRANTED) { + EventLog.writeEvent(0x534e4554, "128599183", -1, ""); + throw new SecurityException(android.Manifest.permission.MANAGE_USERS + + " permission is required to call this API"); + } if (getInstantAppPackageName(callingUid) != null && !isCallerSameApp(packageName, callingUid)) { return false; -- cgit v1.2.3 From dcf3d9f84bbd556c9e9d2c9b76c97bd32cda4e3b Mon Sep 17 00:00:00 2001 From: Pavel Grafov Date: Wed, 10 Apr 2019 12:47:25 +0100 Subject: Limit IsSeparateProfileChallengeAllowed to system callers Fixes: 128599668 Test: build, set up separate challenge Change-Id: I2fef9ab13614627c0f1bcca04759d0974fc6181a (cherry picked from commit 1b6301cf2430f192c9842a05fc22984d782bade9) --- .../com/android/server/devicepolicy/DevicePolicyManagerService.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 11fe76383c76..4c0646ceed86 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -3930,6 +3930,9 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { @Override public boolean isSeparateProfileChallengeAllowed(int userHandle) { + if (!isCallerWithSystemUid()) { + throw new SecurityException("Caller must be system"); + } ComponentName profileOwner = getProfileOwner(userHandle); // Profile challenge is supported on N or newer release. return profileOwner != null && -- cgit v1.2.3 From e4061052379c3400e4db86ec0f3e858b0c75a5c2 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Wed, 27 Mar 2019 12:15:57 -0400 Subject: Add cross user permission check - areNotificationsEnabledForPackage Test: atest Fixes: 128599467 Change-Id: I13a0ca7590f8c4b44379730e0ee2088aba400c2a Merged-In: I13a0ca7590f8c4b44379730e0ee2088aba400c2a (cherry picked from commit 657d164136199126ae241848887de0230699cea0) (cherry picked from commit 63846a7093ca7c6d89b73fc77bdff267b3ecb4ef) --- .../notification/NotificationManagerService.java | 5 +++++ .../notification/NotificationManagerServiceTest.java | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index 82363d102c40..1928cb7d0f0e 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -2186,6 +2186,11 @@ public class NotificationManagerService extends SystemService { @Override public boolean areNotificationsEnabledForPackage(String pkg, int uid) { checkCallerIsSystemOrSameApp(pkg); + if (UserHandle.getCallingUserId() != UserHandle.getUserId(uid)) { + getContext().enforceCallingPermission( + android.Manifest.permission.INTERACT_ACROSS_USERS, + "canNotifyAsPackage for uid " + uid); + } return mRankingHelper.getImportance(pkg, uid) != IMPORTANCE_NONE; } diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java index f02c3f062f35..5622622e925e 100644 --- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java @@ -34,6 +34,7 @@ import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_SCREEN_ON import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_STATUS_BAR; import static android.content.pm.PackageManager.FEATURE_WATCH; import static android.content.pm.PackageManager.PERMISSION_DENIED; +import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.os.Build.VERSION_CODES.O_MR1; import static android.os.Build.VERSION_CODES.P; @@ -106,6 +107,7 @@ import android.testing.AndroidTestingRunner; import android.testing.TestableContext; import android.testing.TestableLooper; import android.testing.TestableLooper.RunWithLooper; +import android.testing.TestablePermissions; import android.text.Html; import android.util.ArrayMap; import android.util.AtomicFile; @@ -3145,4 +3147,21 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { assertEquals(0, captor.getValue().getNotification().flags); } + + @Test + public void testAreNotificationsEnabledForPackage_crossUser() throws Exception { + try { + mBinderService.areNotificationsEnabledForPackage(mContext.getPackageName(), + mUid + UserHandle.PER_USER_RANGE); + fail("Cannot call cross user without permission"); + } catch (SecurityException e) { + // pass + } + + // cross user, with permission, no problem + TestablePermissions perms = mContext.getTestablePermissions(); + perms.setPermission(android.Manifest.permission.INTERACT_ACROSS_USERS, PERMISSION_GRANTED); + mBinderService.areNotificationsEnabledForPackage(mContext.getPackageName(), + mUid + UserHandle.PER_USER_RANGE); + } } -- cgit v1.2.3