Add application-level 'attributionsAreUserVisible' attribute
Bug: 176902658 Test: Manual Change-Id: I56dc9caa6d98b75bc6732bbca0e5adc67bb745e5
This commit is contained in:
@@ -340,6 +340,7 @@ package android {
|
||||
field public static final int appCategory = 16844101; // 0x1010545
|
||||
field public static final int appComponentFactory = 16844154; // 0x101057a
|
||||
field public static final int attributionTags;
|
||||
field public static final int attributionsAreUserVisible;
|
||||
field public static final int author = 16843444; // 0x10102b4
|
||||
field public static final int authorities = 16842776; // 0x1010018
|
||||
field public static final int autoAdvanceViewId = 16843535; // 0x101030f
|
||||
@@ -11933,6 +11934,7 @@ package android.content.pm {
|
||||
public class ApplicationInfo extends android.content.pm.PackageItemInfo implements android.os.Parcelable {
|
||||
ctor public ApplicationInfo();
|
||||
ctor public ApplicationInfo(android.content.pm.ApplicationInfo);
|
||||
method public boolean areAttributionsUserVisible();
|
||||
method public int describeContents();
|
||||
method public void dump(android.util.Printer, String);
|
||||
method public static CharSequence getCategoryTitle(android.content.Context, int);
|
||||
|
||||
@@ -786,10 +786,18 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
|
||||
*/
|
||||
public static final int PRIVATE_FLAG_EXT_REQUEST_FOREGROUND_SERVICE_EXEMPTION = 1 << 1;
|
||||
|
||||
/**
|
||||
* Value for {@link #privateFlagsExt}: whether attributions provided by the application are
|
||||
* meant to be user-visible.
|
||||
* @hide
|
||||
*/
|
||||
public static final int PRIVATE_FLAG_EXT_ATTRIBUTIONS_ARE_USER_VISIBLE = 1 << 2;
|
||||
|
||||
/** @hide */
|
||||
@IntDef(flag = true, prefix = { "PRIVATE_FLAG_EXT_" }, value = {
|
||||
PRIVATE_FLAG_EXT_PROFILEABLE,
|
||||
PRIVATE_FLAG_EXT_REQUEST_FOREGROUND_SERVICE_EXEMPTION,
|
||||
PRIVATE_FLAG_EXT_ATTRIBUTIONS_ARE_USER_VISIBLE,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface ApplicationInfoPrivateFlagsExt {}
|
||||
@@ -2436,6 +2444,15 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
|
||||
return (privateFlagsExt & PRIVATE_FLAG_EXT_PROFILEABLE) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether attributions provided by the application are meant to be user-visible.
|
||||
* Defaults to false if application info is retrieved without
|
||||
* {@link PackageManager#GET_ATTRIBUTIONS}.
|
||||
*/
|
||||
public boolean areAttributionsUserVisible() {
|
||||
return (privateFlagsExt & PRIVATE_FLAG_EXT_ATTRIBUTIONS_ARE_USER_VISIBLE) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the app has declared in its manifest that it wants its split APKs to be
|
||||
* loaded into isolated Contexts, with their own ClassLoaders and Resources objects.
|
||||
|
||||
@@ -298,6 +298,16 @@ public class PackageInfoWithoutStateUtils {
|
||||
pi.attributions[i] = generateAttribution(pkg.getAttributions().get(i));
|
||||
}
|
||||
}
|
||||
if (pkg.areAttributionsUserVisible()) {
|
||||
pi.applicationInfo.privateFlagsExt
|
||||
|= ApplicationInfo.PRIVATE_FLAG_EXT_ATTRIBUTIONS_ARE_USER_VISIBLE;
|
||||
} else {
|
||||
pi.applicationInfo.privateFlagsExt
|
||||
&= ~ApplicationInfo.PRIVATE_FLAG_EXT_ATTRIBUTIONS_ARE_USER_VISIBLE;
|
||||
}
|
||||
} else {
|
||||
pi.applicationInfo.privateFlagsExt
|
||||
&= ~ApplicationInfo.PRIVATE_FLAG_EXT_ATTRIBUTIONS_ARE_USER_VISIBLE;
|
||||
}
|
||||
|
||||
if (apexInfo != null) {
|
||||
@@ -809,7 +819,9 @@ public class PackageInfoWithoutStateUtils {
|
||||
int privateFlagsExt =
|
||||
flag(pkg.isProfileable(), ApplicationInfo.PRIVATE_FLAG_EXT_PROFILEABLE)
|
||||
| flag(pkg.hasRequestForegroundServiceExemption(),
|
||||
ApplicationInfo.PRIVATE_FLAG_EXT_REQUEST_FOREGROUND_SERVICE_EXEMPTION);
|
||||
ApplicationInfo.PRIVATE_FLAG_EXT_REQUEST_FOREGROUND_SERVICE_EXEMPTION)
|
||||
| flag(pkg.areAttributionsUserVisible(),
|
||||
ApplicationInfo.PRIVATE_FLAG_EXT_ATTRIBUTIONS_ARE_USER_VISIBLE);
|
||||
// @formatter:on
|
||||
return privateFlagsExt;
|
||||
}
|
||||
|
||||
@@ -362,6 +362,8 @@ public interface ParsingPackage extends ParsingPackageRead {
|
||||
|
||||
ParsingPackage setCompileSdkVersionCodename(String compileSdkVersionCodename);
|
||||
|
||||
ParsingPackage setAttributionsAreUserVisible(boolean attributionsAreUserVisible);
|
||||
|
||||
// TODO(b/135203078): This class no longer has access to ParsedPackage, find a replacement
|
||||
// for moving to the next step
|
||||
@CallSuper
|
||||
|
||||
@@ -514,6 +514,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
|
||||
private static final long ENABLED = 1L << 44;
|
||||
private static final long DISALLOW_PROFILING = 1L << 45;
|
||||
private static final long REQUEST_FOREGROUND_SERVICE_EXEMPTION = 1L << 46;
|
||||
private static final long ATTRIBUTIONS_ARE_USER_VISIBLE = 1L << 47;
|
||||
}
|
||||
|
||||
private ParsingPackageImpl setBoolean(@Booleans.Values long flag, boolean value) {
|
||||
@@ -2205,6 +2206,11 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
|
||||
return getBoolean(Booleans.REQUEST_FOREGROUND_SERVICE_EXEMPTION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areAttributionsUserVisible() {
|
||||
return getBoolean(Booleans.ATTRIBUTIONS_ARE_USER_VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParsingPackageImpl setBaseRevisionCode(int value) {
|
||||
baseRevisionCode = value;
|
||||
@@ -2760,4 +2766,10 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
|
||||
this.zygotePreloadName = zygotePreloadName;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParsingPackage setAttributionsAreUserVisible(boolean attributionsAreUserVisible) {
|
||||
setBoolean(Booleans.ATTRIBUTIONS_ARE_USER_VISIBLE, attributionsAreUserVisible);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ import android.util.SparseArray;
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
import java.security.PublicKey;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -922,4 +921,10 @@ public interface ParsingPackageRead extends Parcelable {
|
||||
* same as toAppInfoWithoutState except without flag computation.
|
||||
*/
|
||||
ApplicationInfo toAppInfoWithoutStateWithoutFlags();
|
||||
|
||||
/**
|
||||
* Whether or not the app has said its attribution tags can be made user-visible.
|
||||
* @see ApplicationInfo#areAttributionsUserVisible()
|
||||
*/
|
||||
boolean areAttributionsUserVisible();
|
||||
}
|
||||
|
||||
@@ -2198,6 +2198,7 @@ public class ParsingPackageUtils {
|
||||
.setUsesNonSdkApi(bool(false, R.styleable.AndroidManifestApplication_usesNonSdkApi, sa))
|
||||
.setVmSafeMode(bool(false, R.styleable.AndroidManifestApplication_vmSafeMode, sa))
|
||||
.setAutoRevokePermissions(anInt(R.styleable.AndroidManifestApplication_autoRevokePermissions, sa))
|
||||
.setAttributionsAreUserVisible(bool(false, R.styleable.AndroidManifestApplication_attributionsAreUserVisible, sa))
|
||||
// targetSdkVersion gated
|
||||
.setAllowAudioPlaybackCapture(bool(targetSdk >= Build.VERSION_CODES.Q, R.styleable.AndroidManifestApplication_allowAudioPlaybackCapture, sa))
|
||||
.setBaseHardwareAccelerated(bool(targetSdk >= Build.VERSION_CODES.ICE_CREAM_SANDWICH, R.styleable.AndroidManifestApplication_hardwareAccelerated, sa))
|
||||
|
||||
@@ -1538,6 +1538,9 @@
|
||||
|
||||
<attr name="usesNonSdkApi" format="boolean" />
|
||||
|
||||
<!-- Whether attributions provided are meant to be user-visible. -->
|
||||
<attr name="attributionsAreUserVisible" format="boolean" />
|
||||
|
||||
<!-- Specify the type of foreground service. Multiple types can be specified by ORing the flags
|
||||
together. -->
|
||||
<attr name="foregroundServiceType">
|
||||
@@ -1961,6 +1964,9 @@
|
||||
there's no way to be exempted (without using a privileged permission).
|
||||
-->
|
||||
<attr name="requestForegroundServiceExemption" format="boolean" />
|
||||
|
||||
<!-- Whether attributions provided are meant to be user-visible. -->
|
||||
<attr name="attributionsAreUserVisible" format="boolean" />
|
||||
</declare-styleable>
|
||||
|
||||
<!-- An attribution is a logical part of an app and is identified by a tag.
|
||||
|
||||
@@ -3100,6 +3100,7 @@
|
||||
<public name="effectColor" />
|
||||
<!-- @hide @TestApi -->
|
||||
<public name="requestForegroundServiceExemption" />
|
||||
<public name="attributionsAreUserVisible" />
|
||||
</staging-public-group>
|
||||
|
||||
<staging-public-group type="drawable" first-id="0x010800b5">
|
||||
|
||||
@@ -212,6 +212,12 @@ interface PkgAppInfo {
|
||||
*/
|
||||
int getRoundIconRes();
|
||||
|
||||
/**
|
||||
* @see ApplicationInfo#areAttributionsUserVisible()
|
||||
* @see R.styleable#AndroidManifestApplication_attributionsAreUserVisible
|
||||
*/
|
||||
boolean areAttributionsUserVisible();
|
||||
|
||||
/** @see ApplicationInfo#seInfo */
|
||||
@Nullable
|
||||
String getSeInfo();
|
||||
|
||||
Reference in New Issue
Block a user