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

Commit c584b19a authored by Etienne Ruffieux's avatar Etienne Ruffieux
Browse files

Removed hidden API call to getCanonicalUri

Replaced call to getCanonicalUri by keeping the same logic
but with non-hidden methods calls instead. Also checks for
legacy external storage.

Tag: #feature
Bug: 190438212
Test: make and manual tests
Change-Id: I66f73908c15a691c2959935678231a37a9286f2f
parent 87568f57
Loading
Loading
Loading
Loading
+25 −2
Original line number Original line Diff line number Diff line
@@ -444,9 +444,32 @@ public class BluetoothOppUtility {
            Log.e(TAG, "Not a file URI: " + uri);
            Log.e(TAG, "Not a file URI: " + uri);
            return false;
            return false;
        }
        }
        final File file = new File(uri.getCanonicalUri().getPath());

        if ("file".equals(uri.getScheme())) {
            String canonicalPath;
            try {
                canonicalPath = new File(uri.getPath()).getCanonicalPath();
            } catch (IOException e) {
                canonicalPath = uri.getPath();
            }
            File file = new File(canonicalPath);
            //if emulated
            if (Environment.isExternalStorageEmulated()) {
                //Gets legacy external storage path
                final String legacyPath = new File(
                        System.getenv("EXTERNAL_STORAGE")).toString();
                // Splice in user-specific path when legacy path is found
                if (canonicalPath.startsWith(legacyPath)) {
                    file = new File(
                            Environment.getExternalStorageDirectory().toString(),
                            canonicalPath.substring(legacyPath.length() + 1));
                }
            }
            return isSameOrSubDirectory(Environment.getExternalStorageDirectory(), file);
            return isSameOrSubDirectory(Environment.getExternalStorageDirectory(), file);
        }
        }
        return isSameOrSubDirectory(Environment.getExternalStorageDirectory(),
                new File(uri.getPath()));
    }


    static boolean isForbiddenContent(Uri uri) {
    static boolean isForbiddenContent(Uri uri) {
        if ("com.android.bluetooth.map.MmsFileProvider".equals(uri.getHost())) {
        if ("com.android.bluetooth.map.MmsFileProvider".equals(uri.getHost())) {