diff options
author | 2016-04-22 10:27:26 +0000 | |
---|---|---|
committer | 2016-04-22 10:27:27 +0000 | |
commit | 09ae4931a98cb0cb7edac257db30169098ab56c7 (patch) | |
tree | f2aa7ec5079469a9f78b6a70595a6445df349bef | |
parent | c027ae49f0a941c73c692e1153b2a6623fdae152 (diff) | |
parent | 4bd017d6a5437f153b2b0a149a5dde0b85bf6907 (diff) |
Merge "frameworks/base: Avoid Long object allocations in Long.valueOf()"
13 files changed, 36 insertions, 36 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index 74a1fbf1b490..aac9242443f6 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -527,7 +527,7 @@ public class Am extends BaseCommand { String[] strings = value.split(","); long[] list = new long[strings.length]; for (int i = 0; i < strings.length; i++) { - list[i] = Long.valueOf(strings[i]); + list[i] = Long.parseLong(strings[i]); } intent.putExtra(key, list); hasIntentInfo = true; diff --git a/cmds/requestsync/src/com/android/commands/requestsync/RequestSync.java b/cmds/requestsync/src/com/android/commands/requestsync/RequestSync.java index 808618f28666..50ee56455b48 100644 --- a/cmds/requestsync/src/com/android/commands/requestsync/RequestSync.java +++ b/cmds/requestsync/src/com/android/commands/requestsync/RequestSync.java @@ -128,15 +128,15 @@ public class RequestSync { } else if (opt.equals("--el") || opt.equals("--extra-long")) { final String key = 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")) { final String key = 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")) { final String key = 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")) { final String key = nextArgRequired(); final String value = nextArgRequired(); diff --git a/core/java/android/nfc/cardemulation/NfcFCardEmulation.java b/core/java/android/nfc/cardemulation/NfcFCardEmulation.java index d61ac02eb98e..6d907cdc146d 100644 --- a/core/java/android/nfc/cardemulation/NfcFCardEmulation.java +++ b/core/java/android/nfc/cardemulation/NfcFCardEmulation.java @@ -453,7 +453,7 @@ public final class NfcFCardEmulation { return false; } try { - Long.valueOf(nfcid2, 16); + Long.parseLong(nfcid2, 16); } catch (NumberFormatException e) { Log.e(TAG, "NFCID2 " + nfcid2 + " is not a valid NFCID2."); return false; diff --git a/core/java/android/service/notification/ZenModeConfig.java b/core/java/android/service/notification/ZenModeConfig.java index 8763496194d7..6da901981033 100644 --- a/core/java/android/service/notification/ZenModeConfig.java +++ b/core/java/android/service/notification/ZenModeConfig.java @@ -364,7 +364,7 @@ public class ZenModeConfig implements Parcelable { private static long tryParseLong(String value, long defValue) { if (TextUtils.isEmpty(value)) return defValue; try { - return Long.valueOf(value); + return Long.parseLong(value); } catch (NumberFormatException e) { return defValue; } diff --git a/media/java/android/media/ExifInterface.java b/media/java/android/media/ExifInterface.java index 445ee6f91508..4d176d8e00df 100644 --- a/media/java/android/media/ExifInterface.java +++ b/media/java/android/media/ExifInterface.java @@ -386,7 +386,7 @@ public class ExifInterface { String subSecs = mAttributes.get(TAG_SUBSECTIME); if (subSecs != null) { try { - long sub = Long.valueOf(subSecs); + long sub = Long.parseLong(subSecs); while (sub > 1000) { sub /= 10; } diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java index 95d7772e9cfc..708cf681aadf 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java @@ -563,7 +563,7 @@ final class SettingsState { } 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); } diff --git a/services/core/java/com/android/server/DropBoxManagerService.java b/services/core/java/com/android/server/DropBoxManagerService.java index a44cb72034e9..3cf00bb86ab7 100644 --- a/services/core/java/com/android/server/DropBoxManagerService.java +++ b/services/core/java/com/android/server/DropBoxManagerService.java @@ -567,7 +567,7 @@ public final class DropBoxManagerService extends IDropBoxManagerService.Stub { this.flags = flags; 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; } diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java index 3de200954b15..7d63e8d2f4ce 100755 --- a/services/core/java/com/android/server/am/ActivityRecord.java +++ b/services/core/java/com/android/server/am/ActivityRecord.java @@ -1210,7 +1210,7 @@ final class ActivityRecord { if (TaskPersister.DEBUG) Slog.d(TaskPersister.TAG, "ActivityRecord: attribute name=" + attrName + " value=" + attrValue); if (ATTR_ID.equals(attrName)) { - createTime = Long.valueOf(attrValue); + createTime = Long.parseLong(attrValue); } else if (ATTR_LAUNCHEDFROMUID.equals(attrName)) { launchedFromUid = Integer.valueOf(attrValue); } else if (ATTR_LAUNCHEDFROMPACKAGE.equals(attrName)) { diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java index 9da30bff8c94..9ffc29766d6b 100644 --- a/services/core/java/com/android/server/am/TaskRecord.java +++ b/services/core/java/com/android/server/am/TaskRecord.java @@ -1018,7 +1018,7 @@ final class TaskRecord { if (TaskPersister.DEBUG) Slog.d(TaskPersister.TAG, "TaskRecord: attribute name=" + attrName + " value=" + attrValue); 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)) { realActivity = ComponentName.unflattenFromString(attrValue); } else if (ATTR_ORIGACTIVITY.equals(attrName)) { @@ -1029,45 +1029,45 @@ final class TaskRecord { rootAffinity = attrValue; hasRootAffinity = true; } else if (ATTR_ROOTHASRESET.equals(attrName)) { - rootHasReset = Boolean.valueOf(attrValue); + rootHasReset = Boolean.parseBoolean(attrValue); } else if (ATTR_AUTOREMOVERECENTS.equals(attrName)) { - autoRemoveRecents = Boolean.valueOf(attrValue); + autoRemoveRecents = Boolean.parseBoolean(attrValue); } else if (ATTR_ASKEDCOMPATMODE.equals(attrName)) { - askedCompatMode = Boolean.valueOf(attrValue); + askedCompatMode = Boolean.parseBoolean(attrValue); } else if (ATTR_USERID.equals(attrName)) { - userId = Integer.valueOf(attrValue); + userId = Integer.parseInt(attrValue); } else if (ATTR_EFFECTIVE_UID.equals(attrName)) { - effectiveUid = Integer.valueOf(attrValue); + effectiveUid = Integer.parseInt(attrValue); } else if (ATTR_TASKTYPE.equals(attrName)) { - taskType = Integer.valueOf(attrValue); + taskType = Integer.parseInt(attrValue); } else if (ATTR_FIRSTACTIVETIME.equals(attrName)) { - firstActiveTime = Long.valueOf(attrValue); + firstActiveTime = Long.parseLong(attrValue); } else if (ATTR_LASTACTIVETIME.equals(attrName)) { - lastActiveTime = Long.valueOf(attrValue); + lastActiveTime = Long.parseLong(attrValue); } else if (ATTR_LASTDESCRIPTION.equals(attrName)) { lastDescription = attrValue; } else if (ATTR_LASTTIMEMOVED.equals(attrName)) { - lastTimeOnTop = Long.valueOf(attrValue); + lastTimeOnTop = Long.parseLong(attrValue); } else if (ATTR_NEVERRELINQUISH.equals(attrName)) { - neverRelinquishIdentity = Boolean.valueOf(attrValue); + neverRelinquishIdentity = Boolean.parseBoolean(attrValue); } else if (attrName.startsWith(TaskDescription.ATTR_TASKDESCRIPTION_PREFIX)) { taskDescription.restoreFromXml(attrName, attrValue); } else if (ATTR_TASK_AFFILIATION.equals(attrName)) { - taskAffiliation = Integer.valueOf(attrValue); + taskAffiliation = Integer.parseInt(attrValue); } else if (ATTR_PREV_AFFILIATION.equals(attrName)) { - prevTaskId = Integer.valueOf(attrValue); + prevTaskId = Integer.parseInt(attrValue); } else if (ATTR_NEXT_AFFILIATION.equals(attrName)) { - nextTaskId = Integer.valueOf(attrValue); + nextTaskId = Integer.parseInt(attrValue); } else if (ATTR_TASK_AFFILIATION_COLOR.equals(attrName)) { - taskAffiliationColor = Integer.valueOf(attrValue); + taskAffiliationColor = Integer.parseInt(attrValue); } else if (ATTR_CALLING_UID.equals(attrName)) { - callingUid = Integer.valueOf(attrValue); + callingUid = Integer.parseInt(attrValue); } else if (ATTR_CALLING_PACKAGE.equals(attrName)) { callingPackage = attrValue; } else if (ATTR_RESIZEABLE.equals(attrName)) { - resizeable = Boolean.valueOf(attrValue); + resizeable = Boolean.parseBoolean(attrValue); } else if (ATTR_PRIVILEGED.equals(attrName)) { - privileged = Boolean.valueOf(attrValue); + privileged = Boolean.parseBoolean(attrValue); } else { Slog.w(TAG, "TaskRecord: Unknown attribute=" + attrName); } diff --git a/services/core/java/com/android/server/job/JobStore.java b/services/core/java/com/android/server/job/JobStore.java index 0004c42c13ae..6278960d94fa 100644 --- a/services/core/java/com/android/server/job/JobStore.java +++ b/services/core/java/com/android/server/job/JobStore.java @@ -568,7 +568,7 @@ public class JobStore { if (XML_TAG_PERIODIC.equals(parser.getName())) { try { String val = parser.getAttributeValue(null, "period"); - final long periodMillis = Long.valueOf(val); + final long periodMillis = Long.parseLong(val); jobBuilder.setPeriodic(periodMillis); // 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 @@ -675,7 +675,7 @@ public class JobStore { private void maybeBuildBackoffPolicyFromXml(JobInfo.Builder jobBuilder, XmlPullParser parser) { String val = parser.getAttributeValue(null, "initial-backoff"); if (val != null) { - long initialBackoff = Long.valueOf(val); + long initialBackoff = Long.parseLong(val); val = parser.getAttributeValue(null, "backoff-policy"); int backoffPolicy = Integer.valueOf(val); // Will throw NFE which we catch higher up. jobBuilder.setBackoffCriteria(initialBackoff, backoffPolicy); @@ -698,14 +698,14 @@ public class JobStore { long latestRunTimeElapsed = JobStatus.NO_LATEST_RUNTIME; String val = parser.getAttributeValue(null, "deadline"); if (val != null) { - long latestRuntimeWallclock = Long.valueOf(val); + long latestRuntimeWallclock = Long.parseLong(val); long maxDelayElapsed = Math.max(latestRuntimeWallclock - nowWallclock, 0); latestRunTimeElapsed = nowElapsed + maxDelayElapsed; } val = parser.getAttributeValue(null, "delay"); if (val != null) { - long earliestRuntimeWallclock = Long.valueOf(val); + long earliestRuntimeWallclock = Long.parseLong(val); long minDelayElapsed = Math.max(earliestRuntimeWallclock - nowWallclock, 0); earliestRunTimeElapsed = nowElapsed + minDelayElapsed; diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index 288810c5bd8c..c5f632c1b089 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -3530,7 +3530,7 @@ public class NotificationManagerService extends SystemService { filter.stats = true; if (ai < args.length-1) { ai++; - filter.since = Long.valueOf(args[ai]); + filter.since = Long.parseLong(args[ai]); } else { filter.since = 0; } diff --git a/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/MainActivity.java b/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/MainActivity.java index dfbbd7e61472..5aa0d4f35a21 100644 --- a/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/MainActivity.java +++ b/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/MainActivity.java @@ -134,11 +134,11 @@ public class MainActivity extends Activity { String delay = mDelayEditText.getText().toString(); if (delay != null && !TextUtils.isEmpty(delay)) { - builder.setMinimumLatency(Long.valueOf(delay) * 1000); + builder.setMinimumLatency(Long.parseLong(delay) * 1000); } String deadline = mDeadlineEditText.getText().toString(); if (deadline != null && !TextUtils.isEmpty(deadline)) { - builder.setOverrideDeadline(Long.valueOf(deadline) * 1000); + builder.setOverrideDeadline(Long.parseLong(deadline) * 1000); } boolean requiresUnmetered = mWiFiConnectivityRadioButton.isChecked(); boolean requiresAnyConnectivity = mAnyConnectivityRadioButton.isChecked(); diff --git a/tests/LocationTracker/src/com/android/locationtracker/TrackerService.java b/tests/LocationTracker/src/com/android/locationtracker/TrackerService.java index e2332bfe4b8a..e4d21558b8f9 100644 --- a/tests/LocationTracker/src/com/android/locationtracker/TrackerService.java +++ b/tests/LocationTracker/src/com/android/locationtracker/TrackerService.java @@ -214,7 +214,7 @@ public class TrackerService extends Service { private long getLocationUpdateTime() { try { String timeString = getPreferences().getString(MIN_TIME_PREF, "0"); - long secondsTime = Long.valueOf(timeString); + long secondsTime = Long.parseLong(timeString); return secondsTime * 1000; } catch (NumberFormatException e) { |