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

Commit 14003828 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Wire up getStorageVolume() for synthetic paths.

When a getStorageVolume(File) call is for a synthetic path backed
by a content:// Uri, translate it and call getStorageVolume(Uri).

Bug: 124700423
Test: manual
Change-Id: I0f0dc4d5c2205e9d602e4ec2b036fb7822ba1e33
parent b3e90090
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.os.storage;

import static android.content.ContentResolver.DEPRECATE_DATA_PREFIX;

import android.annotation.BytesLong;
import android.annotation.IntDef;
import android.annotation.NonNull;
@@ -30,6 +32,7 @@ import android.annotation.UnsupportedAppUsage;
import android.annotation.WorkerThread;
import android.app.Activity;
import android.app.ActivityThread;
import android.app.AppGlobals;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
@@ -1139,6 +1142,12 @@ public class StorageManager {
        if (file == null) {
            return null;
        }
        final String path = file.getAbsolutePath();
        if (path.startsWith(DEPRECATE_DATA_PREFIX)) {
            final Uri uri = ContentResolver.translateDeprecatedDataPath(path);
            return AppGlobals.getInitialApplication().getSystemService(StorageManager.class)
                    .getStorageVolume(uri);
        }
        try {
            file = file.getCanonicalFile();
        } catch (IOException ignored) {