Wi-Fi panel doesn't need to check permission
Prior to this cl, we use #getPackagesForUid()
to get a list of calling package names and
pick up 1st package name in the list as target
calling package. And then go to check the
Wi-Fi permission.
This implementation is ok for most apps without
sharing system uid. However, this may not work
if the package is set with sharing system ui.
In this case, we get a list of packages
and we don't know which one is caller. So, if we
decide to choose the 1st package as our
calling package, then it could fail to pass
permission check since that package could be not
a correct calling package.
In this cl, we skip permission check for those
packages running with system uid. So, it can resolve
Wi-Fi Panel problem since Wi-Fi panel runs
on settings process(with system uid).
Test: 1. adb shell am start -a android.settings.panel.action.WIFI
2. Verify on assistant app and system ui launcher and search app.
Bug: 240531998
Change-Id: Ia825853dde2e966e3d390cecfbe1a99f6439d31e
Merged-In: Ia825853dde2e966e3d390cecfbe1a99f6439d31e
(cherry picked from commit 5e785a2d99)
Merged-In: Ia825853dde2e966e3d390cecfbe1a99f6439d31e
This commit is contained in:
committed by
Android Build Coastguard Worker
parent
58e574ea2c
commit
de33480583
@@ -103,6 +103,7 @@ public class ContextualWifiSliceTest {
|
||||
mContext.getString(R.string.config_settingsintelligence_package_name);
|
||||
ShadowBinder.setCallingUid(1);
|
||||
when(mPackageManager.getPackagesForUid(1)).thenReturn(new String[]{siPackageName});
|
||||
when(mPackageManager.getNameForUid(1)).thenReturn(siPackageName);
|
||||
ShadowWifiSlice.setWifiPermissible(true);
|
||||
mWifiSlice = new ContextualWifiSlice(mContext);
|
||||
}
|
||||
|
||||
@@ -109,6 +109,7 @@ public class WifiSliceTest {
|
||||
mSIPackageName = mContext.getString(R.string.config_settingsintelligence_package_name);
|
||||
ShadowBinder.setCallingUid(USER_ID);
|
||||
when(mPackageManager.getPackagesForUid(USER_ID)).thenReturn(new String[]{mSIPackageName});
|
||||
when(mPackageManager.getNameForUid(USER_ID)).thenReturn(mSIPackageName);
|
||||
ShadowWifiSlice.setWifiPermissible(true);
|
||||
mWifiSlice = new WifiSlice(mContext, mWifiRestriction);
|
||||
}
|
||||
@@ -116,6 +117,7 @@ public class WifiSliceTest {
|
||||
@Test
|
||||
public void getWifiSlice_fromSIPackage_shouldHaveTitleAndToggle() {
|
||||
when(mPackageManager.getPackagesForUid(USER_ID)).thenReturn(new String[]{mSIPackageName});
|
||||
when(mPackageManager.getNameForUid(USER_ID)).thenReturn(mSIPackageName);
|
||||
ShadowWifiSlice.setWifiPermissible(false);
|
||||
|
||||
final Slice wifiSlice = mWifiSlice.getSlice();
|
||||
@@ -131,6 +133,7 @@ public class WifiSliceTest {
|
||||
@Test
|
||||
public void getWifiSlice_notFromSIPackageAndWithWifiPermission_shouldHaveTitleAndToggle() {
|
||||
when(mPackageManager.getPackagesForUid(USER_ID)).thenReturn(new String[]{"com.test"});
|
||||
when(mPackageManager.getNameForUid(USER_ID)).thenReturn("com.test");
|
||||
ShadowWifiSlice.setWifiPermissible(true);
|
||||
|
||||
final Slice wifiSlice = mWifiSlice.getSlice();
|
||||
@@ -145,6 +148,7 @@ public class WifiSliceTest {
|
||||
@Test
|
||||
public void getWifiSlice_notFromSIPackageAndWithoutWifiPermission_shouldReturnNoToggle() {
|
||||
when(mPackageManager.getPackagesForUid(USER_ID)).thenReturn(new String[]{"com.test"});
|
||||
when(mPackageManager.getNameForUid(USER_ID)).thenReturn("com.test");
|
||||
ShadowWifiSlice.setWifiPermissible(false);
|
||||
|
||||
final Slice wifiSlice = mWifiSlice.getSlice();
|
||||
|
||||
Reference in New Issue
Block a user