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

Commit 31fc93f7 authored by Kiran Ramachandra's avatar Kiran Ramachandra Committed by Android (Google) Code Review
Browse files

Merge "Added telemtery express counter to track explicit uri grants" into main

parents 2edf2edd 788332dd
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ import android.util.Log;
import android.util.proto.ProtoOutputStream;
import com.android.internal.util.XmlUtils;
import com.android.modules.expresslog.Counter;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -12805,6 +12806,8 @@ public class Intent implements Parcelable, Cloneable {
                            new ClipData.Item(text, htmlText, null, stream));
                    setClipData(clipData);
                    if (stream != null) {
                        logCounterIfFlagsMissing(FLAG_GRANT_READ_URI_PERMISSION,
                                "intents.value_explicit_uri_grant_for_send_action");
                        addFlags(FLAG_GRANT_READ_URI_PERMISSION);
                    }
                    return true;
@@ -12846,6 +12849,8 @@ public class Intent implements Parcelable, Cloneable {
                    setClipData(clipData);
                    if (streams != null) {
                        logCounterIfFlagsMissing(FLAG_GRANT_READ_URI_PERMISSION,
                                "intents.value_explicit_uri_grant_for_send_multiple_action");
                        addFlags(FLAG_GRANT_READ_URI_PERMISSION);
                    }
                    return true;
@@ -12865,6 +12870,10 @@ public class Intent implements Parcelable, Cloneable {
                putExtra(MediaStore.EXTRA_OUTPUT, output);
                setClipData(ClipData.newRawUri("", output));
                logCounterIfFlagsMissing(
                        FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_READ_URI_PERMISSION,
                        "intents.value_explicit_uri_grant_for_image_capture_action");
                addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
                return true;
            }
@@ -12873,6 +12882,12 @@ public class Intent implements Parcelable, Cloneable {
        return false;
    }
    private void logCounterIfFlagsMissing(int requiredFlags, String metricId) {
        if ((getFlags() & requiredFlags) != requiredFlags) {
            Counter.logIncrement(metricId);
        }
    }
    @android.ravenwood.annotation.RavenwoodThrow
    private Uri maybeConvertFileToContentUri(Context context, Uri uri) {
        if (ContentResolver.SCHEME_FILE.equals(uri.getScheme())