diff options
author | Sravan Kumar V <sravankumar@codeaurora.org> | 2015-10-15 20:11:58 +0530 |
---|---|---|
committer | Michael Bestas <mikeioannina@gmail.com> | 2016-12-30 06:21:50 +0200 |
commit | 089c94ac2f0350e1813283fd9e23bdc74456da09 (patch) | |
tree | a4ccec72d2bd2908489828155a5e5a66fb7d1c6e | |
parent | 2c8d1f01f6c4e61b95d9f92d34991b437f4e9920 (diff) | |
download | android_packages_apps_Bluetooth-089c94ac2f0350e1813283fd9e23bdc74456da09.tar.gz android_packages_apps_Bluetooth-089c94ac2f0350e1813283fd9e23bdc74456da09.tar.bz2 android_packages_apps_Bluetooth-089c94ac2f0350e1813283fd9e23bdc74456da09.zip |
Bluetooth: Create Custom Intent to avoid Force close.
Use Case:
1. Select a music file with Japanese charecters
2. Push to DUT.
3. Open received OPP file from inbound list.
Failure:
"Unfortunately, Bluetooth share has stopped" error comes.
Root Cause:
Android added "println_native method" to log events of interest
in native library, this method not able to manipulate when message
contains special characters.
Fix:
Add a condition in CustomIntenet.toString() to remove special characters,
if it contains and return plain string to avoid force close.
Change-Id: If1d66b635a8a237e16b0ee684266f2913ec422c9
-rw-r--r-- | src/com/android/bluetooth/opp/BluetoothOppUtility.java | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/com/android/bluetooth/opp/BluetoothOppUtility.java b/src/com/android/bluetooth/opp/BluetoothOppUtility.java index 99777a5ae..c386349b9 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppUtility.java +++ b/src/com/android/bluetooth/opp/BluetoothOppUtility.java @@ -215,7 +215,7 @@ public class BluetoothOppUtility { } if (isRecognizedFileType(context, path, mimetype)) { - Intent activityIntent = new Intent(Intent.ACTION_VIEW); + CustomIntent activityIntent = new CustomIntent(Intent.ACTION_VIEW); activityIntent.setDataAndTypeAndNormalize(path, mimetype); List<ResolveInfo> resInfoList = context.getPackageManager() @@ -389,4 +389,24 @@ public class BluetoothOppUtility { } } } + + // Custom class to remove special characters from Intent.toString() + static class CustomIntent extends Intent { + + public CustomIntent(String actionView) { + super(actionView); + } + + @Override + public String toString() { + if (V) Log.v(TAG, " Intent Info :" + super.toString()); + if(super.toString().length() != super.toString().getBytes().length) { + if (V) Log.v(TAG, "Removed special characters from path"); + // Replace all special characters while returning string. + return super.toString().replaceAll("[^\\x00-\\x7F]", ""); + } else { + return super.toString(); + } + } + } } |