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

Commit ae80b541 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge changes from topic "mar22z"

* changes:
  Point people towards ModernMediaScanner.
  Translate paths before leaving app sandbox.
parents 4b58630e 13d02b59
Loading
Loading
Loading
Loading
+23 −3
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.annotation.UnsupportedAppUsage;
import android.app.AppGlobals;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.ComponentInfo;
@@ -43,6 +44,7 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.IncidentManager;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.PersistableBundle;
@@ -51,6 +53,7 @@ import android.os.ResultReceiver;
import android.os.ShellCommand;
import android.os.StrictMode;
import android.os.UserHandle;
import android.os.storage.StorageManager;
import android.provider.ContactsContract.QuickContact;
import android.provider.DocumentsContract;
import android.provider.DocumentsProvider;
@@ -68,6 +71,7 @@ import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Serializable;
@@ -632,6 +636,8 @@ import java.util.Set;
 * of all possible flags.
 */
public class Intent implements Parcelable, Cloneable {
    private static final String TAG = "Intent";

    private static final String ATTR_ACTION = "action";
    private static final String TAG_CATEGORIES = "categories";
    private static final String ATTR_CATEGORY = "category";
@@ -9807,7 +9813,7 @@ public class Intent implements Parcelable, Cloneable {
                // may fail.  We really should handle this (i.e., the Bundle
                // impl shouldn't be on top of a plain map), but for now just
                // ignore it and keep the original contents. :(
                Log.w("Intent", "Failure filling in extras", e);
                Log.w(TAG, "Failure filling in extras", e);
            }
        }
        if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
@@ -10523,7 +10529,7 @@ public class Intent implements Parcelable, Cloneable {
            } else if (ATTR_FLAGS.equals(attrName)) {
                intent.setFlags(Integer.parseInt(attrValue, 16));
            } else {
                Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
                Log.e(TAG, "restoreFromXml: unknown attribute=" + attrName);
            }
        }

@@ -10539,7 +10545,7 @@ public class Intent implements Parcelable, Cloneable {
                        intent.addCategory(in.getAttributeValue(attrNdx));
                    }
                } else {
                    Log.w("Intent", "restoreFromXml: unknown name=" + name);
                    Log.w(TAG, "restoreFromXml: unknown name=" + name);
                    XmlUtils.skipCurrentTag(in);
                }
            }
@@ -10653,6 +10659,20 @@ public class Intent implements Parcelable, Cloneable {
                    mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
            }
        }

        // Translate raw filesystem paths out of storage sandbox
        if (ACTION_MEDIA_SCANNER_SCAN_FILE.equals(mAction) && mData != null
                && ContentResolver.SCHEME_FILE.equals(mData.getScheme()) && leavingPackage) {
            final StorageManager sm = AppGlobals.getInitialApplication()
                    .getSystemService(StorageManager.class);
            final File before = new File(mData.getPath());
            final File after = sm.translateAppToSystem(before,
                    android.os.Process.myPid(), android.os.Process.myUid());
            if (!Objects.equals(before, after)) {
                Log.v(TAG, "Translated " + before + " to " + after);
                mData = Uri.fromFile(after);
            }
        }
    }

    /**
+7 −0
Original line number Diff line number Diff line
@@ -116,7 +116,14 @@ import java.util.concurrent.atomic.AtomicBoolean;
 * The MediaScanner class is not thread-safe, so it should only be used in a single threaded manner.
 *
 * {@hide}
 *
 * @deprecated this media scanner has served faithfully for many years, but it's
 *             become tedious to test and maintain, mainly due to the way it
 *             weaves obscurely between managed and native code. It's been
 *             replaced by {@code ModernMediaScanner} in the
 *             {@code MediaProvider} package.
 */
@Deprecated
public class MediaScanner implements AutoCloseable {
    static {
        System.loadLibrary("media_jni");