OSDN Git Service

Fix PermissionMonitor issues
authorPaul Hu <paulhu@google.com>
Mon, 25 Nov 2019 18:35:55 +0000 (10:35 -0800)
committerpaulhu <paulhu@google.com>
Thu, 19 Dec 2019 05:43:40 +0000 (13:43 +0800)
commit9352cb24b1afaec657faeffdb0d40ed96d4d912b
treeaf60cb119494d8abe71f255805684ba1d2df36c7
parent3e4f4f9933f81cdf13b0cb1836fd0b3ea0c36ea1
Fix PermissionMonitor issues

PermissionMonitor#hasPermission only checks permssions that app
requested but it doesn't check whether the permission can be
granted to this app. If requested permission doens't be granted
to app, this method still returns that app has this permission.
Then PermissionMonitor will pass this info to netd that means
this app still can use network even restricted network without
granted privileged permission like CONNECTIVITY_INTERNAL or
CONNECTIVITY_USE_RESTRICTED_NETWORKS.

PermissionMonitor#hasUseBackgroundNetworksPermission only uses
the first package name of the uid for checking permission.
This is incorrect since each package declared different
permissions. So using the mApps which already checked both
network and using restricted network permissions. If uid is in
the mApps list that means uid has one of permission at least.

Bug: 144679405
Test: Build, flash, manual test
      atest FrameworksNetTests

Change-Id: I2da730feda4d7ebed1f158b073167bb3964b3e7d
Merged-In: I8b03c9e23ffc9ff46264d6307fb841a7eda76a76
Merged-In: Ib08a940a6e5d3365c392ab7174d8484c197e0947
(cherry picked from commit 2e1da35b3b903f4aa01435c46b7014b88a41328d)
services/core/java/com/android/server/connectivity/PermissionMonitor.java
tests/net/java/com/android/server/ConnectivityServiceTest.java
tests/net/java/com/android/server/connectivity/PermissionMonitorTest.java