Snap for 8157174 from 0c2585b171 to tm-release
Change-Id: I48861d75922128fb1c78c7e60979d99bf5247b15
This commit is contained in:
@@ -16,8 +16,9 @@
|
||||
|
||||
package com.android.settings.development;
|
||||
|
||||
import android.bluetooth.BluetoothManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.os.SystemProperties;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
@@ -39,13 +40,20 @@ public class BluetoothMaxConnectedAudioDevicesPreferenceController extends
|
||||
static final String MAX_CONNECTED_AUDIO_DEVICES_PROPERTY =
|
||||
"persist.bluetooth.maxconnectedaudiodevices";
|
||||
|
||||
private final int mDefaultMaxConnectedAudioDevices;
|
||||
private int mDefaultMaxConnectedAudioDevices = 0;
|
||||
|
||||
public BluetoothMaxConnectedAudioDevicesPreferenceController(Context context) {
|
||||
super(context);
|
||||
BluetoothManager mBluetoothManager = context.getSystemService(BluetoothManager.class);
|
||||
mDefaultMaxConnectedAudioDevices = mBluetoothManager.getAdapter()
|
||||
.getMaxConnectedAudioDevices();
|
||||
|
||||
try {
|
||||
Resources res = context.getPackageManager().getResourcesForApplication(
|
||||
"com.android.bluetooth");
|
||||
mDefaultMaxConnectedAudioDevices = res.getInteger(res.getIdentifier(
|
||||
"config_bluetooth_max_connected_audio_devices",
|
||||
"integer", "com.android.bluetooth"));
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,13 +18,11 @@ package com.android.settings.fuelgauge;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.BatteryStats;
|
||||
import android.os.BatteryStatsManager;
|
||||
import android.os.BatteryUsageStats;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.os.BatteryStatsHelper;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.fuelgauge.Estimate;
|
||||
import com.android.settingslib.fuelgauge.EstimateKt;
|
||||
@@ -37,11 +35,8 @@ import java.util.List;
|
||||
public class DebugEstimatesLoader extends AsyncLoaderCompat<List<BatteryInfo>> {
|
||||
private static final String TAG = "DebugEstimatesLoader";
|
||||
|
||||
private BatteryStatsHelper mStatsHelper;
|
||||
|
||||
public DebugEstimatesLoader(Context context, BatteryStatsHelper statsHelper) {
|
||||
public DebugEstimatesLoader(Context context) {
|
||||
super(context);
|
||||
mStatsHelper = statsHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,7 +55,6 @@ public class DebugEstimatesLoader extends AsyncLoaderCompat<List<BatteryInfo>> {
|
||||
SystemClock.elapsedRealtime());
|
||||
Intent batteryBroadcast = getContext().registerReceiver(null,
|
||||
new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||
BatteryStats stats = mStatsHelper.getStats();
|
||||
BatteryUsageStats batteryUsageStats;
|
||||
try {
|
||||
batteryUsageStats = context.getSystemService(BatteryStatsManager.class)
|
||||
|
||||
@@ -439,7 +439,6 @@ public class AppDataUsageTest {
|
||||
assertThat(mFragment.mTemplate.getMatchRule())
|
||||
.isEqualTo(NetworkTemplate.MATCH_WIFI);
|
||||
assertTrue(mFragment.mTemplate.getSubscriberIds().isEmpty());
|
||||
assertThat(mFragment.mTemplate.getNetworkId())
|
||||
.isEqualTo(NetworkTemplate.WIFI_NETWORKID_ALL);
|
||||
assertTrue(mFragment.mTemplate.getWifiNetworkKeys().isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,8 +81,8 @@ public class DataUsageLibTest {
|
||||
when(mSubscriptionManager.isActiveSubscriptionId(SUB_ID)).thenReturn(false);
|
||||
|
||||
final NetworkTemplate networkTemplate = DataUsageLib.getMobileTemplate(mContext, SUB_ID);
|
||||
assertThat(networkTemplate.matchesSubscriberId(SUBSCRIBER_ID)).isTrue();
|
||||
assertThat(networkTemplate.matchesSubscriberId(SUBSCRIBER_ID_2)).isFalse();
|
||||
assertThat(networkTemplate.getSubscriberIds().contains(SUBSCRIBER_ID)).isTrue();
|
||||
assertThat(networkTemplate.getSubscriberIds().contains(SUBSCRIBER_ID_2)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -94,8 +94,8 @@ public class DataUsageLibTest {
|
||||
.thenReturn(new String[] {SUBSCRIBER_ID});
|
||||
|
||||
final NetworkTemplate networkTemplate = DataUsageLib.getMobileTemplate(mContext, SUB_ID);
|
||||
assertThat(networkTemplate.matchesSubscriberId(SUBSCRIBER_ID)).isTrue();
|
||||
assertThat(networkTemplate.matchesSubscriberId(SUBSCRIBER_ID_2)).isFalse();
|
||||
assertThat(networkTemplate.getSubscriberIds().contains(SUBSCRIBER_ID)).isTrue();
|
||||
assertThat(networkTemplate.getSubscriberIds().contains(SUBSCRIBER_ID_2)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -107,7 +107,7 @@ public class DataUsageLibTest {
|
||||
.thenReturn(new String[] {SUBSCRIBER_ID, SUBSCRIBER_ID_2});
|
||||
|
||||
final NetworkTemplate networkTemplate = DataUsageLib.getMobileTemplate(mContext, SUB_ID);
|
||||
assertThat(networkTemplate.matchesSubscriberId(SUBSCRIBER_ID)).isTrue();
|
||||
assertThat(networkTemplate.matchesSubscriberId(SUBSCRIBER_ID_2)).isTrue();
|
||||
assertThat(networkTemplate.getSubscriberIds().contains(SUBSCRIBER_ID)).isTrue();
|
||||
assertThat(networkTemplate.getSubscriberIds().contains(SUBSCRIBER_ID_2)).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,9 +24,10 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
|
||||
import android.os.SystemProperties;
|
||||
|
||||
import androidx.preference.ListPreference;
|
||||
@@ -46,17 +47,12 @@ import org.robolectric.RuntimeEnvironment;
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class BluetoothMaxConnectedAudioDevicesPreferenceControllerTest {
|
||||
|
||||
private static final int TEST_MAX_CONNECTED_AUDIO_DEVICES = 3;
|
||||
private static int TEST_MAX_CONNECTED_AUDIO_DEVICES = 5;
|
||||
|
||||
@Mock
|
||||
private PreferenceScreen mPreferenceScreen;
|
||||
@Spy
|
||||
private Context mSpyContext = RuntimeEnvironment.application;
|
||||
@Spy
|
||||
private BluetoothManager mBluetoothManager =
|
||||
mSpyContext.getSystemService(BluetoothManager.class);
|
||||
@Spy
|
||||
private BluetoothAdapter mBluetoothAdapter = mBluetoothManager.getAdapter();
|
||||
|
||||
private ListPreference mPreference;
|
||||
private BluetoothMaxConnectedAudioDevicesPreferenceController mController;
|
||||
@@ -67,16 +63,19 @@ public class BluetoothMaxConnectedAudioDevicesPreferenceControllerTest {
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
doReturn(mBluetoothManager).when(mSpyContext).getSystemService(BluetoothManager.class);
|
||||
doReturn(mBluetoothAdapter).when(mBluetoothManager).getAdapter();
|
||||
// Get XML values without mock
|
||||
// Setup test list preference using XML values
|
||||
mPreference = new ListPreference(mSpyContext);
|
||||
mPreference.setEntries(R.array.bluetooth_max_connected_audio_devices);
|
||||
mPreference.setEntryValues(R.array.bluetooth_max_connected_audio_devices_values);
|
||||
// Stub default max connected audio devices to a test controlled value
|
||||
doReturn(TEST_MAX_CONNECTED_AUDIO_DEVICES).when(mBluetoothAdapter)
|
||||
.getMaxConnectedAudioDevices();
|
||||
// Retrieve default max connected audio devices to a test controlled value
|
||||
try {
|
||||
Resources res = mSpyContext.getPackageManager().getResourcesForApplication("com.android.bluetooth");
|
||||
TEST_MAX_CONNECTED_AUDIO_DEVICES = res.getInteger(res.getIdentifier("config_bluetooth_max_connected_audio_devices", "integer", "com.android.bluetooth"));
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Init the actual controller
|
||||
mController = new BluetoothMaxConnectedAudioDevicesPreferenceController(mSpyContext);
|
||||
// Construct preference in the controller via a mocked preference screen object
|
||||
|
||||
Reference in New Issue
Block a user