Merge "Show all system apps to hub teamfood, remove location indicator" into sc-dev
This commit is contained in:
@@ -111,8 +111,7 @@ public class PermissionUsageHelper {
|
||||
|
||||
private static boolean shouldShowLocationIndicator() {
|
||||
return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
|
||||
PROPERTY_LOCATION_INDICATORS_ENABLED, false)
|
||||
|| shouldShowPermissionsHub();
|
||||
PROPERTY_LOCATION_INDICATORS_ENABLED, false);
|
||||
}
|
||||
|
||||
private static long getRecentThreshold(Long now) {
|
||||
@@ -326,10 +325,10 @@ public class PermissionUsageHelper {
|
||||
}
|
||||
|
||||
if (packageName.equals(SYSTEM_PKG)
|
||||
|| (!isUserSensitive(packageName, user, op)
|
||||
|| (!shouldShowPermissionsHub()
|
||||
&& !isUserSensitive(packageName, user, op)
|
||||
&& !isLocationProvider(packageName, user)
|
||||
&& !isAppPredictor(packageName, user))
|
||||
&& !isSpeechRecognizerUsage(op, packageName)) {
|
||||
&& !isSpeechRecognizerUsage(op, packageName))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import static android.hardware.SensorPrivacyManager.Sensors.CAMERA;
|
||||
import static android.hardware.SensorPrivacyManager.Sensors.MICROPHONE;
|
||||
import static android.media.AudioManager.ACTION_MICROPHONE_MUTE_CHANGED;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.AppOpsManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
@@ -43,6 +42,7 @@ import androidx.annotation.WorkerThread;
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
||||
import com.android.systemui.Dumpable;
|
||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||
import com.android.systemui.dagger.SysUISingleton;
|
||||
@@ -370,13 +370,9 @@ public class AppOpsControllerImpl extends BroadcastReceiver implements AppOpsCon
|
||||
}
|
||||
|
||||
// TODO ntmyren: remove after teamfood is finished
|
||||
private boolean shouldShowAppPredictor(String pkgName) {
|
||||
if (!DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY, "permissions_hub_2_enabled",
|
||||
false)) {
|
||||
return false;
|
||||
}
|
||||
return mPackageManager.checkPermission(Manifest.permission.MANAGE_APP_PREDICTIONS, pkgName)
|
||||
== PackageManager.PERMISSION_GRANTED;
|
||||
private boolean showSystemApps() {
|
||||
return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
|
||||
SystemUiDeviceConfigFlags.PROPERTY_PERMISSIONS_HUB_ENABLED, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -399,8 +395,8 @@ public class AppOpsControllerImpl extends BroadcastReceiver implements AppOpsCon
|
||||
return true;
|
||||
}
|
||||
// TODO ntmyren: Replace this with more robust check if this moves beyond teamfood
|
||||
if ((appOpCode == AppOpsManager.OP_CAMERA && isLocationProvider(packageName))
|
||||
|| shouldShowAppPredictor(packageName)
|
||||
if (((showSystemApps() && !packageName.equals("android"))
|
||||
|| appOpCode == AppOpsManager.OP_CAMERA && isLocationProvider(packageName))
|
||||
|| isSpeechRecognizerUsage(appOpCode, packageName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -214,9 +214,7 @@ class PrivacyDialogController(
|
||||
|
||||
private fun filterType(type: PrivacyType?): PrivacyType? {
|
||||
return type?.let {
|
||||
if (privacyItemController.allIndicatorsAvailable) {
|
||||
it
|
||||
} else if ((it == PrivacyType.TYPE_CAMERA || it == PrivacyType.TYPE_MICROPHONE) &&
|
||||
if ((it == PrivacyType.TYPE_CAMERA || it == PrivacyType.TYPE_MICROPHONE) &&
|
||||
privacyItemController.micCameraAvailable) {
|
||||
it
|
||||
} else if (it == PrivacyType.TYPE_LOCATION && privacyItemController.locationAvailable) {
|
||||
|
||||
@@ -68,8 +68,6 @@ class PrivacyItemController @Inject constructor(
|
||||
addAction(Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE)
|
||||
}
|
||||
const val TAG = "PrivacyItemController"
|
||||
private const val ALL_INDICATORS =
|
||||
SystemUiDeviceConfigFlags.PROPERTY_PERMISSIONS_HUB_ENABLED
|
||||
private const val MIC_CAMERA = SystemUiDeviceConfigFlags.PROPERTY_MIC_CAMERA_ENABLED
|
||||
private const val LOCATION = SystemUiDeviceConfigFlags.PROPERTY_LOCATION_INDICATORS_ENABLED
|
||||
private const val DEFAULT_ALL_INDICATORS = false
|
||||
@@ -83,11 +81,6 @@ class PrivacyItemController @Inject constructor(
|
||||
@Synchronized get() = field.toList() // Returns a shallow copy of the list
|
||||
@Synchronized set
|
||||
|
||||
private fun isAllIndicatorsEnabled(): Boolean {
|
||||
return deviceConfigProxy.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
|
||||
ALL_INDICATORS, DEFAULT_ALL_INDICATORS)
|
||||
}
|
||||
|
||||
private fun isMicCameraEnabled(): Boolean {
|
||||
return deviceConfigProxy.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
|
||||
MIC_CAMERA, DEFAULT_MIC_CAMERA)
|
||||
@@ -120,34 +113,29 @@ class PrivacyItemController @Inject constructor(
|
||||
uiExecutor.execute(notifyChanges)
|
||||
}
|
||||
|
||||
var allIndicatorsAvailable = isAllIndicatorsEnabled()
|
||||
private set
|
||||
var micCameraAvailable = isMicCameraEnabled()
|
||||
private set
|
||||
var locationAvailable = isLocationEnabled()
|
||||
|
||||
var allIndicatorsAvailable = micCameraAvailable && locationAvailable
|
||||
|
||||
private val devicePropertiesChangedListener =
|
||||
object : DeviceConfig.OnPropertiesChangedListener {
|
||||
override fun onPropertiesChanged(properties: DeviceConfig.Properties) {
|
||||
if (DeviceConfig.NAMESPACE_PRIVACY.equals(properties.getNamespace()) &&
|
||||
(properties.keyset.contains(ALL_INDICATORS) ||
|
||||
properties.keyset.contains(MIC_CAMERA) ||
|
||||
(properties.keyset.contains(MIC_CAMERA) ||
|
||||
properties.keyset.contains(LOCATION))) {
|
||||
|
||||
// Running on the ui executor so can iterate on callbacks
|
||||
if (properties.keyset.contains(ALL_INDICATORS)) {
|
||||
allIndicatorsAvailable = properties.getBoolean(ALL_INDICATORS,
|
||||
DEFAULT_ALL_INDICATORS)
|
||||
callbacks.forEach { it.get()?.onFlagAllChanged(allIndicatorsAvailable) }
|
||||
}
|
||||
|
||||
if (properties.keyset.contains(MIC_CAMERA)) {
|
||||
micCameraAvailable = properties.getBoolean(MIC_CAMERA, DEFAULT_MIC_CAMERA)
|
||||
allIndicatorsAvailable = micCameraAvailable && locationAvailable
|
||||
callbacks.forEach { it.get()?.onFlagMicCameraChanged(micCameraAvailable) }
|
||||
}
|
||||
|
||||
if (properties.keyset.contains(LOCATION)) {
|
||||
locationAvailable = properties.getBoolean(LOCATION, DEFAULT_LOCATION)
|
||||
allIndicatorsAvailable = micCameraAvailable && locationAvailable
|
||||
callbacks.forEach { it.get()?.onFlagLocationChanged(locationAvailable) }
|
||||
}
|
||||
internalUiExecutor.updateListeningState()
|
||||
@@ -163,8 +151,7 @@ class PrivacyItemController @Inject constructor(
|
||||
active: Boolean
|
||||
) {
|
||||
// Check if we care about this code right now
|
||||
if (!allIndicatorsAvailable &&
|
||||
(code in OPS_LOCATION && !locationAvailable)) {
|
||||
if (code in OPS_LOCATION && !locationAvailable) {
|
||||
return
|
||||
}
|
||||
val userId = UserHandle.getUserId(uid)
|
||||
@@ -231,7 +218,7 @@ class PrivacyItemController @Inject constructor(
|
||||
*/
|
||||
private fun setListeningState() {
|
||||
val listen = !callbacks.isEmpty() and
|
||||
(allIndicatorsAvailable || micCameraAvailable || locationAvailable)
|
||||
(micCameraAvailable || locationAvailable)
|
||||
if (listening == listen) return
|
||||
listening = listen
|
||||
if (listening) {
|
||||
@@ -338,7 +325,7 @@ class PrivacyItemController @Inject constructor(
|
||||
AppOpsManager.OP_RECORD_AUDIO -> PrivacyType.TYPE_MICROPHONE
|
||||
else -> return null
|
||||
}
|
||||
if (type == PrivacyType.TYPE_LOCATION && (!allIndicatorsAvailable && !locationAvailable)) {
|
||||
if (type == PrivacyType.TYPE_LOCATION && !locationAvailable) {
|
||||
return null
|
||||
}
|
||||
val app = PrivacyApplication(appOpItem.packageName, appOpItem.uid)
|
||||
|
||||
@@ -88,7 +88,6 @@ public class TvOngoingPrivacyChip extends SystemUI implements PrivacyItemControl
|
||||
private boolean mViewAndWindowAdded;
|
||||
private ObjectAnimator mAnimator;
|
||||
|
||||
private boolean mAllIndicatorsFlagEnabled;
|
||||
private boolean mMicCameraIndicatorFlagEnabled;
|
||||
private boolean mLocationIndicatorEnabled;
|
||||
private List<PrivacyItem> mPrivacyItems;
|
||||
@@ -111,12 +110,10 @@ public class TvOngoingPrivacyChip extends SystemUI implements PrivacyItemControl
|
||||
mIconMarginStart = Math.round(res.getDimension(R.dimen.privacy_chip_icon_margin));
|
||||
mIconSize = res.getDimensionPixelSize(R.dimen.privacy_chip_icon_size);
|
||||
|
||||
mAllIndicatorsFlagEnabled = privacyItemController.getAllIndicatorsAvailable();
|
||||
mMicCameraIndicatorFlagEnabled = privacyItemController.getMicCameraAvailable();
|
||||
mLocationIndicatorEnabled = privacyItemController.getLocationAvailable();
|
||||
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "allIndicators: " + mAllIndicatorsFlagEnabled);
|
||||
Log.d(TAG, "micCameraIndicators: " + mMicCameraIndicatorFlagEnabled);
|
||||
Log.d(TAG, "locationIndicators: " + mLocationIndicatorEnabled);
|
||||
}
|
||||
@@ -134,12 +131,6 @@ public class TvOngoingPrivacyChip extends SystemUI implements PrivacyItemControl
|
||||
updateUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFlagAllChanged(boolean flag) {
|
||||
if (DEBUG) Log.d(TAG, "all indicators enabled: " + flag);
|
||||
mAllIndicatorsFlagEnabled = flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFlagMicCameraChanged(boolean flag) {
|
||||
if (DEBUG) Log.d(TAG, "mic/camera indicators enabled: " + flag);
|
||||
@@ -155,8 +146,8 @@ public class TvOngoingPrivacyChip extends SystemUI implements PrivacyItemControl
|
||||
private void updateUI() {
|
||||
if (DEBUG) Log.d(TAG, mPrivacyItems.size() + " privacy items");
|
||||
|
||||
if ((mMicCameraIndicatorFlagEnabled || mAllIndicatorsFlagEnabled
|
||||
|| mLocationIndicatorEnabled) && !mPrivacyItems.isEmpty()) {
|
||||
if ((mMicCameraIndicatorFlagEnabled || mLocationIndicatorEnabled)
|
||||
&& !mPrivacyItems.isEmpty()) {
|
||||
if (mState == STATE_NOT_SHOWN || mState == STATE_DISAPPEARING) {
|
||||
showIndicator();
|
||||
} else {
|
||||
|
||||
@@ -97,7 +97,6 @@ class QuickStatusBarHeaderController extends ViewController<QuickStatusBarHeader
|
||||
|
||||
private boolean mListening;
|
||||
private AlarmClockInfo mNextAlarm;
|
||||
private boolean mAllIndicatorsEnabled;
|
||||
private boolean mMicCameraIndicatorsEnabled;
|
||||
private boolean mLocationIndicatorsEnabled;
|
||||
private boolean mPrivacyChipLogged;
|
||||
@@ -150,14 +149,6 @@ class QuickStatusBarHeaderController extends ViewController<QuickStatusBarHeader
|
||||
setChipVisibility(!privacyItems.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFlagAllChanged(boolean flag) {
|
||||
if (mAllIndicatorsEnabled != flag) {
|
||||
mAllIndicatorsEnabled = flag;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFlagMicCameraChanged(boolean flag) {
|
||||
if (mMicCameraIndicatorsEnabled != flag) {
|
||||
@@ -270,7 +261,6 @@ class QuickStatusBarHeaderController extends ViewController<QuickStatusBarHeader
|
||||
mRingerContainer.setOnClickListener(mOnClickListener);
|
||||
mPrivacyChip.setOnClickListener(mOnClickListener);
|
||||
|
||||
mAllIndicatorsEnabled = mPrivacyItemController.getAllIndicatorsAvailable();
|
||||
mMicCameraIndicatorsEnabled = mPrivacyItemController.getMicCameraAvailable();
|
||||
mLocationIndicatorsEnabled = mPrivacyItemController.getLocationAvailable();
|
||||
|
||||
@@ -321,7 +311,6 @@ class QuickStatusBarHeaderController extends ViewController<QuickStatusBarHeader
|
||||
mNextAlarmController.addCallback(mNextAlarmChangeCallback);
|
||||
mLifecycle.setCurrentState(Lifecycle.State.RESUMED);
|
||||
// Get the most up to date info
|
||||
mAllIndicatorsEnabled = mPrivacyItemController.getAllIndicatorsAvailable();
|
||||
mMicCameraIndicatorsEnabled = mPrivacyItemController.getMicCameraAvailable();
|
||||
mLocationIndicatorsEnabled = mPrivacyItemController.getLocationAvailable();
|
||||
mPrivacyItemController.addCallback(mPICCallback);
|
||||
@@ -353,13 +342,13 @@ class QuickStatusBarHeaderController extends ViewController<QuickStatusBarHeader
|
||||
private List<String> getIgnoredIconSlots() {
|
||||
ArrayList<String> ignored = new ArrayList<>();
|
||||
if (getChipEnabled()) {
|
||||
if (mAllIndicatorsEnabled || mMicCameraIndicatorsEnabled) {
|
||||
if (mMicCameraIndicatorsEnabled) {
|
||||
ignored.add(mView.getResources().getString(
|
||||
com.android.internal.R.string.status_bar_camera));
|
||||
ignored.add(mView.getResources().getString(
|
||||
com.android.internal.R.string.status_bar_microphone));
|
||||
}
|
||||
if (mAllIndicatorsEnabled || mLocationIndicatorsEnabled) {
|
||||
if (mLocationIndicatorsEnabled) {
|
||||
ignored.add(mView.getResources().getString(
|
||||
com.android.internal.R.string.status_bar_location));
|
||||
}
|
||||
@@ -368,7 +357,7 @@ class QuickStatusBarHeaderController extends ViewController<QuickStatusBarHeader
|
||||
}
|
||||
|
||||
private boolean getChipEnabled() {
|
||||
return mMicCameraIndicatorsEnabled || mLocationIndicatorsEnabled || mAllIndicatorsEnabled;
|
||||
return mMicCameraIndicatorsEnabled || mLocationIndicatorsEnabled;
|
||||
}
|
||||
|
||||
private boolean isZenOverridingRinger() {
|
||||
|
||||
@@ -675,8 +675,7 @@ public class PhoneStatusBarPolicy
|
||||
|
||||
mIconController.setIconVisibility(mSlotCamera, showCamera);
|
||||
mIconController.setIconVisibility(mSlotMicrophone, showMicrophone);
|
||||
if (mPrivacyItemController.getAllIndicatorsAvailable()
|
||||
|| mPrivacyItemController.getLocationAvailable()) {
|
||||
if (mPrivacyItemController.getLocationAvailable()) {
|
||||
mIconController.setIconVisibility(mSlotLocation, showLocation);
|
||||
}
|
||||
mPrivacyLogger.logStatusBarIconsVisible(showCamera, showMicrophone, showLocation);
|
||||
@@ -684,8 +683,7 @@ public class PhoneStatusBarPolicy
|
||||
|
||||
@Override
|
||||
public void onLocationActiveChanged(boolean active) {
|
||||
if (!mPrivacyItemController.getAllIndicatorsAvailable()
|
||||
&& !mPrivacyItemController.getLocationAvailable()) {
|
||||
if (!mPrivacyItemController.getLocationAvailable()) {
|
||||
updateLocationFromController();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -395,9 +395,8 @@ class PrivacyDialogControllerTest : SysuiTestCase() {
|
||||
`when`(permissionManager.indicatorAppOpUsageData).thenReturn(
|
||||
listOf(usage_camera, usage_location, usage_microphone)
|
||||
)
|
||||
`when`(privacyItemController.micCameraAvailable).thenReturn(false)
|
||||
`when`(privacyItemController.locationAvailable).thenReturn(false)
|
||||
`when`(privacyItemController.allIndicatorsAvailable).thenReturn(true)
|
||||
`when`(privacyItemController.micCameraAvailable).thenReturn(true)
|
||||
`when`(privacyItemController.locationAvailable).thenReturn(true)
|
||||
|
||||
controller.showDialog(context)
|
||||
exhaustExecutors()
|
||||
@@ -422,7 +421,6 @@ class PrivacyDialogControllerTest : SysuiTestCase() {
|
||||
)
|
||||
`when`(privacyItemController.micCameraAvailable).thenReturn(false)
|
||||
`when`(privacyItemController.locationAvailable).thenReturn(false)
|
||||
`when`(privacyItemController.allIndicatorsAvailable).thenReturn(false)
|
||||
|
||||
controller.showDialog(context)
|
||||
exhaustExecutors()
|
||||
@@ -525,7 +523,6 @@ class PrivacyDialogControllerTest : SysuiTestCase() {
|
||||
|
||||
`when`(privacyItemController.locationAvailable).thenReturn(true)
|
||||
`when`(privacyItemController.micCameraAvailable).thenReturn(true)
|
||||
`when`(privacyItemController.allIndicatorsAvailable).thenReturn(false)
|
||||
|
||||
`when`(userTracker.userProfiles).thenReturn(listOf(
|
||||
UserInfo(USER_ID, "", 0),
|
||||
|
||||
@@ -37,7 +37,6 @@ import org.junit.runner.RunWith
|
||||
import org.mockito.ArgumentCaptor
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.Mockito.anyBoolean
|
||||
import org.mockito.Mockito.atLeastOnce
|
||||
import org.mockito.Mockito.never
|
||||
import org.mockito.Mockito.verify
|
||||
@@ -51,8 +50,6 @@ class PrivacyItemControllerFlagsTest : SysuiTestCase() {
|
||||
fun <T> eq(value: T): T = Mockito.eq(value) ?: value
|
||||
fun <T> any(): T = Mockito.any<T>()
|
||||
|
||||
private const val ALL_INDICATORS =
|
||||
SystemUiDeviceConfigFlags.PROPERTY_PERMISSIONS_HUB_ENABLED
|
||||
private const val MIC_CAMERA = SystemUiDeviceConfigFlags.PROPERTY_MIC_CAMERA_ENABLED
|
||||
private const val LOCATION = SystemUiDeviceConfigFlags.PROPERTY_LOCATION_INDICATORS_ENABLED
|
||||
}
|
||||
@@ -95,11 +92,6 @@ class PrivacyItemControllerFlagsTest : SysuiTestCase() {
|
||||
executor.runAllReady()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNotListeningAllByDefault() {
|
||||
assertFalse(privacyItemController.allIndicatorsAvailable)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMicCameraListeningByDefault() {
|
||||
assertTrue(privacyItemController.micCameraAvailable)
|
||||
@@ -111,10 +103,8 @@ class PrivacyItemControllerFlagsTest : SysuiTestCase() {
|
||||
executor.runAllReady()
|
||||
|
||||
verify(callback).onFlagMicCameraChanged(false)
|
||||
verify(callback, never()).onFlagAllChanged(anyBoolean())
|
||||
|
||||
assertFalse(privacyItemController.micCameraAvailable)
|
||||
assertFalse(privacyItemController.allIndicatorsAvailable)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -126,27 +116,16 @@ class PrivacyItemControllerFlagsTest : SysuiTestCase() {
|
||||
assertTrue(privacyItemController.locationAvailable)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAllChanged() {
|
||||
changeAll(true)
|
||||
executor.runAllReady()
|
||||
|
||||
verify(callback).onFlagAllChanged(true)
|
||||
verify(callback, never()).onFlagMicCameraChanged(anyBoolean())
|
||||
|
||||
assertTrue(privacyItemController.allIndicatorsAvailable)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testBothChanged() {
|
||||
changeAll(true)
|
||||
changeMicCamera(false)
|
||||
executor.runAllReady()
|
||||
|
||||
verify(callback, atLeastOnce()).onFlagAllChanged(true)
|
||||
verify(callback, atLeastOnce()).onFlagLocationChanged(true)
|
||||
verify(callback, atLeastOnce()).onFlagMicCameraChanged(false)
|
||||
|
||||
assertTrue(privacyItemController.allIndicatorsAvailable)
|
||||
assertTrue(privacyItemController.locationAvailable)
|
||||
assertFalse(privacyItemController.micCameraAvailable)
|
||||
}
|
||||
|
||||
@@ -185,28 +164,6 @@ class PrivacyItemControllerFlagsTest : SysuiTestCase() {
|
||||
verify(appOpsController).removeCallback(any(), any())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSomeListening_stillListening() {
|
||||
// Mic and camera are true by default
|
||||
changeAll(true)
|
||||
executor.runAllReady()
|
||||
changeAll(false)
|
||||
executor.runAllReady()
|
||||
|
||||
verify(appOpsController, never()).removeCallback(any(), any())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAllDeleted_micCameraFalse_stopListening() {
|
||||
changeMicCamera(false)
|
||||
changeAll(true)
|
||||
executor.runAllReady()
|
||||
changeAll(null)
|
||||
executor.runAllReady()
|
||||
|
||||
verify(appOpsController).removeCallback(any(), any())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMicDeleted_stillListening() {
|
||||
changeMicCamera(true)
|
||||
@@ -219,7 +176,10 @@ class PrivacyItemControllerFlagsTest : SysuiTestCase() {
|
||||
|
||||
private fun changeMicCamera(value: Boolean?) = changeProperty(MIC_CAMERA, value)
|
||||
private fun changeLocation(value: Boolean?) = changeProperty(LOCATION, value)
|
||||
private fun changeAll(value: Boolean?) = changeProperty(ALL_INDICATORS, value)
|
||||
private fun changeAll(value: Boolean?) {
|
||||
changeMicCamera(value)
|
||||
changeLocation(value)
|
||||
}
|
||||
|
||||
private fun changeProperty(name: String, value: Boolean?) {
|
||||
deviceConfigProxy.setProperty(
|
||||
|
||||
@@ -43,7 +43,6 @@ import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertThat
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.ArgumentCaptor
|
||||
@@ -72,8 +71,8 @@ class PrivacyItemControllerTest : SysuiTestCase() {
|
||||
val TEST_UID = CURRENT_USER_ID * UserHandle.PER_USER_RANGE
|
||||
const val TEST_PACKAGE_NAME = "test"
|
||||
|
||||
private const val ALL_INDICATORS =
|
||||
SystemUiDeviceConfigFlags.PROPERTY_PERMISSIONS_HUB_ENABLED
|
||||
private const val LOCATION_INDICATOR =
|
||||
SystemUiDeviceConfigFlags.PROPERTY_LOCATION_INDICATORS_ENABLED
|
||||
private const val MIC_CAMERA = SystemUiDeviceConfigFlags.PROPERTY_MIC_CAMERA_ENABLED
|
||||
fun <T> capture(argumentCaptor: ArgumentCaptor<T>): T = argumentCaptor.capture()
|
||||
fun <T> eq(value: T): T = Mockito.eq(value) ?: value
|
||||
@@ -119,7 +118,8 @@ class PrivacyItemControllerTest : SysuiTestCase() {
|
||||
deviceConfigProxy = DeviceConfigProxyFake()
|
||||
|
||||
// Listen to everything by default
|
||||
changeAll(true)
|
||||
changeMicCamera(true)
|
||||
changeLocation(true)
|
||||
|
||||
`when`(userTracker.userProfiles).thenReturn(listOf(UserInfo(CURRENT_USER_ID, "", 0)))
|
||||
|
||||
@@ -259,9 +259,8 @@ class PrivacyItemControllerTest : SysuiTestCase() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // TODO(b/168209929)
|
||||
fun testNotListeningWhenIndicatorsDisabled() {
|
||||
changeAll(false)
|
||||
changeLocation(false)
|
||||
changeMicCamera(false)
|
||||
privacyItemController.addCallback(callback)
|
||||
executor.runAllReady()
|
||||
@@ -271,7 +270,7 @@ class PrivacyItemControllerTest : SysuiTestCase() {
|
||||
|
||||
@Test
|
||||
fun testNotSendingLocationWhenOnlyMicCamera() {
|
||||
changeAll(false)
|
||||
changeLocation(false)
|
||||
changeMicCamera(true)
|
||||
executor.runAllReady()
|
||||
|
||||
@@ -294,7 +293,7 @@ class PrivacyItemControllerTest : SysuiTestCase() {
|
||||
.`when`(appOpsController).getActiveAppOpsForUser(anyInt())
|
||||
|
||||
privacyItemController.addCallback(callback)
|
||||
changeAll(false)
|
||||
changeLocation(false)
|
||||
changeMicCamera(true)
|
||||
executor.runAllReady()
|
||||
reset(callback) // Clean callback
|
||||
@@ -521,7 +520,7 @@ class PrivacyItemControllerTest : SysuiTestCase() {
|
||||
}
|
||||
|
||||
private fun changeMicCamera(value: Boolean?) = changeProperty(MIC_CAMERA, value)
|
||||
private fun changeAll(value: Boolean?) = changeProperty(ALL_INDICATORS, value)
|
||||
private fun changeLocation(value: Boolean?) = changeProperty(LOCATION_INDICATOR, value)
|
||||
|
||||
private fun changeProperty(name: String, value: Boolean?) {
|
||||
deviceConfigProxy.setProperty(
|
||||
|
||||
@@ -148,7 +148,7 @@ class QuickStatusBarHeaderControllerTest : SysuiTestCase() {
|
||||
|
||||
@Test
|
||||
fun testIgnoredSlotsOnAttached_noIndicators() {
|
||||
setPrivacyController(false, false, false)
|
||||
setPrivacyController(micCamera = false, location = false)
|
||||
|
||||
controller.init()
|
||||
|
||||
@@ -160,7 +160,7 @@ class QuickStatusBarHeaderControllerTest : SysuiTestCase() {
|
||||
|
||||
@Test
|
||||
fun testIgnoredSlotsOnAttached_onlyMicCamera() {
|
||||
setPrivacyController(false, true, false)
|
||||
setPrivacyController(micCamera = true, location = false)
|
||||
|
||||
controller.init()
|
||||
|
||||
@@ -177,7 +177,7 @@ class QuickStatusBarHeaderControllerTest : SysuiTestCase() {
|
||||
|
||||
@Test
|
||||
fun testIgnoredSlotsOnAttached_onlyLocation() {
|
||||
setPrivacyController(false, false, true)
|
||||
setPrivacyController(micCamera = false, location = true)
|
||||
|
||||
controller.init()
|
||||
|
||||
@@ -192,26 +192,7 @@ class QuickStatusBarHeaderControllerTest : SysuiTestCase() {
|
||||
|
||||
@Test
|
||||
fun testIgnoredSlotsOnAttached_locationMicCamera() {
|
||||
setPrivacyController(false, true, true)
|
||||
|
||||
controller.init()
|
||||
|
||||
val captor = argumentCaptor<List<String>>()
|
||||
verify(iconContainer).setIgnoredSlots(capture(captor))
|
||||
|
||||
val cameraString = mContext.resources.getString(
|
||||
com.android.internal.R.string.status_bar_camera)
|
||||
val micString = mContext.resources.getString(
|
||||
com.android.internal.R.string.status_bar_microphone)
|
||||
val locationString = mContext.resources.getString(
|
||||
com.android.internal.R.string.status_bar_location)
|
||||
|
||||
assertThat(captor.value).containsExactly(cameraString, micString, locationString)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIgnoredSlotsOnAttached_all() {
|
||||
setPrivacyController(true, false, false)
|
||||
setPrivacyController(micCamera = true, location = true)
|
||||
|
||||
controller.init()
|
||||
|
||||
@@ -248,8 +229,7 @@ class QuickStatusBarHeaderControllerTest : SysuiTestCase() {
|
||||
`when`(view.findViewById<Clock>(R.id.clock)).thenReturn(clock)
|
||||
}
|
||||
|
||||
private fun setPrivacyController(all: Boolean, micCamera: Boolean, location: Boolean) {
|
||||
`when`(privacyItemController.allIndicatorsAvailable).thenReturn(all)
|
||||
private fun setPrivacyController(micCamera: Boolean, location: Boolean) {
|
||||
`when`(privacyItemController.micCameraAvailable).thenReturn(micCamera)
|
||||
`when`(privacyItemController.locationAvailable).thenReturn(location)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user