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

Commit 498e4b28 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Bluetooth: Create Custom Intent to avoid Force close."

parents 6a1f991c 4a138fdd
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -209,7 +209,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);

            activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -365,4 +365,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();
            }
        }
    }
}