Messaging: Explicitly specify Locale where needed
Change-Id: I636e9cceed0e73bcf957ebbda5e239982e681fd7
This commit is contained in:
@@ -28,6 +28,7 @@ import com.android.messaging.util.ThreadUtil;
|
|||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -273,7 +274,8 @@ public class ActionMonitor {
|
|||||||
newMonitorState = monitor.mState;
|
newMonitorState = monitor.mState;
|
||||||
}
|
}
|
||||||
if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
|
if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
|
||||||
final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
|
final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS",
|
||||||
|
Locale.getDefault());
|
||||||
df.setTimeZone(TimeZone.getTimeZone("UTC"));
|
df.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
LogUtil.v(TAG, "Operation-" + action.actionKey + ": @" + df.format(new Date())
|
LogUtil.v(TAG, "Operation-" + action.actionKey + ": @" + df.format(new Date())
|
||||||
+ "UTC State = " + oldMonitorState + " - " + newMonitorState);
|
+ "UTC State = " + oldMonitorState + " - " + newMonitorState);
|
||||||
@@ -341,7 +343,8 @@ public class ActionMonitor {
|
|||||||
unregisterActionMonitorIfComplete(action.actionKey, monitor);
|
unregisterActionMonitorIfComplete(action.actionKey, monitor);
|
||||||
}
|
}
|
||||||
if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
|
if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
|
||||||
final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
|
final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS",
|
||||||
|
Locale.getDefault());
|
||||||
df.setTimeZone(TimeZone.getTimeZone("UTC"));
|
df.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
LogUtil.v(TAG, "Operation-" + action.actionKey + ": @" + df.format(new Date())
|
LogUtil.v(TAG, "Operation-" + action.actionKey + ": @" + df.format(new Date())
|
||||||
+ "UTC State = " + oldMonitorState + " - " + STATE_COMPLETE);
|
+ "UTC State = " + oldMonitorState + " - " + STATE_COMPLETE);
|
||||||
@@ -399,7 +402,8 @@ public class ActionMonitor {
|
|||||||
monitor.executed(action, expectedOldState, hasBackgroundActions, result);
|
monitor.executed(action, expectedOldState, hasBackgroundActions, result);
|
||||||
}
|
}
|
||||||
if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
|
if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
|
||||||
final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
|
final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS",
|
||||||
|
Locale.getDefault());
|
||||||
df.setTimeZone(TimeZone.getTimeZone("UTC"));
|
df.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
LogUtil.v(TAG, "Operation-" + action.actionKey + ": @" + df.format(new Date())
|
LogUtil.v(TAG, "Operation-" + action.actionKey + ": @" + df.format(new Date())
|
||||||
+ "UTC State = " + oldMonitorState + " - EXECUTED");
|
+ "UTC State = " + oldMonitorState + " - EXECUTED");
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015 The Android Open Source Project
|
* Copyright (C) 2015 The Android Open Source Project
|
||||||
* Copyright (C) 2024 The LineageOS Project
|
* Copyright (C) 2024-2025 The LineageOS Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -327,7 +327,8 @@ public class MmsUtils {
|
|||||||
final String extension = ContentType.getExtensionFromMimeType(contentType);
|
final String extension = ContentType.getExtensionFromMimeType(contentType);
|
||||||
if (ContentType.isImageType(contentType)) {
|
if (ContentType.isImageType(contentType)) {
|
||||||
if (extension != null) {
|
if (extension != null) {
|
||||||
srcName = String.format("image%06d.%s", index, extension);
|
srcName = String.format(Locale.getDefault(), "image%06d.%s", index,
|
||||||
|
extension);
|
||||||
} else {
|
} else {
|
||||||
// There's a good chance that if we selected the image from our media picker
|
// There's a good chance that if we selected the image from our media picker
|
||||||
// the content type is image/*. Fix the content type here for gifs so that
|
// the content type is image/*. Fix the content type here for gifs so that
|
||||||
@@ -335,35 +336,37 @@ public class MmsUtils {
|
|||||||
// checks will only have to do a string comparison which is much cheaper.
|
// checks will only have to do a string comparison which is much cheaper.
|
||||||
final boolean isGif = ImageUtils.isGif(contentType, part.getContentUri());
|
final boolean isGif = ImageUtils.isGif(contentType, part.getContentUri());
|
||||||
contentType = isGif ? ContentType.IMAGE_GIF : contentType;
|
contentType = isGif ? ContentType.IMAGE_GIF : contentType;
|
||||||
srcName = String.format(isGif ? "image%06d.gif" : "image%06d.jpg", index);
|
srcName = String.format(Locale.getDefault(),
|
||||||
|
isGif ? "image%06d.gif" : "image%06d.jpg", index);
|
||||||
}
|
}
|
||||||
smilBody.append(String.format(sSmilImagePart, srcName));
|
smilBody.append(String.format(sSmilImagePart, srcName));
|
||||||
totalLength += addPicturePart(context, pb, index, part,
|
totalLength += addPicturePart(context, pb, index, part,
|
||||||
widthLimit, heightLimit, bytesPerImage, srcName, contentType);
|
widthLimit, heightLimit, bytesPerImage, srcName, contentType);
|
||||||
hasVisualAttachment = true;
|
hasVisualAttachment = true;
|
||||||
} else if (ContentType.isVideoType(contentType)) {
|
} else if (ContentType.isVideoType(contentType)) {
|
||||||
srcName = String.format("video%06d.%s", index,
|
srcName = String.format(Locale.getDefault(), "video%06d.%s", index,
|
||||||
extension != null ? extension : "mp4");
|
extension != null ? extension : "mp4");
|
||||||
final int length = addVideoPart(context, pb, part, srcName);
|
final int length = addVideoPart(context, pb, part, srcName);
|
||||||
totalLength += length;
|
totalLength += length;
|
||||||
smilBody.append(String.format(sSmilVideoPart, srcName,
|
smilBody.append(String.format(Locale.getDefault(), sSmilVideoPart, srcName,
|
||||||
getMediaDurationMs(context, part, DEFAULT_DURATION)));
|
getMediaDurationMs(context, part, DEFAULT_DURATION)));
|
||||||
hasVisualAttachment = true;
|
hasVisualAttachment = true;
|
||||||
} else if (ContentType.isVCardType(contentType)) {
|
} else if (ContentType.isVCardType(contentType)) {
|
||||||
srcName = String.format("contact%06d.vcf", index);
|
srcName = String.format(Locale.getDefault(), "contact%06d.vcf", index);
|
||||||
totalLength += addVCardPart(context, pb, part, srcName);
|
totalLength += addVCardPart(context, pb, part, srcName);
|
||||||
smilBody.append(String.format(sSmilPart, srcName));
|
smilBody.append(String.format(sSmilPart, srcName));
|
||||||
hasNonVisualAttachment = true;
|
hasNonVisualAttachment = true;
|
||||||
} else if (ContentType.isAudioType(contentType)) {
|
} else if (ContentType.isAudioType(contentType)) {
|
||||||
srcName = String.format("recording%06d.%s",
|
srcName = String.format(Locale.getDefault(), "recording%06d.%s",
|
||||||
index, extension != null ? extension : "amr");
|
index, extension != null ? extension : "amr");
|
||||||
totalLength += addOtherPart(context, pb, part, srcName);
|
totalLength += addOtherPart(context, pb, part, srcName);
|
||||||
final int duration = getMediaDurationMs(context, part, -1);
|
final int duration = getMediaDurationMs(context, part, -1);
|
||||||
Assert.isTrue(duration != -1);
|
Assert.isTrue(duration != -1);
|
||||||
smilBody.append(String.format(sSmilAudioPart, srcName, duration));
|
smilBody.append(String.format(Locale.getDefault(), sSmilAudioPart, srcName,
|
||||||
|
duration));
|
||||||
hasNonVisualAttachment = true;
|
hasNonVisualAttachment = true;
|
||||||
} else {
|
} else {
|
||||||
srcName = String.format("other%06d.dat", index);
|
srcName = String.format(Locale.getDefault(), "other%06d.dat", index);
|
||||||
totalLength += addOtherPart(context, pb, part, srcName);
|
totalLength += addOtherPart(context, pb, part, srcName);
|
||||||
smilBody.append(String.format(sSmilPart, srcName));
|
smilBody.append(String.format(sSmilPart, srcName));
|
||||||
}
|
}
|
||||||
@@ -375,7 +378,7 @@ public class MmsUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hasText) {
|
if (hasText) {
|
||||||
final String srcName = String.format("text.%06d.txt", index);
|
final String srcName = String.format(Locale.getDefault(), "text.%06d.txt", index);
|
||||||
final String text = message.getMessageText();
|
final String text = message.getMessageText();
|
||||||
totalLength += addTextPart(context, pb, text, srcName);
|
totalLength += addTextPart(context, pb, text, srcName);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015 The Android Open Source Project
|
* Copyright (C) 2015 The Android Open Source Project
|
||||||
* Copyright (C) 2024 The LineageOS Project
|
* Copyright (C) 2024-2025 The LineageOS Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -170,9 +170,9 @@ public class Dates {
|
|||||||
final String format24, final String format12) {
|
final String format24, final String format12) {
|
||||||
SimpleDateFormat formatter;
|
SimpleDateFormat formatter;
|
||||||
if ((flags & FORCE_24_HOUR) == FORCE_24_HOUR) {
|
if ((flags & FORCE_24_HOUR) == FORCE_24_HOUR) {
|
||||||
formatter = new SimpleDateFormat(format24);
|
formatter = new SimpleDateFormat(format24, Locale.getDefault());
|
||||||
} else {
|
} else {
|
||||||
formatter = new SimpleDateFormat(format12);
|
formatter = new SimpleDateFormat(format12, Locale.getDefault());
|
||||||
}
|
}
|
||||||
return formatter.format(new Date(time));
|
return formatter.format(new Date(time));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015 The Android Open Source Project
|
* Copyright (C) 2015 The Android Open Source Project
|
||||||
* Copyright (C) 2024 The LineageOS Project
|
* Copyright (C) 2024-2025 The LineageOS Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -23,6 +23,7 @@ import android.text.format.Formatter;
|
|||||||
import com.google.common.base.Stopwatch;
|
import com.google.common.base.Stopwatch;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,7 +52,8 @@ public class GifTranscoder {
|
|||||||
final float compression = (inputSize > 0) ? ((float) outputSize / inputSize) : 0;
|
final float compression = (inputSize > 0) ? ((float) outputSize / inputSize) : 0;
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
LogUtil.i(TAG, String.format("Resized GIF (%s) in %d ms, %s => %s (%.0f%%)",
|
LogUtil.i(TAG, String.format(Locale.getDefault(),
|
||||||
|
"Resized GIF (%s) in %d ms, %s => %s (%.0f%%)",
|
||||||
LogUtil.sanitizePII(filePath),
|
LogUtil.sanitizePII(filePath),
|
||||||
elapsedMs,
|
elapsedMs,
|
||||||
Formatter.formatShortFileSize(context, inputSize),
|
Formatter.formatShortFileSize(context, inputSize),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015 The Android Open Source Project
|
* Copyright (C) 2015 The Android Open Source Project
|
||||||
* Copyright (C) 2024 The LineageOS Project
|
* Copyright (C) 2024-2025 The LineageOS Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -54,6 +54,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class ImageUtils {
|
public class ImageUtils {
|
||||||
private static final String TAG = LogUtil.BUGLE_TAG;
|
private static final String TAG = LogUtil.BUGLE_TAG;
|
||||||
@@ -603,7 +604,7 @@ public class ImageUtils {
|
|||||||
sampleSize = sampleSize * 2;
|
sampleSize = sampleSize * 2;
|
||||||
// Note that recodeImage may try using mSampleSize * 2. Hence we use the factor of 4
|
// Note that recodeImage may try using mSampleSize * 2. Hence we use the factor of 4
|
||||||
if (sampleSize >= (Integer.MAX_VALUE / 4)) {
|
if (sampleSize >= (Integer.MAX_VALUE / 4)) {
|
||||||
LogUtil.w(LogUtil.BUGLE_IMAGE_TAG, String.format(
|
LogUtil.w(LogUtil.BUGLE_IMAGE_TAG, String.format(Locale.getDefault(),
|
||||||
"Cannot resize image: widthLimit=%d heightLimit=%d byteLimit=%d " +
|
"Cannot resize image: widthLimit=%d heightLimit=%d byteLimit=%d " +
|
||||||
"imageWidth=%d imageHeight=%d", mWidthLimit, mHeightLimit, mByteLimit,
|
"imageWidth=%d imageHeight=%d", mWidthLimit, mHeightLimit, mByteLimit,
|
||||||
mWidth, mHeight));
|
mWidth, mHeight));
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015 The Android Open Source Project
|
* Copyright (C) 2015 The Android Open Source Project
|
||||||
* Copyright (C) 2024 The LineageOS Project
|
* Copyright (C) 2024-2025 The LineageOS Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -19,6 +19,8 @@ package com.android.messaging.util;
|
|||||||
|
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A utility timer that logs the execution time of operations
|
* A utility timer that logs the execution time of operations
|
||||||
*/
|
*/
|
||||||
@@ -58,7 +60,8 @@ public class LoggingTimer {
|
|||||||
public void stopAndLog() {
|
public void stopAndLog() {
|
||||||
final long elapsedMs = SystemClock.elapsedRealtime() - mStartMillis;
|
final long elapsedMs = SystemClock.elapsedRealtime() - mStartMillis;
|
||||||
|
|
||||||
final String logMessage = String.format("Used %dms for %s", elapsedMs, mName);
|
final String logMessage = String.format(Locale.getDefault(), "Used %dms for %s",
|
||||||
|
elapsedMs, mName);
|
||||||
|
|
||||||
if (mWarnLimitMillis != NO_WARN_LIMIT && elapsedMs > mWarnLimitMillis) {
|
if (mWarnLimitMillis != NO_WARN_LIMIT && elapsedMs > mWarnLimitMillis) {
|
||||||
LogUtil.w(mTag, logMessage);
|
LogUtil.w(mTag, logMessage);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015 The Android Open Source Project
|
* Copyright (C) 2015 The Android Open Source Project
|
||||||
* Copyright (C) 2024 The LineageOS Project
|
* Copyright (C) 2024-2025 The LineageOS Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -628,12 +628,13 @@ public class PhoneUtils {
|
|||||||
if (mccmnc == null || mccmnc.length != 2) {
|
if (mccmnc == null || mccmnc.length != 2) {
|
||||||
return "000000";
|
return "000000";
|
||||||
}
|
}
|
||||||
return String.format("%03d%03d", mccmnc[0], mccmnc[1]);
|
return String.format(Locale.getDefault(), "%03d%03d", mccmnc[0], mccmnc[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String canonicalizeMccMnc(final String mcc, final String mnc) {
|
public static String canonicalizeMccMnc(final String mcc, final String mnc) {
|
||||||
try {
|
try {
|
||||||
return String.format("%03d%03d", Integer.parseInt(mcc), Integer.parseInt(mnc));
|
return String.format(Locale.getDefault(), "%03d%03d", Integer.parseInt(mcc),
|
||||||
|
Integer.parseInt(mnc));
|
||||||
} catch (final NumberFormatException e) {
|
} catch (final NumberFormatException e) {
|
||||||
// Return invalid as is
|
// Return invalid as is
|
||||||
LogUtil.w(TAG, "canonicalizeMccMnc: invalid mccmnc:" + mcc + " ," + mnc);
|
LogUtil.w(TAG, "canonicalizeMccMnc: invalid mccmnc:" + mcc + " ," + mnc);
|
||||||
|
|||||||
Reference in New Issue
Block a user