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