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

Commit 788332dd authored by Kiran Ramachandra's avatar Kiran Ramachandra
Browse files

Added telemtery express counter to track explicit uri grants

The counter monitors cases where the activity starter is explicitly set the uri grant. This statistic will reveal potential app compatibility problems that may arise once the explicit grant is removed.

Bug: 239417868
Bug: 295238578
Test: manual + pre-submit
Flag: EXEMPT bugfix

Change-Id: I99a2b0aff6bb2376bacd6072816824cc44aa0625
parent 11721d01
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())