Snap for 11255311 from a579912892 to 24Q2-release

Change-Id: Ib7691600e32b425d1557b3b8aabd0e50465fd964
This commit is contained in:
Android Build Coastguard Worker
2023-12-27 00:22:55 +00:00
9 changed files with 65 additions and 16 deletions

View File

@@ -784,4 +784,7 @@
<!-- Package responsible for updating Mainline Modules -->
<string name="config_mainline_module_update_package" translatable="false">com.android.vending</string>
<!-- Whether location services setting is available or not. -->
<bool name="config_show_location_services">true</bool>
</resources>

View File

@@ -37,6 +37,9 @@ import com.android.settings.R;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.utils.ThreadUtils;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* The controller of the Spatial audio setting in the bluetooth detail settings.
@@ -56,6 +59,8 @@ public class BluetoothDetailsSpatialAudioController extends BluetoothDetailsCont
@VisibleForTesting
AudioDeviceAttributes mAudioDevice = null;
AtomicBoolean mHasHeadTracker = new AtomicBoolean(false);
public BluetoothDetailsSpatialAudioController(
Context context,
PreferenceFragmentCompat fragment,
@@ -77,7 +82,13 @@ public class BluetoothDetailsSpatialAudioController extends BluetoothDetailsCont
String key = switchPreference.getKey();
if (TextUtils.equals(key, KEY_SPATIAL_AUDIO)) {
updateSpatializerEnabled(switchPreference.isChecked());
refreshSpatialAudioEnabled(switchPreference);
ThreadUtils.postOnBackgroundThread(
() -> {
mHasHeadTracker.set(
mAudioDevice != null && mSpatializer.hasHeadTracker(mAudioDevice));
mContext.getMainExecutor()
.execute(() -> refreshSpatialAudioEnabled(switchPreference));
});
return true;
} else if (TextUtils.equals(key, KEY_HEAD_TRACKING)) {
updateSpatializerHeadTracking(switchPreference.isChecked());
@@ -124,7 +135,15 @@ public class BluetoothDetailsSpatialAudioController extends BluetoothDetailsCont
if (mAudioDevice == null) {
getAvailableDevice();
}
ThreadUtils.postOnBackgroundThread(
() -> {
mHasHeadTracker.set(
mAudioDevice != null && mSpatializer.hasHeadTracker(mAudioDevice));
mContext.getMainExecutor().execute(this::refreshUi);
});
}
private void refreshUi() {
TwoStatePreference spatialAudioPref = mProfilesContainer.findPreference(KEY_SPATIAL_AUDIO);
if (spatialAudioPref == null && mAudioDevice != null) {
spatialAudioPref = createSpatialAudioPreference(mProfilesContainer.getContext());
@@ -145,7 +164,8 @@ public class BluetoothDetailsSpatialAudioController extends BluetoothDetailsCont
refreshSpatialAudioEnabled(spatialAudioPref);
}
private void refreshSpatialAudioEnabled(TwoStatePreference spatialAudioPref) {
private void refreshSpatialAudioEnabled(
TwoStatePreference spatialAudioPref) {
boolean isSpatialAudioOn = mSpatializer.getCompatibleAudioDevices().contains(mAudioDevice);
Log.d(TAG, "refresh() isSpatialAudioOn : " + isSpatialAudioOn);
spatialAudioPref.setChecked(isSpatialAudioOn);
@@ -160,9 +180,8 @@ public class BluetoothDetailsSpatialAudioController extends BluetoothDetailsCont
private void refreshHeadTracking(TwoStatePreference spatialAudioPref,
TwoStatePreference headTrackingPref) {
boolean isHeadTrackingAvailable =
spatialAudioPref.isChecked() && mSpatializer.hasHeadTracker(mAudioDevice);
Log.d(TAG, "refresh() has head tracker : " + mSpatializer.hasHeadTracker(mAudioDevice));
boolean isHeadTrackingAvailable = spatialAudioPref.isChecked() && mHasHeadTracker.get();
Log.d(TAG, "refresh() has head tracker : " + mHasHeadTracker.get());
headTrackingPref.setVisible(isHeadTrackingAvailable);
if (isHeadTrackingAvailable) {
headTrackingPref.setChecked(mSpatializer.isHeadTrackerEnabled(mAudioDevice));

View File

@@ -31,6 +31,7 @@ import android.util.Log;
import androidx.annotation.VisibleForTesting;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Set;
/** A class to dynamically manage per apps {@link NetworkPolicyManager} POLICY_ flags. */
@@ -87,6 +88,7 @@ public final class DynamicDenylistManager {
/** Set policy flags for specific UID. */
public void setUidPolicyLocked(int uid, int policy) {
Log.i(TAG, "setUidPolicyLocked: uid=" + uid + " policy=" + policy);
synchronized (mLock) {
mNetworkPolicyManager.setUidPolicy(uid, policy);
}
@@ -152,17 +154,21 @@ public final class DynamicDenylistManager {
/** Reset the UIDs in the denylist if needed. */
public void resetDenylistIfNeeded(String packageName, boolean force) {
if (!force && !SETTINGS_PACKAGE_NAME.equals(packageName)) {
Log.w(TAG, "resetDenylistIfNeeded: invalid conditions");
return;
}
synchronized (mLock) {
final int[] uids = mNetworkPolicyManager
.getUidsWithPolicy(POLICY_REJECT_METERED_BACKGROUND);
if (uids != null && uids.length != 0) {
Log.i(TAG, "resetDenylistIfNeeded: " + Arrays.toString(uids));
for (int uid : uids) {
if (!getDenylistAllUids(getManualDenylistPref()).contains(uid)) {
mNetworkPolicyManager.setUidPolicy(uid, POLICY_NONE);
}
}
} else {
Log.w(TAG, "resetDenylistIfNeeded: there is no valid UIDs");
}
}
clearSharedPreferences();
@@ -209,6 +215,7 @@ public final class DynamicDenylistManager {
}
void clearSharedPreferences() {
Log.i(TAG, "clearSharedPreferences()");
getManualDenylistPref().edit().clear().apply();
getDynamicDenylistPref().edit().clear().apply();
}

View File

@@ -32,7 +32,7 @@ public class LocationServicesPreferenceController extends BasePreferenceControll
@AvailabilityStatus
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(R.bool.config_show_location_scanning)
return mContext.getResources().getBoolean(R.bool.config_show_location_services)
? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}

View File

@@ -58,22 +58,29 @@ public class UiccSlotUtil {
public static final int INVALID_PORT_ID = -1;
@VisibleForTesting
static class SimSlotChangeReceiver extends BroadcastReceiver{
static class SimCardStateChangeReceiver extends BroadcastReceiver{
private final CountDownLatch mLatch;
SimSlotChangeReceiver(CountDownLatch latch) {
SimCardStateChangeReceiver(CountDownLatch latch) {
mLatch = latch;
}
public void registerOn(Context context) {
context.registerReceiver(this,
new IntentFilter(TelephonyManager.ACTION_SIM_SLOT_STATUS_CHANGED),
Context.RECEIVER_EXPORTED/*UNAUDITED*/);
new IntentFilter(TelephonyManager.ACTION_SIM_CARD_STATE_CHANGED),
Context.RECEIVER_NOT_EXPORTED);
}
@Override
public void onReceive(Context context, Intent intent) {
Log.i(TAG, "Action: " + intent.getAction());
if (TelephonyManager.ACTION_SIM_SLOT_STATUS_CHANGED.equals(intent.getAction())) {
if (!TelephonyManager.ACTION_SIM_CARD_STATE_CHANGED.equals(intent.getAction())) {
return;
}
final int simState = intent.getIntExtra(
TelephonyManager.EXTRA_SIM_STATE, TelephonyManager.SIM_STATE_UNKNOWN);
Log.i(TAG, "simState: " + simState);
if (simState != TelephonyManager.SIM_STATE_UNKNOWN
&& simState != TelephonyManager.SIM_STATE_ABSENT) {
mLatch.countDown();
}
}
@@ -269,8 +276,8 @@ public class UiccSlotUtil {
try {
CountDownLatch latch = new CountDownLatch(1);
if (isMultipleEnabledProfilesSupported(telMgr)) {
receiver = new SimSlotChangeReceiver(latch);
((SimSlotChangeReceiver) receiver).registerOn(context);
receiver = new SimCardStateChangeReceiver(latch);
((SimCardStateChangeReceiver) receiver).registerOn(context);
} else {
receiver = new CarrierConfigChangedReceiver(latch);
((CarrierConfigChangedReceiver) receiver).registerOn(context);

View File

@@ -38,6 +38,7 @@
<bool name="config_show_enabled_vr_listeners">false</bool>
<bool name="config_location_mode_available">false</bool>
<bool name="config_show_location_scanning">false</bool>
<bool name="config_show_location_services">false</bool>
<bool name="config_show_manage_device_admin">false</bool>
<bool name="config_show_unlock_set_or_change">false</bool>
<bool name="config_show_screen_pinning_settings">false</bool>

View File

@@ -20,4 +20,5 @@
<bool name="config_show_camera_laser_sensor">true</bool>
<bool name="config_show_connectivity_monitor">true</bool>
<bool name="config_show_smooth_display">true</bool>
<bool name="config_show_location_services">true</bool>
</resources>

View File

@@ -43,6 +43,7 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowLooper;
import java.util.ArrayList;
import java.util.List;
@@ -120,6 +121,7 @@ public class BluetoothDetailsSpatialAudioControllerTest extends BluetoothDetails
when(mSpatializer.getCompatibleAudioDevices()).thenReturn(compatibleAudioDevices);
mController.refresh();
ShadowLooper.idleMainLooper();
assertThat(mSpatialAudioPref.isChecked()).isTrue();
}
@@ -130,6 +132,7 @@ public class BluetoothDetailsSpatialAudioControllerTest extends BluetoothDetails
when(mSpatializer.getCompatibleAudioDevices()).thenReturn(compatibleAudioDevices);
mController.refresh();
ShadowLooper.idleMainLooper();
assertThat(mSpatialAudioPref.isChecked()).isFalse();
}
@@ -142,6 +145,7 @@ public class BluetoothDetailsSpatialAudioControllerTest extends BluetoothDetails
when(mSpatializer.hasHeadTracker(mController.mAudioDevice)).thenReturn(true);
mController.refresh();
ShadowLooper.idleMainLooper();
assertThat(mHeadTrackingPref.isVisible()).isTrue();
}
@@ -156,6 +160,7 @@ public class BluetoothDetailsSpatialAudioControllerTest extends BluetoothDetails
when(mSpatializer.hasHeadTracker(mController.mAudioDevice)).thenReturn(false);
mController.refresh();
ShadowLooper.idleMainLooper();
verify(mProfilesContainer).removePreference(mHeadTrackingPref);
}
@@ -166,6 +171,7 @@ public class BluetoothDetailsSpatialAudioControllerTest extends BluetoothDetails
when(mSpatializer.getCompatibleAudioDevices()).thenReturn(compatibleAudioDevices);
mController.refresh();
ShadowLooper.idleMainLooper();
verify(mProfilesContainer).removePreference(mHeadTrackingPref);
}
@@ -181,6 +187,7 @@ public class BluetoothDetailsSpatialAudioControllerTest extends BluetoothDetails
when(mSpatializer.isHeadTrackerEnabled(mController.mAudioDevice)).thenReturn(true);
mController.refresh();
ShadowLooper.idleMainLooper();
assertThat(mHeadTrackingPref.isChecked()).isTrue();
}
@@ -196,6 +203,7 @@ public class BluetoothDetailsSpatialAudioControllerTest extends BluetoothDetails
when(mSpatializer.isHeadTrackerEnabled(mController.mAudioDevice)).thenReturn(false);
mController.refresh();
ShadowLooper.idleMainLooper();
assertThat(mHeadTrackingPref.isChecked()).isFalse();
}

View File

@@ -752,11 +752,14 @@ public class UiccSlotUtilTest {
}
@Test
public void onReceiveSimSlotChangeReceiver_receiveAction_timerCountDown() {
public void onReceiveSimCardStateChangeReceiver_receiveAction_timerCountDown() {
CountDownLatch latch = spy(new CountDownLatch(1));
UiccSlotUtil.SimSlotChangeReceiver receive = new UiccSlotUtil.SimSlotChangeReceiver(latch);
UiccSlotUtil.SimCardStateChangeReceiver receive =
new UiccSlotUtil.SimCardStateChangeReceiver(latch);
Intent intent = new Intent(TelephonyManager.ACTION_SIM_SLOT_STATUS_CHANGED);
intent.putExtra(TelephonyManager.EXTRA_SIM_STATE, TelephonyManager.SIM_STATE_PRESENT);
receive.onReceive(mContext, new Intent(TelephonyManager.ACTION_SIM_SLOT_STATUS_CHANGED));
receive.onReceive(mContext, intent);
verify(latch).countDown();
}