Loading core/api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -10560,6 +10560,7 @@ package android.content { public final class ContextParams { method @Nullable public String getAttributionTag(); method @Nullable public android.content.AttributionSource getNextAttributionSource(); method @NonNull public boolean shouldRegisterAttributionSource(); } public static final class ContextParams.Builder { Loading @@ -10568,6 +10569,7 @@ package android.content { method @NonNull public android.content.ContextParams build(); method @NonNull public android.content.ContextParams.Builder setAttributionTag(@Nullable String); method @NonNull public android.content.ContextParams.Builder setNextAttributionSource(@Nullable android.content.AttributionSource); method @NonNull public android.content.ContextParams.Builder setShouldRegisterAttributionSource(boolean); } public class ContextWrapper extends android.content.Context { core/java/android/app/ContextImpl.java +3 −3 Original line number Diff line number Diff line Loading @@ -3455,20 +3455,20 @@ class ContextImpl extends Context { mOpPackageName = overrideOpPackageName != null ? overrideOpPackageName : opPackageName; mParams = Objects.requireNonNull(params); mAttributionSource = createAttributionSource(attributionTag, nextAttributionSource, params.getRenouncedPermissions()); params.getRenouncedPermissions(), params.shouldRegisterAttributionSource()); mContentResolver = new ApplicationContentResolver(this, mainThread); } private @NonNull AttributionSource createAttributionSource(@Nullable String attributionTag, @Nullable AttributionSource nextAttributionSource, @Nullable Set<String> renouncedPermissions) { @Nullable Set<String> renouncedPermissions, boolean shouldRegister) { AttributionSource attributionSource = new AttributionSource(Process.myUid(), Process.myPid(), mOpPackageName, attributionTag, (renouncedPermissions != null) ? renouncedPermissions.toArray(new String[0]) : null, getDeviceId(), nextAttributionSource); // If we want to access protected data on behalf of another app we need to // tell the OS that we opt in to participate in the attribution chain. if (nextAttributionSource != null) { if (nextAttributionSource != null || shouldRegister) { attributionSource = getSystemService(PermissionManager.class) .registerAttributionSource(attributionSource); } Loading core/java/android/content/ContextParams.java +28 −2 Original line number Diff line number Diff line Loading @@ -50,17 +50,20 @@ public final class ContextParams { private final @Nullable String mAttributionTag; private final @Nullable AttributionSource mNext; private final @NonNull Set<String> mRenouncedPermissions; private final boolean mShouldRegisterAttributionSource; /** {@hide} */ public static final ContextParams EMPTY = new ContextParams.Builder().build(); private ContextParams(@Nullable String attributionTag, @Nullable AttributionSource next, @Nullable Set<String> renouncedPermissions) { @Nullable Set<String> renouncedPermissions, boolean shouldRegister) { mAttributionTag = attributionTag; mNext = next; mRenouncedPermissions = (renouncedPermissions != null) ? renouncedPermissions : Collections.emptySet(); mShouldRegisterAttributionSource = shouldRegister; } /** Loading Loading @@ -94,6 +97,15 @@ public final class ContextParams { return mNext; } /** * @return Whether the attribution source associated with the Context being created should be * registered. */ @NonNull public boolean shouldRegisterAttributionSource() { return mShouldRegisterAttributionSource; } /** * Builder for creating a {@link ContextParams}. */ Loading @@ -101,6 +113,7 @@ public final class ContextParams { private @Nullable String mAttributionTag; private @NonNull Set<String> mRenouncedPermissions = Collections.emptySet(); private @Nullable AttributionSource mNext; private boolean mShouldRegisterAttributionSource; /** * Create a new builder. Loading Loading @@ -158,6 +171,19 @@ public final class ContextParams { return this; } /** * Sets whether the attribution source associated with the context created from these params * should be registered. * * @param shouldRegister Whether the attribution source associated with the Context being * created should be registered. */ @NonNull public Builder setShouldRegisterAttributionSource(boolean shouldRegister) { mShouldRegisterAttributionSource = shouldRegister; return this; } /** * Sets permissions which have been voluntarily "renounced" by the * calling app. Loading Loading @@ -205,7 +231,7 @@ public final class ContextParams { @NonNull public ContextParams build() { return new ContextParams(mAttributionTag, mNext, mRenouncedPermissions); mRenouncedPermissions, mShouldRegisterAttributionSource); } } } Loading
core/api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -10560,6 +10560,7 @@ package android.content { public final class ContextParams { method @Nullable public String getAttributionTag(); method @Nullable public android.content.AttributionSource getNextAttributionSource(); method @NonNull public boolean shouldRegisterAttributionSource(); } public static final class ContextParams.Builder { Loading @@ -10568,6 +10569,7 @@ package android.content { method @NonNull public android.content.ContextParams build(); method @NonNull public android.content.ContextParams.Builder setAttributionTag(@Nullable String); method @NonNull public android.content.ContextParams.Builder setNextAttributionSource(@Nullable android.content.AttributionSource); method @NonNull public android.content.ContextParams.Builder setShouldRegisterAttributionSource(boolean); } public class ContextWrapper extends android.content.Context {
core/java/android/app/ContextImpl.java +3 −3 Original line number Diff line number Diff line Loading @@ -3455,20 +3455,20 @@ class ContextImpl extends Context { mOpPackageName = overrideOpPackageName != null ? overrideOpPackageName : opPackageName; mParams = Objects.requireNonNull(params); mAttributionSource = createAttributionSource(attributionTag, nextAttributionSource, params.getRenouncedPermissions()); params.getRenouncedPermissions(), params.shouldRegisterAttributionSource()); mContentResolver = new ApplicationContentResolver(this, mainThread); } private @NonNull AttributionSource createAttributionSource(@Nullable String attributionTag, @Nullable AttributionSource nextAttributionSource, @Nullable Set<String> renouncedPermissions) { @Nullable Set<String> renouncedPermissions, boolean shouldRegister) { AttributionSource attributionSource = new AttributionSource(Process.myUid(), Process.myPid(), mOpPackageName, attributionTag, (renouncedPermissions != null) ? renouncedPermissions.toArray(new String[0]) : null, getDeviceId(), nextAttributionSource); // If we want to access protected data on behalf of another app we need to // tell the OS that we opt in to participate in the attribution chain. if (nextAttributionSource != null) { if (nextAttributionSource != null || shouldRegister) { attributionSource = getSystemService(PermissionManager.class) .registerAttributionSource(attributionSource); } Loading
core/java/android/content/ContextParams.java +28 −2 Original line number Diff line number Diff line Loading @@ -50,17 +50,20 @@ public final class ContextParams { private final @Nullable String mAttributionTag; private final @Nullable AttributionSource mNext; private final @NonNull Set<String> mRenouncedPermissions; private final boolean mShouldRegisterAttributionSource; /** {@hide} */ public static final ContextParams EMPTY = new ContextParams.Builder().build(); private ContextParams(@Nullable String attributionTag, @Nullable AttributionSource next, @Nullable Set<String> renouncedPermissions) { @Nullable Set<String> renouncedPermissions, boolean shouldRegister) { mAttributionTag = attributionTag; mNext = next; mRenouncedPermissions = (renouncedPermissions != null) ? renouncedPermissions : Collections.emptySet(); mShouldRegisterAttributionSource = shouldRegister; } /** Loading Loading @@ -94,6 +97,15 @@ public final class ContextParams { return mNext; } /** * @return Whether the attribution source associated with the Context being created should be * registered. */ @NonNull public boolean shouldRegisterAttributionSource() { return mShouldRegisterAttributionSource; } /** * Builder for creating a {@link ContextParams}. */ Loading @@ -101,6 +113,7 @@ public final class ContextParams { private @Nullable String mAttributionTag; private @NonNull Set<String> mRenouncedPermissions = Collections.emptySet(); private @Nullable AttributionSource mNext; private boolean mShouldRegisterAttributionSource; /** * Create a new builder. Loading Loading @@ -158,6 +171,19 @@ public final class ContextParams { return this; } /** * Sets whether the attribution source associated with the context created from these params * should be registered. * * @param shouldRegister Whether the attribution source associated with the Context being * created should be registered. */ @NonNull public Builder setShouldRegisterAttributionSource(boolean shouldRegister) { mShouldRegisterAttributionSource = shouldRegister; return this; } /** * Sets permissions which have been voluntarily "renounced" by the * calling app. Loading Loading @@ -205,7 +231,7 @@ public final class ContextParams { @NonNull public ContextParams build() { return new ContextParams(mAttributionTag, mNext, mRenouncedPermissions); mRenouncedPermissions, mShouldRegisterAttributionSource); } } }