Skip to content

Commit fe464a7

Browse files
dujin.chamarcone
authored andcommitted
[Prime K] Fix gabage character issue
Korean characters show up as gabage characters in Music player. Reason : MTP service does not set the locale for the MediaScanner Solution : Set locale when MtpDatabase creates MediaScanner. Bug ID : 5567433 Signed-off-by: dujin.cha <dujin.cha@samsung.com> Change-Id: I4bfe5f603c113170d45bd57a8709c21c665e260b
1 parent e36657e commit fe464a7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

media/java/android/mtp/MtpDatabase.java

100644100755
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
import java.io.File;
4040
import java.util.HashMap;
41+
import java.util.Locale;
4142

4243
/**
4344
* {@hide}
@@ -120,6 +121,20 @@ public MtpDatabase(Context context, String volumeName, String storagePath) {
120121
mMediaStoragePath = storagePath;
121122
mObjectsUri = Files.getMtpObjectsUri(volumeName);
122123
mMediaScanner = new MediaScanner(context);
124+
125+
// Set locale to MediaScanner.
126+
Locale locale = context.getResources().getConfiguration().locale;
127+
if (locale != null) {
128+
String language = locale.getLanguage();
129+
String country = locale.getCountry();
130+
if (language != null) {
131+
if (country != null) {
132+
mMediaScanner.setLocale(language + "_" + country);
133+
} else {
134+
mMediaScanner.setLocale(language);
135+
}
136+
}
137+
}
123138
initDeviceProperties(context);
124139
}
125140

0 commit comments

Comments
 (0)