Merge "frameworks/base: Avoid Long object allocations in Long.valueOf()"
This commit is contained in:
@@ -527,7 +527,7 @@ public class Am extends BaseCommand {
|
|||||||
String[] strings = value.split(",");
|
String[] strings = value.split(",");
|
||||||
long[] list = new long[strings.length];
|
long[] list = new long[strings.length];
|
||||||
for (int i = 0; i < strings.length; i++) {
|
for (int i = 0; i < strings.length; i++) {
|
||||||
list[i] = Long.valueOf(strings[i]);
|
list[i] = Long.parseLong(strings[i]);
|
||||||
}
|
}
|
||||||
intent.putExtra(key, list);
|
intent.putExtra(key, list);
|
||||||
hasIntentInfo = true;
|
hasIntentInfo = true;
|
||||||
|
|||||||
@@ -128,15 +128,15 @@ public class RequestSync {
|
|||||||
} else if (opt.equals("--el") || opt.equals("--extra-long")) {
|
} else if (opt.equals("--el") || opt.equals("--extra-long")) {
|
||||||
final String key = nextArgRequired();
|
final String key = nextArgRequired();
|
||||||
final String value = nextArgRequired();
|
final String value = nextArgRequired();
|
||||||
mExtras.putLong(key, Long.valueOf(value));
|
mExtras.putLong(key, Long.parseLong(value));
|
||||||
} else if (opt.equals("--ef") || opt.equals("--extra-float")) {
|
} else if (opt.equals("--ef") || opt.equals("--extra-float")) {
|
||||||
final String key = nextArgRequired();
|
final String key = nextArgRequired();
|
||||||
final String value = nextArgRequired();
|
final String value = nextArgRequired();
|
||||||
mExtras.putFloat(key, Long.valueOf(value));
|
mExtras.putFloat(key, Long.parseLong(value));
|
||||||
} else if (opt.equals("--ed") || opt.equals("--extra-double")) {
|
} else if (opt.equals("--ed") || opt.equals("--extra-double")) {
|
||||||
final String key = nextArgRequired();
|
final String key = nextArgRequired();
|
||||||
final String value = nextArgRequired();
|
final String value = nextArgRequired();
|
||||||
mExtras.putFloat(key, Long.valueOf(value));
|
mExtras.putFloat(key, Long.parseLong(value));
|
||||||
} else if (opt.equals("--ez") || opt.equals("--extra-bool")) {
|
} else if (opt.equals("--ez") || opt.equals("--extra-bool")) {
|
||||||
final String key = nextArgRequired();
|
final String key = nextArgRequired();
|
||||||
final String value = nextArgRequired();
|
final String value = nextArgRequired();
|
||||||
|
|||||||
@@ -453,7 +453,7 @@ public final class NfcFCardEmulation {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Long.valueOf(nfcid2, 16);
|
Long.parseLong(nfcid2, 16);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
Log.e(TAG, "NFCID2 " + nfcid2 + " is not a valid NFCID2.");
|
Log.e(TAG, "NFCID2 " + nfcid2 + " is not a valid NFCID2.");
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -364,7 +364,7 @@ public class ZenModeConfig implements Parcelable {
|
|||||||
private static long tryParseLong(String value, long defValue) {
|
private static long tryParseLong(String value, long defValue) {
|
||||||
if (TextUtils.isEmpty(value)) return defValue;
|
if (TextUtils.isEmpty(value)) return defValue;
|
||||||
try {
|
try {
|
||||||
return Long.valueOf(value);
|
return Long.parseLong(value);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
return defValue;
|
return defValue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -386,7 +386,7 @@ public class ExifInterface {
|
|||||||
String subSecs = mAttributes.get(TAG_SUBSECTIME);
|
String subSecs = mAttributes.get(TAG_SUBSECTIME);
|
||||||
if (subSecs != null) {
|
if (subSecs != null) {
|
||||||
try {
|
try {
|
||||||
long sub = Long.valueOf(subSecs);
|
long sub = Long.parseLong(subSecs);
|
||||||
while (sub > 1000) {
|
while (sub > 1000) {
|
||||||
sub /= 10;
|
sub /= 10;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -563,7 +563,7 @@ final class SettingsState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Setting(String name, String value, String packageName, String id) {
|
public Setting(String name, String value, String packageName, String id) {
|
||||||
mNextId = Math.max(mNextId, Long.valueOf(id) + 1);
|
mNextId = Math.max(mNextId, Long.parseLong(id) + 1);
|
||||||
init(name, value, packageName, id);
|
init(name, value, packageName, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -567,7 +567,7 @@ public final class DropBoxManagerService extends IDropBoxManagerService.Stub {
|
|||||||
this.flags = flags;
|
this.flags = flags;
|
||||||
|
|
||||||
long millis;
|
long millis;
|
||||||
try { millis = Long.valueOf(name); } catch (NumberFormatException e) { millis = 0; }
|
try { millis = Long.parseLong(name); } catch (NumberFormatException e) { millis = 0; }
|
||||||
this.timestampMillis = millis;
|
this.timestampMillis = millis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1210,7 +1210,7 @@ final class ActivityRecord {
|
|||||||
if (TaskPersister.DEBUG) Slog.d(TaskPersister.TAG,
|
if (TaskPersister.DEBUG) Slog.d(TaskPersister.TAG,
|
||||||
"ActivityRecord: attribute name=" + attrName + " value=" + attrValue);
|
"ActivityRecord: attribute name=" + attrName + " value=" + attrValue);
|
||||||
if (ATTR_ID.equals(attrName)) {
|
if (ATTR_ID.equals(attrName)) {
|
||||||
createTime = Long.valueOf(attrValue);
|
createTime = Long.parseLong(attrValue);
|
||||||
} else if (ATTR_LAUNCHEDFROMUID.equals(attrName)) {
|
} else if (ATTR_LAUNCHEDFROMUID.equals(attrName)) {
|
||||||
launchedFromUid = Integer.valueOf(attrValue);
|
launchedFromUid = Integer.valueOf(attrValue);
|
||||||
} else if (ATTR_LAUNCHEDFROMPACKAGE.equals(attrName)) {
|
} else if (ATTR_LAUNCHEDFROMPACKAGE.equals(attrName)) {
|
||||||
|
|||||||
@@ -1018,7 +1018,7 @@ final class TaskRecord {
|
|||||||
if (TaskPersister.DEBUG) Slog.d(TaskPersister.TAG, "TaskRecord: attribute name=" +
|
if (TaskPersister.DEBUG) Slog.d(TaskPersister.TAG, "TaskRecord: attribute name=" +
|
||||||
attrName + " value=" + attrValue);
|
attrName + " value=" + attrValue);
|
||||||
if (ATTR_TASKID.equals(attrName)) {
|
if (ATTR_TASKID.equals(attrName)) {
|
||||||
if (taskId == INVALID_TASK_ID) taskId = Integer.valueOf(attrValue);
|
if (taskId == INVALID_TASK_ID) taskId = Integer.parseInt(attrValue);
|
||||||
} else if (ATTR_REALACTIVITY.equals(attrName)) {
|
} else if (ATTR_REALACTIVITY.equals(attrName)) {
|
||||||
realActivity = ComponentName.unflattenFromString(attrValue);
|
realActivity = ComponentName.unflattenFromString(attrValue);
|
||||||
} else if (ATTR_ORIGACTIVITY.equals(attrName)) {
|
} else if (ATTR_ORIGACTIVITY.equals(attrName)) {
|
||||||
@@ -1029,45 +1029,45 @@ final class TaskRecord {
|
|||||||
rootAffinity = attrValue;
|
rootAffinity = attrValue;
|
||||||
hasRootAffinity = true;
|
hasRootAffinity = true;
|
||||||
} else if (ATTR_ROOTHASRESET.equals(attrName)) {
|
} else if (ATTR_ROOTHASRESET.equals(attrName)) {
|
||||||
rootHasReset = Boolean.valueOf(attrValue);
|
rootHasReset = Boolean.parseBoolean(attrValue);
|
||||||
} else if (ATTR_AUTOREMOVERECENTS.equals(attrName)) {
|
} else if (ATTR_AUTOREMOVERECENTS.equals(attrName)) {
|
||||||
autoRemoveRecents = Boolean.valueOf(attrValue);
|
autoRemoveRecents = Boolean.parseBoolean(attrValue);
|
||||||
} else if (ATTR_ASKEDCOMPATMODE.equals(attrName)) {
|
} else if (ATTR_ASKEDCOMPATMODE.equals(attrName)) {
|
||||||
askedCompatMode = Boolean.valueOf(attrValue);
|
askedCompatMode = Boolean.parseBoolean(attrValue);
|
||||||
} else if (ATTR_USERID.equals(attrName)) {
|
} else if (ATTR_USERID.equals(attrName)) {
|
||||||
userId = Integer.valueOf(attrValue);
|
userId = Integer.parseInt(attrValue);
|
||||||
} else if (ATTR_EFFECTIVE_UID.equals(attrName)) {
|
} else if (ATTR_EFFECTIVE_UID.equals(attrName)) {
|
||||||
effectiveUid = Integer.valueOf(attrValue);
|
effectiveUid = Integer.parseInt(attrValue);
|
||||||
} else if (ATTR_TASKTYPE.equals(attrName)) {
|
} else if (ATTR_TASKTYPE.equals(attrName)) {
|
||||||
taskType = Integer.valueOf(attrValue);
|
taskType = Integer.parseInt(attrValue);
|
||||||
} else if (ATTR_FIRSTACTIVETIME.equals(attrName)) {
|
} else if (ATTR_FIRSTACTIVETIME.equals(attrName)) {
|
||||||
firstActiveTime = Long.valueOf(attrValue);
|
firstActiveTime = Long.parseLong(attrValue);
|
||||||
} else if (ATTR_LASTACTIVETIME.equals(attrName)) {
|
} else if (ATTR_LASTACTIVETIME.equals(attrName)) {
|
||||||
lastActiveTime = Long.valueOf(attrValue);
|
lastActiveTime = Long.parseLong(attrValue);
|
||||||
} else if (ATTR_LASTDESCRIPTION.equals(attrName)) {
|
} else if (ATTR_LASTDESCRIPTION.equals(attrName)) {
|
||||||
lastDescription = attrValue;
|
lastDescription = attrValue;
|
||||||
} else if (ATTR_LASTTIMEMOVED.equals(attrName)) {
|
} else if (ATTR_LASTTIMEMOVED.equals(attrName)) {
|
||||||
lastTimeOnTop = Long.valueOf(attrValue);
|
lastTimeOnTop = Long.parseLong(attrValue);
|
||||||
} else if (ATTR_NEVERRELINQUISH.equals(attrName)) {
|
} else if (ATTR_NEVERRELINQUISH.equals(attrName)) {
|
||||||
neverRelinquishIdentity = Boolean.valueOf(attrValue);
|
neverRelinquishIdentity = Boolean.parseBoolean(attrValue);
|
||||||
} else if (attrName.startsWith(TaskDescription.ATTR_TASKDESCRIPTION_PREFIX)) {
|
} else if (attrName.startsWith(TaskDescription.ATTR_TASKDESCRIPTION_PREFIX)) {
|
||||||
taskDescription.restoreFromXml(attrName, attrValue);
|
taskDescription.restoreFromXml(attrName, attrValue);
|
||||||
} else if (ATTR_TASK_AFFILIATION.equals(attrName)) {
|
} else if (ATTR_TASK_AFFILIATION.equals(attrName)) {
|
||||||
taskAffiliation = Integer.valueOf(attrValue);
|
taskAffiliation = Integer.parseInt(attrValue);
|
||||||
} else if (ATTR_PREV_AFFILIATION.equals(attrName)) {
|
} else if (ATTR_PREV_AFFILIATION.equals(attrName)) {
|
||||||
prevTaskId = Integer.valueOf(attrValue);
|
prevTaskId = Integer.parseInt(attrValue);
|
||||||
} else if (ATTR_NEXT_AFFILIATION.equals(attrName)) {
|
} else if (ATTR_NEXT_AFFILIATION.equals(attrName)) {
|
||||||
nextTaskId = Integer.valueOf(attrValue);
|
nextTaskId = Integer.parseInt(attrValue);
|
||||||
} else if (ATTR_TASK_AFFILIATION_COLOR.equals(attrName)) {
|
} else if (ATTR_TASK_AFFILIATION_COLOR.equals(attrName)) {
|
||||||
taskAffiliationColor = Integer.valueOf(attrValue);
|
taskAffiliationColor = Integer.parseInt(attrValue);
|
||||||
} else if (ATTR_CALLING_UID.equals(attrName)) {
|
} else if (ATTR_CALLING_UID.equals(attrName)) {
|
||||||
callingUid = Integer.valueOf(attrValue);
|
callingUid = Integer.parseInt(attrValue);
|
||||||
} else if (ATTR_CALLING_PACKAGE.equals(attrName)) {
|
} else if (ATTR_CALLING_PACKAGE.equals(attrName)) {
|
||||||
callingPackage = attrValue;
|
callingPackage = attrValue;
|
||||||
} else if (ATTR_RESIZEABLE.equals(attrName)) {
|
} else if (ATTR_RESIZEABLE.equals(attrName)) {
|
||||||
resizeable = Boolean.valueOf(attrValue);
|
resizeable = Boolean.parseBoolean(attrValue);
|
||||||
} else if (ATTR_PRIVILEGED.equals(attrName)) {
|
} else if (ATTR_PRIVILEGED.equals(attrName)) {
|
||||||
privileged = Boolean.valueOf(attrValue);
|
privileged = Boolean.parseBoolean(attrValue);
|
||||||
} else {
|
} else {
|
||||||
Slog.w(TAG, "TaskRecord: Unknown attribute=" + attrName);
|
Slog.w(TAG, "TaskRecord: Unknown attribute=" + attrName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -568,7 +568,7 @@ public class JobStore {
|
|||||||
if (XML_TAG_PERIODIC.equals(parser.getName())) {
|
if (XML_TAG_PERIODIC.equals(parser.getName())) {
|
||||||
try {
|
try {
|
||||||
String val = parser.getAttributeValue(null, "period");
|
String val = parser.getAttributeValue(null, "period");
|
||||||
final long periodMillis = Long.valueOf(val);
|
final long periodMillis = Long.parseLong(val);
|
||||||
jobBuilder.setPeriodic(periodMillis);
|
jobBuilder.setPeriodic(periodMillis);
|
||||||
// As a sanity check, cap the recreated run time to be no later than 2 periods
|
// As a sanity check, cap the recreated run time to be no later than 2 periods
|
||||||
// from now. This is the latest the periodic could be pushed out. This could
|
// from now. This is the latest the periodic could be pushed out. This could
|
||||||
@@ -675,7 +675,7 @@ public class JobStore {
|
|||||||
private void maybeBuildBackoffPolicyFromXml(JobInfo.Builder jobBuilder, XmlPullParser parser) {
|
private void maybeBuildBackoffPolicyFromXml(JobInfo.Builder jobBuilder, XmlPullParser parser) {
|
||||||
String val = parser.getAttributeValue(null, "initial-backoff");
|
String val = parser.getAttributeValue(null, "initial-backoff");
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
long initialBackoff = Long.valueOf(val);
|
long initialBackoff = Long.parseLong(val);
|
||||||
val = parser.getAttributeValue(null, "backoff-policy");
|
val = parser.getAttributeValue(null, "backoff-policy");
|
||||||
int backoffPolicy = Integer.valueOf(val); // Will throw NFE which we catch higher up.
|
int backoffPolicy = Integer.valueOf(val); // Will throw NFE which we catch higher up.
|
||||||
jobBuilder.setBackoffCriteria(initialBackoff, backoffPolicy);
|
jobBuilder.setBackoffCriteria(initialBackoff, backoffPolicy);
|
||||||
@@ -698,14 +698,14 @@ public class JobStore {
|
|||||||
long latestRunTimeElapsed = JobStatus.NO_LATEST_RUNTIME;
|
long latestRunTimeElapsed = JobStatus.NO_LATEST_RUNTIME;
|
||||||
String val = parser.getAttributeValue(null, "deadline");
|
String val = parser.getAttributeValue(null, "deadline");
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
long latestRuntimeWallclock = Long.valueOf(val);
|
long latestRuntimeWallclock = Long.parseLong(val);
|
||||||
long maxDelayElapsed =
|
long maxDelayElapsed =
|
||||||
Math.max(latestRuntimeWallclock - nowWallclock, 0);
|
Math.max(latestRuntimeWallclock - nowWallclock, 0);
|
||||||
latestRunTimeElapsed = nowElapsed + maxDelayElapsed;
|
latestRunTimeElapsed = nowElapsed + maxDelayElapsed;
|
||||||
}
|
}
|
||||||
val = parser.getAttributeValue(null, "delay");
|
val = parser.getAttributeValue(null, "delay");
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
long earliestRuntimeWallclock = Long.valueOf(val);
|
long earliestRuntimeWallclock = Long.parseLong(val);
|
||||||
long minDelayElapsed =
|
long minDelayElapsed =
|
||||||
Math.max(earliestRuntimeWallclock - nowWallclock, 0);
|
Math.max(earliestRuntimeWallclock - nowWallclock, 0);
|
||||||
earliestRunTimeElapsed = nowElapsed + minDelayElapsed;
|
earliestRunTimeElapsed = nowElapsed + minDelayElapsed;
|
||||||
|
|||||||
@@ -3530,7 +3530,7 @@ public class NotificationManagerService extends SystemService {
|
|||||||
filter.stats = true;
|
filter.stats = true;
|
||||||
if (ai < args.length-1) {
|
if (ai < args.length-1) {
|
||||||
ai++;
|
ai++;
|
||||||
filter.since = Long.valueOf(args[ai]);
|
filter.since = Long.parseLong(args[ai]);
|
||||||
} else {
|
} else {
|
||||||
filter.since = 0;
|
filter.since = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,11 +134,11 @@ public class MainActivity extends Activity {
|
|||||||
|
|
||||||
String delay = mDelayEditText.getText().toString();
|
String delay = mDelayEditText.getText().toString();
|
||||||
if (delay != null && !TextUtils.isEmpty(delay)) {
|
if (delay != null && !TextUtils.isEmpty(delay)) {
|
||||||
builder.setMinimumLatency(Long.valueOf(delay) * 1000);
|
builder.setMinimumLatency(Long.parseLong(delay) * 1000);
|
||||||
}
|
}
|
||||||
String deadline = mDeadlineEditText.getText().toString();
|
String deadline = mDeadlineEditText.getText().toString();
|
||||||
if (deadline != null && !TextUtils.isEmpty(deadline)) {
|
if (deadline != null && !TextUtils.isEmpty(deadline)) {
|
||||||
builder.setOverrideDeadline(Long.valueOf(deadline) * 1000);
|
builder.setOverrideDeadline(Long.parseLong(deadline) * 1000);
|
||||||
}
|
}
|
||||||
boolean requiresUnmetered = mWiFiConnectivityRadioButton.isChecked();
|
boolean requiresUnmetered = mWiFiConnectivityRadioButton.isChecked();
|
||||||
boolean requiresAnyConnectivity = mAnyConnectivityRadioButton.isChecked();
|
boolean requiresAnyConnectivity = mAnyConnectivityRadioButton.isChecked();
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ public class TrackerService extends Service {
|
|||||||
private long getLocationUpdateTime() {
|
private long getLocationUpdateTime() {
|
||||||
try {
|
try {
|
||||||
String timeString = getPreferences().getString(MIN_TIME_PREF, "0");
|
String timeString = getPreferences().getString(MIN_TIME_PREF, "0");
|
||||||
long secondsTime = Long.valueOf(timeString);
|
long secondsTime = Long.parseLong(timeString);
|
||||||
return secondsTime * 1000;
|
return secondsTime * 1000;
|
||||||
}
|
}
|
||||||
catch (NumberFormatException e) {
|
catch (NumberFormatException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user