Fix issues in Settings: 16660423, 13172381, 16868094

Issue #16660423: Stability: ArrayIndexOutOfBoundsException in settings:
at com.android.settings.fuelgauge.BatteryHistoryChart$ChartData.draw(
BatteryHistoryChart.java:109)

Issue #13172381: No content description in Battery charging section

Issue #16868094: Settings crash on switching to landscape mode with
"Google Text-to-speech" settings icon selected

Change-Id: I94d0e83f72d571eb90aad6742acabce56c0298ec
This commit is contained in:
Dianne Hackborn
2014-08-10 16:32:08 -07:00
parent 092c62f1f3
commit 1cf2077c37
2 changed files with 9 additions and 2 deletions

View File

@@ -86,7 +86,7 @@ public class BatteryHistoryChart extends View {
void addTick(int x, int bin) { void addTick(int x, int bin) {
if (bin != mLastBin && mNumTicks < mTicks.length) { if (bin != mLastBin && mNumTicks < mTicks.length) {
mTicks[mNumTicks] = x | bin << CHART_DATA_BIN_SHIFT; mTicks[mNumTicks] = (x&CHART_DATA_X_MASK) | (bin<<CHART_DATA_BIN_SHIFT);
mNumTicks++; mNumTicks++;
mLastBin = bin; mLastBin = bin;
} }
@@ -540,6 +540,7 @@ public class BatteryHistoryChart extends View {
} }
mDrainString = ""; mDrainString = "";
mChargeDurationString = ""; mChargeDurationString = "";
setContentDescription(mChargeLabelString);
int pos = 0; int pos = 0;
int lastInteresting = 0; int lastInteresting = 0;
@@ -804,6 +805,9 @@ public class BatteryHistoryChart extends View {
} }
if (curWalltime != 0 && rec.isDeltaData()) { if (curWalltime != 0 && rec.isDeltaData()) {
x = mLevelLeft + (int)(((curWalltime-walltimeStart)*levelWidth)/walltimeChange); x = mLevelLeft + (int)(((curWalltime-walltimeStart)*levelWidth)/walltimeChange);
if (x < 0) {
x = 0;
}
if (false) { if (false) {
StringBuilder sb = new StringBuilder(128); StringBuilder sb = new StringBuilder(128);
sb.append("walloff="); sb.append("walloff=");
@@ -984,6 +988,9 @@ public class BatteryHistoryChart extends View {
} else { } else {
// Figure out where the actual data ends on the screen. // Figure out where the actual data ends on the screen.
x = mLevelLeft + (int)(((mEndDataWallTime-walltimeStart)*levelWidth)/walltimeChange); x = mLevelLeft + (int)(((mEndDataWallTime-walltimeStart)*levelWidth)/walltimeChange);
if (x < 0) {
x = 0;
}
} }
finishPaths(x, h, levelh, startX, lastY, curLevelPath, lastX, finishPaths(x, h, levelh, startX, lastY, curLevelPath, lastX,

View File

@@ -140,7 +140,7 @@ public class TtsEngineSettingsFragment extends SettingsPreferenceFragment implem
mLocalePreference.setEntries(entries); mLocalePreference.setEntries(entries);
mLocalePreference.setEntryValues(entryValues); mLocalePreference.setEntryValues(entryValues);
mLocalePreference.setValue(value.toString()); mLocalePreference.setValue(value != null ? value.toString() : null);
mLocalePreference.setEnabled(entries.length > 0); mLocalePreference.setEnabled(entries.length > 0);
} }