Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9aa9766b authored by Sravan Kumar V's avatar Sravan Kumar V Committed by Steve Kondik
Browse files

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
parent 58cf885d
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -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()
@@ -386,4 +386,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();
            }
        }
    }
}