Merge "Add getEmergencyAssistancePackageName API to TelephonyManager." into main
diff --git a/core/api/current.txt b/core/api/current.txt
index 47685a5..1046789 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -144,10 +144,12 @@
field public static final String MANAGE_DEVICE_POLICY_AUDIO_OUTPUT = "android.permission.MANAGE_DEVICE_POLICY_AUDIO_OUTPUT";
field public static final String MANAGE_DEVICE_POLICY_AUTOFILL = "android.permission.MANAGE_DEVICE_POLICY_AUTOFILL";
field public static final String MANAGE_DEVICE_POLICY_BACKUP_SERVICE = "android.permission.MANAGE_DEVICE_POLICY_BACKUP_SERVICE";
+ field @FlaggedApi("android.app.admin.flags.dedicated_device_control_api_enabled") public static final String MANAGE_DEVICE_POLICY_BLOCK_UNINSTALL = "android.permission.MANAGE_DEVICE_POLICY_BLOCK_UNINSTALL";
field public static final String MANAGE_DEVICE_POLICY_BLUETOOTH = "android.permission.MANAGE_DEVICE_POLICY_BLUETOOTH";
field public static final String MANAGE_DEVICE_POLICY_BUGREPORT = "android.permission.MANAGE_DEVICE_POLICY_BUGREPORT";
field public static final String MANAGE_DEVICE_POLICY_CALLS = "android.permission.MANAGE_DEVICE_POLICY_CALLS";
field public static final String MANAGE_DEVICE_POLICY_CAMERA = "android.permission.MANAGE_DEVICE_POLICY_CAMERA";
+ field @FlaggedApi("android.app.admin.flags.dedicated_device_control_api_enabled") public static final String MANAGE_DEVICE_POLICY_CAMERA_TOGGLE = "android.permission.MANAGE_DEVICE_POLICY_CAMERA_TOGGLE";
field public static final String MANAGE_DEVICE_POLICY_CERTIFICATES = "android.permission.MANAGE_DEVICE_POLICY_CERTIFICATES";
field public static final String MANAGE_DEVICE_POLICY_COMMON_CRITERIA_MODE = "android.permission.MANAGE_DEVICE_POLICY_COMMON_CRITERIA_MODE";
field @FlaggedApi("android.view.contentprotection.flags.manage_device_policy_enabled") public static final String MANAGE_DEVICE_POLICY_CONTENT_PROTECTION = "android.permission.MANAGE_DEVICE_POLICY_CONTENT_PROTECTION";
@@ -169,6 +171,7 @@
field @FlaggedApi("android.app.admin.flags.esim_management_enabled") public static final String MANAGE_DEVICE_POLICY_MANAGED_SUBSCRIPTIONS = "android.permission.MANAGE_DEVICE_POLICY_MANAGED_SUBSCRIPTIONS";
field public static final String MANAGE_DEVICE_POLICY_METERED_DATA = "android.permission.MANAGE_DEVICE_POLICY_METERED_DATA";
field public static final String MANAGE_DEVICE_POLICY_MICROPHONE = "android.permission.MANAGE_DEVICE_POLICY_MICROPHONE";
+ field @FlaggedApi("android.app.admin.flags.dedicated_device_control_api_enabled") public static final String MANAGE_DEVICE_POLICY_MICROPHONE_TOGGLE = "android.permission.MANAGE_DEVICE_POLICY_MICROPHONE_TOGGLE";
field public static final String MANAGE_DEVICE_POLICY_MOBILE_NETWORK = "android.permission.MANAGE_DEVICE_POLICY_MOBILE_NETWORK";
field public static final String MANAGE_DEVICE_POLICY_MODIFY_USERS = "android.permission.MANAGE_DEVICE_POLICY_MODIFY_USERS";
field public static final String MANAGE_DEVICE_POLICY_MTE = "android.permission.MANAGE_DEVICE_POLICY_MTE";
@@ -454,6 +457,7 @@
field public static final int allowBackup = 16843392; // 0x1010280
field public static final int allowClearUserData = 16842757; // 0x1010005
field public static final int allowClickWhenDisabled = 16844312; // 0x1010618
+ field @FlaggedApi("android.security.asm_restrictions_enabled") public static final int allowCrossUidActivitySwitchFromBelow;
field public static final int allowEmbedded = 16843765; // 0x10103f5
field public static final int allowGameAngleDriver = 16844376; // 0x1010658
field public static final int allowGameDownscaling = 16844377; // 0x1010659
@@ -8114,6 +8118,7 @@
method public boolean isLogoutEnabled();
method public boolean isManagedProfile(@NonNull android.content.ComponentName);
method public boolean isMasterVolumeMuted(@NonNull android.content.ComponentName);
+ method @FlaggedApi("android.app.admin.flags.is_mte_policy_enforced") public static boolean isMtePolicyEnforced();
method public boolean isNetworkLoggingEnabled(@Nullable android.content.ComponentName);
method public boolean isOrganizationOwnedDeviceWithManagedProfile();
method public boolean isOverrideApnEnabled(@NonNull android.content.ComponentName);
@@ -22750,12 +22755,16 @@
method @NonNull public String getCanonicalName();
method public android.media.MediaCodecInfo.CodecCapabilities getCapabilitiesForType(String);
method @NonNull public String getName();
+ method @FlaggedApi("android.media.codec.in_process_sw_audio_codec") public int getSecurityModel();
method public String[] getSupportedTypes();
method public boolean isAlias();
method public boolean isEncoder();
method public boolean isHardwareAccelerated();
method public boolean isSoftwareOnly();
method public boolean isVendor();
+ field @FlaggedApi("android.media.codec.in_process_sw_audio_codec") public static final int SECURITY_MODEL_MEMORY_SAFE = 1; // 0x1
+ field @FlaggedApi("android.media.codec.in_process_sw_audio_codec") public static final int SECURITY_MODEL_SANDBOXED = 0; // 0x0
+ field @FlaggedApi("android.media.codec.in_process_sw_audio_codec") public static final int SECURITY_MODEL_TRUSTED_CONTENT_ONLY = 2; // 0x2
}
public static final class MediaCodecInfo.AudioCapabilities {
@@ -23584,6 +23593,9 @@
field public static final int COLOR_TRANSFER_LINEAR = 1; // 0x1
field public static final int COLOR_TRANSFER_SDR_VIDEO = 3; // 0x3
field public static final int COLOR_TRANSFER_ST2084 = 6; // 0x6
+ field @FlaggedApi("android.media.codec.in_process_sw_audio_codec") public static final int FLAG_SECURITY_MODEL_MEMORY_SAFE = 2; // 0x2
+ field @FlaggedApi("android.media.codec.in_process_sw_audio_codec") public static final int FLAG_SECURITY_MODEL_SANDBOXED = 1; // 0x1
+ field @FlaggedApi("android.media.codec.in_process_sw_audio_codec") public static final int FLAG_SECURITY_MODEL_TRUSTED_CONTENT_ONLY = 4; // 0x4
field public static final String KEY_AAC_DRC_ALBUM_MODE = "aac-drc-album-mode";
field public static final String KEY_AAC_DRC_ATTENUATION_FACTOR = "aac-drc-cut-level";
field public static final String KEY_AAC_DRC_BOOST_FACTOR = "aac-drc-boost-level";
@@ -23665,6 +23677,7 @@
field public static final String KEY_REPEAT_PREVIOUS_FRAME_AFTER = "repeat-previous-frame-after";
field public static final String KEY_ROTATION = "rotation-degrees";
field public static final String KEY_SAMPLE_RATE = "sample-rate";
+ field @FlaggedApi("android.media.codec.in_process_sw_audio_codec") public static final String KEY_SECURITY_MODEL = "security-model";
field public static final String KEY_SLICE_HEIGHT = "slice-height";
field public static final String KEY_SLOW_MOTION_MARKERS = "slow-motion-markers";
field public static final String KEY_STRIDE = "stride";
@@ -42391,6 +42404,7 @@
field public static final int SUPPORTS_SET_INACTIVE = 2; // 0x2
field public static final int SUPPORTS_STREAM = 4; // 0x4
field public static final int SUPPORTS_TRANSFER = 8; // 0x8
+ field @FlaggedApi("com.android.server.telecom.flags.transactional_video_state") public static final int SUPPORTS_VIDEO_CALLING = 16; // 0x10
field public static final int VIDEO_CALL = 2; // 0x2
}
@@ -42426,6 +42440,7 @@
method @NonNull public android.os.ParcelUuid getCallId();
method public void requestCallEndpointChange(@NonNull android.telecom.CallEndpoint, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.telecom.CallException>);
method @FlaggedApi("com.android.server.telecom.flags.set_mute_state") public void requestMuteState(boolean, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.telecom.CallException>);
+ method @FlaggedApi("com.android.server.telecom.flags.transactional_video_state") public void requestVideoState(int, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.telecom.CallException>);
method public void sendEvent(@NonNull String, @NonNull android.os.Bundle);
method public void setActive(@NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.telecom.CallException>);
method public void setInactive(@NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.telecom.CallException>);
@@ -42474,6 +42489,7 @@
method public void onCallStreamingFailed(int);
method public void onEvent(@NonNull String, @NonNull android.os.Bundle);
method public void onMuteStateChanged(boolean);
+ method @FlaggedApi("com.android.server.telecom.flags.transactional_video_state") public default void onVideoStateChanged(int);
}
public final class CallException extends java.lang.RuntimeException implements android.os.Parcelable {
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index d06b380..340a79d 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -195,6 +195,7 @@
field public static final String MANAGE_DEFAULT_APPLICATIONS = "android.permission.MANAGE_DEFAULT_APPLICATIONS";
field public static final String MANAGE_DEVICE_ADMINS = "android.permission.MANAGE_DEVICE_ADMINS";
field public static final String MANAGE_DEVICE_POLICY_APP_EXEMPTIONS = "android.permission.MANAGE_DEVICE_POLICY_APP_EXEMPTIONS";
+ field @FlaggedApi("android.app.admin.flags.device_theft_api_enabled") public static final String MANAGE_DEVICE_POLICY_THEFT_DETECTION = "android.permission.MANAGE_DEVICE_POLICY_THEFT_DETECTION";
field @FlaggedApi("android.permission.flags.enhanced_confirmation_mode_apis_enabled") public static final String MANAGE_ENHANCED_CONFIRMATION_STATES = "android.permission.MANAGE_ENHANCED_CONFIRMATION_STATES";
field public static final String MANAGE_ETHERNET_NETWORKS = "android.permission.MANAGE_ETHERNET_NETWORKS";
field public static final String MANAGE_FACTORY_RESET_PROTECTION = "android.permission.MANAGE_FACTORY_RESET_PROTECTION";
@@ -203,7 +204,6 @@
field public static final String MANAGE_HOTWORD_DETECTION = "android.permission.MANAGE_HOTWORD_DETECTION";
field public static final String MANAGE_IPSEC_TUNNELS = "android.permission.MANAGE_IPSEC_TUNNELS";
field public static final String MANAGE_LOW_POWER_STANDBY = "android.permission.MANAGE_LOW_POWER_STANDBY";
- field @FlaggedApi("com.android.media.flags.limit_manage_media_projection") public static final String MANAGE_MEDIA_PROJECTION = "android.permission.MANAGE_MEDIA_PROJECTION";
field public static final String MANAGE_MUSIC_RECOGNITION = "android.permission.MANAGE_MUSIC_RECOGNITION";
field public static final String MANAGE_NOTIFICATION_LISTENERS = "android.permission.MANAGE_NOTIFICATION_LISTENERS";
field public static final String MANAGE_ONE_TIME_PERMISSION_SESSIONS = "android.permission.MANAGE_ONE_TIME_PERMISSION_SESSIONS";
@@ -1322,6 +1322,7 @@
method @RequiresPermission(android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS) public boolean isDpcDownloaded();
method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS}) public boolean isManagedKiosk();
method public boolean isSecondaryLockscreenEnabled(@NonNull android.os.UserHandle);
+ method @FlaggedApi("android.app.admin.flags.device_theft_api_enabled") @RequiresPermission(android.Manifest.permission.MANAGE_DEVICE_POLICY_THEFT_DETECTION) public boolean isTheftDetectionTriggered();
method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS}) public boolean isUnattendedManagedKiosk();
method @RequiresPermission("android.permission.NOTIFY_PENDING_SYSTEM_UPDATE") public void notifyPendingSystemUpdate(long);
method @RequiresPermission("android.permission.NOTIFY_PENDING_SYSTEM_UPDATE") public void notifyPendingSystemUpdate(long, boolean);
@@ -14353,9 +14354,9 @@
@FlaggedApi("com.android.internal.telephony.flags.use_oem_domain_selection_service") public abstract class DomainSelectionService extends android.app.Service {
ctor public DomainSelectionService();
+ method @NonNull public java.util.concurrent.Executor getCreateExecutor();
method public void onBarringInfoUpdated(int, int, @NonNull android.telephony.BarringInfo);
method @Nullable public final android.os.IBinder onBind(@Nullable android.content.Intent);
- method @NonNull public java.util.concurrent.Executor onCreateExecutor();
method public abstract void onDomainSelection(@NonNull android.telephony.DomainSelectionService.SelectionAttributes, @NonNull android.telephony.TransportSelectorCallback);
method public void onServiceStateUpdated(int, int, @NonNull android.telephony.ServiceState);
field public static final int SCAN_TYPE_FULL_SERVICE = 2; // 0x2
diff --git a/core/java/android/app/ActivityOptions.java b/core/java/android/app/ActivityOptions.java
index e14bf68..2a2c5f0 100644
--- a/core/java/android/app/ActivityOptions.java
+++ b/core/java/android/app/ActivityOptions.java
@@ -20,6 +20,7 @@
import static android.Manifest.permission.START_TASKS_FROM_RECENTS;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
+import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static android.content.Intent.FLAG_RECEIVER_FOREGROUND;
import static android.view.Display.INVALID_DISPLAY;
@@ -1849,7 +1850,7 @@
public int getPendingIntentLaunchFlags() {
// b/243794108: Ignore all flags except the new task flag, to be reconsidered in b/254490217
return mPendingIntentLaunchFlags &
- (FLAG_ACTIVITY_NEW_TASK | FLAG_RECEIVER_FOREGROUND);
+ (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK | FLAG_RECEIVER_FOREGROUND);
}
/**
diff --git a/core/java/android/app/OWNERS b/core/java/android/app/OWNERS
index f92ff83..da0cc01 100644
--- a/core/java/android/app/OWNERS
+++ b/core/java/android/app/OWNERS
@@ -31,6 +31,7 @@
per-file SystemServiceRegistry.java = file:/services/core/java/com/android/server/am/OWNERS
per-file *UserSwitchObserver* = file:/services/core/java/com/android/server/am/OWNERS
per-file *UiAutomation* = file:/services/accessibility/OWNERS
+per-file *UiAutomation* = file:/core/java/android/permission/OWNERS
per-file GameManager* = file:/GAME_MANAGER_OWNERS
per-file GameMode* = file:/GAME_MANAGER_OWNERS
per-file GameState* = file:/GAME_MANAGER_OWNERS
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 34fb754..367ade0 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -45,6 +45,7 @@
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_STATUS_BAR;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_SUPPORT_MESSAGE;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_SYSTEM_UPDATES;
+import static android.Manifest.permission.MANAGE_DEVICE_POLICY_THEFT_DETECTION;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_USB_DATA_SIGNALLING;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_WIFI;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_WIPE_DATA;
@@ -55,6 +56,7 @@
import static android.app.admin.flags.Flags.FLAG_ESIM_MANAGEMENT_ENABLED;
import static android.app.admin.flags.Flags.FLAG_DEVICE_POLICY_SIZE_TRACKING_ENABLED;
import static android.app.admin.flags.Flags.onboardingBugreportV2Enabled;
+import static android.app.admin.flags.Flags.FLAG_IS_MTE_POLICY_ENFORCED;
import static android.content.Intent.LOCAL_FLAG_FROM_SYSTEM;
import static android.net.NetworkCapabilities.NET_ENTERPRISE_ID_1;
import static android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE;
@@ -153,6 +155,7 @@
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.Preconditions;
import com.android.org.conscrypt.TrustedCertificateStore;
+import com.android.internal.os.Zygote;
import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;
@@ -4117,6 +4120,19 @@
return MTE_NOT_CONTROLLED_BY_POLICY;
}
+ /**
+ * Get the current MTE state of the device.
+ *
+ * <a href="https://source.android.com/docs/security/test/memory-safety/arm-mte">
+ * Learn more about MTE</a>
+ *
+ * @return whether MTE is currently enabled on the device.
+ */
+ @FlaggedApi(FLAG_IS_MTE_POLICY_ENFORCED)
+ public static boolean isMtePolicyEnforced() {
+ return Zygote.nativeSupportsMemoryTagging();
+ }
+
/** Indicates that content protection is not controlled by policy, allowing user to choose. */
@FlaggedApi(android.view.contentprotection.flags.Flags.FLAG_MANAGE_DEVICE_POLICY_ENABLED)
public static final int CONTENT_PROTECTION_NOT_CONTROLLED_BY_POLICY = 0;
@@ -17044,6 +17060,26 @@
}
/**
+ *
+ * Returns whether the device considers itself to be potentially stolen.
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(value = MANAGE_DEVICE_POLICY_THEFT_DETECTION)
+ @FlaggedApi(Flags.FLAG_DEVICE_THEFT_API_ENABLED)
+ public boolean isTheftDetectionTriggered() {
+ throwIfParentInstance("isTheftDetectionTriggered");
+ if (mService == null) {
+ return false;
+ }
+ try {
+ return mService.isTheftDetectionTriggered(mContext.getPackageName());
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* Returns a {@link DevicePolicyResourcesManager} containing the required APIs to set, reset,
* and get device policy related resources.
*/
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index f2466ac..ca4a5ab 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -576,6 +576,8 @@
void setWifiSsidPolicy(String callerPackageName, in WifiSsidPolicy policy);
WifiSsidPolicy getWifiSsidPolicy(String callerPackageName);
+ boolean isTheftDetectionTriggered(String callerPackageName);
+
List<UserHandle> listForegroundAffiliatedUsers();
void setDrawables(in List<DevicePolicyDrawableResource> drawables);
void resetDrawables(in List<String> drawableIds);
diff --git a/core/java/android/app/admin/flags/flags.aconfig b/core/java/android/app/admin/flags/flags.aconfig
index 726ddad..cbd8e5b 100644
--- a/core/java/android/app/admin/flags/flags.aconfig
+++ b/core/java/android/app/admin/flags/flags.aconfig
@@ -139,3 +139,10 @@
description: "Add Headless DO support."
bug: "289515470"
}
+
+flag {
+ name: "is_mte_policy_enforced"
+ namespace: "enterprise"
+ description: "Allow to query whether MTE is enabled or not to check for compliance for enterprise policy"
+ bug: "322777918"
+}
diff --git a/core/java/android/app/ondeviceintelligence/OWNERS b/core/java/android/app/ondeviceintelligence/OWNERS
new file mode 100644
index 0000000..6932ba2
--- /dev/null
+++ b/core/java/android/app/ondeviceintelligence/OWNERS
@@ -0,0 +1,7 @@
+# Bug component: 1363385
+
+sandeepbandaru@google.com
+shivanker@google.com
+hackz@google.com
+volnov@google.com
+
diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java
index a8dba51..cae4fab 100644
--- a/core/java/android/content/pm/ApplicationInfo.java
+++ b/core/java/android/content/pm/ApplicationInfo.java
@@ -1565,6 +1565,14 @@
private Boolean requestRawExternalStorageAccess;
/**
+ * If {@code false}, this app does not allow its activities to be replaced by another app.
+ * Is set from application manifest application tag's allowCrossUidActivitySwitchFromBelow
+ * attribute.
+ * @hide
+ */
+ public boolean allowCrossUidActivitySwitchFromBelow = true;
+
+ /**
* Represents the default policy. The actual policy used will depend on other properties of
* the application, e.g. the target SDK version.
* @hide
@@ -1760,6 +1768,9 @@
+ Integer.toHexString(localeConfigRes));
}
pw.println(prefix + "enableOnBackInvokedCallback=" + isOnBackInvokedCallbackEnabled());
+ pw.println(prefix + "allowCrossUidActivitySwitchFromBelow="
+ + allowCrossUidActivitySwitchFromBelow);
+
}
pw.println(prefix + "createTimestamp=" + createTimestamp);
if (mKnownActivityEmbeddingCerts != null) {
@@ -1877,6 +1888,8 @@
proto.write(ApplicationInfoProto.Detail.NATIVE_HEAP_ZERO_INIT,
nativeHeapZeroInitialized);
}
+ proto.write(ApplicationInfoProto.Detail.ALLOW_CROSS_UID_ACTIVITY_SWITCH_FROM_BELOW,
+ allowCrossUidActivitySwitchFromBelow);
proto.end(detailToken);
}
if (!ArrayUtils.isEmpty(mKnownActivityEmbeddingCerts)) {
@@ -2002,6 +2015,7 @@
nativeHeapZeroInitialized = orig.nativeHeapZeroInitialized;
requestRawExternalStorageAccess = orig.requestRawExternalStorageAccess;
localeConfigRes = orig.localeConfigRes;
+ allowCrossUidActivitySwitchFromBelow = orig.allowCrossUidActivitySwitchFromBelow;
createTimestamp = SystemClock.uptimeMillis();
}
@@ -2106,6 +2120,8 @@
}
}
dest.writeInt(localeConfigRes);
+ dest.writeInt(allowCrossUidActivitySwitchFromBelow ? 1 : 0);
+
sForStringSet.parcel(mKnownActivityEmbeddingCerts, dest, flags);
}
@@ -2204,6 +2220,8 @@
}
}
localeConfigRes = source.readInt();
+ allowCrossUidActivitySwitchFromBelow = source.readInt() != 0;
+
mKnownActivityEmbeddingCerts = sForStringSet.unparcel(source);
if (mKnownActivityEmbeddingCerts.isEmpty()) {
mKnownActivityEmbeddingCerts = null;
diff --git a/core/java/android/service/ondeviceintelligence/OWNERS b/core/java/android/service/ondeviceintelligence/OWNERS
new file mode 100644
index 0000000..09774f7
--- /dev/null
+++ b/core/java/android/service/ondeviceintelligence/OWNERS
@@ -0,0 +1 @@
+file:/core/java/android/app/ondeviceintelligence/OWNERS
diff --git a/core/java/com/android/internal/pm/parsing/pkg/PackageImpl.java b/core/java/com/android/internal/pm/parsing/pkg/PackageImpl.java
index d433ca3..73df5e8 100644
--- a/core/java/com/android/internal/pm/parsing/pkg/PackageImpl.java
+++ b/core/java/com/android/internal/pm/parsing/pkg/PackageImpl.java
@@ -408,6 +408,7 @@
// Derived fields
private long mLongVersionCode;
private int mLocaleConfigRes;
+ private boolean mAllowCrossUidActivitySwitchFromBelow;
private List<AndroidPackageSplit> mSplits;
@@ -1542,6 +1543,11 @@
}
@Override
+ public boolean isAllowCrossUidActivitySwitchFromBelow() {
+ return mAllowCrossUidActivitySwitchFromBelow;
+ }
+
+ @Override
public boolean hasPreserveLegacyExternalStorage() {
return getBoolean(Booleans.PRESERVE_LEGACY_EXTERNAL_STORAGE);
}
@@ -2199,6 +2205,12 @@
}
@Override
+ public ParsingPackage setAllowCrossUidActivitySwitchFromBelow(boolean value) {
+ mAllowCrossUidActivitySwitchFromBelow = value;
+ return this;
+ }
+
+ @Override
public PackageImpl setResourceOverlay(boolean value) {
return setBoolean(Booleans.OVERLAY, value);
}
@@ -2656,6 +2668,7 @@
if (!mKnownActivityEmbeddingCerts.isEmpty()) {
appInfo.setKnownActivityEmbeddingCerts(mKnownActivityEmbeddingCerts);
}
+ appInfo.allowCrossUidActivitySwitchFromBelow = mAllowCrossUidActivitySwitchFromBelow;
return appInfo;
}
@@ -3250,6 +3263,7 @@
dest.writeInt(this.uid);
dest.writeLong(this.mBooleans);
dest.writeLong(this.mBooleans2);
+ dest.writeBoolean(this.mAllowCrossUidActivitySwitchFromBelow);
}
public PackageImpl(Parcel in) {
@@ -3411,6 +3425,7 @@
this.uid = in.readInt();
this.mBooleans = in.readLong();
this.mBooleans2 = in.readLong();
+ this.mAllowCrossUidActivitySwitchFromBelow = in.readBoolean();
assignDerivedFields();
assignDerivedFields2();
diff --git a/core/java/com/android/internal/pm/pkg/parsing/ParsingPackage.java b/core/java/com/android/internal/pm/pkg/parsing/ParsingPackage.java
index ef106e0..5d185af 100644
--- a/core/java/com/android/internal/pm/pkg/parsing/ParsingPackage.java
+++ b/core/java/com/android/internal/pm/pkg/parsing/ParsingPackage.java
@@ -374,6 +374,9 @@
ParsingPackage setZygotePreloadName(String zygotePreloadName);
+ ParsingPackage setAllowCrossUidActivitySwitchFromBelow(
+ boolean allowCrossUidActivitySwitchFromBelow);
+
ParsingPackage sortActivities();
ParsingPackage sortReceivers();
@@ -518,6 +521,8 @@
@Nullable
String getZygotePreloadName();
+ boolean isAllowCrossUidActivitySwitchFromBelow();
+
boolean isBackupAllowed();
boolean isTaskReparentingAllowed();
diff --git a/core/java/com/android/internal/pm/pkg/parsing/ParsingPackageUtils.java b/core/java/com/android/internal/pm/pkg/parsing/ParsingPackageUtils.java
index e0fdbc6..2e6053d 100644
--- a/core/java/com/android/internal/pm/pkg/parsing/ParsingPackageUtils.java
+++ b/core/java/com/android/internal/pm/pkg/parsing/ParsingPackageUtils.java
@@ -2374,8 +2374,10 @@
.setRestrictedAccountType(string(R.styleable.AndroidManifestApplication_restrictedAccountType, sa))
.setZygotePreloadName(string(R.styleable.AndroidManifestApplication_zygotePreloadName, sa))
// Non-Config String
- .setPermission(nonConfigString(0, R.styleable.AndroidManifestApplication_permission, sa));
- // CHECKSTYLE:on
+ .setPermission(nonConfigString(0, R.styleable.AndroidManifestApplication_permission, sa))
+ .setAllowCrossUidActivitySwitchFromBelow(bool(true, R.styleable.AndroidManifestApplication_allowCrossUidActivitySwitchFromBelow, sa));
+
+ // CHECKSTYLE:on
//@formatter:on
}
diff --git a/core/java/com/android/server/pm/pkg/AndroidPackage.java b/core/java/com/android/server/pm/pkg/AndroidPackage.java
index 096f246..d430fe3 100644
--- a/core/java/com/android/server/pm/pkg/AndroidPackage.java
+++ b/core/java/com/android/server/pm/pkg/AndroidPackage.java
@@ -1507,4 +1507,11 @@
* @hide
*/
boolean isVisibleToInstantApps();
+
+ /**
+ * @see ApplicationInfo#allowCrossUidActivitySwitchFromBelow
+ * @see R.styleable#AndroidManifestApplication_allowCrossUidActivitySwitchFromBelow
+ * @hide
+ */
+ boolean isAllowCrossUidActivitySwitchFromBelow();
}
diff --git a/core/proto/android/content/package_item_info.proto b/core/proto/android/content/package_item_info.proto
index b9905e8..b7408a4 100644
--- a/core/proto/android/content/package_item_info.proto
+++ b/core/proto/android/content/package_item_info.proto
@@ -113,6 +113,7 @@
optional int32 enable_gwp_asan = 19;
optional int32 enable_memtag = 20;
optional bool native_heap_zero_init = 21;
+ optional bool allow_cross_uid_activity_switch_from_below = 22;
}
optional Detail detail = 17;
repeated string overlay_paths = 18;
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index e7df19c..4131644 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -3793,6 +3793,14 @@
<permission android:name="android.permission.MANAGE_DEVICE_POLICY_LOCK"
android:protectionLevel="internal|role" />
+ <!-- Allows an application to manage policy related to theft detection.
+ @FlaggedApi("android.app.admin.flags.device_theft_api_enabled")
+ @hide
+ @SystemApi
+ -->
+ <permission android:name="android.permission.MANAGE_DEVICE_POLICY_THEFT_DETECTION"
+ android:protectionLevel="internal|role" />
+
<!-- Allows an application to manage policy related to system apps.
<p>{@link Manifest.permission#MANAGE_DEVICE_POLICY_ACROSS_USERS_FULL} is required to call
APIs protected by this permission on users different to the calling user.
@@ -3830,6 +3838,24 @@
<permission android:name="android.permission.MANAGE_DEVICE_POLICY_MANAGED_SUBSCRIPTIONS"
android:protectionLevel="internal|role" />
+ <!-- Allows an application to manage policy related to block package uninstallation.
+ @FlaggedApi("android.app.admin.flags.dedicated_device_control_api_enabled")
+ -->
+ <permission android:name="android.permission.MANAGE_DEVICE_POLICY_BLOCK_UNINSTALL"
+ android:protectionLevel="internal|role" />
+
+ <!-- Allows an application to manage policy related to camera toggle.
+ @FlaggedApi("android.app.admin.flags.dedicated_device_control_api_enabled")
+ -->
+ <permission android:name="android.permission.MANAGE_DEVICE_POLICY_CAMERA_TOGGLE"
+ android:protectionLevel="internal|role" />
+
+ <!-- Allows an application to manage policy related to microphone toggle.
+ @FlaggedApi("android.app.admin.flags.dedicated_device_control_api_enabled")
+ -->
+ <permission android:name="android.permission.MANAGE_DEVICE_POLICY_MICROPHONE_TOGGLE"
+ android:protectionLevel="internal|role" />
+
<!-- Allows an application to set device policies outside the current user
that are critical for securing data within the current user.
<p>Holding this permission allows the use of other held MANAGE_DEVICE_POLICY_*
@@ -6884,13 +6910,10 @@
<permission android:name="android.permission.ACCESS_DRM_CERTIFICATES"
android:protectionLevel="signature|privileged" />
- <!-- Allows an application to manage media projection sessions, by showing the permission dialog
- to the user and creating a new token for each capture session.
- @FlaggedApi("com.android.media.flags.limit_manage_media_projection")
- @SystemApi Only granted to apps holding role SYSTEM_UI.
+ <!-- Api Allows an application to manage media projection sessions.
@hide This is not a third-party API (intended for system apps). -->
<permission android:name="android.permission.MANAGE_MEDIA_PROJECTION"
- android:protectionLevel="internal|role" />
+ android:protectionLevel="signature" />
<!-- @SystemApi Allows an application to read install sessions
@hide This is not a third-party API (intended for system apps). -->
diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml
index 734ff8d..b2e0be7c 100644
--- a/core/res/res/values/attrs_manifest.xml
+++ b/core/res/res/values/attrs_manifest.xml
@@ -1919,6 +1919,12 @@
try to load its code when launching components. The default is true
for normal behavior. -->
<attr name="hasCode" format="boolean" />
+ <!-- Specifies if activities can be launched on top of this application by activities from
+ other applications in the same task. If set to false, activity launches which would
+ replace this application with another when in the user's view will be blocked.
+ The default is true. -->
+ <!-- @FlaggedApi("android.security.asm_restrictions_enabled") -->
+ <attr name="allowCrossUidActivitySwitchFromBelow" format="boolean" />
<attr name="persistent" />
<attr name="persistentWhenFeatureAvailable" />
<attr name="requiredForAllUsers" />
diff --git a/core/res/res/values/public-staging.xml b/core/res/res/values/public-staging.xml
index 981969a..13ebae1 100644
--- a/core/res/res/values/public-staging.xml
+++ b/core/res/res/values/public-staging.xml
@@ -161,6 +161,8 @@
<public name="supportsConnectionlessStylusHandwriting" />
<!-- @FlaggedApi("android.nfc.Flags.FLAG_OBSERVE_MODE") -->
<public name="defaultToObserveMode"/>
+ <!-- @FlaggedApi("android.security.asm_restrictions_enabled") -->
+ <public name="allowCrossUidActivitySwitchFromBelow"/>
</staging-public-group>
<staging-public-group type="id" first-id="0x01bc0000">
diff --git a/core/tests/BroadcastRadioTests/TEST_MAPPING b/core/tests/BroadcastRadioTests/TEST_MAPPING
index b085a27..5637063 100644
--- a/core/tests/BroadcastRadioTests/TEST_MAPPING
+++ b/core/tests/BroadcastRadioTests/TEST_MAPPING
@@ -1,5 +1,5 @@
{
- "postsubmit": [
+ "presubmit": [
{
"name": "BroadcastRadioTests"
}
diff --git a/media/java/android/media/MediaCodecInfo.java b/media/java/android/media/MediaCodecInfo.java
index 3174c37..1e7bc47 100644
--- a/media/java/android/media/MediaCodecInfo.java
+++ b/media/java/android/media/MediaCodecInfo.java
@@ -20,10 +20,12 @@
import static android.media.Utils.sortDistinctRanges;
import static android.media.codec.Flags.FLAG_DYNAMIC_COLOR_ASPECTS;
import static android.media.codec.Flags.FLAG_HLG_EDITING;
+import static android.media.codec.Flags.FLAG_IN_PROCESS_SW_AUDIO_CODEC;
import static android.media.codec.Flags.FLAG_NULL_OUTPUT_SURFACE;
import static android.media.codec.Flags.FLAG_REGION_OF_INTEREST;
import android.annotation.FlaggedApi;
+import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -40,6 +42,8 @@
import android.util.Rational;
import android.util.Size;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -1808,6 +1812,55 @@
}
}
+ /** @hide */
+ @IntDef(prefix = {"SECURITY_MODEL_"}, value = {
+ SECURITY_MODEL_SANDBOXED,
+ SECURITY_MODEL_MEMORY_SAFE,
+ SECURITY_MODEL_TRUSTED_CONTENT_ONLY,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface SecurityModel {}
+
+ /**
+ * In this model the codec is running in a sandboxed process. Even if a
+ * malicious content was fed to the codecs in this model, the impact will
+ * be contained in the sandboxed process.
+ */
+ @FlaggedApi(FLAG_IN_PROCESS_SW_AUDIO_CODEC)
+ public static final int SECURITY_MODEL_SANDBOXED = 0;
+ /**
+ * In this model the codec is not running in a sandboxed process, but
+ * written in a memory-safe way. It typically means that the software
+ * implementation of the codec is written in a memory-safe language such
+ * as Rust.
+ */
+ @FlaggedApi(FLAG_IN_PROCESS_SW_AUDIO_CODEC)
+ public static final int SECURITY_MODEL_MEMORY_SAFE = 1;
+ /**
+ * In this model the codec is suitable only for trusted content where
+ * the input can be verified to be well-formed and no malicious actor
+ * can alter it. For example, codecs in this model are not suitable
+ * for arbitrary media downloaded from the internet or present in a user
+ * directory. On the other hand, they could be suitable for media encoded
+ * in the backend that the app developer wholly controls.
+ * <p>
+ * Codecs with this security model is not included in
+ * {@link MediaCodecList#REGULAR_CODECS}, but included in
+ * {@link MediaCodecList#ALL_CODECS}.
+ */
+ @FlaggedApi(FLAG_IN_PROCESS_SW_AUDIO_CODEC)
+ public static final int SECURITY_MODEL_TRUSTED_CONTENT_ONLY = 2;
+
+ /**
+ * Query the security model of the codec.
+ */
+ @FlaggedApi(FLAG_IN_PROCESS_SW_AUDIO_CODEC)
+ @SecurityModel
+ public int getSecurityModel() {
+ // TODO b/297922713 --- detect security model of out-of-sandbox codecs
+ return SECURITY_MODEL_SANDBOXED;
+ }
+
/**
* A class that supports querying the video capabilities of a codec.
*/
diff --git a/media/java/android/media/MediaFormat.java b/media/java/android/media/MediaFormat.java
index 5e40eee..7b83842 100644
--- a/media/java/android/media/MediaFormat.java
+++ b/media/java/android/media/MediaFormat.java
@@ -16,6 +16,8 @@
package android.media;
+import static android.media.codec.Flags.FLAG_IN_PROCESS_SW_AUDIO_CODEC;
+
import static com.android.media.codec.flags.Flags.FLAG_CODEC_IMPORTANCE;
import static com.android.media.codec.flags.Flags.FLAG_LARGE_AUDIO_FRAME;
@@ -1715,6 +1717,58 @@
@FlaggedApi(FLAG_CODEC_IMPORTANCE)
public static final String KEY_IMPORTANCE = "importance";
+ /** @hide */
+ @IntDef(flag = true, prefix = {"FLAG_SECURITY_MODEL_"}, value = {
+ FLAG_SECURITY_MODEL_SANDBOXED,
+ FLAG_SECURITY_MODEL_MEMORY_SAFE,
+ FLAG_SECURITY_MODEL_TRUSTED_CONTENT_ONLY,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface SecurityModelFlag {}
+
+ /**
+ * Flag for {@link MediaCodecInfo#SECURITY_MODEL_SANDBOXED}.
+ */
+ @FlaggedApi(FLAG_IN_PROCESS_SW_AUDIO_CODEC)
+ public static final int FLAG_SECURITY_MODEL_SANDBOXED =
+ (1 << MediaCodecInfo.SECURITY_MODEL_SANDBOXED);
+ /**
+ * Flag for {@link MediaCodecInfo#SECURITY_MODEL_MEMORY_SAFE}.
+ */
+ @FlaggedApi(FLAG_IN_PROCESS_SW_AUDIO_CODEC)
+ public static final int FLAG_SECURITY_MODEL_MEMORY_SAFE =
+ (1 << MediaCodecInfo.SECURITY_MODEL_MEMORY_SAFE);
+ /**
+ * Flag for {@link MediaCodecInfo#SECURITY_MODEL_TRUSTED_CONTENT_ONLY}.
+ */
+ @FlaggedApi(FLAG_IN_PROCESS_SW_AUDIO_CODEC)
+ public static final int FLAG_SECURITY_MODEL_TRUSTED_CONTENT_ONLY =
+ (1 << MediaCodecInfo.SECURITY_MODEL_TRUSTED_CONTENT_ONLY);
+
+ /**
+ * A key describing the requested security model as flags.
+ * <p>
+ * The associated value is a flag of the following values:
+ * {@link FLAG_SECURITY_MODEL_SANDBOXED},
+ * {@link FLAG_SECURITY_MODEL_MEMORY_SAFE},
+ * {@link FLAG_SECURITY_MODEL_TRUSTED_CONTENT_ONLY}. The default value is
+ * {@link FLAG_SECURITY_MODEL_SANDBOXED}.
+ * <p>
+ * When passed to {@link MediaCodecList#findDecoderForFormat} or
+ * {@link MediaCodecList#findEncoderForFormat}, MediaCodecList filters
+ * the security model of the codecs according to this flag value.
+ * <p>
+ * When passed to {@link MediaCodec#configure}, MediaCodec verifies
+ * the security model matches the flag value passed, and throws
+ * {@link java.lang.IllegalArgumentException} if the model does not match.
+ * <p>
+ * @see MediaCodecInfo#getSecurityModel
+ * @see MediaCodecList#findDecoderForFormat
+ * @see MediaCodecList#findEncoderForFormat
+ */
+ @FlaggedApi(FLAG_IN_PROCESS_SW_AUDIO_CODEC)
+ public static final String KEY_SECURITY_MODEL = "security-model";
+
/* package private */ MediaFormat(@NonNull Map<String, Object> map) {
mMap = map;
}
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/SideFpsOverlayViewBinder.kt b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/SideFpsOverlayViewBinder.kt
index 7b4be02..9c28f1c 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/SideFpsOverlayViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/SideFpsOverlayViewBinder.kt
@@ -115,17 +115,11 @@
}
private var overlayView: View? = null
- private var lottie: LottieAnimationView? = null
/** Show the side fingerprint sensor indicator */
private fun show() {
- overlayView?.let {
- if (it.isAttachedToWindow) {
- lottie = it.requireViewById<LottieAnimationView>(R.id.sidefps_animation)
- lottie?.pauseAnimation()
- lottie?.removeAllLottieOnCompositionLoadedListener()
- windowManager.get().removeView(it)
- }
+ if (overlayView?.isAttachedToWindow == true) {
+ return
}
overlayView = layoutInflater.get().inflate(R.layout.sidefps_view, null, false)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java
index 2a4753d..9916ef6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java
@@ -749,7 +749,7 @@
|| isNotifUserRedacted;
boolean notificationRequestsRedaction =
- ent.getSbn().getNotification().visibility == Notification.VISIBILITY_PRIVATE;
+ ent.isNotificationVisibilityPrivate();
boolean userForcesRedaction = packageHasVisibilityOverride(ent.getSbn().getKey());
if (keyguardPrivateNotifications()) {
@@ -767,9 +767,7 @@
}
NotificationEntry entry = mCommonNotifCollectionLazy.get().getEntry(key);
if (mFeatureFlags.isEnabled(Flags.NOTIF_LS_BACKGROUND_THREAD)) {
- return entry != null && entry.getRanking().getChannel() != null
- && entry.getRanking().getChannel().getLockscreenVisibility()
- == Notification.VISIBILITY_PRIVATE;
+ return entry != null && entry.isChannelVisibilityPrivate();
} else {
return entry != null
&& entry.getRanking().getLockscreenVisibilityOverride()
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java
index 8678f0a..e111525 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java
@@ -998,6 +998,23 @@
return style == null ? "nostyle" : style.getSimpleName();
}
+ /**
+ * Return {@code true} if notification's visibility is {@link Notification.VISIBILITY_PRIVATE}
+ */
+ public boolean isNotificationVisibilityPrivate() {
+ return getSbn().getNotification().visibility == Notification.VISIBILITY_PRIVATE;
+ }
+
+ /**
+ * Return {@code true} if notification's channel lockscreen visibility is
+ * {@link Notification.VISIBILITY_PRIVATE}
+ */
+ public boolean isChannelVisibilityPrivate() {
+ return getRanking().getChannel() != null
+ && getRanking().getChannel().getLockscreenVisibility()
+ == Notification.VISIBILITY_PRIVATE;
+ }
+
/** Information about a suggestion that is being edited. */
public static class EditedSuggestionInfo {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SensitiveNotificationProtectionControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SensitiveNotificationProtectionControllerImpl.java
index 2b0a92c..6956a7d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SensitiveNotificationProtectionControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SensitiveNotificationProtectionControllerImpl.java
@@ -221,10 +221,15 @@
// Exempt foreground service notifications from protection in effort to keep screen share
// stop actions easily accessible
StatusBarNotification sbn = entry.getSbn();
- if (sbn.getNotification().isFgsOrUij()) {
- return !sbn.getPackageName().equals(projection.getPackageName());
+ if (sbn.getNotification().isFgsOrUij()
+ && sbn.getPackageName().equals(projection.getPackageName())) {
+ return false;
}
- return true;
+ // Only protect/redact notifications if the developer has not explicitly set notification
+ // visibility as public and users has not adjusted default channel visibility to private
+ boolean notificationRequestsRedaction = entry.isNotificationVisibilityPrivate();
+ boolean userForcesRedaction = entry.isChannelVisibilityPrivate();
+ return notificationRequestsRedaction || userForcesRedaction;
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotificationEntryTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotificationEntryTest.java
index ccc9dc0..8a48fe1 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotificationEntryTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotificationEntryTest.java
@@ -50,8 +50,8 @@
import androidx.test.filters.SmallTest;
-import com.android.systemui.res.R;
import com.android.systemui.SysuiTestCase;
+import com.android.systemui.res.R;
import com.android.systemui.statusbar.RankingBuilder;
import com.android.systemui.statusbar.SbnBuilder;
import com.android.systemui.util.time.FakeSystemClock;
@@ -280,6 +280,66 @@
}
@Test
+ public void testIsNotificationVisibilityPrivate_true() {
+ assertTrue(mEntry.isNotificationVisibilityPrivate());
+ }
+
+ @Test
+ public void testIsNotificationVisibilityPrivate_visibilityPublic_false() {
+ Notification.Builder notification = new Notification.Builder(mContext, "")
+ .setVisibility(Notification.VISIBILITY_PUBLIC)
+ .setSmallIcon(R.drawable.ic_person)
+ .setContentTitle("Title")
+ .setContentText("Text");
+
+ NotificationEntry entry = new NotificationEntryBuilder()
+ .setPkg(TEST_PACKAGE_NAME)
+ .setOpPkg(TEST_PACKAGE_NAME)
+ .setUid(TEST_UID)
+ .setChannel(mChannel)
+ .setId(mId++)
+ .setNotification(notification.build())
+ .setUser(new UserHandle(ActivityManager.getCurrentUser()))
+ .build();
+
+ assertFalse(entry.isNotificationVisibilityPrivate());
+ }
+
+ @Test
+ public void testIsChannelVisibilityPrivate_true() {
+ assertTrue(mEntry.isChannelVisibilityPrivate());
+ }
+
+ @Test
+ public void testIsChannelVisibilityPrivate_visibilityPublic_false() {
+ NotificationChannel channel =
+ new NotificationChannel("id", "name", NotificationChannel.USER_LOCKED_IMPORTANCE);
+ channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
+ StatusBarNotification sbn = new SbnBuilder().build();
+ Ranking ranking = new RankingBuilder()
+ .setChannel(channel)
+ .setKey(sbn.getKey())
+ .build();
+ NotificationEntry entry =
+ new NotificationEntry(sbn, ranking, mClock.uptimeMillis());
+
+ assertFalse(entry.isChannelVisibilityPrivate());
+ }
+
+ @Test
+ public void testIsChannelVisibilityPrivate_entryHasNoChannel_false() {
+ StatusBarNotification sbn = new SbnBuilder().build();
+ Ranking ranking = new RankingBuilder()
+ .setChannel(null)
+ .setKey(sbn.getKey())
+ .build();
+ NotificationEntry entry =
+ new NotificationEntry(sbn, ranking, mClock.uptimeMillis());
+
+ assertFalse(entry.isChannelVisibilityPrivate());
+ }
+
+ @Test
public void notificationDataEntry_testIsLastMessageFromReply() {
Person.Builder person = new Person.Builder()
.setName("name")
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SensitiveNotificationProtectionControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SensitiveNotificationProtectionControllerTest.kt
index 1dac642..a2af38f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SensitiveNotificationProtectionControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SensitiveNotificationProtectionControllerTest.kt
@@ -19,17 +19,24 @@
import android.app.ActivityOptions
import android.app.IActivityManager
import android.app.Notification
+import android.app.Notification.FLAG_FOREGROUND_SERVICE
+import android.app.Notification.VISIBILITY_PRIVATE
+import android.app.Notification.VISIBILITY_PUBLIC
+import android.app.NotificationChannel
+import android.app.NotificationManager.IMPORTANCE_HIGH
+import android.app.NotificationManager.VISIBILITY_NO_OVERRIDE
import android.media.projection.MediaProjectionInfo
import android.media.projection.MediaProjectionManager
import android.platform.test.annotations.EnableFlags
import android.provider.Settings.Global.DISABLE_SCREEN_SHARE_PROTECTIONS_FOR_APPS_AND_NOTIFICATIONS
-import android.service.notification.StatusBarNotification
import android.testing.AndroidTestingRunner
import android.testing.TestableLooper.RunWithLooper
import androidx.test.filters.SmallTest
import com.android.server.notification.Flags
import com.android.systemui.SysuiTestCase
+import com.android.systemui.statusbar.RankingBuilder
import com.android.systemui.statusbar.notification.collection.NotificationEntry
+import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder
import com.android.systemui.util.concurrency.FakeExecutor
import com.android.systemui.util.concurrency.mockExecutorHandler
import com.android.systemui.util.mockito.whenever
@@ -316,6 +323,25 @@
assertFalse(controller.shouldProtectNotification(notificationEntry))
}
+ @Test
+ fun shouldProtectNotification_projectionActive_publicNotification_false() {
+ mediaProjectionCallback.onStart(mediaProjectionInfo)
+
+ // App marked notification visibility as public
+ val notificationEntry = setupPublicNotificationEntry(TEST_PROJECTION_PACKAGE_NAME)
+
+ assertFalse(controller.shouldProtectNotification(notificationEntry))
+ }
+
+ @Test
+ fun shouldProtectNotification_projectionActive_publicNotificationUserChannelOverride_true() {
+ mediaProjectionCallback.onStart(mediaProjectionInfo)
+
+ val notificationEntry =
+ setupPublicNotificationEntryWithUserOverriddenChannel(TEST_PROJECTION_PACKAGE_NAME)
+
+ assertTrue(controller.shouldProtectNotification(notificationEntry))
+ }
private fun setDisabledViaDeveloperOption() {
globalSettings.putInt(DISABLE_SCREEN_SHARE_PROTECTIONS_FOR_APPS_AND_NOTIFICATIONS, 1)
@@ -336,21 +362,50 @@
private fun setupNotificationEntry(
packageName: String,
- isFgs: Boolean = false
+ isFgs: Boolean = false,
+ overrideVisibility: Boolean = false,
+ overrideChannelVisibility: Boolean = false,
): NotificationEntry {
- val notificationEntry = mock(NotificationEntry::class.java)
- val sbn = mock(StatusBarNotification::class.java)
- val notification = mock(Notification::class.java)
- whenever(notificationEntry.sbn).thenReturn(sbn)
- whenever(sbn.packageName).thenReturn(packageName)
- whenever(sbn.notification).thenReturn(notification)
- whenever(notification.isFgsOrUij).thenReturn(isFgs)
-
+ val notification = Notification()
+ if (isFgs) {
+ notification.flags = notification.flags or FLAG_FOREGROUND_SERVICE
+ }
+ if (overrideVisibility) {
+ // Developer has marked notification as public
+ notification.visibility = VISIBILITY_PUBLIC
+ }
+ val notificationEntry =
+ NotificationEntryBuilder().setNotification(notification).setPkg(packageName).build()
+ val channel = NotificationChannel("1", "1", IMPORTANCE_HIGH)
+ if (overrideChannelVisibility) {
+ // User doesn't allow private notifications at the channel level
+ channel.lockscreenVisibility = VISIBILITY_PRIVATE
+ }
+ notificationEntry.setRanking(
+ RankingBuilder(notificationEntry.ranking)
+ .setChannel(channel)
+ .setVisibilityOverride(VISIBILITY_NO_OVERRIDE)
+ .build()
+ )
return notificationEntry
}
private fun setupFgsNotificationEntry(packageName: String): NotificationEntry {
- return setupNotificationEntry(packageName, /* isFgs= */ true)
+ return setupNotificationEntry(packageName, isFgs = true)
+ }
+
+ private fun setupPublicNotificationEntry(packageName: String): NotificationEntry {
+ return setupNotificationEntry(packageName, overrideVisibility = true)
+ }
+
+ private fun setupPublicNotificationEntryWithUserOverriddenChannel(
+ packageName: String
+ ): NotificationEntry {
+ return setupNotificationEntry(
+ packageName,
+ overrideVisibility = true,
+ overrideChannelVisibility = true
+ )
}
companion object {
diff --git a/ravenwood/run-ravenwood-tests.sh b/ravenwood/run-ravenwood-tests.sh
index 3f4b8a7..259aa70 100755
--- a/ravenwood/run-ravenwood-tests.sh
+++ b/ravenwood/run-ravenwood-tests.sh
@@ -13,10 +13,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Run all the ravenwood tests.
+# Run all the ravenwood tests + hoststubgen unit tests.
+
+all_tests="hoststubgentest tiny-framework-dump-test hoststubgen-invoke-test"
# "echo" is to remove the newlines
-all_tests=$(echo $(${0%/*}/list-ravenwood-tests.sh) )
+all_tests="$all_tests $(echo $(${0%/*}/list-ravenwood-tests.sh) )"
echo "Running tests: $all_tests"
atest $all_tests
diff --git a/services/core/java/com/android/server/am/OomAdjusterModernImpl.java b/services/core/java/com/android/server/am/OomAdjusterModernImpl.java
index f85b03e..1bf779a 100644
--- a/services/core/java/com/android/server/am/OomAdjusterModernImpl.java
+++ b/services/core/java/com/android/server/am/OomAdjusterModernImpl.java
@@ -722,14 +722,8 @@
performNewUpdateOomAdjLSP(oomAdjReason, topApp, targetProcesses, activeUids,
fullUpdate, now, UNKNOWN_ADJ);
- if (fullUpdate) {
- assignCachedAdjIfNecessary(mProcessList.getLruProcessesLOSP());
- } else {
- activeProcesses.clear();
- activeProcesses.addAll(targetProcesses);
- assignCachedAdjIfNecessary(activeProcesses);
- activeProcesses.clear();
- }
+ // TODO: b/319163103 - optimize cache adj assignment to not require the whole lru list.
+ assignCachedAdjIfNecessary(mProcessList.getLruProcessesLOSP());
postUpdateOomAdjInnerLSP(oomAdjReason, activeUids, now, nowElapsed, oldTime);
targetProcesses.clear();
@@ -996,11 +990,11 @@
&& service.mState.getMaxAdj() < FOREGROUND_APP_ADJ)
|| (service.mState.getCurAdj() <= FOREGROUND_APP_ADJ
&& service.mState.getCurrentSchedulingGroup() > SCHED_GROUP_BACKGROUND
- && service.mState.getCurProcState() <= PROCESS_STATE_TOP)) {
+ && service.mState.getCurProcState() <= PROCESS_STATE_TOP)
+ || (service.isSdkSandbox && cr.binding.attributedClient != null)) {
continue;
}
-
computeServiceHostOomAdjLSP(cr, service, app, now, topApp, fullUpdate, false, false,
oomAdjReason, cachedAdj, false, false);
}
diff --git a/services/core/java/com/android/server/am/ProcessRecord.java b/services/core/java/com/android/server/am/ProcessRecord.java
index d23d9fb..9883f09 100644
--- a/services/core/java/com/android/server/am/ProcessRecord.java
+++ b/services/core/java/com/android/server/am/ProcessRecord.java
@@ -1678,7 +1678,11 @@
final ArrayList<ConnectionRecord> clist = serviceConnections.valueAt(j);
for (int k = clist.size() - 1; k >= 0; k--) {
final ConnectionRecord cr = clist.get(k);
- consumer.accept(cr.binding.client);
+ if (isSdkSandbox && cr.binding.attributedClient != null) {
+ consumer.accept(cr.binding.attributedClient);
+ } else {
+ consumer.accept(cr.binding.client);
+ }
}
}
}
@@ -1689,25 +1693,5 @@
consumer.accept(conn.client);
}
}
- // If this process is a sandbox itself, also add the app on whose behalf
- // its running
- if (isSdkSandbox) {
- for (int is = mServices.numberOfRunningServices() - 1; is >= 0; is--) {
- ServiceRecord s = mServices.getRunningServiceAt(is);
- ArrayMap<IBinder, ArrayList<ConnectionRecord>> serviceConnections =
- s.getConnections();
- for (int conni = serviceConnections.size() - 1; conni >= 0; conni--) {
- ArrayList<ConnectionRecord> clist = serviceConnections.valueAt(conni);
- for (int i = clist.size() - 1; i >= 0; i--) {
- ConnectionRecord cr = clist.get(i);
- ProcessRecord attributedApp = cr.binding.attributedClient;
- if (attributedApp == null || attributedApp == this) {
- continue;
- }
- consumer.accept(attributedApp);
- }
- }
- }
- }
}
}
diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java
index 145b213..fd09ad1 100644
--- a/services/core/java/com/android/server/appop/AppOpsService.java
+++ b/services/core/java/com/android/server/appop/AppOpsService.java
@@ -166,7 +166,6 @@
import com.android.server.LocalManagerRegistry;
import com.android.server.LocalServices;
import com.android.server.LockGuard;
-import com.android.server.SystemServerInitThreadPool;
import com.android.server.SystemServiceManager;
import com.android.server.companion.virtual.VirtualDeviceManagerInternal;
import com.android.server.pm.PackageList;
@@ -1038,7 +1037,7 @@
new Ops(pkgName, uidState));
}
- createSandboxUidStateIfNotExistsForAppLocked(uid);
+ createSandboxUidStateIfNotExistsForAppLocked(uid, null);
}
} else if (action.equals(ACTION_PACKAGE_REMOVED) && !intent.hasExtra(EXTRA_REPLACING)) {
synchronized (AppOpsService.this) {
@@ -1050,69 +1049,8 @@
return;
}
- ArrayMap<String, String> dstAttributionTags = new ArrayMap<>();
- ArraySet<String> attributionTags = new ArraySet<>();
- attributionTags.add(null);
- if (pkg.getAttributions() != null) {
- int numAttributions = pkg.getAttributions().size();
- for (int attributionNum = 0; attributionNum < numAttributions;
- attributionNum++) {
- ParsedAttribution attribution = pkg.getAttributions().get(attributionNum);
- attributionTags.add(attribution.getTag());
-
- int numInheritFrom = attribution.getInheritFrom().size();
- for (int inheritFromNum = 0; inheritFromNum < numInheritFrom;
- inheritFromNum++) {
- dstAttributionTags.put(attribution.getInheritFrom().get(inheritFromNum),
- attribution.getTag());
- }
- }
- }
-
synchronized (AppOpsService.this) {
- UidState uidState = mUidStates.get(uid);
- if (uidState == null) {
- return;
- }
-
- Ops ops = uidState.pkgOps.get(pkgName);
- if (ops == null) {
- return;
- }
-
- // Reset cached package properties to re-initialize when needed
- ops.bypass = null;
- ops.knownAttributionTags.clear();
-
- // Merge data collected for removed attributions into their successor
- // attributions
- int numOps = ops.size();
- for (int opNum = 0; opNum < numOps; opNum++) {
- Op op = ops.valueAt(opNum);
- for (int deviceIndex = op.mDeviceAttributedOps.size() - 1; deviceIndex >= 0;
- deviceIndex--) {
- ArrayMap<String, AttributedOp> attributedOps =
- op.mDeviceAttributedOps.valueAt(deviceIndex);
- for (int tagIndex = attributedOps.size() - 1; tagIndex >= 0;
- tagIndex--) {
- String tag = attributedOps.keyAt(tagIndex);
- if (attributionTags.contains(tag)) {
- // attribution still exist after upgrade
- continue;
- }
-
- String newAttributionTag = dstAttributionTags.get(tag);
-
- AttributedOp newAttributedOp = op.getOrCreateAttribution(op,
- newAttributionTag,
- op.mDeviceAttributedOps.keyAt(deviceIndex));
- newAttributedOp.add(attributedOps.get(tag));
- attributedOps.remove(tag);
-
- scheduleFastWriteLocked();
- }
- }
- }
+ refreshAttributionsLocked(pkg, uid);
}
}
}
@@ -1136,41 +1074,6 @@
mContext.registerReceiverAsUser(mOnPackageUpdatedReceiver, UserHandle.ALL,
packageUpdateFilter, null, null);
- synchronized (this) {
- for (int uidNum = mUidStates.size() - 1; uidNum >= 0; uidNum--) {
- int uid = mUidStates.keyAt(uidNum);
- UidState uidState = mUidStates.valueAt(uidNum);
-
- String[] pkgsInUid = getPackagesForUid(uidState.uid);
- if (ArrayUtils.isEmpty(pkgsInUid) && uid >= Process.FIRST_APPLICATION_UID) {
- uidState.clear();
- mUidStates.removeAt(uidNum);
- scheduleFastWriteLocked();
- continue;
- }
-
- ArrayMap<String, Ops> pkgs = uidState.pkgOps;
-
- int numPkgs = pkgs.size();
- for (int pkgNum = 0; pkgNum < numPkgs; pkgNum++) {
- String pkg = pkgs.keyAt(pkgNum);
-
- String action;
- if (!ArrayUtils.contains(pkgsInUid, pkg)) {
- action = ACTION_PACKAGE_REMOVED;
- } else {
- action = Intent.ACTION_PACKAGE_REPLACED;
- }
-
- SystemServerInitThreadPool.submit(
- () -> mOnPackageUpdatedReceiver.onReceive(mContext, new Intent(action)
- .setData(Uri.fromParts("package", pkg, null))
- .putExtra(Intent.EXTRA_UID, uid)),
- "Update app-ops uidState in case package " + pkg + " changed");
- }
- }
- }
-
prepareInternalCallbacks();
final IntentFilter packageSuspendFilter = new IntentFilter();
@@ -1258,20 +1161,27 @@
void initializeUidStates() {
UserManagerInternal umi = getUserManagerInternal();
synchronized (this) {
+ SparseBooleanArray knownUids = new SparseBooleanArray();
+
+ for (int uid : NON_PACKAGE_UIDS) {
+ if (!mUidStates.contains(uid)) {
+ mUidStates.put(uid, new UidState(uid));
+ }
+ knownUids.put(uid, true);
+ }
+
int[] userIds = umi.getUserIds();
try (PackageManagerLocal.UnfilteredSnapshot snapshot =
getPackageManagerLocal().withUnfilteredSnapshot()) {
Map<String, PackageState> packageStates = snapshot.getPackageStates();
for (int i = 0; i < userIds.length; i++) {
int userId = userIds[i];
- initializeUserUidStatesLocked(userId, packageStates);
+ initializeUserUidStatesLocked(userId, packageStates, knownUids);
}
- }
- for (int uid : NON_PACKAGE_UIDS) {
- mUidStates.put(uid, new UidState(uid));
+ trimUidStatesLocked(knownUids, packageStates);
+ mUidStatesInitialized = true;
}
- mUidStatesInitialized = true;
}
}
@@ -1279,26 +1189,34 @@
synchronized (this) {
try (PackageManagerLocal.UnfilteredSnapshot snapshot =
getPackageManagerLocal().withUnfilteredSnapshot()) {
- initializeUserUidStatesLocked(userId, snapshot.getPackageStates());
+ initializeUserUidStatesLocked(userId, snapshot.getPackageStates(), null);
}
}
}
private void initializeUserUidStatesLocked(int userId, Map<String,
- PackageState> packageStates) {
+ PackageState> packageStates, SparseBooleanArray knownUids) {
for (Map.Entry<String, PackageState> entry : packageStates.entrySet()) {
- int appId = entry.getValue().getAppId();
+ PackageState packageState = entry.getValue();
+ if (packageState.isApex()) {
+ continue;
+ }
+ int appId = packageState.getAppId();
String packageName = entry.getKey();
- initializePackageUidStateLocked(userId, appId, packageName);
+ initializePackageUidStateLocked(userId, appId, packageName, knownUids);
}
}
/*
Be careful not to clear any existing data; only want to add objects that don't already exist.
*/
- private void initializePackageUidStateLocked(int userId, int appId, String packageName) {
+ private void initializePackageUidStateLocked(int userId, int appId, String packageName,
+ SparseBooleanArray knownUids) {
int uid = UserHandle.getUid(userId, appId);
+ if (knownUids != null) {
+ knownUids.put(uid, true);
+ }
UidState uidState = getUidStateLocked(uid, true);
Ops ops = uidState.pkgOps.get(packageName);
if (ops == null) {
@@ -1316,7 +1234,105 @@
}
}
- createSandboxUidStateIfNotExistsForAppLocked(uid);
+ createSandboxUidStateIfNotExistsForAppLocked(uid, knownUids);
+ }
+
+ private void trimUidStatesLocked(SparseBooleanArray knownUids,
+ Map<String, PackageState> packageStates) {
+ synchronized (this) {
+ // Remove what may have been added during persistence parsing
+ for (int i = mUidStates.size() - 1; i >= 0; i--) {
+ int uid = mUidStates.keyAt(i);
+ if (knownUids.get(uid, false)) {
+ if (uid >= Process.FIRST_APPLICATION_UID) {
+ ArrayMap<String, Ops> pkgOps = mUidStates.valueAt(i).pkgOps;
+ for (int j = 0; j < pkgOps.size(); j++) {
+ String pkgName = pkgOps.keyAt(j);
+ if (!packageStates.containsKey(pkgName)) {
+ pkgOps.removeAt(j);
+ continue;
+ }
+ AndroidPackage pkg = packageStates.get(pkgName).getAndroidPackage();
+ if (pkg != null) {
+ refreshAttributionsLocked(pkg, uid);
+ }
+ }
+ if (pkgOps.isEmpty()) {
+ mUidStates.remove(i);
+ }
+ }
+ } else {
+ mUidStates.removeAt(i);
+ }
+ }
+ }
+ }
+
+ @GuardedBy("this")
+ private void refreshAttributionsLocked(AndroidPackage pkg, int uid) {
+ String pkgName = pkg.getPackageName();
+ ArrayMap<String, String> dstAttributionTags = new ArrayMap<>();
+ ArraySet<String> attributionTags = new ArraySet<>();
+ attributionTags.add(null);
+ if (pkg.getAttributions() != null) {
+ int numAttributions = pkg.getAttributions().size();
+ for (int attributionNum = 0; attributionNum < numAttributions;
+ attributionNum++) {
+ ParsedAttribution attribution = pkg.getAttributions().get(attributionNum);
+ attributionTags.add(attribution.getTag());
+
+ int numInheritFrom = attribution.getInheritFrom().size();
+ for (int inheritFromNum = 0; inheritFromNum < numInheritFrom;
+ inheritFromNum++) {
+ dstAttributionTags.put(attribution.getInheritFrom().get(inheritFromNum),
+ attribution.getTag());
+ }
+ }
+ }
+
+ UidState uidState = mUidStates.get(uid);
+ if (uidState == null) {
+ return;
+ }
+
+ Ops ops = uidState.pkgOps.get(pkgName);
+ if (ops == null) {
+ return;
+ }
+
+ // Reset cached package properties to re-initialize when needed
+ ops.bypass = null;
+ ops.knownAttributionTags.clear();
+
+ // Merge data collected for removed attributions into their successor
+ // attributions
+ int numOps = ops.size();
+ for (int opNum = 0; opNum < numOps; opNum++) {
+ Op op = ops.valueAt(opNum);
+ for (int deviceIndex = op.mDeviceAttributedOps.size() - 1; deviceIndex >= 0;
+ deviceIndex--) {
+ ArrayMap<String, AttributedOp> attributedOps =
+ op.mDeviceAttributedOps.valueAt(deviceIndex);
+ for (int tagIndex = attributedOps.size() - 1; tagIndex >= 0;
+ tagIndex--) {
+ String tag = attributedOps.keyAt(tagIndex);
+ if (attributionTags.contains(tag)) {
+ // attribution still exist after upgrade
+ continue;
+ }
+
+ String newAttributionTag = dstAttributionTags.get(tag);
+
+ AttributedOp newAttributedOp = op.getOrCreateAttribution(op,
+ newAttributionTag,
+ op.mDeviceAttributedOps.keyAt(deviceIndex));
+ newAttributedOp.add(attributedOps.get(tag));
+ attributedOps.remove(tag);
+
+ scheduleFastWriteLocked();
+ }
+ }
+ }
}
/**
@@ -4251,8 +4267,15 @@
return uidState;
}
- private void createSandboxUidStateIfNotExistsForAppLocked(int uid) {
+ private void createSandboxUidStateIfNotExistsForAppLocked(int uid,
+ SparseBooleanArray knownUids) {
+ if (UserHandle.getAppId(uid) < Process.FIRST_APPLICATION_UID) {
+ return;
+ }
final int sandboxUid = Process.toSdkSandboxUid(uid);
+ if (knownUids != null) {
+ knownUids.put(sandboxUid, true);
+ }
getUidStateLocked(sandboxUid, true);
}
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
index 4bb8e19..bc169ca 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
@@ -2901,16 +2901,12 @@
@GuardedBy("ImfLock.class")
void clearClientSessionsLocked() {
if (getCurMethodLocked() != null) {
- // TODO(b/322816970): Replace this with lambda.
- mClientController.forAllClients(new Consumer<ClientState>() {
-
- @GuardedBy("ImfLock.class")
- @Override
- public void accept(ClientState c) {
- clearClientSessionLocked(c);
- clearClientSessionForAccessibilityLocked(c);
- }
- });
+ // TODO(b/324907325): Remove the suppress warnings once b/324907325 is fixed.
+ @SuppressWarnings("GuardedBy") Consumer<ClientState> clearClientSession = c -> {
+ clearClientSessionLocked(c);
+ clearClientSessionForAccessibilityLocked(c);
+ };
+ mClientController.forAllClients(clearClientSession);
finishSessionLocked(mEnabledSession);
for (int i = 0; i < mEnabledAccessibilitySessions.size(); i++) {
@@ -4653,15 +4649,7 @@
super.startImeTrace_enforcePermission();
ImeTracing.getInstance().startTrace(null /* printwriter */);
synchronized (ImfLock.class) {
- // TODO(b/322816970): Replace this with lambda.
- mClientController.forAllClients(new Consumer<ClientState>() {
-
- @GuardedBy("ImfLock.class")
- @Override
- public void accept(ClientState c) {
- c.mClient.setImeTraceEnabled(true /* enabled */);
- }
- });
+ mClientController.forAllClients(c -> c.mClient.setImeTraceEnabled(true /* enabled */));
}
}
@@ -4673,15 +4661,7 @@
ImeTracing.getInstance().stopTrace(null /* printwriter */);
synchronized (ImfLock.class) {
- // TODO(b/322816970): Replace this with lambda.
- mClientController.forAllClients(new Consumer<ClientState>() {
-
- @GuardedBy("ImfLock.class")
- @Override
- public void accept(ClientState c) {
- c.mClient.setImeTraceEnabled(false /* enabled */);
- }
- });
+ mClientController.forAllClients(c -> c.mClient.setImeTraceEnabled(false /* enabled */));
}
}
@@ -5916,15 +5896,12 @@
// We only have sessions when we bound to an input method. Remove this session
// from all clients.
if (getCurMethodLocked() != null) {
- // TODO(b/322816970): Replace this with lambda.
- mClientController.forAllClients(new Consumer<ClientState>() {
+ // TODO(b/324907325): Remove the suppress warnings once b/324907325 is fixed.
+ @SuppressWarnings("GuardedBy") Consumer<ClientState> clearClientSession =
+ c -> clearClientSessionForAccessibilityLocked(c,
+ accessibilityConnectionId);
+ mClientController.forAllClients(clearClientSession);
- @GuardedBy("ImfLock.class")
- @Override
- public void accept(ClientState c) {
- clearClientSessionForAccessibilityLocked(c, accessibilityConnectionId);
- }
- });
AccessibilitySessionState session = mEnabledAccessibilitySessions.get(
accessibilityConnectionId);
if (session != null) {
@@ -6126,24 +6103,21 @@
}
// Dump ClientController#mClients
p.println(" ClientStates:");
- // TODO(b/322816970): Replace this with lambda.
- mClientController.forAllClients(new Consumer<ClientState>() {
+ // TODO(b/324907325): Remove the suppress warnings once b/324907325 is fixed.
+ @SuppressWarnings("GuardedBy") Consumer<ClientState> clientControllerDump = c -> {
+ p.println(" " + c + ":");
+ p.println(" client=" + c.mClient);
+ p.println(" fallbackInputConnection="
+ + c.mFallbackInputConnection);
+ p.println(" sessionRequested="
+ + c.mSessionRequested);
+ p.println(
+ " sessionRequestedForAccessibility="
+ + c.mSessionRequestedForAccessibility);
+ p.println(" curSession=" + c.mCurSession);
+ };
+ mClientController.forAllClients(clientControllerDump);
- @GuardedBy("ImfLock.class")
- @Override
- public void accept(ClientState c) {
- p.println(" " + c + ":");
- p.println(" client=" + c.mClient);
- p.println(" fallbackInputConnection="
- + c.mFallbackInputConnection);
- p.println(" sessionRequested="
- + c.mSessionRequested);
- p.println(
- " sessionRequestedForAccessibility="
- + c.mSessionRequestedForAccessibility);
- p.println(" curSession=" + c.mCurSession);
- }
- });
p.println(" mCurMethodId=" + getSelectedMethodIdLocked());
client = mCurClient;
p.println(" mCurClient=" + client + " mCurSeq=" + getSequenceNumberLocked());
diff --git a/services/core/java/com/android/server/media/projection/MediaProjectionManagerService.java b/services/core/java/com/android/server/media/projection/MediaProjectionManagerService.java
index 1546895..bbb19e3 100644
--- a/services/core/java/com/android/server/media/projection/MediaProjectionManagerService.java
+++ b/services/core/java/com/android/server/media/projection/MediaProjectionManagerService.java
@@ -550,8 +550,8 @@
break;
case RECORD_CONTENT_TASK:
IBinder taskWindowContainerToken =
- mProjectionGrant.getLaunchCookieInternal() == null ? null
- : mProjectionGrant.getLaunchCookieInternal().binder;
+ mProjectionGrant.getLaunchCookie() == null ? null
+ : mProjectionGrant.getLaunchCookie().binder;
setReviewedConsentSessionLocked(
ContentRecordingSession.createTaskSession(taskWindowContainerToken));
break;
@@ -603,17 +603,6 @@
return projection;
}
- /**
- * Test API mirroring the types in the aidl interface for access outside the projection
- * package.
- */
- @VisibleForTesting
- public IMediaProjection createProjectionInternal(int processUid, String packageName, int type,
- boolean isPermanentGrant) {
- return createProjectionInternal(processUid, packageName, type, isPermanentGrant,
- Binder.getCallingUserHandle());
- }
-
// TODO(b/261563516): Remove internal method and test aidl directly, here and elsewhere.
@VisibleForTesting
MediaProjection getProjectionInternal(int uid, String packageName) {
@@ -1203,10 +1192,6 @@
@Override // Binder call
public void setLaunchCookie(LaunchCookie launchCookie) {
setLaunchCookie_enforcePermission();
- setLaunchCookieInternal(launchCookie);
- }
-
- @VisibleForTesting void setLaunchCookieInternal(LaunchCookie launchCookie) {
mLaunchCookie = launchCookie;
}
@@ -1214,10 +1199,6 @@
@Override // Binder call
public LaunchCookie getLaunchCookie() {
getLaunchCookie_enforcePermission();
- return getLaunchCookieInternal();
- }
-
- @VisibleForTesting LaunchCookie getLaunchCookieInternal() {
return mLaunchCookie;
}
@@ -1225,11 +1206,6 @@
@Override
public boolean isValid() {
isValid_enforcePermission();
- return isValidInternal();
- }
-
- @VisibleForTesting
- boolean isValidInternal() {
synchronized (mLock) {
final long curMs = mClock.uptimeMillis();
final boolean hasTimedOut = curMs - mCreateTimeMs > mTimeoutMs;
@@ -1260,11 +1236,6 @@
@Override
public void notifyVirtualDisplayCreated(int displayId) {
notifyVirtualDisplayCreated_enforcePermission();
- notifyVirtualDisplayCreatedInternal(displayId);
- }
-
- @VisibleForTesting
- void notifyVirtualDisplayCreatedInternal(int displayId) {
synchronized (mLock) {
mVirtualDisplayId = displayId;
diff --git a/services/core/java/com/android/server/ondeviceintelligence/OWNERS b/services/core/java/com/android/server/ondeviceintelligence/OWNERS
new file mode 100644
index 0000000..09774f7
--- /dev/null
+++ b/services/core/java/com/android/server/ondeviceintelligence/OWNERS
@@ -0,0 +1 @@
+file:/core/java/android/app/ondeviceintelligence/OWNERS
diff --git a/services/core/java/com/android/server/pm/permission/PermissionManagerService.java b/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
index f44fcf0..21e2bf2 100644
--- a/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
+++ b/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
@@ -42,6 +42,7 @@
import android.app.AppOpsManager;
import android.app.AppOpsManager.AttributionFlags;
import android.app.IActivityManager;
+import android.companion.virtual.VirtualDeviceManager;
import android.content.AttributionSource;
import android.content.AttributionSourceState;
import android.content.Context;
@@ -78,6 +79,7 @@
import com.android.internal.util.function.QuadFunction;
import com.android.internal.util.function.TriFunction;
import com.android.server.LocalServices;
+import com.android.server.companion.virtual.VirtualDeviceManagerInternal;
import com.android.server.pm.UserManagerService;
import com.android.server.pm.permission.PermissionManagerServiceInternal.HotwordDetectionServiceProvider;
import com.android.server.pm.pkg.AndroidPackage;
@@ -135,6 +137,9 @@
@Nullable
private HotwordDetectionServiceProvider mHotwordDetectionServiceProvider;
+ @Nullable
+ private VirtualDeviceManagerInternal mVirtualDeviceManagerInternal;
+
PermissionManagerService(@NonNull Context context,
@NonNull ArrayMap<String, FeatureInfo> availableFeatures) {
// The package info cache is the cache for package and permission information.
@@ -146,6 +151,8 @@
mContext = context;
mPackageManagerInt = LocalServices.getService(PackageManagerInternal.class);
mAppOpsManager = context.getSystemService(AppOpsManager.class);
+ mVirtualDeviceManagerInternal =
+ LocalServices.getService(VirtualDeviceManagerInternal.class);
mAttributionSourceRegistry = new AttributionSourceRegistry(context);
@@ -246,16 +253,30 @@
return PackageManager.PERMISSION_DENIED;
}
+ String persistentDeviceId = getPersistentDeviceId(deviceId);
+
final CheckPermissionDelegate checkPermissionDelegate;
synchronized (mLock) {
checkPermissionDelegate = mCheckPermissionDelegate;
}
-
- if (checkPermissionDelegate == null) {
- return mPermissionManagerServiceImpl.checkUidPermission(uid, permissionName, deviceId);
+ if (checkPermissionDelegate == null) {
+ return mPermissionManagerServiceImpl.checkUidPermission(uid, permissionName,
+ persistentDeviceId);
}
return checkPermissionDelegate.checkUidPermission(uid, permissionName,
- deviceId, mPermissionManagerServiceImpl::checkUidPermission);
+ persistentDeviceId, mPermissionManagerServiceImpl::checkUidPermission);
+ }
+
+ private String getPersistentDeviceId(int deviceId) {
+ if (deviceId == Context.DEVICE_ID_DEFAULT) {
+ return VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT;
+ }
+
+ if (mVirtualDeviceManagerInternal == null) {
+ mVirtualDeviceManagerInternal =
+ LocalServices.getService(VirtualDeviceManagerInternal.class);
+ }
+ return mVirtualDeviceManagerInternal.getPersistentIdForDevice(deviceId);
}
@Override
@@ -608,15 +629,17 @@
@Override
public boolean shouldShowRequestPermissionRationale(String packageName, String permissionName,
int deviceId, int userId) {
+ String persistentDeviceId = getPersistentDeviceId(deviceId);
return mPermissionManagerServiceImpl.shouldShowRequestPermissionRationale(packageName,
- permissionName, deviceId, userId);
+ permissionName, persistentDeviceId, userId);
}
@Override
public boolean isPermissionRevokedByPolicy(String packageName, String permissionName,
int deviceId, int userId) {
+ String persistentDeviceId = getPersistentDeviceId(deviceId);
return mPermissionManagerServiceImpl.isPermissionRevokedByPolicy(packageName,
- permissionName, deviceId, userId);
+ permissionName, persistentDeviceId, userId);
}
@Override
@@ -914,13 +937,13 @@
*
* @param uid the UID to be checked
* @param permissionName the name of the permission to be checked
- * @param deviceId The device ID
+ * @param persistentDeviceId The persistent device ID
* @param superImpl the original implementation that can be delegated to
* @return {@link android.content.pm.PackageManager#PERMISSION_GRANTED} if the package has
* the permission, or {@link android.content.pm.PackageManager#PERMISSION_DENIED} otherwise
*/
- int checkUidPermission(int uid, @NonNull String permissionName, int deviceId,
- TriFunction<Integer, String, Integer, Integer> superImpl);
+ int checkUidPermission(int uid, @NonNull String permissionName, String persistentDeviceId,
+ TriFunction<Integer, String, String, Integer> superImpl);
/**
* @return list of delegated permissions
@@ -965,17 +988,18 @@
}
@Override
- public int checkUidPermission(int uid, @NonNull String permissionName, int deviceId,
- @NonNull TriFunction<Integer, String, Integer, Integer> superImpl) {
+ public int checkUidPermission(int uid, @NonNull String permissionName,
+ String persistentDeviceId,
+ @NonNull TriFunction<Integer, String, String, Integer> superImpl) {
if (uid == mDelegatedUid && isDelegatedPermission(permissionName)) {
final long identity = Binder.clearCallingIdentity();
try {
- return superImpl.apply(Process.SHELL_UID, permissionName, deviceId);
+ return superImpl.apply(Process.SHELL_UID, permissionName, persistentDeviceId);
} finally {
Binder.restoreCallingIdentity(identity);
}
}
- return superImpl.apply(uid, permissionName, deviceId);
+ return superImpl.apply(uid, permissionName, persistentDeviceId);
}
@Override
diff --git a/services/core/java/com/android/server/pm/permission/PermissionManagerServiceImpl.java b/services/core/java/com/android/server/pm/permission/PermissionManagerServiceImpl.java
index c5b637d..70913c3 100644
--- a/services/core/java/com/android/server/pm/permission/PermissionManagerServiceImpl.java
+++ b/services/core/java/com/android/server/pm/permission/PermissionManagerServiceImpl.java
@@ -682,7 +682,7 @@
}
@Override
- public int getPermissionFlags(String packageName, String permName, String persistentDeviceId,
+ public int getPermissionFlags(String packageName, String permName, String deviceId,
int userId) {
final int callingUid = Binder.getCallingUid();
return getPermissionFlagsInternal(packageName, permName, callingUid, userId);
@@ -726,8 +726,7 @@
@Override
public void updatePermissionFlags(String packageName, String permName, int flagMask,
- int flagValues, boolean checkAdjustPolicyFlagPermission, String persistentDeviceId,
- int userId) {
+ int flagValues, boolean checkAdjustPolicyFlagPermission, String deviceId, int userId) {
final int callingUid = Binder.getCallingUid();
boolean overridePolicy = false;
@@ -917,8 +916,7 @@
}
@Override
- public int checkPermission(String pkgName, String permName, String persistentDeviceId,
- int userId) {
+ public int checkPermission(String pkgName, String permName, String deviceId, int userId) {
if (!mUserManagerInt.exists(userId)) {
return PackageManager.PERMISSION_DENIED;
}
@@ -985,11 +983,11 @@
}
private int checkUidPermission(int uid, String permName) {
- return checkUidPermission(uid, permName, Context.DEVICE_ID_DEFAULT);
+ return checkUidPermission(uid, permName, VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT);
}
@Override
- public int checkUidPermission(int uid, String permName, int deviceId) {
+ public int checkUidPermission(int uid, String permName, String deviceId) {
final int userId = UserHandle.getUserId(uid);
if (!mUserManagerInt.exists(userId)) {
return PackageManager.PERMISSION_DENIED;
@@ -1001,7 +999,7 @@
@Override
public Map<String, PermissionManager.PermissionState> getAllPermissionStates(
- @NonNull String packageName, @NonNull String persistentDeviceId, int userId) {
+ @NonNull String packageName, @NonNull String deviceId, int userId) {
throw new UnsupportedOperationException(
"This method is supported in newer implementation only");
}
@@ -1315,8 +1313,8 @@
}
@Override
- public void grantRuntimePermission(String packageName, String permName,
- String persistentDeviceId, int userId) {
+ public void grantRuntimePermission(String packageName, String permName, String deviceId,
+ int userId) {
final int callingUid = Binder.getCallingUid();
final boolean overridePolicy =
checkUidPermission(callingUid, ADJUST_RUNTIME_PERMISSIONS_POLICY)
@@ -1489,12 +1487,13 @@
}
@Override
- public void revokeRuntimePermission(String packageName, String permName,
- String persistentDeviceId, int userId, String reason) {
+ public void revokeRuntimePermission(String packageName, String permName, String deviceId,
+ int userId, String reason) {
final int callingUid = Binder.getCallingUid();
final boolean overridePolicy =
checkUidPermission(callingUid, ADJUST_RUNTIME_PERMISSIONS_POLICY,
- Context.DEVICE_ID_DEFAULT) == PackageManager.PERMISSION_GRANTED;
+ VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT)
+ == PackageManager.PERMISSION_GRANTED;
revokeRuntimePermissionInternal(packageName, permName, overridePolicy, callingUid, userId,
reason, mDefaultPermissionCallback);
@@ -1880,7 +1879,7 @@
@Override
public boolean shouldShowRequestPermissionRationale(String packageName, String permName,
- int deviceId, @UserIdInt int userId) {
+ String deviceId, @UserIdInt int userId) {
final int callingUid = Binder.getCallingUid();
if (UserHandle.getCallingUserId() != userId) {
mContext.enforceCallingPermission(
@@ -1943,7 +1942,7 @@
}
@Override
- public boolean isPermissionRevokedByPolicy(String packageName, String permName, int deviceId,
+ public boolean isPermissionRevokedByPolicy(String packageName, String permName, String deviceId,
int userId) {
if (UserHandle.getCallingUserId() != userId) {
mContext.enforceCallingPermission(
diff --git a/services/core/java/com/android/server/pm/permission/PermissionManagerServiceInterface.java b/services/core/java/com/android/server/pm/permission/PermissionManagerServiceInterface.java
index 7c10425..47032ea 100644
--- a/services/core/java/com/android/server/pm/permission/PermissionManagerServiceInterface.java
+++ b/services/core/java/com/android/server/pm/permission/PermissionManagerServiceInterface.java
@@ -141,11 +141,11 @@
*
* @param packageName the package name for which to get the flags
* @param permName the permission for which to get the flags
- * @param persistentDeviceId The device for which to get the flags
+ * @param deviceId The device for which to get the flags
* @param userId the user for which to get permission flags
* @return the permission flags
*/
- int getPermissionFlags(String packageName, String permName, String persistentDeviceId,
+ int getPermissionFlags(String packageName, String permName, String deviceId,
@UserIdInt int userId);
/**
@@ -156,11 +156,11 @@
* @param permName The permission for which to update the flags
* @param flagMask The flags which to replace
* @param flagValues The flags with which to replace
- * @param persistentDeviceId The device for which to update the permission flags
+ * @param deviceId The device for which to update the permission flags
* @param userId The user for which to update the permission flags
*/
void updatePermissionFlags(String packageName, String permName, int flagMask, int flagValues,
- boolean checkAdjustPolicyFlagPermission, String persistentDeviceId,
+ boolean checkAdjustPolicyFlagPermission, String deviceId,
@UserIdInt int userId);
/**
@@ -295,12 +295,12 @@
*
* @param packageName the package to which to grant the permission
* @param permName the permission name to grant
- * @param persistentDeviceId the device for which to grant the permission
+ * @param deviceId the device for which to grant the permission
* @param userId the user for which to grant the permission
*
* @see #revokeRuntimePermission(String, String, String, int, String)
*/
- void grantRuntimePermission(String packageName, String permName, String persistentDeviceId,
+ void grantRuntimePermission(String packageName, String permName, String deviceId,
@UserIdInt int userId);
/**
@@ -316,13 +316,13 @@
*
* @param packageName the package from which to revoke the permission
* @param permName the permission name to revoke
- * @param persistentDeviceId the device for which to revoke the permission
+ * @param deviceId the device for which to revoke the permission
* @param userId the user for which to revoke the permission
* @param reason the reason for the revoke, or {@code null} for unspecified
*
* @see #grantRuntimePermission(String, String, String, int)
*/
- void revokeRuntimePermission(String packageName, String permName, String persistentDeviceId,
+ void revokeRuntimePermission(String packageName, String permName, String deviceId,
@UserIdInt int userId, String reason);
/**
@@ -347,7 +347,7 @@
* @return whether you can show permission rationale UI
*/
boolean shouldShowRequestPermissionRationale(String packageName, String permName,
- int deviceId, @UserIdInt int userId);
+ String deviceId, @UserIdInt int userId);
/**
* Checks whether a particular permission has been revoked for a package by policy. Typically,
@@ -361,8 +361,8 @@
* @param userId the device for which you are checking the permission
* @return whether the permission is restricted by policy
*/
- boolean isPermissionRevokedByPolicy(String packageName, String permName, int deviceId,
- @UserIdInt int userId);
+ boolean isPermissionRevokedByPolicy(String packageName, String permName,
+ String deviceId, @UserIdInt int userId);
/**
* Get set of permissions that have been split into more granular or dependent permissions.
@@ -389,11 +389,11 @@
*
* @param pkgName package name
* @param permName permission name
- * @param persistentDeviceId persistent device ID
+ * @param deviceId persistent device ID
* @param userId user ID
* @return permission result {@link PackageManager.PermissionResult}
*/
- int checkPermission(String pkgName, String permName, String persistentDeviceId,
+ int checkPermission(String pkgName, String permName, String deviceId,
@UserIdInt int userId);
/**
@@ -401,23 +401,23 @@
*
* @param uid UID
* @param permName permission name
- * @param deviceId device ID
+ * @param deviceId persistent device ID
* @return permission result {@link PackageManager.PermissionResult}
*/
- int checkUidPermission(int uid, String permName, int deviceId);
+ int checkUidPermission(int uid, String permName, String deviceId);
/**
* Gets the permission states for requested package, persistent device and user.
*
* @param packageName name of the package you are checking against
- * @param persistentDeviceId id of the persistent device you are checking against
+ * @param deviceId id of the persistent device you are checking against
* @param userId id of the user for which to get permission flags
* @return mapping of all permission states keyed by their permission names
*
* @hide
*/
Map<String, PermissionState> getAllPermissionStates(@NonNull String packageName,
- @NonNull String persistentDeviceId, @UserIdInt int userId);
+ @NonNull String deviceId, @UserIdInt int userId);
/**
* Get all the package names requesting app op permissions.
diff --git a/services/core/java/com/android/server/pm/permission/PermissionManagerServiceLoggingDecorator.java b/services/core/java/com/android/server/pm/permission/PermissionManagerServiceLoggingDecorator.java
index 91a778d..c18f856 100644
--- a/services/core/java/com/android/server/pm/permission/PermissionManagerServiceLoggingDecorator.java
+++ b/services/core/java/com/android/server/pm/permission/PermissionManagerServiceLoggingDecorator.java
@@ -121,24 +121,22 @@
}
@Override
- public int getPermissionFlags(String packageName, String permName, String persistentDeviceId,
+ public int getPermissionFlags(String packageName, String permName, String deviceId,
int userId) {
Log.i(LOG_TAG, "getPermissionFlags(packageName = " + packageName + ", permName = "
- + permName + ", persistentDeviceId = " + persistentDeviceId + ", userId = " + userId
- + ")");
- return mService.getPermissionFlags(packageName, permName, persistentDeviceId, userId);
+ + permName + ", deviceId = " + deviceId + ", userId = " + userId + ")");
+ return mService.getPermissionFlags(packageName, permName, deviceId, userId);
}
@Override
public void updatePermissionFlags(String packageName, String permName, int flagMask,
- int flagValues, boolean checkAdjustPolicyFlagPermission, String persistentDeviceId,
- int userId) {
+ int flagValues, boolean checkAdjustPolicyFlagPermission, String deviceId, int userId) {
Log.i(LOG_TAG, "updatePermissionFlags(packageName = " + packageName + ", permName = "
+ permName + ", flagMask = " + flagMask + ", flagValues = " + flagValues
+ ", checkAdjustPolicyFlagPermission = " + checkAdjustPolicyFlagPermission
- + ", persistentDeviceId = " + persistentDeviceId + ", userId = " + userId + ")");
+ + ", deviceId = " + deviceId + ", userId = " + userId + ")");
mService.updatePermissionFlags(packageName, permName, flagMask, flagValues,
- checkAdjustPolicyFlagPermission, persistentDeviceId, userId);
+ checkAdjustPolicyFlagPermission, deviceId, userId);
}
@Override
@@ -186,21 +184,20 @@
}
@Override
- public void grantRuntimePermission(String packageName, String permName,
- String persistentDeviceId, int userId) {
+ public void grantRuntimePermission(String packageName, String permName, String deviceId,
+ int userId) {
Log.i(LOG_TAG, "grantRuntimePermission(packageName = " + packageName + ", permName = "
- + permName + ", persistentDeviceId = " + persistentDeviceId + ", userId = " + userId
- + ")");
- mService.grantRuntimePermission(packageName, permName, persistentDeviceId, userId);
+ + permName + ", deviceId = " + deviceId + ", userId = " + userId + ")");
+ mService.grantRuntimePermission(packageName, permName, deviceId, userId);
}
@Override
- public void revokeRuntimePermission(String packageName, String permName,
- String persistentDeviceId, int userId, String reason) {
+ public void revokeRuntimePermission(String packageName, String permName, String deviceId,
+ int userId, String reason) {
Log.i(LOG_TAG, "revokeRuntimePermission(packageName = " + packageName + ", permName = "
- + permName + ", persistentDeviceId = " + persistentDeviceId + ", userId = " + userId
- + ", reason = " + reason + ")");
- mService.revokeRuntimePermission(packageName, permName, persistentDeviceId, userId, reason);
+ + permName + ", deviceId = " + deviceId + ", userId = " + userId + ", reason = "
+ + reason + ")");
+ mService.revokeRuntimePermission(packageName, permName, deviceId, userId, reason);
}
@Override
@@ -212,16 +209,16 @@
@Override
public boolean shouldShowRequestPermissionRationale(String packageName, String permName,
- int deviceId, int userId) {
+ String deviceId, int userId) {
Log.i(LOG_TAG, "shouldShowRequestPermissionRationale(packageName = " + packageName
- + ", permName = " + permName + ", deviceId = " + deviceId
- + ", userId = " + userId + ")");
+ + ", permName = " + permName + ", deviceId = " + deviceId + ", userId = "
+ + userId + ")");
return mService.shouldShowRequestPermissionRationale(packageName, permName, deviceId,
userId);
}
@Override
- public boolean isPermissionRevokedByPolicy(String packageName, String permName, int deviceId,
+ public boolean isPermissionRevokedByPolicy(String packageName, String permName, String deviceId,
int userId) {
Log.i(LOG_TAG, "isPermissionRevokedByPolicy(packageName = " + packageName + ", permName = "
+ permName + ", deviceId = " + deviceId + ", userId = " + userId + ")");
@@ -235,26 +232,27 @@
}
@Override
- public int checkPermission(String pkgName, String permName, String persistentDeviceId,
+ public int checkPermission(String pkgName, String permName, String deviceId,
int userId) {
Log.i(LOG_TAG, "checkPermission(pkgName = " + pkgName + ", permName = " + permName
- + ", persistentDeviceId = " + persistentDeviceId + ", userId = " + userId + ")");
- return mService.checkPermission(pkgName, permName, persistentDeviceId, userId);
+ + ", deviceId = " + deviceId + ", userId = " + userId + ")");
+ return mService.checkPermission(pkgName, permName, deviceId, userId);
}
@Override
- public int checkUidPermission(int uid, String permName, int deviceId) {
- Log.i(LOG_TAG, "checkUidPermission(uid = " + uid + ", permName = "
- + permName + ", deviceId = " + deviceId + ")");
+ public int checkUidPermission(int uid, String permName, String deviceId) {
+ Log.i(LOG_TAG, "checkUidPermission(uid = " + uid + ", permName = " + permName
+ + ", deviceId = " + deviceId + ")");
return mService.checkUidPermission(uid, permName, deviceId);
}
@Override
public Map<String, PermissionState> getAllPermissionStates(@NonNull String packageName,
- @NonNull String persistentDeviceId, int userId) {
- Log.i(LOG_TAG, "getAllPermissionStates(packageName = " + packageName
- + ", persistentDeviceId = " + persistentDeviceId + ", userId = " + userId + ")");
- return mService.getAllPermissionStates(packageName, persistentDeviceId, userId);
+ @NonNull String deviceId, int userId) {
+ Log.i(LOG_TAG,
+ "getAllPermissionStates(packageName = " + packageName + ", deviceId = " + deviceId
+ + ", userId = " + userId + ")");
+ return mService.getAllPermissionStates(packageName, deviceId, userId);
}
@Override
diff --git a/services/core/java/com/android/server/pm/permission/PermissionManagerServiceTestingShim.java b/services/core/java/com/android/server/pm/permission/PermissionManagerServiceTestingShim.java
index 0a4ff07..40139ba 100644
--- a/services/core/java/com/android/server/pm/permission/PermissionManagerServiceTestingShim.java
+++ b/services/core/java/com/android/server/pm/permission/PermissionManagerServiceTestingShim.java
@@ -154,12 +154,10 @@
}
@Override
- public int getPermissionFlags(String packageName, String permName, String persistentDeviceId,
+ public int getPermissionFlags(String packageName, String permName, String deviceId,
@UserIdInt int userId) {
- int oldVal = mOldImplementation.getPermissionFlags(packageName, permName,
- persistentDeviceId, userId);
- int newVal = mNewImplementation.getPermissionFlags(packageName, permName,
- persistentDeviceId, userId);
+ int oldVal = mOldImplementation.getPermissionFlags(packageName, permName, deviceId, userId);
+ int newVal = mNewImplementation.getPermissionFlags(packageName, permName, deviceId, userId);
if (!Objects.equals(oldVal, newVal)) {
signalImplDifference("getPermissionFlags");
@@ -169,12 +167,12 @@
@Override
public void updatePermissionFlags(String packageName, String permName, int flagMask,
- int flagValues, boolean checkAdjustPolicyFlagPermission, String persistentDeviceId,
+ int flagValues, boolean checkAdjustPolicyFlagPermission, String deviceId,
@UserIdInt int userId) {
mOldImplementation.updatePermissionFlags(packageName, permName, flagMask, flagValues,
- checkAdjustPolicyFlagPermission, persistentDeviceId, userId);
+ checkAdjustPolicyFlagPermission, deviceId, userId);
mNewImplementation.updatePermissionFlags(packageName, permName, flagMask, flagValues,
- checkAdjustPolicyFlagPermission, persistentDeviceId, userId);
+ checkAdjustPolicyFlagPermission, deviceId, userId);
}
@Override
@@ -239,21 +237,17 @@
}
@Override
- public void grantRuntimePermission(String packageName, String permName,
- String persistentDeviceId, @UserIdInt int userId) {
- mOldImplementation.grantRuntimePermission(packageName, permName, persistentDeviceId,
- userId);
- mNewImplementation.grantRuntimePermission(packageName, permName, persistentDeviceId,
- userId);
+ public void grantRuntimePermission(String packageName, String permName, String deviceId,
+ @UserIdInt int userId) {
+ mOldImplementation.grantRuntimePermission(packageName, permName, deviceId, userId);
+ mNewImplementation.grantRuntimePermission(packageName, permName, deviceId, userId);
}
@Override
- public void revokeRuntimePermission(String packageName, String permName,
- String persistentDeviceId, @UserIdInt int userId, String reason) {
- mOldImplementation.revokeRuntimePermission(packageName, permName, persistentDeviceId,
- userId, reason);
- mNewImplementation.revokeRuntimePermission(packageName, permName, persistentDeviceId,
- userId, reason);
+ public void revokeRuntimePermission(String packageName, String permName, String deviceId,
+ @UserIdInt int userId, String reason) {
+ mOldImplementation.revokeRuntimePermission(packageName, permName, deviceId, userId, reason);
+ mNewImplementation.revokeRuntimePermission(packageName, permName, deviceId, userId, reason);
}
@Override
@@ -265,7 +259,7 @@
@Override
public boolean shouldShowRequestPermissionRationale(String packageName, String permName,
- int deviceId, @UserIdInt int userId) {
+ String deviceId, @UserIdInt int userId) {
boolean oldVal = mOldImplementation.shouldShowRequestPermissionRationale(packageName,
permName, deviceId, userId);
boolean newVal = mNewImplementation.shouldShowRequestPermissionRationale(packageName,
@@ -278,7 +272,7 @@
}
@Override
- public boolean isPermissionRevokedByPolicy(String packageName, String permName, int deviceId,
+ public boolean isPermissionRevokedByPolicy(String packageName, String permName, String deviceId,
@UserIdInt int userId) {
boolean oldVal = mOldImplementation.isPermissionRevokedByPolicy(packageName, permName,
deviceId, userId);
@@ -303,12 +297,9 @@
}
@Override
- public int checkPermission(String pkgName, String permName, String persistentDeviceId,
- int userId) {
- int oldVal = mOldImplementation.checkPermission(pkgName, permName, persistentDeviceId,
- userId);
- int newVal = mNewImplementation.checkPermission(pkgName, permName, persistentDeviceId,
- userId);
+ public int checkPermission(String pkgName, String permName, String deviceId, int userId) {
+ int oldVal = mOldImplementation.checkPermission(pkgName, permName, deviceId, userId);
+ int newVal = mNewImplementation.checkPermission(pkgName, permName, deviceId, userId);
if (!Objects.equals(oldVal, newVal)) {
signalImplDifference("checkPermission");
@@ -317,7 +308,7 @@
}
@Override
- public int checkUidPermission(int uid, String permName, int deviceId) {
+ public int checkUidPermission(int uid, String permName, String deviceId) {
int oldVal = mOldImplementation.checkUidPermission(uid, permName, deviceId);
int newVal = mNewImplementation.checkUidPermission(uid, permName, deviceId);
@@ -329,8 +320,8 @@
@Override
public Map<String, PermissionState> getAllPermissionStates(@NonNull String packageName,
- @NonNull String persistentDeviceId, int userId) {
- return mNewImplementation.getAllPermissionStates(packageName, persistentDeviceId, userId);
+ @NonNull String deviceId, int userId) {
+ return mNewImplementation.getAllPermissionStates(packageName, deviceId, userId);
}
@Override
diff --git a/services/core/java/com/android/server/pm/permission/PermissionManagerServiceTracingDecorator.java b/services/core/java/com/android/server/pm/permission/PermissionManagerServiceTracingDecorator.java
index bc29e67..981d3d9 100644
--- a/services/core/java/com/android/server/pm/permission/PermissionManagerServiceTracingDecorator.java
+++ b/services/core/java/com/android/server/pm/permission/PermissionManagerServiceTracingDecorator.java
@@ -159,11 +159,11 @@
}
@Override
- public int getPermissionFlags(String packageName, String permName, String persistentDeviceId,
+ public int getPermissionFlags(String packageName, String permName, String deviceId,
int userId) {
Trace.traceBegin(TRACE_TAG, "TaggedTracingPermissionManagerServiceImpl#getPermissionFlags");
try {
- return mService.getPermissionFlags(packageName, permName, persistentDeviceId, userId);
+ return mService.getPermissionFlags(packageName, permName, deviceId, userId);
} finally {
Trace.traceEnd(TRACE_TAG);
}
@@ -171,13 +171,12 @@
@Override
public void updatePermissionFlags(String packageName, String permName, int flagMask,
- int flagValues, boolean checkAdjustPolicyFlagPermission, String persistentDeviceId,
- int userId) {
+ int flagValues, boolean checkAdjustPolicyFlagPermission, String deviceId, int userId) {
Trace.traceBegin(TRACE_TAG,
"TaggedTracingPermissionManagerServiceImpl#updatePermissionFlags");
try {
mService.updatePermissionFlags(packageName, permName, flagMask, flagValues,
- checkAdjustPolicyFlagPermission, persistentDeviceId, userId);
+ checkAdjustPolicyFlagPermission, deviceId, userId);
} finally {
Trace.traceEnd(TRACE_TAG);
}
@@ -256,25 +255,24 @@
}
@Override
- public void grantRuntimePermission(String packageName, String permName,
- String persistentDeviceId, int userId) {
+ public void grantRuntimePermission(String packageName, String permName, String deviceId,
+ int userId) {
Trace.traceBegin(TRACE_TAG,
"TaggedTracingPermissionManagerServiceImpl#grantRuntimePermission");
try {
- mService.grantRuntimePermission(packageName, permName, persistentDeviceId, userId);
+ mService.grantRuntimePermission(packageName, permName, deviceId, userId);
} finally {
Trace.traceEnd(TRACE_TAG);
}
}
@Override
- public void revokeRuntimePermission(String packageName, String permName,
- String persistentDeviceId, int userId, String reason) {
+ public void revokeRuntimePermission(String packageName, String permName, String deviceId,
+ int userId, String reason) {
Trace.traceBegin(TRACE_TAG,
"TaggedTracingPermissionManagerServiceImpl#revokeRuntimePermission");
try {
- mService.revokeRuntimePermission(packageName, permName, persistentDeviceId, userId,
- reason);
+ mService.revokeRuntimePermission(packageName, permName, deviceId, userId, reason);
} finally {
Trace.traceEnd(TRACE_TAG);
}
@@ -293,19 +291,19 @@
@Override
public boolean shouldShowRequestPermissionRationale(String packageName, String permName,
- int deviceId, int userId) {
+ String deviceId, int userId) {
Trace.traceBegin(TRACE_TAG,
"TaggedTracingPermissionManagerServiceImpl#shouldShowRequestPermissionRationale");
try {
- return mService.shouldShowRequestPermissionRationale(
- packageName, permName, deviceId, userId);
+ return mService.shouldShowRequestPermissionRationale(packageName, permName, deviceId,
+ userId);
} finally {
Trace.traceEnd(TRACE_TAG);
}
}
@Override
- public boolean isPermissionRevokedByPolicy(String packageName, String permName, int deviceId,
+ public boolean isPermissionRevokedByPolicy(String packageName, String permName, String deviceId,
int userId) {
Trace.traceBegin(TRACE_TAG,
"TaggedTracingPermissionManagerServiceImpl#isPermissionRevokedByPolicy");
@@ -328,18 +326,17 @@
}
@Override
- public int checkPermission(String pkgName, String permName, String persistentDeviceId,
- int userId) {
+ public int checkPermission(String pkgName, String permName, String deviceId, int userId) {
Trace.traceBegin(TRACE_TAG, "TaggedTracingPermissionManagerServiceImpl#checkPermission");
try {
- return mService.checkPermission(pkgName, permName, persistentDeviceId, userId);
+ return mService.checkPermission(pkgName, permName, deviceId, userId);
} finally {
Trace.traceEnd(TRACE_TAG);
}
}
@Override
- public int checkUidPermission(int uid, String permName, int deviceId) {
+ public int checkUidPermission(int uid, String permName, String deviceId) {
Trace.traceBegin(TRACE_TAG, "TaggedTracingPermissionManagerServiceImpl#checkUidPermission");
try {
return mService.checkUidPermission(uid, permName, deviceId);
@@ -350,11 +347,11 @@
@Override
public Map<String, PermissionState> getAllPermissionStates(@NonNull String packageName,
- @NonNull String persistentDeviceId, int userId) {
+ @NonNull String deviceId, int userId) {
Trace.traceBegin(TRACE_TAG, "TaggedTracingPermissionManagerServiceImpl"
+ "#getAllPermissionStates");
try {
- return mService.getAllPermissionStates(packageName, persistentDeviceId, userId);
+ return mService.getAllPermissionStates(packageName, deviceId, userId);
} finally {
Trace.traceEnd(TRACE_TAG);
}
diff --git a/services/core/java/com/android/server/wm/ActivitySecurityModelFeatureFlags.java b/services/core/java/com/android/server/wm/ActivitySecurityModelFeatureFlags.java
index db27f60..01d077a 100644
--- a/services/core/java/com/android/server/wm/ActivitySecurityModelFeatureFlags.java
+++ b/services/core/java/com/android/server/wm/ActivitySecurityModelFeatureFlags.java
@@ -22,12 +22,10 @@
import android.annotation.NonNull;
import android.app.compat.CompatChanges;
-import android.content.pm.PackageManager;
import android.provider.DeviceConfig;
import com.android.internal.annotations.GuardedBy;
-import java.util.HashSet;
import java.util.concurrent.Executor;
/**
@@ -50,74 +48,49 @@
private static final String KEY_ASM_RESTRICTIONS_ENABLED = KEY_ASM_PREFIX
+ "asm_restrictions_enabled";
private static final String KEY_ASM_TOASTS_ENABLED = KEY_ASM_PREFIX + "asm_toasts_enabled";
- private static final String KEY_ASM_EXEMPTED_PACKAGES = KEY_ASM_PREFIX
- + "asm_exempted_packages";
+
private static final int VALUE_DISABLE = 0;
private static final int VALUE_ENABLE_FOR_V = 1;
private static final int VALUE_ENABLE_FOR_ALL = 2;
private static final int DEFAULT_VALUE = VALUE_DISABLE;
- private static final String DEFAULT_EXCEPTION_LIST = "";
private static int sAsmToastsEnabled;
private static int sAsmRestrictionsEnabled;
- private static final HashSet<String> sExcludedPackageNames = new HashSet<>();
- private static PackageManager sPm;
@GuardedBy("ActivityTaskManagerService.mGlobalLock")
- static void initialize(@NonNull Executor executor, @NonNull PackageManager pm) {
+ static void initialize(@NonNull Executor executor) {
updateFromDeviceConfig();
DeviceConfig.addOnPropertiesChangedListener(NAMESPACE, executor,
properties -> updateFromDeviceConfig());
- sPm = pm;
}
@GuardedBy("ActivityTaskManagerService.mGlobalLock")
static boolean shouldShowToast(int uid) {
- return flagEnabledForUid(sAsmToastsEnabled, uid);
+ return sAsmToastsEnabled == VALUE_ENABLE_FOR_ALL
+ || (sAsmToastsEnabled == VALUE_ENABLE_FOR_V
+ && CompatChanges.isChangeEnabled(ASM_RESTRICTIONS, uid));
}
@GuardedBy("ActivityTaskManagerService.mGlobalLock")
static boolean shouldRestrictActivitySwitch(int uid) {
- return flagEnabledForUid(sAsmRestrictionsEnabled, uid);
- }
-
- private static boolean flagEnabledForUid(int flag, int uid) {
- boolean flagEnabled = flag == VALUE_ENABLE_FOR_ALL
- || (flag == VALUE_ENABLE_FOR_V
- && CompatChanges.isChangeEnabled(ASM_RESTRICTIONS, uid));
-
- if (flagEnabled) {
- String[] packageNames = sPm.getPackagesForUid(uid);
- if (packageNames == null) {
- return true;
- }
- for (int i = 0; i < packageNames.length; i++) {
- if (sExcludedPackageNames.contains(packageNames[i])) {
- return false;
- }
- }
- return true;
+ if (android.security.Flags.asmRestrictionsEnabled()) {
+ return CompatChanges.isChangeEnabled(ASM_RESTRICTIONS, uid)
+ || asmRestrictionsEnabledForAll();
}
return false;
}
+ @GuardedBy("ActivityTaskManagerService.mGlobalLock")
+ static boolean asmRestrictionsEnabledForAll() {
+ return sAsmRestrictionsEnabled == VALUE_ENABLE_FOR_ALL;
+ }
+
private static void updateFromDeviceConfig() {
sAsmToastsEnabled = DeviceConfig.getInt(NAMESPACE, KEY_ASM_TOASTS_ENABLED,
DEFAULT_VALUE);
sAsmRestrictionsEnabled = DeviceConfig.getInt(NAMESPACE, KEY_ASM_RESTRICTIONS_ENABLED,
DEFAULT_VALUE);
-
- String rawExceptionList = DeviceConfig.getString(NAMESPACE,
- KEY_ASM_EXEMPTED_PACKAGES, DEFAULT_EXCEPTION_LIST);
- sExcludedPackageNames.clear();
- String[] packages = rawExceptionList.split(",");
- for (String packageName : packages) {
- String packageNameTrimmed = packageName.trim();
- if (!packageNameTrimmed.isEmpty()) {
- sExcludedPackageNames.add(packageNameTrimmed);
- }
- }
}
}
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
index 0e6c06d..445295a 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@@ -881,7 +881,7 @@
mTaskSupervisor.onSystemReady();
mActivityClientController.onSystemReady();
// TODO(b/258792202) Cleanup once ASM is ready to launch
- ActivitySecurityModelFeatureFlags.initialize(mContext.getMainExecutor(), pm);
+ ActivitySecurityModelFeatureFlags.initialize(mContext.getMainExecutor());
mGrammaticalManagerInternal = LocalServices.getService(
GrammaticalInflectionManagerInternal.class);
}
diff --git a/services/core/java/com/android/server/wm/BackgroundActivityStartController.java b/services/core/java/com/android/server/wm/BackgroundActivityStartController.java
index 2d6f03a..3bc5319 100644
--- a/services/core/java/com/android/server/wm/BackgroundActivityStartController.java
+++ b/services/core/java/com/android/server/wm/BackgroundActivityStartController.java
@@ -56,6 +56,7 @@
import android.compat.annotation.EnabledAfter;
import android.content.ComponentName;
import android.content.Intent;
+import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Process;
import android.os.SystemClock;
@@ -529,6 +530,9 @@
static final BalVerdict BLOCK = new BalVerdict(BAL_BLOCK, false, "Blocked");
static final BalVerdict ALLOW_BY_DEFAULT =
new BalVerdict(BAL_ALLOW_DEFAULT, false, "Default");
+ // Careful using this - it will bypass all ASM checks.
+ static final BalVerdict ALLOW_PRIVILEGED =
+ new BalVerdict(BAL_ALLOW_ALLOWLISTED_UID, false, "PRIVILEGED");
private final @BalCode int mCode;
private final boolean mBackground;
private final String mMessage;
@@ -1234,7 +1238,8 @@
boolean shouldBlockActivityStart = ActivitySecurityModelFeatureFlags
.shouldRestrictActivitySwitch(callingUid);
int[] finishCount = new int[0];
- if (shouldBlockActivityStart) {
+ if (shouldBlockActivityStart
+ && blockCrossUidActivitySwitchFromBelowForActivity(targetTaskTop)) {
ActivityRecord activity = targetTask.getActivity(isLaunchingOrLaunched);
if (activity == null) {
// mStartActivity is not in task, so clear everything
@@ -1319,7 +1324,7 @@
boolean restrictActivitySwitch = ActivitySecurityModelFeatureFlags
.shouldRestrictActivitySwitch(callingUid)
- && bas.mBlockActivityStartIfFlagEnabled;
+ && bas.mBlockActivityStartIfFlagEnabled;
PackageManager pm = mService.mContext.getPackageManager();
String callingPackage = pm.getNameForUid(callingUid);
@@ -1373,19 +1378,19 @@
int uid, @Nullable ActivityRecord sourceRecord) {
// If the source is visible, consider it 'top'.
if (sourceRecord != null && sourceRecord.isVisibleRequested()) {
- return new BlockActivityStart(false, false);
+ return BlockActivityStart.ACTIVITY_START_ALLOWED;
}
// Always allow actual top activity to clear task
ActivityRecord topActivity = task.getTopMostActivity();
if (topActivity != null && topActivity.isUid(uid)) {
- return new BlockActivityStart(false, false);
+ return BlockActivityStart.ACTIVITY_START_ALLOWED;
}
// If UID is visible in target task, allow launch
if (task.forAllActivities((Predicate<ActivityRecord>)
ar -> ar.isUid(uid) && ar.isVisibleRequested())) {
- return new BlockActivityStart(false, false);
+ return BlockActivityStart.ACTIVITY_START_ALLOWED;
}
// Consider the source activity, whether or not it is finishing. Do not consider any other
@@ -1452,12 +1457,11 @@
private BlockActivityStart blockCrossUidActivitySwitchFromBelow(ActivityRecord ar,
int sourceUid) {
if (ar.isUid(sourceUid)) {
- return new BlockActivityStart(false, false);
+ return BlockActivityStart.ACTIVITY_START_ALLOWED;
}
- // If mAllowCrossUidActivitySwitchFromBelow is set, honor it.
- if (ar.mAllowCrossUidActivitySwitchFromBelow) {
- return new BlockActivityStart(false, false);
+ if (!blockCrossUidActivitySwitchFromBelowForActivity(ar)) {
+ return BlockActivityStart.ACTIVITY_START_ALLOWED;
}
// At this point, we would block if the feature is launched and both apps were V+
@@ -1468,8 +1472,11 @@
ActivitySecurityModelFeatureFlags.shouldRestrictActivitySwitch(ar.getUid())
&& ActivitySecurityModelFeatureFlags
.shouldRestrictActivitySwitch(sourceUid);
- return new BackgroundActivityStartController
- .BlockActivityStart(restrictActivitySwitch, true);
+ if (restrictActivitySwitch) {
+ return BlockActivityStart.BLOCK;
+ } else {
+ return BlockActivityStart.LOG_ONLY;
+ }
}
/**
@@ -1675,14 +1682,52 @@
}
}
- static class BlockActivityStart {
+ /**
+ * Activity level allowCrossUidActivitySwitchFromBelow defaults to false.
+ * Package level defaults to true.
+ * We block the launch if dev has explicitly set package level to false, and activity level has
+ * not opted out
+ */
+ private boolean blockCrossUidActivitySwitchFromBelowForActivity(@NonNull ActivityRecord ar) {
+ // We don't need to check package level if activity has opted out.
+ if (ar.mAllowCrossUidActivitySwitchFromBelow) {
+ return false;
+ }
+
+ if (ActivitySecurityModelFeatureFlags.asmRestrictionsEnabledForAll()) {
+ return true;
+ }
+
+ String packageName = ar.packageName;
+ if (packageName == null) {
+ return false;
+ }
+
+ PackageManager pm = mService.mContext.getPackageManager();
+ ApplicationInfo applicationInfo;
+
+ try {
+ applicationInfo = pm.getApplicationInfo(packageName, 0);
+ } catch (PackageManager.NameNotFoundException e) {
+ Slog.wtf(TAG, "Package name: " + packageName + " not found.");
+ return false;
+ }
+
+ return !applicationInfo.allowCrossUidActivitySwitchFromBelow;
+ }
+
+ private static class BlockActivityStart {
+ private static final BlockActivityStart ACTIVITY_START_ALLOWED =
+ new BlockActivityStart(false, false);
+ private static final BlockActivityStart LOG_ONLY = new BlockActivityStart(false, true);
+ private static final BlockActivityStart BLOCK = new BlockActivityStart(true, true);
// We should block if feature flag is enabled
private final boolean mBlockActivityStartIfFlagEnabled;
// Used for logging/toasts. Would we block if target sdk was V and feature was
// enabled?
private final boolean mWouldBlockActivityStartIgnoringFlag;
- BlockActivityStart(boolean shouldBlockActivityStart,
+ private BlockActivityStart(boolean shouldBlockActivityStart,
boolean wouldBlockActivityStartIgnoringFlags) {
this.mBlockActivityStartIfFlagEnabled = shouldBlockActivityStart;
this.mWouldBlockActivityStartIgnoringFlag = wouldBlockActivityStartIgnoringFlags;
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index 25a5fca..e743172 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -6783,14 +6783,6 @@
return mSandboxDisplayApis;
}
- /**
- * For testing only; inject a ContentRecorder instance.
- */
- @VisibleForTesting
- void setContentRecorder(ContentRecorder contentRecorder) {
- mContentRecorder = contentRecorder;
- }
-
private ContentRecorder getContentRecorder() {
if (mContentRecorder == null) {
mContentRecorder = new ContentRecorder(this);
diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java
index 609ad1e..bf45804 100644
--- a/services/core/java/com/android/server/wm/RootWindowContainer.java
+++ b/services/core/java/com/android/server/wm/RootWindowContainer.java
@@ -612,10 +612,8 @@
}
void refreshSecureSurfaceState() {
- forAllWindows((w) -> {
- if (w.mHasSurface) {
- w.setSecureLocked(w.isSecureLocked());
- }
+ forAllWindows(w -> {
+ w.setSecureLocked(w.isSecureLocked());
}, true /* traverseTopToBottom */);
}
diff --git a/services/core/java/com/android/server/wm/SensitiveContentPackages.java b/services/core/java/com/android/server/wm/SensitiveContentPackages.java
index a7d6903b..5fe48d1 100644
--- a/services/core/java/com/android/server/wm/SensitiveContentPackages.java
+++ b/services/core/java/com/android/server/wm/SensitiveContentPackages.java
@@ -56,6 +56,17 @@
}
/**
+ * Clears apps added to collection of apps in which screen capture should be disabled.
+ *
+ * @param packageInfos set of {@link PackageInfo} whose windows should be unblocked
+ * from capture.
+ * @return {@code true} if packages set is modified, {@code false} otherwise.
+ */
+ public boolean removeBlockScreenCaptureForApps(@NonNull ArraySet<PackageInfo> packageInfos) {
+ return mProtectedPackages.removeAll(packageInfos);
+ }
+
+ /**
* Clears the set of package/uid pairs that should be blocked from screen capture
*
* @return {@code true} if packages set is modified, {@code false} otherwise.
diff --git a/services/core/java/com/android/server/wm/WindowManagerInternal.java b/services/core/java/com/android/server/wm/WindowManagerInternal.java
index ae4c3b9..669c61c 100644
--- a/services/core/java/com/android/server/wm/WindowManagerInternal.java
+++ b/services/core/java/com/android/server/wm/WindowManagerInternal.java
@@ -1043,6 +1043,15 @@
/**
* Clears apps added to collection of apps in which screen capture should be disabled.
*
+ * @param packageInfos set of {@link PackageInfo} whose windows should be unblocked
+ * from capture.
+ */
+ public abstract void removeBlockScreenCaptureForApps(
+ @NonNull ArraySet<PackageInfo> packageInfos);
+
+ /**
+ * Clears all apps added to collection of apps in which screen capture should be disabled.
+ *
* <p> This clears and resets any existing set or added applications from
* * {@link #addBlockScreenCaptureForApps(ArraySet)}
*/
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 631ebcd..520f6cb 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -8632,6 +8632,17 @@
}
@Override
+ public void removeBlockScreenCaptureForApps(ArraySet<PackageInfo> packageInfos) {
+ synchronized (mGlobalLock) {
+ boolean modified =
+ mSensitiveContentPackages.removeBlockScreenCaptureForApps(packageInfos);
+ if (modified) {
+ WindowManagerService.this.refreshScreenCaptureDisabled();
+ }
+ }
+ }
+
+ @Override
public void clearBlockedApps() {
synchronized (mGlobalLock) {
boolean modified = mSensitiveContentPackages.clearBlockedApps();
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index e619440..9b84f39 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -29,9 +29,11 @@
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_APP_RESTRICTIONS;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_AUDIO_OUTPUT;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_AUTOFILL;
+import static android.Manifest.permission.MANAGE_DEVICE_POLICY_BLOCK_UNINSTALL;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_BLUETOOTH;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_CALLS;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_CAMERA;
+import static android.Manifest.permission.MANAGE_DEVICE_POLICY_CAMERA_TOGGLE;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_CERTIFICATES;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_COMMON_CRITERIA_MODE;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_CONTENT_PROTECTION;
@@ -50,6 +52,7 @@
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_LOCK_TASK;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_MANAGED_SUBSCRIPTIONS;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_MICROPHONE;
+import static android.Manifest.permission.MANAGE_DEVICE_POLICY_MICROPHONE_TOGGLE;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_MOBILE_NETWORK;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_MODIFY_USERS;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_MTE;
@@ -74,6 +77,7 @@
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_SUPPORT_MESSAGE;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_SYSTEM_DIALOGS;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_SYSTEM_UPDATES;
+import static android.Manifest.permission.MANAGE_DEVICE_POLICY_THEFT_DETECTION;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_THREAD_NETWORK;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_TIME;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_USB_DATA_SIGNALLING;
@@ -21984,6 +21988,20 @@
}
@Override
+ public boolean isTheftDetectionTriggered(String callerPackageName) {
+ final CallerIdentity caller = getCallerIdentity(callerPackageName);
+ if (!android.app.admin.flags.Flags.deviceTheftImplEnabled()) {
+ return false;
+ }
+ enforcePermission(MANAGE_DEVICE_POLICY_THEFT_DETECTION, caller.getPackageName(),
+ caller.getUserId());
+
+ //STOPSHIP: replace 1<<9 with
+ // LockPatternUtils.SOME_AUTH_REQUIRED_AFTER_ADAPTIVE_AUTH_REQUEST once ag/26042068 lands
+ return 0 != (mLockPatternUtils.getStrongAuthForUser(caller.getUserId()) & (1 << 9));
+ }
+
+ @Override
public void setWifiSsidPolicy(String callerPackageName, WifiSsidPolicy policy) {
CallerIdentity caller;
@@ -22424,14 +22442,6 @@
});
}
- // Permission that will need to be created in V.
- private static final String MANAGE_DEVICE_POLICY_BLOCK_UNINSTALL =
- "manage_device_policy_block_uninstall";
- private static final String MANAGE_DEVICE_POLICY_CAMERA_TOGGLE =
- "manage_device_policy_camera_toggle";
- private static final String MANAGE_DEVICE_POLICY_MICROPHONE_TOGGLE =
- "manage_device_policy_microphone_toggle";
-
// DPC types
private static final int NOT_A_DPC = -1;
private static final int DEFAULT_DEVICE_OWNER = 0;
diff --git a/services/permission/java/com/android/server/permission/access/permission/PermissionService.kt b/services/permission/java/com/android/server/permission/access/permission/PermissionService.kt
index 67f66de..0704c8f 100644
--- a/services/permission/java/com/android/server/permission/access/permission/PermissionService.kt
+++ b/services/permission/java/com/android/server/permission/access/permission/PermissionService.kt
@@ -466,7 +466,7 @@
return size
}
- override fun checkUidPermission(uid: Int, permissionName: String, deviceId: Int): Int {
+ override fun checkUidPermission(uid: Int, permissionName: String, deviceId: String): Int {
val userId = UserHandle.getUserId(uid)
if (!userManagerInternal.exists(userId)) {
return PackageManager.PERMISSION_DENIED
@@ -489,15 +489,9 @@
return PackageManager.PERMISSION_DENIED
}
- val persistentDeviceId = getPersistentDeviceId(deviceId)
- if (persistentDeviceId == null) {
- Slog.e(LOG_TAG, "Cannot find persistent device id for $deviceId.")
- return PackageManager.PERMISSION_DENIED
- }
-
val isPermissionGranted =
service.getState {
- isPermissionGranted(packageState, userId, permissionName, persistentDeviceId)
+ isPermissionGranted(packageState, userId, permissionName, deviceId)
}
return if (isPermissionGranted) {
PackageManager.PERMISSION_GRANTED
@@ -531,7 +525,7 @@
override fun checkPermission(
packageName: String,
permissionName: String,
- persistentDeviceId: String,
+ deviceId: String,
userId: Int
): Int {
if (!userManagerInternal.exists(userId)) {
@@ -545,9 +539,7 @@
?: return PackageManager.PERMISSION_DENIED
val isPermissionGranted =
- service.getState {
- isPermissionGranted(packageState, userId, permissionName, persistentDeviceId)
- }
+ service.getState { isPermissionGranted(packageState, userId, permissionName, deviceId) }
return if (isPermissionGranted) {
PackageManager.PERMISSION_GRANTED
} else {
@@ -565,21 +557,13 @@
packageState: PackageState,
userId: Int,
permissionName: String,
- persistentDeviceId: String
+ deviceId: String
): Boolean {
val appId = packageState.appId
// Note that instant apps can't have shared UIDs, so we only need to check the current
// package state.
val isInstantApp = packageState.getUserStateOrDefault(userId).isInstantApp
- if (
- isSinglePermissionGranted(
- appId,
- userId,
- isInstantApp,
- permissionName,
- persistentDeviceId
- )
- ) {
+ if (isSinglePermissionGranted(appId, userId, isInstantApp, permissionName, deviceId)) {
return true
}
@@ -591,7 +575,7 @@
userId,
isInstantApp,
fullerPermissionName,
- persistentDeviceId
+ deviceId
)
) {
return true
@@ -606,9 +590,9 @@
userId: Int,
isInstantApp: Boolean,
permissionName: String,
- persistentDeviceId: String,
+ deviceId: String,
): Boolean {
- val flags = getPermissionFlagsWithPolicy(appId, userId, permissionName, persistentDeviceId)
+ val flags = getPermissionFlagsWithPolicy(appId, userId, permissionName, deviceId)
if (!PermissionFlags.isPermissionGranted(flags)) {
return false
}
@@ -689,22 +673,16 @@
override fun grantRuntimePermission(
packageName: String,
permissionName: String,
- persistentDeviceId: String,
+ deviceId: String,
userId: Int
) {
- setRuntimePermissionGranted(
- packageName,
- userId,
- permissionName,
- persistentDeviceId,
- isGranted = true
- )
+ setRuntimePermissionGranted(packageName, userId, permissionName, deviceId, isGranted = true)
}
override fun revokeRuntimePermission(
packageName: String,
permissionName: String,
- persistentDeviceId: String,
+ deviceId: String,
userId: Int,
reason: String?
) {
@@ -712,7 +690,7 @@
packageName,
userId,
permissionName,
- persistentDeviceId,
+ deviceId,
isGranted = false,
revokeReason = reason
)
@@ -740,7 +718,7 @@
packageName: String,
userId: Int,
permissionName: String,
- persistentDeviceId: String,
+ deviceId: String,
isGranted: Boolean,
skipKillUid: Boolean = false,
revokeReason: String? = null
@@ -765,7 +743,7 @@
(if (isGranted) "" else "skipKillUid = $skipKillUid, reason = $revokeReason") +
", userId = $userId," +
" callingUid = $callingUidName ($callingUid))," +
- " persistentDeviceId = $persistentDeviceId",
+ " deviceId = $deviceId",
RuntimeException()
)
}
@@ -835,7 +813,7 @@
packageState,
userId,
permissionName,
- persistentDeviceId,
+ deviceId,
isGranted,
canManageRolePermission,
overridePolicyFixed,
@@ -923,7 +901,7 @@
packageState: PackageState,
userId: Int,
permissionName: String,
- persistentDeviceId: String,
+ deviceId: String,
isGranted: Boolean,
canManageRolePermission: Boolean,
overridePolicyFixed: Boolean,
@@ -982,8 +960,7 @@
}
val appId = packageState.appId
- val oldFlags =
- getPermissionFlagsWithPolicy(appId, userId, permissionName, persistentDeviceId)
+ val oldFlags = getPermissionFlagsWithPolicy(appId, userId, permissionName, deviceId)
if (permissionName !in androidPackage.requestedPermissions && oldFlags == 0) {
if (reportError) {
@@ -1055,7 +1032,7 @@
return
}
- setPermissionFlagsWithPolicy(appId, userId, permissionName, persistentDeviceId, newFlags)
+ setPermissionFlagsWithPolicy(appId, userId, permissionName, deviceId, newFlags)
if (permission.isRuntime) {
val action =
@@ -1089,7 +1066,7 @@
override fun getPermissionFlags(
packageName: String,
permissionName: String,
- persistentDeviceId: String,
+ deviceId: String,
userId: Int,
): Int {
if (!userManagerInternal.exists(userId)) {
@@ -1125,12 +1102,7 @@
}
val flags =
- getPermissionFlagsWithPolicy(
- packageState.appId,
- userId,
- permissionName,
- persistentDeviceId
- )
+ getPermissionFlagsWithPolicy(packageState.appId, userId, permissionName, deviceId)
return PermissionFlags.toApiFlags(flags)
}
@@ -1138,7 +1110,7 @@
override fun getAllPermissionStates(
packageName: String,
- persistentDeviceId: String,
+ deviceId: String,
userId: Int
): Map<String, PermissionState> {
if (!userManagerInternal.exists(userId)) {
@@ -1165,14 +1137,15 @@
val permissionFlagsMap =
service.getState {
- if (persistentDeviceId == VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT) {
+ if (deviceId == VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT) {
with(policy) { getAllPermissionFlags(packageState.appId, userId) }
} else {
with(devicePolicy) {
- getAllPermissionFlags(packageState.appId, persistentDeviceId, userId)
+ getAllPermissionFlags(packageState.appId, deviceId, userId)
}
}
- } ?: return emptyMap()
+ }
+ ?: return emptyMap()
val permissionStates = ArrayMap<String, PermissionState>()
permissionFlagsMap.forEachIndexed { _, permissionName, flags ->
@@ -1186,7 +1159,7 @@
override fun isPermissionRevokedByPolicy(
packageName: String,
permissionName: String,
- deviceId: Int,
+ deviceId: String,
userId: Int
): Boolean {
if (!userManagerInternal.exists(userId)) {
@@ -1207,24 +1180,13 @@
}
?: return false
- val persistentDeviceId = getPersistentDeviceId(deviceId)
- if (persistentDeviceId == null) {
- Slog.w(LOG_TAG, "Cannot find persistent device Id for $deviceId")
- return false
- }
-
service.getState {
- if (isPermissionGranted(packageState, userId, permissionName, persistentDeviceId)) {
+ if (isPermissionGranted(packageState, userId, permissionName, deviceId)) {
return false
}
val flags =
- getPermissionFlagsWithPolicy(
- packageState.appId,
- userId,
- permissionName,
- persistentDeviceId
- )
+ getPermissionFlagsWithPolicy(packageState.appId, userId, permissionName, deviceId)
return flags.hasBits(PermissionFlags.POLICY_FIXED)
}
@@ -1248,7 +1210,7 @@
override fun shouldShowRequestPermissionRationale(
packageName: String,
permissionName: String,
- deviceId: Int,
+ deviceId: String,
userId: Int,
): Boolean {
if (!userManagerInternal.exists(userId)) {
@@ -1274,19 +1236,13 @@
return false
}
- val persistentDeviceId = getPersistentDeviceId(deviceId)
- if (persistentDeviceId == null) {
- Slog.w(LOG_TAG, "Cannot find persistent device Id for $deviceId")
- return false
- }
-
val flags: Int
service.getState {
- if (isPermissionGranted(packageState, userId, permissionName, persistentDeviceId)) {
+ if (isPermissionGranted(packageState, userId, permissionName, deviceId)) {
return false
}
- flags = getPermissionFlagsWithPolicy(appId, userId, permissionName, persistentDeviceId)
+ flags = getPermissionFlagsWithPolicy(appId, userId, permissionName, deviceId)
}
if (flags.hasAnyBit(UNREQUESTABLE_MASK)) {
return false
@@ -1325,7 +1281,7 @@
flagMask: Int,
flagValues: Int,
enforceAdjustPolicyPermission: Boolean,
- persistentDeviceId: String,
+ deviceId: String,
userId: Int
) {
val callingUid = Binder.getCallingUid()
@@ -1351,7 +1307,7 @@
"updatePermissionFlags(packageName = $packageName," +
" permissionName = $permissionName, flagMask = $flagMaskString," +
" flagValues = $flagValuesString, userId = $userId," +
- " persistentDeviceId = $persistentDeviceId," +
+ " deviceId = $deviceId," +
" callingUid = $callingUidName ($callingUid))",
RuntimeException()
)
@@ -1441,7 +1397,7 @@
appId,
userId,
permissionName,
- persistentDeviceId,
+ deviceId,
flagMask,
flagValues,
canUpdateSystemFlags,
@@ -1527,7 +1483,7 @@
appId: Int,
userId: Int,
permissionName: String,
- persistentDeviceId: String,
+ deviceId: String,
flagMask: Int,
flagValues: Int,
canUpdateSystemFlags: Boolean,
@@ -1561,8 +1517,7 @@
return
}
- val oldFlags =
- getPermissionFlagsWithPolicy(appId, userId, permissionName, persistentDeviceId)
+ val oldFlags = getPermissionFlagsWithPolicy(appId, userId, permissionName, deviceId)
if (!isPermissionRequested && oldFlags == 0) {
Slog.w(
LOG_TAG,
@@ -1573,7 +1528,7 @@
}
val newFlags = PermissionFlags.updateFlags(permission, oldFlags, flagMask, flagValues)
- setPermissionFlagsWithPolicy(appId, userId, permissionName, persistentDeviceId, newFlags)
+ setPermissionFlagsWithPolicy(appId, userId, permissionName, deviceId, newFlags)
}
override fun getAllowlistedRestrictedPermissions(
@@ -1648,11 +1603,11 @@
appId: Int,
userId: Int,
permissionName: String,
- persistentDeviceId: String,
+ deviceId: String,
): Int {
return if (
!Flags.deviceAwarePermissionApisEnabled() ||
- persistentDeviceId == VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT
+ deviceId == VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT
) {
with(policy) { getPermissionFlags(appId, userId, permissionName) }
} else {
@@ -1664,9 +1619,7 @@
)
return with(policy) { getPermissionFlags(appId, userId, permissionName) }
}
- with(devicePolicy) {
- getPermissionFlags(appId, persistentDeviceId, userId, permissionName)
- }
+ with(devicePolicy) { getPermissionFlags(appId, deviceId, userId, permissionName) }
}
}
@@ -1674,12 +1627,12 @@
appId: Int,
userId: Int,
permissionName: String,
- persistentDeviceId: String,
+ deviceId: String,
flags: Int
): Boolean {
return if (
!Flags.deviceAwarePermissionApisEnabled() ||
- persistentDeviceId == VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT
+ deviceId == VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT
) {
with(policy) { setPermissionFlags(appId, userId, permissionName, flags) }
} else {
@@ -1693,23 +1646,11 @@
}
with(devicePolicy) {
- setPermissionFlags(appId, persistentDeviceId, userId, permissionName, flags)
+ setPermissionFlags(appId, deviceId, userId, permissionName, flags)
}
}
}
- private fun getPersistentDeviceId(deviceId: Int): String? {
- if (deviceId == Context.DEVICE_ID_DEFAULT) {
- return VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT
- }
-
- if (virtualDeviceManagerInternal == null) {
- virtualDeviceManagerInternal =
- LocalServices.getService(VirtualDeviceManagerInternal::class.java)
- }
- return virtualDeviceManagerInternal?.getPersistentIdForDevice(deviceId)
- }
-
/**
* This method does not enforce checks on the caller, should only be called after required
* checks.
@@ -2270,9 +2211,9 @@
userState.appIdDevicePermissionFlags[appId]?.forEachIndexed {
_,
- persistentDeviceId,
+ deviceId,
devicePermissionFlags ->
- println("Permissions (Device $persistentDeviceId):")
+ println("Permissions (Device $deviceId):")
withIndent {
devicePermissionFlags.forEachIndexed { _, permissionName, flags ->
val isGranted = PermissionFlags.isPermissionGranted(flags)
@@ -2415,9 +2356,8 @@
with(devicePolicy) { trimDevicePermissionStates(persistentDeviceIds) }
}
}
- virtualDeviceManagerInternal?.registerPersistentDeviceIdRemovedListener { persistentDeviceId
- ->
- service.mutateState { with(devicePolicy) { onDeviceIdRemoved(persistentDeviceId) } }
+ virtualDeviceManagerInternal?.registerPersistentDeviceIdRemovedListener { deviceId ->
+ service.mutateState { with(devicePolicy) { onDeviceIdRemoved(deviceId) } }
}
permissionControllerManager =
@@ -2764,7 +2704,7 @@
override fun onDevicePermissionFlagsChanged(
appId: Int,
userId: Int,
- persistentDeviceId: String,
+ deviceId: String,
permissionName: String,
oldFlags: Int,
newFlags: Int
@@ -2787,8 +2727,7 @@
permissionName in NOTIFICATIONS_PERMISSIONS &&
runtimePermissionRevokedUids.get(uid, true)
}
- runtimePermissionChangedUidDevices.getOrPut(uid) { mutableSetOf() } +=
- persistentDeviceId
+ runtimePermissionChangedUidDevices.getOrPut(uid) { mutableSetOf() } += deviceId
}
if (permission.hasGids && !wasPermissionGranted && isPermissionGranted) {
@@ -2803,8 +2742,8 @@
}
runtimePermissionChangedUidDevices.forEachIndexed { _, uid, persistentDeviceIds ->
- persistentDeviceIds.forEach { persistentDeviceId ->
- onPermissionsChangeListeners.onPermissionsChanged(uid, persistentDeviceId)
+ persistentDeviceIds.forEach { deviceId ->
+ onPermissionsChangeListeners.onPermissionsChanged(uid, deviceId)
}
}
runtimePermissionChangedUidDevices.clear()
@@ -2844,8 +2783,11 @@
private fun isAppBackupAndRestoreRunning(uid: Int): Boolean {
if (
- checkUidPermission(uid, Manifest.permission.BACKUP, Context.DEVICE_ID_DEFAULT) !=
- PackageManager.PERMISSION_GRANTED
+ checkUidPermission(
+ uid,
+ Manifest.permission.BACKUP,
+ VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT
+ ) != PackageManager.PERMISSION_GRANTED
) {
return false
}
@@ -2879,16 +2821,16 @@
when (msg.what) {
MSG_ON_PERMISSIONS_CHANGED -> {
val uid = msg.arg1
- val persistentDeviceId = msg.obj as String
- handleOnPermissionsChanged(uid, persistentDeviceId)
+ val deviceId = msg.obj as String
+ handleOnPermissionsChanged(uid, deviceId)
}
}
}
- private fun handleOnPermissionsChanged(uid: Int, persistentDeviceId: String) {
+ private fun handleOnPermissionsChanged(uid: Int, deviceId: String) {
listeners.broadcast { listener ->
try {
- listener.onPermissionsChanged(uid, persistentDeviceId)
+ listener.onPermissionsChanged(uid, deviceId)
} catch (e: RemoteException) {
Slog.e(LOG_TAG, "Error when calling OnPermissionsChangeListener", e)
}
@@ -2903,9 +2845,9 @@
listeners.unregister(listener)
}
- fun onPermissionsChanged(uid: Int, persistentDeviceId: String) {
+ fun onPermissionsChanged(uid: Int, deviceId: String) {
if (listeners.registeredCallbackCount > 0) {
- obtainMessage(MSG_ON_PERMISSIONS_CHANGED, uid, 0, persistentDeviceId).sendToTarget()
+ obtainMessage(MSG_ON_PERMISSIONS_CHANGED, uid, 0, deviceId).sendToTarget()
}
}
diff --git a/services/tests/PackageManagerServiceTests/appenumeration/Android.bp b/services/tests/PackageManagerServiceTests/appenumeration/Android.bp
index bd86fe2..f15e533 100644
--- a/services/tests/PackageManagerServiceTests/appenumeration/Android.bp
+++ b/services/tests/PackageManagerServiceTests/appenumeration/Android.bp
@@ -32,8 +32,6 @@
"androidx.test.runner",
"truth",
"Harrier",
- "frameworks-base-testutils",
- "services.core",
],
platform_apis: true,
certificate: "platform",
diff --git a/services/tests/PackageManagerServiceTests/appenumeration/src/com/android/server/pm/test/appenumeration/AppEnumerationInternalTests.java b/services/tests/PackageManagerServiceTests/appenumeration/src/com/android/server/pm/test/appenumeration/AppEnumerationInternalTests.java
index c615823..4012d8e 100644
--- a/services/tests/PackageManagerServiceTests/appenumeration/src/com/android/server/pm/test/appenumeration/AppEnumerationInternalTests.java
+++ b/services/tests/PackageManagerServiceTests/appenumeration/src/com/android/server/pm/test/appenumeration/AppEnumerationInternalTests.java
@@ -16,36 +16,32 @@
package com.android.server.pm.test.appenumeration;
+import static android.content.Context.MEDIA_PROJECTION_SERVICE;
+
import static com.android.compatibility.common.util.ShellUtils.runShellCommand;
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.MockitoAnnotations.initMocks;
-
-import android.app.ActivityManagerInternal;
import android.app.AppGlobals;
import android.app.PendingIntent;
import android.content.Context;
import android.content.IntentSender;
import android.content.pm.IPackageManager;
import android.content.pm.ProviderInfo;
+import android.media.projection.IMediaProjectionManager;
import android.media.projection.MediaProjectionManager;
import android.os.Process;
+import android.os.ServiceManager;
import android.os.UserHandle;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
-import com.android.internal.util.test.LocalServiceKeeperRule;
-import com.android.server.media.projection.MediaProjectionManagerService;
-
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Mock;
import java.util.ArrayList;
import java.util.List;
@@ -77,17 +73,9 @@
private IPackageManager mIPackageManager;
- @Rule
- public LocalServiceKeeperRule mLocalServiceKeeperRule = new LocalServiceKeeperRule();
-
- @Mock private ActivityManagerInternal mActivityManagerInternal;
-
@Before
public void setup() {
- initMocks(this);
mIPackageManager = AppGlobals.getPackageManager();
- mLocalServiceKeeperRule.overrideLocalService(ActivityManagerInternal.class,
- mActivityManagerInternal);
}
@After
@@ -181,11 +169,11 @@
public void mediaProjectionManager_createProjection_canSeeForceQueryable()
throws Exception {
installPackage(SHARED_USER_APK_PATH, true /* forceQueryable */);
- final Context context = InstrumentationRegistry.getInstrumentation().getContext();
- final MediaProjectionManagerService mediaProjectionManager =
- new MediaProjectionManagerService(context);
+ final IMediaProjectionManager mediaProjectionManager =
+ IMediaProjectionManager.Stub.asInterface(
+ ServiceManager.getService(MEDIA_PROJECTION_SERVICE));
- assertThat(mediaProjectionManager.createProjectionInternal(0 /* uid */, TARGET_SHARED_USER,
+ assertThat(mediaProjectionManager.createProjection(0 /* uid */, TARGET_SHARED_USER,
MediaProjectionManager.TYPE_SCREEN_CAPTURE, false /* permanentGrant */))
.isNotNull();
}
@@ -193,13 +181,12 @@
@Test
public void mediaProjectionManager_createProjection_cannotSeeTarget() {
installPackage(SHARED_USER_APK_PATH, false /* forceQueryable */);
- final Context context = InstrumentationRegistry.getInstrumentation().getContext();
- final MediaProjectionManagerService mediaProjectionManager =
- new MediaProjectionManagerService(context);
+ final IMediaProjectionManager mediaProjectionManager =
+ IMediaProjectionManager.Stub.asInterface(
+ ServiceManager.getService(MEDIA_PROJECTION_SERVICE));
Assert.assertThrows(IllegalArgumentException.class,
- () -> mediaProjectionManager.createProjectionInternal(0 /* uid */,
- TARGET_SHARED_USER,
+ () -> mediaProjectionManager.createProjection(0 /* uid */, TARGET_SHARED_USER,
MediaProjectionManager.TYPE_SCREEN_CAPTURE, false /* permanentGrant */));
}
diff --git a/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/parsing/parcelling/AndroidPackageTest.kt b/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/parsing/parcelling/AndroidPackageTest.kt
index cfe701f..d4b57f1 100644
--- a/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/parsing/parcelling/AndroidPackageTest.kt
+++ b/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/parsing/parcelling/AndroidPackageTest.kt
@@ -273,7 +273,8 @@
AndroidPackage::hasRequestForegroundServiceExemption,
AndroidPackage::hasRequestRawExternalStorageAccess,
AndroidPackage::isUpdatableSystem,
- AndroidPackage::getEmergencyInstaller
+ AndroidPackage::getEmergencyInstaller,
+ AndroidPackage::isAllowCrossUidActivitySwitchFromBelow,
)
override fun extraParams() = listOf(
diff --git a/services/tests/mockingservicestests/src/com/android/server/am/MockingOomAdjusterTests.java b/services/tests/mockingservicestests/src/com/android/server/am/MockingOomAdjusterTests.java
index d876dae..47928bc 100644
--- a/services/tests/mockingservicestests/src/com/android/server/am/MockingOomAdjusterTests.java
+++ b/services/tests/mockingservicestests/src/com/android/server/am/MockingOomAdjusterTests.java
@@ -72,6 +72,8 @@
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.AdditionalAnswers.answer;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.anyInt;
@@ -157,9 +159,11 @@
private static final int MOCKAPP2_UID_OTHER = MOCKAPP2_UID + UserHandle.PER_USER_RANGE;
private static final int MOCKAPP_ISOLATED_UID = Process.FIRST_ISOLATED_UID + 321;
private static final String MOCKAPP_ISOLATED_PROCESSNAME = "isolated test #1";
+ private static final int MOCKAPP_SDK_SANDBOX_UID = Process.FIRST_SDK_SANDBOX_UID + 654;
+ private static final String MOCKAPP_SDK_SANDBOX_PROCESSNAME = "sandbox test #1";
private static int sFirstCachedAdj = ProcessList.CACHED_APP_MIN_ADJ
- + ProcessList.CACHED_APP_IMPORTANCE_LEVELS;
+ + ProcessList.CACHED_APP_IMPORTANCE_LEVELS;
private static Context sContext;
private static PackageManagerInternal sPackageManagerInternal;
private static ActivityManagerService sService;
@@ -271,7 +275,6 @@
/**
* Replace the process LRU with the given processes.
- * @param apps
*/
@SuppressWarnings("GuardedBy")
private void setProcessesToLru(ProcessRecord... apps) {
@@ -660,7 +663,7 @@
app.mState.setLastTopTime(nowUptime);
// Simulate the system starting and binding to a service in the app.
ServiceRecord s = bindService(app, system,
- null, Context.BIND_ALMOST_PERCEPTIBLE, mock(IBinder.class));
+ null, null, Context.BIND_ALMOST_PERCEPTIBLE, mock(IBinder.class));
s.lastTopAlmostPerceptibleBindRequestUptimeMs = nowUptime;
s.getConnections().clear();
app.mServices.updateHasTopStartedAlmostPerceptibleServices();
@@ -682,7 +685,7 @@
app.mState.setLastTopTime(nowUptime);
// Simulate the system starting and binding to a service in the app.
ServiceRecord s = bindService(app, system,
- null, Context.BIND_ALMOST_PERCEPTIBLE + 2, mock(IBinder.class));
+ null, null, Context.BIND_ALMOST_PERCEPTIBLE + 2, mock(IBinder.class));
s.lastTopAlmostPerceptibleBindRequestUptimeMs =
nowUptime - 2 * sService.mConstants.mServiceBindAlmostPerceptibleTimeoutMs;
app.mServices.updateHasTopStartedAlmostPerceptibleServices();
@@ -704,7 +707,7 @@
app.mState.setLastTopTime(nowUptime);
// Simulate the system starting and binding to a service in the app.
ServiceRecord s = bindService(app, system,
- null, Context.BIND_ALMOST_PERCEPTIBLE, mock(IBinder.class));
+ null, null, Context.BIND_ALMOST_PERCEPTIBLE, mock(IBinder.class));
s.lastTopAlmostPerceptibleBindRequestUptimeMs =
nowUptime - 2 * sService.mConstants.mServiceBindAlmostPerceptibleTimeoutMs;
s.getConnections().clear();
@@ -729,7 +732,7 @@
system.mState.setHasTopUi(true);
// Simulate the system starting and binding to a service in the app.
ServiceRecord s = bindService(app, system,
- null, Context.BIND_ALMOST_PERCEPTIBLE, mock(IBinder.class));
+ null, null, Context.BIND_ALMOST_PERCEPTIBLE, mock(IBinder.class));
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(system, app);
@@ -901,7 +904,7 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, true));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- ServiceRecord s = bindService(app, client, null, Context.BIND_WAIVE_PRIORITY,
+ ServiceRecord s = bindService(app, client, null, null, Context.BIND_WAIVE_PRIORITY,
mock(IBinder.class));
s.startRequested = true;
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
@@ -921,7 +924,7 @@
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
client.mServices.setTreatLikeActivity(true);
- bindService(app, client, null, Context.BIND_WAIVE_PRIORITY
+ bindService(app, client, null, null, Context.BIND_WAIVE_PRIORITY
| Context.BIND_TREAT_LIKE_ACTIVITY, mock(IBinder.class));
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(client, app);
@@ -937,7 +940,7 @@
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
IBinder binder = mock(IBinder.class);
- ServiceRecord s = bindService(app, client, null, Context.BIND_WAIVE_PRIORITY
+ ServiceRecord s = bindService(app, client, null, null, Context.BIND_WAIVE_PRIORITY
| Context.BIND_ADJUST_WITH_ACTIVITY | Context.BIND_IMPORTANT, binder);
ConnectionRecord cr = s.getConnections().get(binder).get(0);
setFieldValue(ConnectionRecord.class, cr, "activity",
@@ -955,7 +958,7 @@
public void testUpdateOomAdj_DoOne_Service_Self() {
ProcessRecord app = spy(makeDefaultProcessRecord(MOCKAPP_PID, MOCKAPP_UID,
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
- bindService(app, app, null, 0, mock(IBinder.class));
+ bindService(app, app, null, null, 0, mock(IBinder.class));
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(app);
@@ -970,7 +973,7 @@
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
client.mServices.setTreatLikeActivity(true);
- bindService(app, client, null, 0, mock(IBinder.class));
+ bindService(app, client, null, null, 0, mock(IBinder.class));
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(client, app);
@@ -988,7 +991,8 @@
doReturn(true).when(wpc).hasActivities();
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, Context.BIND_ALLOW_OOM_MANAGEMENT, mock(IBinder.class));
+ bindService(app, client, null, null, Context.BIND_ALLOW_OOM_MANAGEMENT,
+ mock(IBinder.class));
doReturn(PROCESS_STATE_TOP).when(sService.mAtmInternal).getTopProcessState();
doReturn(client).when(sService).getTopApp();
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
@@ -1005,7 +1009,7 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, Context.BIND_FOREGROUND_SERVICE, mock(IBinder.class));
+ bindService(app, client, null, null, Context.BIND_FOREGROUND_SERVICE, mock(IBinder.class));
client.mState.setMaxAdj(PERSISTENT_PROC_ADJ);
client.mState.setHasTopUi(true);
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
@@ -1023,7 +1027,7 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, Context.BIND_IMPORTANT, mock(IBinder.class));
+ bindService(app, client, null, null, Context.BIND_IMPORTANT, mock(IBinder.class));
client.mServices.startExecutingService(mock(ServiceRecord.class));
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(client, app);
@@ -1039,7 +1043,7 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, 0, mock(IBinder.class));
+ bindService(app, client, null, null, 0, mock(IBinder.class));
doReturn(PROCESS_STATE_TOP).when(sService.mAtmInternal).getTopProcessState();
doReturn(client).when(sService).getTopApp();
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
@@ -1056,7 +1060,7 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, Context.BIND_FOREGROUND_SERVICE, mock(IBinder.class));
+ bindService(app, client, null, null, Context.BIND_FOREGROUND_SERVICE, mock(IBinder.class));
client.mState.setMaxAdj(PERSISTENT_PROC_ADJ);
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(client, app);
@@ -1074,7 +1078,7 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, Context.BIND_NOT_FOREGROUND, mock(IBinder.class));
+ bindService(app, client, null, null, Context.BIND_NOT_FOREGROUND, mock(IBinder.class));
client.mState.setMaxAdj(PERSISTENT_PROC_ADJ);
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(client, app);
@@ -1090,7 +1094,7 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, 0, mock(IBinder.class));
+ bindService(app, client, null, null, 0, mock(IBinder.class));
client.mServices.setHasForegroundServices(true, 0, /* hasNoneType=*/true);
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(client, app);
@@ -1109,7 +1113,7 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, 0, mock(IBinder.class));
+ bindService(app, client, null, null, 0, mock(IBinder.class));
// In order to trick OomAdjuster to think it has a short-service, we need this logic.
ServiceRecord s = ServiceRecord.newEmptyInstanceForTest(sService);
@@ -1172,8 +1176,8 @@
ProcessRecord app1 = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app1, pers, null, Context.BIND_FOREGROUND_SERVICE, mock(IBinder.class));
- bindService(app2, app1, null, 0, mock(IBinder.class));
+ bindService(app1, pers, null, null, Context.BIND_FOREGROUND_SERVICE, mock(IBinder.class));
+ bindService(app2, app1, null, null, 0, mock(IBinder.class));
updateOomAdj(pers, app1, app2);
@@ -1192,7 +1196,7 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, Context.BIND_ABOVE_CLIENT, mock(IBinder.class));
+ bindService(app, client, null, null, Context.BIND_ABOVE_CLIENT, mock(IBinder.class));
BackupRecord backupTarget = new BackupRecord(null, 0, 0, 0);
backupTarget.app = client;
doReturn(backupTarget).when(sService.mBackupTargets).get(anyInt());
@@ -1218,7 +1222,7 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, Context.BIND_NOT_PERCEPTIBLE, mock(IBinder.class));
+ bindService(app, client, null, null, Context.BIND_NOT_PERCEPTIBLE, mock(IBinder.class));
client.mState.setRunningRemoteAnimation(true);
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(client, app);
@@ -1233,7 +1237,7 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, Context.BIND_NOT_VISIBLE, mock(IBinder.class));
+ bindService(app, client, null, null, Context.BIND_NOT_VISIBLE, mock(IBinder.class));
client.mState.setRunningRemoteAnimation(true);
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(client, app);
@@ -1248,7 +1252,7 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, 0, mock(IBinder.class));
+ bindService(app, client, null, null, 0, mock(IBinder.class));
client.mState.setHasOverlayUi(true);
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(client, app);
@@ -1264,7 +1268,7 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null,
+ bindService(app, client, null, null,
Context.BIND_ALMOST_PERCEPTIBLE | Context.BIND_NOT_FOREGROUND,
mock(IBinder.class));
client.mState.setMaxAdj(PERSISTENT_PROC_ADJ);
@@ -1283,7 +1287,7 @@
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
WindowProcessController wpc = client.getWindowProcessController();
doReturn(true).when(wpc).isHeavyWeightProcess();
- bindService(app, client, null,
+ bindService(app, client, null, null,
Context.BIND_ALMOST_PERCEPTIBLE | Context.BIND_NOT_FOREGROUND,
mock(IBinder.class));
client.mState.setMaxAdj(PERSISTENT_PROC_ADJ);
@@ -1301,7 +1305,7 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null,
+ bindService(app, client, null, null,
Context.BIND_ALMOST_PERCEPTIBLE,
mock(IBinder.class));
client.mState.setMaxAdj(PERSISTENT_PROC_ADJ);
@@ -1320,7 +1324,7 @@
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
WindowProcessController wpc = client.getWindowProcessController();
doReturn(true).when(wpc).isHeavyWeightProcess();
- bindService(app, client, null,
+ bindService(app, client, null, null,
Context.BIND_ALMOST_PERCEPTIBLE,
mock(IBinder.class));
client.mState.setMaxAdj(PERSISTENT_PROC_ADJ);
@@ -1341,7 +1345,7 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, 0, mock(IBinder.class));
+ bindService(app, client, null, null, 0, mock(IBinder.class));
client.mState.setRunningRemoteAnimation(true);
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(client, app);
@@ -1356,7 +1360,8 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, Context.BIND_IMPORTANT_BACKGROUND, mock(IBinder.class));
+ bindService(app, client, null, null, Context.BIND_IMPORTANT_BACKGROUND,
+ mock(IBinder.class));
client.mState.setHasOverlayUi(true);
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(client, app);
@@ -1496,10 +1501,10 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, 0, mock(IBinder.class));
+ bindService(app, client, null, null, 0, mock(IBinder.class));
ProcessRecord client2 = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID,
MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, false));
- bindService(client, client2, null, 0, mock(IBinder.class));
+ bindService(client, client2, null, null, 0, mock(IBinder.class));
doReturn(PROCESS_STATE_TOP).when(sService.mAtmInternal).getTopProcessState();
doReturn(client2).when(sService).getTopApp();
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
@@ -1517,10 +1522,10 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, 0, mock(IBinder.class));
+ bindService(app, client, null, null, 0, mock(IBinder.class));
ProcessRecord client2 = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID,
MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, false));
- bindService(app, client2, null, 0, mock(IBinder.class));
+ bindService(app, client2, null, null, 0, mock(IBinder.class));
client2.mServices.setHasForegroundServices(true, 0, /* hasNoneType=*/true);
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(client, client2, app);
@@ -1537,10 +1542,10 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, 0, mock(IBinder.class));
+ bindService(app, client, null, null, 0, mock(IBinder.class));
ProcessRecord client2 = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID,
MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, false));
- bindService(client, client2, null, 0, mock(IBinder.class));
+ bindService(client, client2, null, null, 0, mock(IBinder.class));
client2.mServices.setHasForegroundServices(true, 0, /* hasNoneType=*/true);
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(client, client2, app);
@@ -1557,12 +1562,12 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, 0, mock(IBinder.class));
+ bindService(app, client, null, null, 0, mock(IBinder.class));
ProcessRecord client2 = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID,
MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, false));
- bindService(client, client2, null, 0, mock(IBinder.class));
+ bindService(client, client2, null, null, 0, mock(IBinder.class));
client2.mServices.setHasForegroundServices(true, 0, /* hasNoneType=*/true);
- bindService(client2, app, null, 0, mock(IBinder.class));
+ bindService(client2, app, null, null, 0, mock(IBinder.class));
// Note: We add processes to LRU but still call updateOomAdjLocked() with a specific
// processes.
@@ -1599,11 +1604,11 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, 0, mock(IBinder.class));
- bindService(client, app, null, 0, mock(IBinder.class));
+ bindService(app, client, null, null, 0, mock(IBinder.class));
+ bindService(client, app, null, null, 0, mock(IBinder.class));
ProcessRecord client2 = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID,
MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, false));
- bindService(client2, client, null, 0, mock(IBinder.class));
+ bindService(client2, client, null, null, 0, mock(IBinder.class));
client.mServices.setHasForegroundServices(true, 0, /* hasNoneType=*/true);
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(app, client, client2);
@@ -1626,11 +1631,11 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, 0, mock(IBinder.class));
+ bindService(app, client, null, null, 0, mock(IBinder.class));
ProcessRecord client2 = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID,
MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, false));
- bindService(client, client2, null, 0, mock(IBinder.class));
- bindService(client2, client, null, 0, mock(IBinder.class));
+ bindService(client, client2, null, null, 0, mock(IBinder.class));
+ bindService(client2, client, null, null, 0, mock(IBinder.class));
client.mServices.setHasForegroundServices(true, 0, /* hasNoneType=*/true);
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(app, client, client2);
@@ -1653,18 +1658,18 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, 0, mock(IBinder.class));
+ bindService(app, client, null, null, 0, mock(IBinder.class));
ProcessRecord client2 = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID,
MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, false));
- bindService(client, client2, null, 0, mock(IBinder.class));
- bindService(client2, client, null, 0, mock(IBinder.class));
+ bindService(client, client2, null, null, 0, mock(IBinder.class));
+ bindService(client2, client, null, null, 0, mock(IBinder.class));
ProcessRecord client3 = spy(makeDefaultProcessRecord(MOCKAPP4_PID, MOCKAPP4_UID,
MOCKAPP4_PROCESSNAME, MOCKAPP4_PACKAGENAME, false));
- bindService(client3, client, null, 0, mock(IBinder.class));
+ bindService(client3, client, null, null, 0, mock(IBinder.class));
ProcessRecord client4 = spy(makeDefaultProcessRecord(MOCKAPP5_PID, MOCKAPP5_UID,
MOCKAPP5_PROCESSNAME, MOCKAPP5_PACKAGENAME, false));
- bindService(client3, client4, null, 0, mock(IBinder.class));
- bindService(client4, client3, null, 0, mock(IBinder.class));
+ bindService(client3, client4, null, null, 0, mock(IBinder.class));
+ bindService(client4, client3, null, null, 0, mock(IBinder.class));
client.mServices.setHasForegroundServices(true, 0, /* hasNoneType=*/true);
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(app, client, client2, client3, client4);
@@ -1693,16 +1698,16 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, 0, mock(IBinder.class));
+ bindService(app, client, null, null, 0, mock(IBinder.class));
ProcessRecord client2 = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID,
MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, false));
- bindService(client, client2, null, 0, mock(IBinder.class));
+ bindService(client, client2, null, null, 0, mock(IBinder.class));
client2.mServices.setHasForegroundServices(true, 0, /* hasNoneType=*/true);
- bindService(client2, app, null, 0, mock(IBinder.class));
+ bindService(client2, app, null, null, 0, mock(IBinder.class));
ProcessRecord client3 = spy(makeDefaultProcessRecord(MOCKAPP4_PID, MOCKAPP4_UID,
MOCKAPP4_PROCESSNAME, MOCKAPP4_PACKAGENAME, false));
client3.mState.setForcingToImportant(new Object());
- bindService(app, client3, null, 0, mock(IBinder.class));
+ bindService(app, client3, null, null, 0, mock(IBinder.class));
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(app, client, client2, client3);
@@ -1718,17 +1723,17 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, 0, mock(IBinder.class));
+ bindService(app, client, null, null, 0, mock(IBinder.class));
ProcessRecord client2 = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID,
MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, false));
- bindService(client, client2, null, 0, mock(IBinder.class));
- bindService(client2, app, null, 0, mock(IBinder.class));
+ bindService(client, client2, null, null, 0, mock(IBinder.class));
+ bindService(client2, app, null, null, 0, mock(IBinder.class));
WindowProcessController wpc = client2.getWindowProcessController();
doReturn(true).when(wpc).isHomeProcess();
ProcessRecord client3 = spy(makeDefaultProcessRecord(MOCKAPP4_PID, MOCKAPP4_UID,
MOCKAPP4_PROCESSNAME, MOCKAPP4_PACKAGENAME, false));
client3.mState.setForcingToImportant(new Object());
- bindService(app, client3, null, 0, mock(IBinder.class));
+ bindService(app, client3, null, null, 0, mock(IBinder.class));
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(app, client, client2, client3);
@@ -1743,11 +1748,11 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, 0, mock(IBinder.class));
+ bindService(app, client, null, null, 0, mock(IBinder.class));
ProcessRecord client2 = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID,
MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, false));
- bindService(client, client2, null, 0, mock(IBinder.class));
- bindService(client2, app, null, 0, mock(IBinder.class));
+ bindService(client, client2, null, null, 0, mock(IBinder.class));
+ bindService(client2, app, null, null, 0, mock(IBinder.class));
WindowProcessController wpc = client2.getWindowProcessController();
doReturn(true).when(wpc).isHomeProcess();
ProcessRecord client3 = spy(makeDefaultProcessRecord(MOCKAPP4_PID, MOCKAPP4_UID,
@@ -1755,7 +1760,7 @@
ProcessRecord client4 = spy(makeDefaultProcessRecord(MOCKAPP5_PID, MOCKAPP5_UID,
MOCKAPP5_PROCESSNAME, MOCKAPP5_PACKAGENAME, false));
client4.mState.setForcingToImportant(new Object());
- bindService(app, client4, null, 0, mock(IBinder.class));
+ bindService(app, client4, null, null, 0, mock(IBinder.class));
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(app, client, client2, client3, client4);
@@ -1770,21 +1775,21 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, 0, mock(IBinder.class));
+ bindService(app, client, null, null, 0, mock(IBinder.class));
ProcessRecord client2 = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID,
MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, false));
- bindService(client, client2, null, 0, mock(IBinder.class));
- bindService(client2, app, null, 0, mock(IBinder.class));
+ bindService(client, client2, null, null, 0, mock(IBinder.class));
+ bindService(client2, app, null, null, 0, mock(IBinder.class));
WindowProcessController wpc = client2.getWindowProcessController();
doReturn(true).when(wpc).isHomeProcess();
ProcessRecord client3 = spy(makeDefaultProcessRecord(MOCKAPP4_PID, MOCKAPP4_UID,
MOCKAPP4_PROCESSNAME, MOCKAPP4_PACKAGENAME, false));
client3.mState.setForcingToImportant(new Object());
- bindService(app, client3, null, 0, mock(IBinder.class));
+ bindService(app, client3, null, null, 0, mock(IBinder.class));
ProcessRecord client4 = spy(makeDefaultProcessRecord(MOCKAPP5_PID, MOCKAPP5_UID,
MOCKAPP5_PROCESSNAME, MOCKAPP5_PACKAGENAME, false));
client4.mServices.setHasForegroundServices(true, 0, /* hasNoneType=*/true);
- bindService(app, client4, null, 0, mock(IBinder.class));
+ bindService(app, client4, null, null, 0, mock(IBinder.class));
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(app, client, client2, client3, client4);
@@ -1802,15 +1807,15 @@
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
WindowProcessController wpc = client.getWindowProcessController();
doReturn(true).when(wpc).isHomeProcess();
- bindService(app, client, null, 0, mock(IBinder.class));
+ bindService(app, client, null, null, 0, mock(IBinder.class));
ProcessRecord client2 = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID,
MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, false));
- bindService(app, client2, null, 0, mock(IBinder.class));
+ bindService(app, client2, null, null, 0, mock(IBinder.class));
client2.mServices.setHasForegroundServices(true, 0, /* hasNoneType=*/true);
ProcessRecord client3 = spy(makeDefaultProcessRecord(MOCKAPP4_PID, MOCKAPP4_UID,
MOCKAPP4_PROCESSNAME, MOCKAPP4_PACKAGENAME, false));
client3.mState.setForcingToImportant(new Object());
- bindService(app, client3, null, 0, mock(IBinder.class));
+ bindService(app, client3, null, null, 0, mock(IBinder.class));
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(client, client2, client3, app);
@@ -1826,7 +1831,7 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, 0, mock(IBinder.class));
+ bindService(app, client, null, null, 0, mock(IBinder.class));
ProcessRecord client2 = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID,
MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, false));
bindProvider(client, client2, null, null, false);
@@ -1846,12 +1851,12 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, 0, mock(IBinder.class));
+ bindService(app, client, null, null, 0, mock(IBinder.class));
ProcessRecord client2 = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID,
MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, false));
bindProvider(client, client2, null, null, false);
client2.mServices.setHasForegroundServices(true, 0, /* hasNoneType=*/true);
- bindService(client2, app, null, 0, mock(IBinder.class));
+ bindService(client2, app, null, null, 0, mock(IBinder.class));
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(app, client, client2);
@@ -1912,9 +1917,9 @@
MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, false));
final ProcessRecord client2 = spy(makeDefaultProcessRecord(MOCKAPP4_PID, MOCKAPP4_UID,
MOCKAPP4_PROCESSNAME, MOCKAPP4_PACKAGENAME, false));
- bindService(app1, client1, null, Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE,
+ bindService(app1, client1, null, null, Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE,
mock(IBinder.class));
- bindService(app2, client2, null, Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE,
+ bindService(app2, client2, null, null, Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE,
mock(IBinder.class));
client1.mState.setMaxAdj(PERSISTENT_PROC_ADJ);
client2.mServices.setHasForegroundServices(true, 0, /* hasNoneType=*/true);
@@ -1929,8 +1934,10 @@
assertBfsl(app1);
assertBfsl(app2);
- bindService(app1, client1, null, Context.BIND_SCHEDULE_LIKE_TOP_APP, mock(IBinder.class));
- bindService(app2, client2, null, Context.BIND_SCHEDULE_LIKE_TOP_APP, mock(IBinder.class));
+ bindService(app1, client1, null, null, Context.BIND_SCHEDULE_LIKE_TOP_APP,
+ mock(IBinder.class));
+ bindService(app2, client2, null, null, Context.BIND_SCHEDULE_LIKE_TOP_APP,
+ mock(IBinder.class));
updateOomAdj(client1, client2, app1, app2);
assertProcStates(app1, PROCESS_STATE_BOUND_FOREGROUND_SERVICE, VISIBLE_APP_ADJ,
@@ -1946,8 +1953,8 @@
SCHED_GROUP_DEFAULT);
assertBfsl(app2);
- bindService(client2, app1, null, 0, mock(IBinder.class));
- bindService(app1, client2, null, 0, mock(IBinder.class));
+ bindService(client2, app1, null, null, 0, mock(IBinder.class));
+ bindService(app1, client2, null, null, 0, mock(IBinder.class));
client2.mServices.setHasForegroundServices(false, 0, /* hasNoneType=*/false);
updateOomAdj(app1, client1, client2);
assertProcStates(app1, PROCESS_STATE_IMPORTANT_FOREGROUND, VISIBLE_APP_ADJ,
@@ -1968,9 +1975,9 @@
client1.mState.setMaxAdj(PERSISTENT_PROC_ADJ);
client2.mState.setMaxAdj(PERSISTENT_PROC_ADJ);
- final ServiceRecord s1 = bindService(app1, client1, null,
+ final ServiceRecord s1 = bindService(app1, client1, null, null,
Context.BIND_TREAT_LIKE_VISIBLE_FOREGROUND_SERVICE, mock(IBinder.class));
- final ServiceRecord s2 = bindService(app2, client2, null,
+ final ServiceRecord s2 = bindService(app2, client2, null, null,
Context.BIND_IMPORTANT, mock(IBinder.class));
updateOomAdj(client1, client2, app1, app2);
@@ -1980,7 +1987,7 @@
assertProcStates(app2, PROCESS_STATE_PERSISTENT, PERSISTENT_SERVICE_ADJ,
SCHED_GROUP_DEFAULT);
- bindService(app2, client1, s2, Context.BIND_TREAT_LIKE_VISIBLE_FOREGROUND_SERVICE,
+ bindService(app2, client1, null, s2, Context.BIND_TREAT_LIKE_VISIBLE_FOREGROUND_SERVICE,
mock(IBinder.class));
updateOomAdj(app2);
assertProcStates(app2, PROCESS_STATE_PERSISTENT, PERSISTENT_SERVICE_ADJ,
@@ -1995,9 +2002,9 @@
client1.mServices.setHasForegroundServices(true, 0, /* hasNoneType=*/true);
client2.mState.setHasOverlayUi(true);
- bindService(app1, client1, s1, Context.BIND_TREAT_LIKE_VISIBLE_FOREGROUND_SERVICE,
+ bindService(app1, client1, null, s1, Context.BIND_TREAT_LIKE_VISIBLE_FOREGROUND_SERVICE,
mock(IBinder.class));
- bindService(app2, client2, s2, Context.BIND_TREAT_LIKE_VISIBLE_FOREGROUND_SERVICE,
+ bindService(app2, client2, null, s2, Context.BIND_TREAT_LIKE_VISIBLE_FOREGROUND_SERVICE,
mock(IBinder.class));
updateOomAdj(client1, client2, app1, app2);
@@ -2030,7 +2037,7 @@
app1.mServices.setHasForegroundServices(true, 0, /* hasNoneType=*/true);
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
- bindService(app1, client1, null, Context.BIND_NOT_PERCEPTIBLE, mock(IBinder.class));
+ bindService(app1, client1, null, null, Context.BIND_NOT_PERCEPTIBLE, mock(IBinder.class));
updateOomAdj(client1, app1);
@@ -2051,7 +2058,8 @@
app1.mServices.setHasForegroundServices(true, 0, /* hasNoneType=*/true);
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
- bindService(app1, client1, null, Context.BIND_ALMOST_PERCEPTIBLE, mock(IBinder.class));
+ bindService(app1, client1, null, null, Context.BIND_ALMOST_PERCEPTIBLE,
+ mock(IBinder.class));
updateOomAdj(client1, app1);
@@ -2121,19 +2129,19 @@
final ComponentName cn1 = ComponentName.unflattenFromString(
MOCKAPP_PACKAGENAME + "/.TestService");
- final ServiceRecord s1 = bindService(app1, client1, null, 0, mock(IBinder.class));
+ final ServiceRecord s1 = bindService(app1, client1, null, null, 0, mock(IBinder.class));
setFieldValue(ServiceRecord.class, s1, "name", cn1);
s1.startRequested = true;
final ComponentName cn2 = ComponentName.unflattenFromString(
MOCKAPP2_PACKAGENAME + "/.TestService");
- final ServiceRecord s2 = bindService(app2, client2, null, 0, mock(IBinder.class));
+ final ServiceRecord s2 = bindService(app2, client2, null, null, 0, mock(IBinder.class));
setFieldValue(ServiceRecord.class, s2, "name", cn2);
s2.startRequested = true;
final ComponentName cn3 = ComponentName.unflattenFromString(
MOCKAPP5_PACKAGENAME + "/.TestService");
- final ServiceRecord s3 = bindService(app3, client1, null, 0, mock(IBinder.class));
+ final ServiceRecord s3 = bindService(app3, client1, null, null, 0, mock(IBinder.class));
setFieldValue(ServiceRecord.class, s3, "name", cn3);
s3.startRequested = true;
@@ -2177,7 +2185,7 @@
clientUidRecord.setIdle(true);
doReturn(ActivityManager.APP_START_MODE_DELAYED).when(sService)
.getAppStartModeLOSP(anyInt(), any(String.class), anyInt(),
- anyInt(), anyBoolean(), anyBoolean(), anyBoolean());
+ anyInt(), anyBoolean(), anyBoolean(), anyBoolean());
doNothing().when(sService.mServices)
.scheduleServiceTimeoutLocked(any(ProcessRecord.class));
updateOomAdj(client1, client2, app1, app2, app3);
@@ -2188,7 +2196,7 @@
} finally {
doCallRealMethod().when(sService)
.getAppStartModeLOSP(anyInt(), any(String.class), anyInt(),
- anyInt(), anyBoolean(), anyBoolean(), anyBoolean());
+ anyInt(), anyBoolean(), anyBoolean(), anyBoolean());
sService.mServices.mServiceMap.clear();
sService.mOomAdjuster.mActiveUids.clear();
}
@@ -2223,7 +2231,7 @@
ProcessRecord app2 = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
app2.mServices.setHasForegroundServices(true, 0, /* hasNoneType=*/true);
- bindService(app, app2, null, 0, mock(IBinder.class));
+ bindService(app, app2, null, null, 0, mock(IBinder.class));
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(app, app2);
@@ -2242,12 +2250,12 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord app2 = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, app2, null, 0, mock(IBinder.class));
+ bindService(app, app2, null, null, 0, mock(IBinder.class));
ProcessRecord app3 = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID,
MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, false));
- bindService(app2, app3, null, 0, mock(IBinder.class));
+ bindService(app2, app3, null, null, 0, mock(IBinder.class));
app3.mServices.setHasForegroundServices(true, 0, /* hasNoneType=*/true);
- bindService(app3, app, null, 0, mock(IBinder.class));
+ bindService(app3, app, null, null, 0, mock(IBinder.class));
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(app, app2, app3);
@@ -2278,21 +2286,21 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord app2 = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- ServiceRecord s = bindService(app, app2, null, 0, mock(IBinder.class));
+ ServiceRecord s = bindService(app, app2, null, null, 0, mock(IBinder.class));
ProcessRecord app3 = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID,
MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, false));
- bindService(app2, app3, null, 0, mock(IBinder.class));
- bindService(app3, app, null, 0, mock(IBinder.class));
+ bindService(app2, app3, null, null, 0, mock(IBinder.class));
+ bindService(app3, app, null, null, 0, mock(IBinder.class));
WindowProcessController wpc = app3.getWindowProcessController();
doReturn(true).when(wpc).isHomeProcess();
ProcessRecord app4 = spy(makeDefaultProcessRecord(MOCKAPP4_PID, MOCKAPP4_UID,
MOCKAPP4_PROCESSNAME, MOCKAPP4_PACKAGENAME, false));
app4.mState.setHasOverlayUi(true);
- bindService(app, app4, s, 0, mock(IBinder.class));
+ bindService(app, app4, null, s, 0, mock(IBinder.class));
ProcessRecord app5 = spy(makeDefaultProcessRecord(MOCKAPP5_PID, MOCKAPP5_UID,
MOCKAPP5_PROCESSNAME, MOCKAPP5_PACKAGENAME, false));
app5.mServices.setHasForegroundServices(true, 0, /* hasNoneType=*/true);
- bindService(app, app5, s, 0, mock(IBinder.class));
+ bindService(app, app5, null, s, 0, mock(IBinder.class));
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(app, app2, app3, app4, app5);
@@ -2320,21 +2328,21 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord app2 = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- ServiceRecord s = bindService(app, app2, null, 0, mock(IBinder.class));
+ ServiceRecord s = bindService(app, app2, null, null, 0, mock(IBinder.class));
ProcessRecord app3 = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID,
MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, false));
- bindService(app2, app3, null, 0, mock(IBinder.class));
- bindService(app3, app, null, 0, mock(IBinder.class));
+ bindService(app2, app3, null, null, 0, mock(IBinder.class));
+ bindService(app3, app, null, null, 0, mock(IBinder.class));
WindowProcessController wpc = app3.getWindowProcessController();
doReturn(true).when(wpc).isHomeProcess();
ProcessRecord app4 = spy(makeDefaultProcessRecord(MOCKAPP4_PID, MOCKAPP4_UID,
MOCKAPP4_PROCESSNAME, MOCKAPP4_PACKAGENAME, false));
app4.mState.setHasOverlayUi(true);
- bindService(app, app4, s, 0, mock(IBinder.class));
+ bindService(app, app4, null, s, 0, mock(IBinder.class));
ProcessRecord app5 = spy(makeDefaultProcessRecord(MOCKAPP5_PID, MOCKAPP5_UID,
MOCKAPP5_PROCESSNAME, MOCKAPP5_PACKAGENAME, false));
app5.mServices.setHasForegroundServices(true, 0, /* hasNoneType=*/true);
- bindService(app, app5, s, 0, mock(IBinder.class));
+ bindService(app, app5, null, s, 0, mock(IBinder.class));
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(app5, app4, app3, app2, app);
@@ -2362,21 +2370,21 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord app2 = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- ServiceRecord s = bindService(app, app2, null, 0, mock(IBinder.class));
+ ServiceRecord s = bindService(app, app2, null, null, 0, mock(IBinder.class));
ProcessRecord app3 = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID,
MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, false));
- bindService(app2, app3, null, 0, mock(IBinder.class));
- bindService(app3, app, null, 0, mock(IBinder.class));
+ bindService(app2, app3, null, null, 0, mock(IBinder.class));
+ bindService(app3, app, null, null, 0, mock(IBinder.class));
WindowProcessController wpc = app3.getWindowProcessController();
doReturn(true).when(wpc).isHomeProcess();
ProcessRecord app4 = spy(makeDefaultProcessRecord(MOCKAPP4_PID, MOCKAPP4_UID,
MOCKAPP4_PROCESSNAME, MOCKAPP4_PACKAGENAME, false));
app4.mState.setHasOverlayUi(true);
- bindService(app, app4, s, 0, mock(IBinder.class));
+ bindService(app, app4, null, s, 0, mock(IBinder.class));
ProcessRecord app5 = spy(makeDefaultProcessRecord(MOCKAPP5_PID, MOCKAPP5_UID,
MOCKAPP5_PROCESSNAME, MOCKAPP5_PACKAGENAME, false));
app5.mServices.setHasForegroundServices(true, 0, /* hasNoneType=*/true);
- bindService(app, app5, s, 0, mock(IBinder.class));
+ bindService(app, app5, null, s, 0, mock(IBinder.class));
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(app3, app4, app2, app, app5);
@@ -2404,15 +2412,19 @@
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
- bindService(app, client, null, Context.BIND_INCLUDE_CAPABILITIES, mock(IBinder.class));
+ bindService(app, client, null, null, Context.BIND_INCLUDE_CAPABILITIES,
+ mock(IBinder.class));
ProcessRecord client2 = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID,
MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, false));
- bindService(client, client2, null, Context.BIND_INCLUDE_CAPABILITIES, mock(IBinder.class));
- bindService(client2, app, null, Context.BIND_INCLUDE_CAPABILITIES, mock(IBinder.class));
+ bindService(client, client2, null, null, Context.BIND_INCLUDE_CAPABILITIES,
+ mock(IBinder.class));
+ bindService(client2, app, null, null, Context.BIND_INCLUDE_CAPABILITIES,
+ mock(IBinder.class));
ProcessRecord client3 = spy(makeDefaultProcessRecord(MOCKAPP4_PID, MOCKAPP4_UID,
MOCKAPP4_PROCESSNAME, MOCKAPP4_PACKAGENAME, false));
client3.mState.setMaxAdj(PERSISTENT_PROC_ADJ);
- bindService(app, client3, null, Context.BIND_INCLUDE_CAPABILITIES, mock(IBinder.class));
+ bindService(app, client3, null, null, Context.BIND_INCLUDE_CAPABILITIES,
+ mock(IBinder.class));
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
updateOomAdj(app, client, client2, client3);
@@ -2472,10 +2484,10 @@
ProcessRecord app2 = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
long now = SystemClock.uptimeMillis();
- ServiceRecord s = bindService(app, app2, null, 0, mock(IBinder.class));
+ ServiceRecord s = bindService(app, app2, null, null, 0, mock(IBinder.class));
s.startRequested = true;
s.lastActivity = now;
- s = bindService(app2, app, null, 0, mock(IBinder.class));
+ s = bindService(app2, app, null, null, 0, mock(IBinder.class));
s.startRequested = true;
s.lastActivity = now;
ProcessRecord app3 = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID,
@@ -2507,11 +2519,11 @@
final int userOwner = 0;
final int userOther = 1;
final int cachedAdj1 = sService.mConstants.USE_TIERED_CACHED_ADJ
- ? CACHED_APP_MIN_ADJ + 10
- : CACHED_APP_MIN_ADJ + ProcessList.CACHED_APP_IMPORTANCE_LEVELS;
+ ? CACHED_APP_MIN_ADJ + 10
+ : CACHED_APP_MIN_ADJ + ProcessList.CACHED_APP_IMPORTANCE_LEVELS;
final int cachedAdj2 = sService.mConstants.USE_TIERED_CACHED_ADJ
- ? CACHED_APP_MIN_ADJ + 10
- : cachedAdj1 + ProcessList.CACHED_APP_IMPORTANCE_LEVELS * 2;
+ ? CACHED_APP_MIN_ADJ + 10
+ : cachedAdj1 + ProcessList.CACHED_APP_IMPORTANCE_LEVELS * 2;
doReturn(userOwner).when(sService.mUserController).getCurrentUserId();
final ArrayList<ProcessRecord> lru = sService.mProcessList.getLruProcessesLOSP();
@@ -2626,7 +2638,7 @@
// Simulate binding to a service in the same process using BIND_ABOVE_CLIENT and
// verify that its OOM adjustment level is unaffected.
- bindService(app, app, null, Context.BIND_ABOVE_CLIENT, mock(IBinder.class));
+ bindService(app, app, null, null, Context.BIND_ABOVE_CLIENT, mock(IBinder.class));
app.mServices.updateHasAboveClientLocked();
assertFalse(app.mServices.hasAboveClient());
@@ -2644,12 +2656,12 @@
final ProcessRecord app3 = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID,
MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, false));
long now = SystemClock.uptimeMillis();
- ServiceRecord s = bindService(app, app2, null, 0, mock(IBinder.class));
+ ServiceRecord s = bindService(app, app2, null, null, 0, mock(IBinder.class));
s.startRequested = true;
s.lastActivity = now;
- s = bindService(app2, app3, null, 0, mock(IBinder.class));
+ s = bindService(app2, app3, null, null, 0, mock(IBinder.class));
s.lastActivity = now;
- s = bindService(app3, app2, null, 0, mock(IBinder.class));
+ s = bindService(app3, app2, null, null, 0, mock(IBinder.class));
s.lastActivity = now;
sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
@@ -2678,7 +2690,7 @@
// Start binding to a service that isn't running yet.
ServiceRecord sr = makeServiceRecord(app);
sr.app = null;
- bindService(null, app, sr, Context.BIND_ABOVE_CLIENT, mock(IBinder.class));
+ bindService(null, app, null, sr, Context.BIND_ABOVE_CLIENT, mock(IBinder.class));
// Since sr.app is null, this service cannot be in the same process as the
// client so we expect the BIND_ABOVE_CLIENT adjustment to take effect.
@@ -2772,91 +2784,37 @@
ApplicationExitInfo.SUBREASON_ISOLATED_NOT_NEEDED, true);
}
- private ProcessRecord makeDefaultProcessRecord(int pid, int uid, String processName,
- String packageName, boolean hasShownUi) {
- long now = SystemClock.uptimeMillis();
- return makeProcessRecord(sService, pid, uid, processName,
- packageName, 12345, Build.VERSION_CODES.CUR_DEVELOPMENT,
- now, now, now, 12345, UNKNOWN_ADJ, UNKNOWN_ADJ,
- UNKNOWN_ADJ, CACHED_APP_MAX_ADJ,
- SCHED_GROUP_DEFAULT, SCHED_GROUP_DEFAULT,
- PROCESS_STATE_NONEXISTENT, PROCESS_STATE_NONEXISTENT,
- PROCESS_STATE_NONEXISTENT, PROCESS_STATE_NONEXISTENT,
- 0, 0, false, false, false, ServiceInfo.FOREGROUND_SERVICE_TYPE_NONE,
- false, false, false, hasShownUi, false, false, false, false, false, false, null,
- 0, Long.MIN_VALUE, Long.MIN_VALUE, true, 0, null, false);
+ @SuppressWarnings("GuardedBy")
+ @Test
+ public void testUpdateOomAdj_DoAll_SdkSandbox_attributedClient() {
+ ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
+ MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
+ ProcessRecord attributedClient = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID,
+ MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, true));
+ ProcessRecord sandboxService = spy(new ProcessRecordBuilder(MOCKAPP_PID,
+ MOCKAPP_SDK_SANDBOX_UID, MOCKAPP_SDK_SANDBOX_PROCESSNAME, MOCKAPP_PACKAGENAME)
+ .setSdkSandboxClientAppPackage(MOCKAPP3_PACKAGENAME)
+ .build());
+
+ setProcessesToLru(sandboxService, client, attributedClient);
+
+ client.mState.setMaxAdj(PERSISTENT_PROC_ADJ);
+ attributedClient.mServices.setHasForegroundServices(true, 0, true);
+ bindService(sandboxService, client, attributedClient, null, 0, mock(IBinder.class));
+ sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
+ updateOomAdj();
+ assertProcStates(client, PROCESS_STATE_PERSISTENT, PERSISTENT_PROC_ADJ,
+ SCHED_GROUP_DEFAULT);
+ assertProcStates(attributedClient, PROCESS_STATE_FOREGROUND_SERVICE, PERCEPTIBLE_APP_ADJ,
+ SCHED_GROUP_DEFAULT);
+ assertProcStates(sandboxService, PROCESS_STATE_FOREGROUND_SERVICE, PERCEPTIBLE_APP_ADJ,
+ SCHED_GROUP_DEFAULT);
}
- private ProcessRecord makeProcessRecord(ActivityManagerService service, int pid, int uid,
- String processName, String packageName, long versionCode, int targetSdkVersion,
- long lastActivityTime, long lastPssTime, long nextPssTime, long lastPss, int maxAdj,
- int setRawAdj, int curAdj, int setAdj, int curSchedGroup, int setSchedGroup,
- int curProcState, int repProcState, int curRawProcState, int setProcState,
- int connectionGroup, int connectionImportance, boolean serviceb,
- boolean hasClientActivities, boolean hasForegroundServices, int fgServiceTypes,
- boolean hasForegroundActivities, boolean repForegroundActivities, boolean systemNoUi,
- boolean hasShownUi, boolean hasTopUi, boolean hasOverlayUi,
- boolean runningRemoteAnimation, boolean hasAboveClient, boolean treatLikeActivity,
- boolean killedByAm, Object forcingToImportant, int numOfCurReceivers,
- long lastProviderTime, long lastTopTime, boolean cached, int numOfExecutingServices,
- String isolatedEntryPoint, boolean execServicesFg) {
- ApplicationInfo ai = spy(new ApplicationInfo());
- ai.uid = uid;
- ai.packageName = packageName;
- ai.longVersionCode = versionCode;
- ai.targetSdkVersion = targetSdkVersion;
- ProcessRecord app = new ProcessRecord(service, ai, processName, uid);
- final ProcessStateRecord state = app.mState;
- final ProcessServiceRecord services = app.mServices;
- final ProcessReceiverRecord receivers = app.mReceivers;
- final ProcessProfileRecord profile = app.mProfile;
- final ProcessProviderRecord providers = app.mProviders;
- app.makeActive(mock(IApplicationThread.class), sService.mProcessStats);
- app.setLastActivityTime(lastActivityTime);
- app.setKilledByAm(killedByAm);
- app.setIsolatedEntryPoint(isolatedEntryPoint);
- setFieldValue(ProcessRecord.class, app, "mWindowProcessController",
- mock(WindowProcessController.class));
- profile.setLastPssTime(lastPssTime);
- profile.setNextPssTime(nextPssTime);
- profile.setLastPss(lastPss);
- state.setMaxAdj(maxAdj);
- state.setSetRawAdj(setRawAdj);
- state.setCurAdj(curAdj);
- state.setSetAdj(setAdj);
- state.setCurrentSchedulingGroup(curSchedGroup);
- state.setSetSchedGroup(setSchedGroup);
- state.setCurProcState(curProcState);
- state.setReportedProcState(repProcState);
- state.setCurRawProcState(curRawProcState);
- state.setSetProcState(setProcState);
- state.setServiceB(serviceb);
- state.setRepForegroundActivities(repForegroundActivities);
- state.setHasForegroundActivities(hasForegroundActivities);
- state.setSystemNoUi(systemNoUi);
- state.setHasShownUi(hasShownUi);
- state.setHasTopUi(hasTopUi);
- state.setRunningRemoteAnimation(runningRemoteAnimation);
- state.setHasOverlayUi(hasOverlayUi);
- state.setCached(cached);
- state.setLastTopTime(lastTopTime);
- state.setForcingToImportant(forcingToImportant);
- services.setConnectionGroup(connectionGroup);
- services.setConnectionImportance(connectionImportance);
- services.setHasClientActivities(hasClientActivities);
- services.setHasForegroundServices(hasForegroundServices, fgServiceTypes,
- /* hasNoneType=*/false);
- services.setHasAboveClient(hasAboveClient);
- services.setTreatLikeActivity(treatLikeActivity);
- services.setExecServicesFg(execServicesFg);
- for (int i = 0; i < numOfExecutingServices; i++) {
- services.startExecutingService(mock(ServiceRecord.class));
- }
- for (int i = 0; i < numOfCurReceivers; i++) {
- receivers.addCurReceiver(mock(BroadcastRecord.class));
- }
- providers.setLastProviderTime(lastProviderTime);
- return app;
+ private ProcessRecord makeDefaultProcessRecord(int pid, int uid, String processName,
+ String packageName, boolean hasShownUi) {
+ return new ProcessRecordBuilder(pid, uid, processName, packageName).setHasShownUi(
+ hasShownUi).build();
}
private ServiceRecord makeServiceRecord(ProcessRecord app) {
@@ -2870,6 +2828,7 @@
record.appInfo = app.info;
setFieldValue(ServiceRecord.class, record, "bindings", new ArrayMap<>());
setFieldValue(ServiceRecord.class, record, "pendingStarts", new ArrayList<>());
+ setFieldValue(ServiceRecord.class, record, "isSdkSandbox", app.isSdkSandbox);
return record;
}
@@ -2892,11 +2851,11 @@
}
private ServiceRecord bindService(ProcessRecord service, ProcessRecord client,
- ServiceRecord record, long bindFlags, IBinder binder) {
+ ProcessRecord attributedClient, ServiceRecord record, long bindFlags, IBinder binder) {
if (record == null) {
record = makeServiceRecord(service);
}
- AppBindRecord binding = new AppBindRecord(record, null, client, null);
+ AppBindRecord binding = new AppBindRecord(record, null, client, attributedClient);
ConnectionRecord cr = spy(new ConnectionRecord(binding,
mock(ActivityServiceConnectionsHolder.class),
mock(IServiceConnection.class), bindFlags,
@@ -2961,4 +2920,140 @@
assertBfsl(app);
}
}
+
+ private static class ProcessRecordBuilder {
+ @SuppressWarnings("UnusedVariable")
+ int mPid;
+ int mUid;
+ String mProcessName;
+ String mPackageName;
+ long mVersionCode = 12345;
+ int mTargetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT;
+ long mLastActivityTime;
+ long mLastPssTime;
+ long mNextPssTime;
+ long mLastPss = 12345;
+ int mMaxAdj = UNKNOWN_ADJ;
+ int mSetRawAdj = UNKNOWN_ADJ;
+ int mCurAdj = UNKNOWN_ADJ;
+ int mSetAdj = CACHED_APP_MAX_ADJ;
+ int mCurSchedGroup = SCHED_GROUP_DEFAULT;
+ int mSetSchedGroup = SCHED_GROUP_DEFAULT;
+ int mCurProcState = PROCESS_STATE_NONEXISTENT;
+ int mRepProcState = PROCESS_STATE_NONEXISTENT;
+ int mCurRawProcState = PROCESS_STATE_NONEXISTENT;
+ int mSetProcState = PROCESS_STATE_NONEXISTENT;
+ int mConnectionGroup = 0;
+ int mConnectionImportance = 0;
+ boolean mServiceb = false;
+ boolean mHasClientActivities = false;
+ boolean mHasForegroundServices = false;
+ int mFgServiceTypes = ServiceInfo.FOREGROUND_SERVICE_TYPE_NONE;
+ boolean mHasForegroundActivities = false;
+ boolean mRepForegroundActivities = false;
+ boolean mSystemNoUi = false;
+ boolean mHasShownUi = false;
+ boolean mHasTopUi = false;
+ boolean mHasOverlayUi = false;
+ boolean mRunningRemoteAnimation = false;
+ boolean mHasAboveClient = false;
+ boolean mTreatLikeActivity = false;
+ boolean mKilledByAm = false;
+ Object mForcingToImportant;
+ int mNumOfCurReceivers = 0;
+ long mLastProviderTime = Long.MIN_VALUE;
+ long mLastTopTime = Long.MIN_VALUE;
+ boolean mCached = true;
+ int mNumOfExecutingServices = 0;
+ String mIsolatedEntryPoint = null;
+ boolean mExecServicesFg = false;
+ String mSdkSandboxClientAppPackage = null;
+
+ ProcessRecordBuilder(int pid, int uid, String processName, String packageName) {
+ mPid = pid;
+ mUid = uid;
+ mProcessName = processName;
+ mPackageName = packageName;
+
+ long now = SystemClock.uptimeMillis();
+ mLastActivityTime = now;
+ mLastPssTime = now;
+ mNextPssTime = now;
+ }
+
+ ProcessRecordBuilder setHasShownUi(boolean hasShownUi) {
+ mHasShownUi = hasShownUi;
+ return this;
+ }
+
+ ProcessRecordBuilder setSdkSandboxClientAppPackage(String sdkSandboxClientAppPackage) {
+ mSdkSandboxClientAppPackage = sdkSandboxClientAppPackage;
+ return this;
+ }
+
+ @SuppressWarnings("GuardedBy")
+ public ProcessRecord build() {
+ ApplicationInfo ai = spy(new ApplicationInfo());
+ ai.uid = mUid;
+ ai.packageName = mPackageName;
+ ai.longVersionCode = mVersionCode;
+ ai.targetSdkVersion = mTargetSdkVersion;
+ doCallRealMethod().when(sService).getPackageManagerInternal();
+ doReturn(null).when(sPackageManagerInternal).getApplicationInfo(
+ eq(mSdkSandboxClientAppPackage), anyLong(), anyInt(), anyInt());
+ ProcessRecord app = new ProcessRecord(sService, ai, mProcessName, mUid,
+ mSdkSandboxClientAppPackage, -1, null);
+ final ProcessStateRecord state = app.mState;
+ final ProcessServiceRecord services = app.mServices;
+ final ProcessReceiverRecord receivers = app.mReceivers;
+ final ProcessProfileRecord profile = app.mProfile;
+ final ProcessProviderRecord providers = app.mProviders;
+ app.makeActive(mock(IApplicationThread.class), sService.mProcessStats);
+ app.setLastActivityTime(mLastActivityTime);
+ app.setKilledByAm(mKilledByAm);
+ app.setIsolatedEntryPoint(mIsolatedEntryPoint);
+ setFieldValue(ProcessRecord.class, app, "mWindowProcessController",
+ mock(WindowProcessController.class));
+ profile.setLastPssTime(mLastPssTime);
+ profile.setNextPssTime(mNextPssTime);
+ profile.setLastPss(mLastPss);
+ state.setMaxAdj(mMaxAdj);
+ state.setSetRawAdj(mSetRawAdj);
+ state.setCurAdj(mCurAdj);
+ state.setSetAdj(mSetAdj);
+ state.setCurrentSchedulingGroup(mCurSchedGroup);
+ state.setSetSchedGroup(mSetSchedGroup);
+ state.setCurProcState(mCurProcState);
+ state.setReportedProcState(mRepProcState);
+ state.setCurRawProcState(mCurRawProcState);
+ state.setSetProcState(mSetProcState);
+ state.setServiceB(mServiceb);
+ state.setRepForegroundActivities(mRepForegroundActivities);
+ state.setHasForegroundActivities(mHasForegroundActivities);
+ state.setSystemNoUi(mSystemNoUi);
+ state.setHasShownUi(mHasShownUi);
+ state.setHasTopUi(mHasTopUi);
+ state.setRunningRemoteAnimation(mRunningRemoteAnimation);
+ state.setHasOverlayUi(mHasOverlayUi);
+ state.setCached(mCached);
+ state.setLastTopTime(mLastTopTime);
+ state.setForcingToImportant(mForcingToImportant);
+ services.setConnectionGroup(mConnectionGroup);
+ services.setConnectionImportance(mConnectionImportance);
+ services.setHasClientActivities(mHasClientActivities);
+ services.setHasForegroundServices(mHasForegroundServices, mFgServiceTypes,
+ /* hasNoneType=*/false);
+ services.setHasAboveClient(mHasAboveClient);
+ services.setTreatLikeActivity(mTreatLikeActivity);
+ services.setExecServicesFg(mExecServicesFg);
+ for (int i = 0; i < mNumOfExecutingServices; i++) {
+ services.startExecutingService(mock(ServiceRecord.class));
+ }
+ for (int i = 0; i < mNumOfCurReceivers; i++) {
+ receivers.addCurReceiver(mock(BroadcastRecord.class));
+ }
+ providers.setLastProviderTime(mLastProviderTime);
+ return app;
+ }
+ }
}
diff --git a/services/tests/servicestests/src/com/android/server/media/projection/MediaProjectionManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/media/projection/MediaProjectionManagerServiceTest.java
index aefa6de..abd3abe 100644
--- a/services/tests/servicestests/src/com/android/server/media/projection/MediaProjectionManagerServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/media/projection/MediaProjectionManagerServiceTest.java
@@ -75,12 +75,12 @@
import androidx.test.filters.SmallTest;
import androidx.test.platform.app.InstrumentationRegistry;
-import com.android.internal.util.test.LocalServiceKeeperRule;
+import com.android.server.LocalServices;
import com.android.server.testutils.OffsettableClock;
import com.android.server.wm.WindowManagerInternal;
+import org.junit.After;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
@@ -164,17 +164,15 @@
@Captor
private ArgumentCaptor<ContentRecordingSession> mSessionCaptor;
- @Rule
- public LocalServiceKeeperRule mLocalServiceKeeperRule = new LocalServiceKeeperRule();
-
@Before
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
when(mWatcherCallback.asBinder()).thenReturn(new Binder());
- mLocalServiceKeeperRule.overrideLocalService(ActivityManagerInternal.class, mAmInternal);
- mLocalServiceKeeperRule.overrideLocalService(WindowManagerInternal.class,
- mWindowManagerInternal);
+ LocalServices.removeServiceForTest(ActivityManagerInternal.class);
+ LocalServices.addService(ActivityManagerInternal.class, mAmInternal);
+ LocalServices.removeServiceForTest(WindowManagerInternal.class);
+ LocalServices.addService(WindowManagerInternal.class, mWindowManagerInternal);
mContext = spy(new ContextWrapper(
InstrumentationRegistry.getInstrumentation().getTargetContext()));
@@ -189,6 +187,12 @@
mService = new MediaProjectionManagerService(mContext);
}
+ @After
+ public void tearDown() {
+ LocalServices.removeServiceForTest(ActivityManagerInternal.class);
+ LocalServices.removeServiceForTest(WindowManagerInternal.class);
+ }
+
@Test
public void testGetActiveProjectionInfoInternal() throws NameNotFoundException {
assertThat(mService.getActiveProjectionInfo()).isNull();
@@ -384,16 +388,16 @@
MediaProjectionManagerService.MediaProjection projection = startProjectionPreconditions(
service);
// No starts yet, and not timed out yet - so still valid.
- assertThat(projection.isValidInternal()).isTrue();
+ assertThat(projection.isValid()).isTrue();
// Only one start - so still valid.
projection.start(mIMediaProjectionCallback);
- assertThat(projection.isValidInternal()).isTrue();
+ assertThat(projection.isValid()).isTrue();
// Second start - technically allowed to start again, without stopping in between.
// Token should no longer be valid.
projection.start(mIMediaProjectionCallback);
- assertThat(projection.isValidInternal()).isFalse();
+ assertThat(projection.isValid()).isFalse();
}
@Test
@@ -403,17 +407,17 @@
MediaProjectionManagerService.MediaProjection projection = startProjectionPreconditions(
service);
// No starts yet, and not timed out yet - so still valid.
- assertThat(projection.isValidInternal()).isTrue();
+ assertThat(projection.isValid()).isTrue();
// Only one start - so still valid.
projection.start(mIMediaProjectionCallback);
- assertThat(projection.isValidInternal()).isTrue();
+ assertThat(projection.isValid()).isTrue();
projection.stop();
// Second start - so not valid.
projection.start(mIMediaProjectionCallback);
- assertThat(projection.isValidInternal()).isFalse();
+ assertThat(projection.isValid()).isFalse();
}
@Test
@@ -438,7 +442,7 @@
mClock.fastForward(projection.mDefaultTimeoutMs + 10);
// Immediate timeout - so no longer valid.
- assertThat(projection.isValidInternal()).isFalse();
+ assertThat(projection.isValid()).isFalse();
}
@Test
@@ -448,10 +452,10 @@
MediaProjectionManagerService.MediaProjection projection = startProjectionPreconditions(
service);
// Simulate MediaProjection#createVirtualDisplay being invoked previously.
- projection.notifyVirtualDisplayCreatedInternal(10);
+ projection.notifyVirtualDisplayCreated(10);
// Trying to re-use token on another MediaProjection#createVirtualDisplay - no longer valid.
- assertThat(projection.isValidInternal()).isFalse();
+ assertThat(projection.isValid()).isFalse();
}
// TODO(269273190): Test flag using compat annotations instead.
@@ -467,7 +471,7 @@
// Second start - so not valid.
projection.start(mIMediaProjectionCallback);
- assertThrows(SecurityException.class, projection::isValidInternal);
+ assertThrows(SecurityException.class, projection::isValid);
}
// TODO(269273190): Test flag using compat annotations instead.
@@ -484,7 +488,7 @@
// Second start - so not valid.
projection.start(mIMediaProjectionCallback);
- assertThat(projection.isValidInternal()).isFalse();
+ assertThat(projection.isValid()).isFalse();
}
@Test
@@ -623,7 +627,7 @@
mService.setUserReviewGrantedConsentResult(RECORD_CONTENT_DISPLAY, projection);
// Virtual Display is finally created.
- projection.notifyVirtualDisplayCreatedInternal(10);
+ projection.notifyVirtualDisplayCreated(10);
verifySetSessionWithContent(ContentRecordingSession.RECORD_CONTENT_DISPLAY);
}
@@ -726,7 +730,7 @@
throws Exception {
MediaProjectionManagerService.MediaProjection projection = startProjectionPreconditions();
projection.start(mIMediaProjectionCallback);
- projection.notifyVirtualDisplayCreatedInternal(10);
+ projection.notifyVirtualDisplayCreated(10);
// Waiting for user to review consent.
assertThat(mService.isCurrentProjection(projection)).isTrue();
doReturn(true).when(mWindowManagerInternal).setContentRecordingSession(
@@ -781,9 +785,9 @@
@RecordContent int recordedContent)
throws NameNotFoundException {
MediaProjectionManagerService.MediaProjection projection = startProjectionPreconditions();
- projection.setLaunchCookieInternal(new LaunchCookie());
+ projection.setLaunchCookie(new LaunchCookie());
projection.start(mIMediaProjectionCallback);
- projection.notifyVirtualDisplayCreatedInternal(10);
+ projection.notifyVirtualDisplayCreated(10);
// Waiting for user to review consent.
doReturn(true).when(mWindowManagerInternal).setContentRecordingSession(
any(ContentRecordingSession.class));
@@ -804,7 +808,7 @@
throws NameNotFoundException {
MediaProjectionManagerService.MediaProjection projection = startProjectionPreconditions();
projection.start(mIMediaProjectionCallback);
- projection.notifyVirtualDisplayCreatedInternal(10);
+ projection.notifyVirtualDisplayCreated(10);
// Waiting for user to review consent.
doReturn(true).when(mWindowManagerInternal).setContentRecordingSession(
eq(mWaitingDisplaySession));
@@ -822,7 +826,7 @@
public void testSetUserReviewGrantedConsentResult_displayMirroring_noPriorSession()
throws NameNotFoundException {
MediaProjectionManagerService.MediaProjection projection = startProjectionPreconditions();
- projection.setLaunchCookieInternal(new LaunchCookie());
+ projection.setLaunchCookie(new LaunchCookie());
projection.start(mIMediaProjectionCallback);
// Skip setting the prior session details.
@@ -841,7 +845,7 @@
public void testSetUserReviewGrantedConsentResult_displayMirroring_sessionNotWaiting()
throws NameNotFoundException {
MediaProjectionManagerService.MediaProjection projection = startProjectionPreconditions();
- projection.setLaunchCookieInternal(new LaunchCookie());
+ projection.setLaunchCookie(new LaunchCookie());
projection.start(mIMediaProjectionCallback);
// Session is not waiting for user's consent.
doReturn(true).when(mWindowManagerInternal).setContentRecordingSession(
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
index 847c9d0..d5eeaa7 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
@@ -1561,7 +1561,7 @@
.build();
final int result = starter.recycleTask(task, null, null, null,
- BalVerdict.ALLOW_BY_DEFAULT);
+ BalVerdict.ALLOW_PRIVILEGED);
assertThat(result == START_SUCCESS).isTrue();
assertThat(starter.mAddingToTask).isTrue();
}
@@ -2075,7 +2075,7 @@
starter.startActivityInner(target, source, null /* voiceSession */,
null /* voiceInteractor */, 0 /* startFlags */,
options, inTask, inTaskFragment,
- BalVerdict.ALLOW_BY_DEFAULT,
+ BalVerdict.ALLOW_PRIVILEGED,
null /* intentGrants */, -1 /* realCallingUid */);
}
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/ContentRecorderTests.java b/services/tests/wmtests/src/com/android/server/wm/ContentRecorderTests.java
index 60dfe6f..887e5ee 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ContentRecorderTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ContentRecorderTests.java
@@ -811,7 +811,7 @@
@Test
public void testDisplayContentUpdatesRecording_withSurface() {
- createContentRecorder(createDefaultDisplayInfo());
+ defaultInit();
// GIVEN MediaProjection has already initialized the WindowToken of the DisplayArea to
// mirror.
setUpDefaultTaskDisplayAreaWindowToken();
@@ -820,7 +820,6 @@
// getDisplaySurfaceDefaultSize (done by surfaceControlMirrors in setUp).
final DisplayContent virtualDisplay =
mRootWindowContainer.getDisplayContent(mDisplaySession.getVirtualDisplayId());
- virtualDisplay.setContentRecorder(mContentRecorder);
mWm.mContentRecordingController.setContentRecordingSessionLocked(mDisplaySession, mWm);
virtualDisplay.updateRecording();
@@ -845,7 +844,6 @@
// WHEN getting the DisplayContent for the new virtual display.
final DisplayContent virtualDisplay =
mRootWindowContainer.getDisplayContent(mDisplaySession.getVirtualDisplayId());
- virtualDisplay.setContentRecorder(mContentRecorder);
// Return the default display as the value to mirror to ensure the VD with flag mirroring
// creates a ContentRecordingSession automatically.
doReturn(DEFAULT_DISPLAY).when(mWm.mDisplayManagerInternal).getDisplayIdToMirror(anyInt());
diff --git a/services/tests/wmtests/src/com/android/server/wm/ContentRecordingControllerTests.java b/services/tests/wmtests/src/com/android/server/wm/ContentRecordingControllerTests.java
index 42004c3..c84fe08 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ContentRecordingControllerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ContentRecordingControllerTests.java
@@ -24,7 +24,6 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.atLeastOnce;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import android.platform.test.annotations.Presubmit;
@@ -32,8 +31,6 @@
import androidx.test.filters.SmallTest;
-import com.android.server.wm.ContentRecorder.MediaProjectionManagerWrapper;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -71,11 +68,6 @@
mVirtualDisplayId = mVirtualDisplayContent.getDisplayId();
mWm.mRoot.onDisplayAdded(mVirtualDisplayId);
spyOn(mVirtualDisplayContent);
- final MediaProjectionManagerWrapper
- mediaProjectionManagerWrapper = mock(MediaProjectionManagerWrapper.class);
- final ContentRecorder contentRecorder = new ContentRecorder(mVirtualDisplayContent,
- mediaProjectionManagerWrapper, /* correctForAnisotropicPixels= */ false);
- mVirtualDisplayContent.setContentRecorder(contentRecorder);
mDefaultSession.setVirtualDisplayId(mVirtualDisplayId);
mWaitingDisplaySession.setVirtualDisplayId(mVirtualDisplayId);
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayWindowPolicyControllerTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayWindowPolicyControllerTests.java
index c404c77..bb5887d 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayWindowPolicyControllerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayWindowPolicyControllerTests.java
@@ -187,7 +187,7 @@
/* options */null,
/* inTask */null,
/* inTaskFragment */ null,
- BalVerdict.ALLOW_BY_DEFAULT,
+ BalVerdict.ALLOW_PRIVILEGED,
/* intentGrants */null,
/* realCaiingUid */ -1);
@@ -217,7 +217,7 @@
/* options= */null,
/* inTask= */null,
/* inTaskFragment= */ null,
- BalVerdict.ALLOW_BY_DEFAULT,
+ BalVerdict.ALLOW_PRIVILEGED,
/* intentGrants= */null,
/* realCaiingUid */ -1);
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
index 8b0fc2c..cd3ce91 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
@@ -1424,6 +1424,25 @@
assertFalse(window2.isSecureLocked());
}
+ @Test
+ @RequiresFlagsEnabled(FLAG_SENSITIVE_NOTIFICATION_APP_PROTECTION)
+ public void testIsSecureLocked_sensitiveContentBlockOrClearScreenCaptureForApp() {
+ String testPackage = "test";
+ int ownerId = 20;
+ final WindowState window = createWindow(null, TYPE_APPLICATION, "window", ownerId);
+ window.mAttrs.packageName = testPackage;
+ assertFalse(window.isSecureLocked());
+
+ PackageInfo blockedPackage = new PackageInfo(testPackage, ownerId);
+ ArraySet<PackageInfo> blockedPackages = new ArraySet();
+ blockedPackages.add(blockedPackage);
+ mWm.mSensitiveContentPackages.addBlockScreenCaptureForApps(blockedPackages);
+ assertTrue(window.isSecureLocked());
+
+ mWm.mSensitiveContentPackages.removeBlockScreenCaptureForApps(blockedPackages);
+ assertFalse(window.isSecureLocked());
+ }
+
private static class TestImeTargetChangeListener implements ImeTargetChangeListener {
private IBinder mImeTargetToken;
private boolean mIsRemoved;
diff --git a/telecomm/java/android/telecom/CallAttributes.java b/telecomm/java/android/telecom/CallAttributes.java
index 8c6e101..afd34fc 100644
--- a/telecomm/java/android/telecom/CallAttributes.java
+++ b/telecomm/java/android/telecom/CallAttributes.java
@@ -16,6 +16,7 @@
package android.telecom;
+import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -24,6 +25,8 @@
import android.os.Parcelable;
import android.text.TextUtils;
+import com.android.server.telecom.flags.Flags;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Objects;
@@ -113,7 +116,8 @@
public static final int VIDEO_CALL = 2;
/** @hide */
- @IntDef(value = {SUPPORTS_SET_INACTIVE, SUPPORTS_STREAM, SUPPORTS_TRANSFER}, flag = true)
+ @IntDef(value = {SUPPORTS_SET_INACTIVE, SUPPORTS_STREAM, SUPPORTS_TRANSFER,
+ SUPPORTS_VIDEO_CALLING}, flag = true)
@Retention(RetentionPolicy.SOURCE)
public @interface CallCapability {
}
@@ -133,6 +137,12 @@
* The call can be completely transferred from one endpoint to another.
*/
public static final int SUPPORTS_TRANSFER = 1 << 3;
+ /**
+ * The call supports video calling. This allows clients to gate video calling on a per call
+ * basis as opposed to re-registering the phone account.
+ */
+ @FlaggedApi(Flags.FLAG_TRANSACTIONAL_VIDEO_STATE)
+ public static final int SUPPORTS_VIDEO_CALLING = 1 << 4;
/**
* Build an instance of {@link CallAttributes}. In order to build a valid instance, a
diff --git a/telecomm/java/android/telecom/CallControl.java b/telecomm/java/android/telecom/CallControl.java
index a1407869..808a575 100644
--- a/telecomm/java/android/telecom/CallControl.java
+++ b/telecomm/java/android/telecom/CallControl.java
@@ -293,12 +293,50 @@
try {
mServerInterface.setMuteState(isMuted,
new CallControlResultReceiver("requestMuteState", executor, callback));
-
} catch (RemoteException e) {
throw e.rethrowAsRuntimeException();
}
}
+ /**
+ * Request a new video state for the ongoing call. This can only be changed if the application
+ * has registered a {@link PhoneAccount} with the
+ * {@link PhoneAccount#CAPABILITY_SUPPORTS_VIDEO_CALLING} and set the
+ * {@link CallAttributes#SUPPORTS_VIDEO_CALLING} when adding the call via
+ * {@link TelecomManager#addCall(CallAttributes, Executor, OutcomeReceiver,
+ * CallControlCallback, CallEventCallback)}
+ *
+ * @param videoState to report to Telecom. To see the valid argument to pass,
+ * see {@link CallAttributes.CallType}.
+ * @param executor The {@link Executor} on which the {@link OutcomeReceiver} callback
+ * will be called on.
+ * @param callback that will be completed on the Telecom side that details success or failure
+ * of the requested operation.
+ *
+ * {@link OutcomeReceiver#onResult} will be called if Telecom has successfully
+ * switched the video state.
+ *
+ * {@link OutcomeReceiver#onError} will be called if Telecom has failed to set
+ * the new video state. A {@link CallException} will be passed
+ * that details why the operation failed.
+ * @throws IllegalArgumentException if the argument passed for videoState is invalid. To see a
+ * list of valid states, see {@link CallAttributes.CallType}.
+ */
+ @FlaggedApi(Flags.FLAG_TRANSACTIONAL_VIDEO_STATE)
+ public void requestVideoState(@CallAttributes.CallType int videoState,
+ @CallbackExecutor @NonNull Executor executor,
+ @NonNull OutcomeReceiver<Void, CallException> callback) {
+ validateVideoState(videoState);
+ Objects.requireNonNull(executor);
+ Objects.requireNonNull(callback);
+ try {
+ mServerInterface.requestVideoState(videoState, mCallId,
+ new CallControlResultReceiver("requestVideoState", executor, callback));
+ } catch (RemoteException e) {
+ throw e.rethrowAsRuntimeException();
+ }
+ }
+
/**
* Raises an event to the {@link android.telecom.InCallService} implementations tracking this
* call via {@link android.telecom.Call.Callback#onConnectionEvent(Call, String, Bundle)}.
diff --git a/telecomm/java/android/telecom/CallEventCallback.java b/telecomm/java/android/telecom/CallEventCallback.java
index a41c011..b0438bf 100644
--- a/telecomm/java/android/telecom/CallEventCallback.java
+++ b/telecomm/java/android/telecom/CallEventCallback.java
@@ -16,9 +16,12 @@
package android.telecom;
+import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.os.Bundle;
+import com.android.server.telecom.flags.Flags;
+
import java.util.List;
/**
@@ -51,6 +54,14 @@
void onMuteStateChanged(boolean isMuted);
/**
+ * Called when the video state changes.
+ *
+ * @param videoState The current video state.
+ */
+ @FlaggedApi(Flags.FLAG_TRANSACTIONAL_VIDEO_STATE)
+ default void onVideoStateChanged(@CallAttributes.CallType int videoState) {}
+
+ /**
* Telecom is informing the client user requested call streaming but the stream can't be
* started.
*
diff --git a/telecomm/java/com/android/internal/telecom/ClientTransactionalServiceWrapper.java b/telecomm/java/com/android/internal/telecom/ClientTransactionalServiceWrapper.java
index 467e89c..a2c6086 100644
--- a/telecomm/java/com/android/internal/telecom/ClientTransactionalServiceWrapper.java
+++ b/telecomm/java/com/android/internal/telecom/ClientTransactionalServiceWrapper.java
@@ -33,6 +33,8 @@
import android.text.TextUtils;
import android.util.Log;
+import com.android.server.telecom.flags.Flags;
+
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
@@ -148,6 +150,7 @@
private static final String ON_REQ_ENDPOINT_CHANGE = "onRequestEndpointChange";
private static final String ON_AVAILABLE_CALL_ENDPOINTS = "onAvailableCallEndpointsChanged";
private static final String ON_MUTE_STATE_CHANGED = "onMuteStateChanged";
+ private static final String ON_VIDEO_STATE_CHANGED = "onVideoStateChanged";
private static final String ON_CALL_STREAMING_FAILED = "onCallStreamingFailed";
private static final String ON_EVENT = "onEvent";
@@ -261,6 +264,11 @@
handleEventCallback(callId, ON_MUTE_STATE_CHANGED, isMuted);
}
+ @Override
+ public void onVideoStateChanged(String callId, int videoState) {
+ handleEventCallback(callId, ON_VIDEO_STATE_CHANGED, videoState);
+ }
+
public void handleEventCallback(String callId, String action, Object arg) {
Log.d(TAG, TextUtils.formatSimple("hEC: [%s], callId=[%s]", action, callId));
// lookup the callEventCallback associated with the particular call
@@ -281,6 +289,11 @@
case ON_MUTE_STATE_CHANGED:
callback.onMuteStateChanged((boolean) arg);
break;
+ case ON_VIDEO_STATE_CHANGED:
+ if (Flags.transactionalVideoState()) {
+ callback.onVideoStateChanged((int) arg);
+ }
+ break;
case ON_CALL_STREAMING_FAILED:
callback.onCallStreamingFailed((int) arg /* reason */);
break;
diff --git a/telecomm/java/com/android/internal/telecom/ICallControl.aidl b/telecomm/java/com/android/internal/telecom/ICallControl.aidl
index 372e4a12..ac49660 100644
--- a/telecomm/java/com/android/internal/telecom/ICallControl.aidl
+++ b/telecomm/java/com/android/internal/telecom/ICallControl.aidl
@@ -34,4 +34,5 @@
void requestCallEndpointChange(in CallEndpoint callEndpoint, in ResultReceiver callback);
void setMuteState(boolean isMuted, in ResultReceiver callback);
void sendEvent(String callId, String event, in Bundle extras);
+ void requestVideoState(int videoState, String callId, in ResultReceiver callback);
}
\ No newline at end of file
diff --git a/telecomm/java/com/android/internal/telecom/ICallEventCallback.aidl b/telecomm/java/com/android/internal/telecom/ICallEventCallback.aidl
index 213cafb..e4d6b0c 100644
--- a/telecomm/java/com/android/internal/telecom/ICallEventCallback.aidl
+++ b/telecomm/java/com/android/internal/telecom/ICallEventCallback.aidl
@@ -45,6 +45,8 @@
void onCallEndpointChanged(String callId, in CallEndpoint endpoint);
void onAvailableCallEndpointsChanged(String callId, in List<CallEndpoint> endpoint);
void onMuteStateChanged(String callId, boolean isMuted);
+ // -- Video Related
+ void onVideoStateChanged(String callId, int videoState);
// -- Events
void onEvent(String callId, String event, in Bundle extras);
// hidden methods that help with cleanup
diff --git a/telephony/java/android/telephony/DomainSelectionService.java b/telephony/java/android/telephony/DomainSelectionService.java
index 4ff9712..633694a 100644
--- a/telephony/java/android/telephony/DomainSelectionService.java
+++ b/telephony/java/android/telephony/DomainSelectionService.java
@@ -20,6 +20,7 @@
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.app.Service;
import android.content.Intent;
@@ -855,7 +856,8 @@
*
* @return an {@link Executor} used to execute methods called remotely by the framework.
*/
- public @NonNull Executor onCreateExecutor() {
+ @SuppressLint("OnNameExpected")
+ public @NonNull Executor getCreateExecutor() {
return Runnable::run;
}
@@ -869,7 +871,7 @@
public final @NonNull Executor getCachedExecutor() {
synchronized (mExecutorLock) {
if (mExecutor == null) {
- Executor e = onCreateExecutor();
+ Executor e = getCreateExecutor();
mExecutor = (e != null) ? e : Runnable::run;
}
return mExecutor;
diff --git a/tools/hoststubgen/scripts/run-all-tests.sh b/tools/hoststubgen/scripts/run-all-tests.sh
deleted file mode 100755
index a6847ae..0000000
--- a/tools/hoststubgen/scripts/run-all-tests.sh
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/bin/bash
-# Copyright (C) 2023 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-source "${0%/*}"/../common.sh
-
-# Move to the top directory of hoststubgen
-cd ..
-
-ATEST_ARGS="--host"
-
-# These tests are known to pass.
-READY_TEST_MODULES=(
- hoststubgen-test-tiny-test
- CtsUtilTestCasesRavenwood
- CtsOsTestCasesRavenwood # This one uses native sustitution, so let's run it too.
-)
-
-MUST_BUILD_MODULES=(
- "${NOT_READY_TEST_MODULES[*]}"
-)
-
-# First, build all the test / etc modules. This shouldn't fail.
-run m "${MUST_BUILD_MODULES[@]}"
-
-# Run the hoststubgen unittests / etc
-run atest $ATEST_ARGS hoststubgentest hoststubgen-invoke-test
-
-# Next, run the golden check. This should always pass too.
-# The following scripts _should_ pass too, but they depend on the internal paths to soong generated
-# files, and they may fail when something changes in the build system.
-run ./hoststubgen/test-tiny-framework/diff-and-update-golden.sh
-
-run ./hoststubgen/test-tiny-framework/run-test-manually.sh
-run atest $ATEST_ARGS tiny-framework-dump-test
-
-# This script is already broken on goog/master
-# run ./scripts/build-framework-hostside-jars-without-genrules.sh
-
-# These tests should all pass.
-run atest $ATEST_ARGS ${READY_TEST_MODULES[*]}
-
-echo ""${0##*/}" finished, with no failures. Ready to submit!"