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

Commit 6e690501 authored by Yuting Fang's avatar Yuting Fang Committed by Android (Google) Code Review
Browse files

Merge "Force the device Id associated with...

Merge "Force the device Id associated with AttributionSource.myAttributionSource() to be the default device Id" into main
parents 0e6c6cd2 111afd05
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.os.UserHandle;
import android.permission.PermissionManager;
import android.permission.flags.Flags;
import android.util.ArraySet;
import android.util.Log;

import com.android.internal.annotations.Immutable;

@@ -90,6 +91,7 @@ import java.util.Set;
 */
@Immutable
public final class AttributionSource implements Parcelable {
    private static final String TAG = "AttributionSource";
    private static final String DESCRIPTOR = "android.content.AttributionSource";

    private static final Binder sDefaultToken = new Binder(DESCRIPTOR);
@@ -273,6 +275,13 @@ public final class AttributionSource implements Parcelable {

        final AttributionSource globalSource = ActivityThread.currentAttributionSource();
        if (globalSource != null) {
            if (Flags.enforceDefaultDeviceIdInMyAttributionSource()
                    && globalSource.getDeviceId() != Context.DEVICE_ID_DEFAULT) {
                Log.w(TAG,
                        "Avoid using myAttributionSource() to fetch an attributionSource with a "
                                + "non-default device Id");
                return globalSource.withDeviceId(Context.DEVICE_ID_DEFAULT);
            }
            return globalSource;
        }

+7 −0
Original line number Diff line number Diff line
@@ -507,3 +507,10 @@ flag {
    description: "Use IoThread handler for AppOpsService background/IO work."
    bug: "394380603"
}

flag {
    name: "enforce_default_device_id_in_my_attribution_source"
    namespace: "permissions"
    description: "Force AttributionSource.myAttributionSource() to return a default device id"
    bug: "343121936"
}