Dynamic advanced button for about phone v2

- Set the number of tiles for the advanced button based on the device's
 sim count

Bug: 36458278
Test: make RunSettingsRoboTests -j40
Change-Id: I86a5e95476eb93a94607e8c379b132a80a5a1fc5
This commit is contained in:
jeffreyhuang
2017-11-15 14:23:44 -08:00
parent e50254dce0
commit 848e904eed
3 changed files with 82 additions and 5 deletions

View File

@@ -22,8 +22,11 @@ import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.provider.SearchIndexableResource;
import android.telephony.TelephonyManager;
import android.util.FeatureFlagUtils;
import android.support.annotation.VisibleForTesting;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.dashboard.DashboardFragment;
@@ -61,6 +64,11 @@ public class DeviceInfoSettings extends DashboardFragment implements Indexable {
private static final String KEY_LEGAL_CONTAINER = "legal_container";
@VisibleForTesting
static final int SIM_PREFERENCES_COUNT = 3;
@VisibleForTesting
static final int NON_SIM_PREFERENCES_COUNT = 2;
@Override
public int getMetricsCategory() {
return MetricsEvent.DEVICEINFO;
@@ -71,6 +79,21 @@ public class DeviceInfoSettings extends DashboardFragment implements Indexable {
return R.string.help_uri_about;
}
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
if (FeatureFlagUtils.isEnabled(getContext(), DEVICE_INFO_V2)) {
// Increase the number of children when the device contains more than 1 sim.
final TelephonyManager telephonyManager = (TelephonyManager) getSystemService(
Context.TELEPHONY_SERVICE);
final int numberOfChildren = Math.max(SIM_PREFERENCES_COUNT,
SIM_PREFERENCES_COUNT * telephonyManager.getPhoneCount())
+ NON_SIM_PREFERENCES_COUNT;
getPreferenceScreen().setInitialExpandedChildrenCount(numberOfChildren);
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
final BuildNumberPreferenceController buildNumberPreferenceController =