Santos Cordon
2014-12-09 23:21:11 +00:00
committed by Android Git Automerger
3 changed files with 29 additions and 17 deletions

View File

@@ -966,22 +966,29 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
} }
/** /**
* Local cache of value, used to work around delay when * Local cache of value, used to work around delays.
* {@link ConnectivityManager#setMobileDataEnabled(boolean)} is async.
*/ */
private Boolean mMobileDataEnabled; private Boolean mMobileDataEnabled;
private boolean isMobileDataEnabled(int subId) { private boolean isMobileDataEnabled(int subId) {
if (LOGD) Log.d(TAG, "isMobileDataEnabled:+ subId=" + subId);
boolean isEnable = false; boolean isEnable = false;
if (mMobileDataEnabled != null) { if (mMobileDataEnabled != null) {
// TODO: deprecate and remove this once enabled flag is on policy // TODO: deprecate and remove this once enabled flag is on policy
// Multiple Subscriptions, the value need to be reseted // Multiple Subscriptions, the value need to be reseted
isEnable = mMobileDataEnabled.booleanValue(); isEnable = mMobileDataEnabled.booleanValue();
if (LOGD) {
Log.d(TAG, "isMobileDataEnabled: != null, subId=" + subId
+ " isEnable=" + isEnable);
}
mMobileDataEnabled = null; mMobileDataEnabled = null;
} else { } else {
// SUB SELECT // SUB SELECT
isEnable = mTelephonyManager.getDataEnabled() isEnable = mTelephonyManager.getDataEnabled(subId);
&& (subId == mSubscriptionManager.getDefaultDataSubId()); if (LOGD) {
Log.d(TAG, "isMobileDataEnabled: == null, subId=" + subId
+ " isEnable=" + isEnable);
}
} }
return isEnable; return isEnable;
} }

View File

@@ -50,6 +50,7 @@ public class VolumeSeekBarPreference extends SeekBarPreference
private boolean mMuted; private boolean mMuted;
private int mIconResId; private int mIconResId;
private int mMuteIconResId; private int mMuteIconResId;
private boolean mStopped;
public VolumeSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr, public VolumeSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr,
int defStyleRes) { int defStyleRes) {
@@ -77,8 +78,15 @@ public class VolumeSeekBarPreference extends SeekBarPreference
mCallback = callback; mCallback = callback;
} }
public void onActivityResume() {
if (mStopped) {
init();
}
}
@Override @Override
public void onActivityStop() { public void onActivityStop() {
mStopped = true;
if (mVolumizer != null) { if (mVolumizer != null) {
mVolumizer.stop(); mVolumizer.stop();
} }
@@ -91,10 +99,15 @@ public class VolumeSeekBarPreference extends SeekBarPreference
Log.w(TAG, "No stream found, not binding volumizer"); Log.w(TAG, "No stream found, not binding volumizer");
return; return;
} }
mSeekBar = (SeekBar) view.findViewById(com.android.internal.R.id.seekbar);
mIconView = (ImageView) view.findViewById(com.android.internal.R.id.icon);
mSuppressionTextView = (TextView) view.findViewById(R.id.suppression_text);
init();
}
private void init() {
if (mSeekBar == null) return;
getPreferenceManager().registerOnActivityStopListener(this); getPreferenceManager().registerOnActivityStopListener(this);
final SeekBar seekBar = (SeekBar) view.findViewById(com.android.internal.R.id.seekbar);
if (seekBar == mSeekBar) return;
mSeekBar = seekBar;
final SeekBarVolumizer.Callback sbvc = new SeekBarVolumizer.Callback() { final SeekBarVolumizer.Callback sbvc = new SeekBarVolumizer.Callback() {
@Override @Override
public void onSampleStarting(SeekBarVolumizer sbv) { public void onSampleStarting(SeekBarVolumizer sbv) {
@@ -121,19 +134,11 @@ public class VolumeSeekBarPreference extends SeekBarPreference
} }
mVolumizer.start(); mVolumizer.start();
mVolumizer.setSeekBar(mSeekBar); mVolumizer.setSeekBar(mSeekBar);
mIconView = (ImageView) view.findViewById(com.android.internal.R.id.icon);
updateIconView(); updateIconView();
mSuppressionTextView = (TextView) view.findViewById(R.id.suppression_text);
mCallback.onStreamValueChanged(mStream, mSeekBar.getProgress()); mCallback.onStreamValueChanged(mStream, mSeekBar.getProgress());
updateSuppressionText(); updateSuppressionText();
} }
public void onActivityResume() {
if (mVolumizer != null) {
mVolumizer.start();
}
}
// during initialization, this preference is the SeekBar listener // during initialization, this preference is the SeekBar listener
@Override @Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) {

View File

@@ -152,7 +152,7 @@ public class SimDialogActivity extends Activity {
final SubscriptionManager subscriptionManager = SubscriptionManager.from(context); final SubscriptionManager subscriptionManager = SubscriptionManager.from(context);
final List<SubscriptionInfo> subInfoList = final List<SubscriptionInfo> subInfoList =
subscriptionManager.getActiveSubscriptionInfoList(); subscriptionManager.getActiveSubscriptionInfoList();
final int selectableSubInfoLength = subInfoList.size(); final int selectableSubInfoLength = subInfoList == null ? 0 : subInfoList.size();
final DialogInterface.OnClickListener selectionListener = final DialogInterface.OnClickListener selectionListener =
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {