summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nikita Ioffe <ioffe@google.com> 2022-11-16 15:56:02 +0000
committer Nikita Ioffe <ioffe@google.com> 2022-11-24 16:39:13 +0000
commit167b913ad48e23453c1bb20817c6b6dc63fca25c (patch)
treeca5d986db90fa342103f9052d72c2f5b79304b9c
parentd567dc56b8b390a52579fbce28e1d68f007aadc8 (diff)
Register managers provided by the com.android.virt APEX
This allows apps to retrieve an instance of VirtualMachineManager via Context.getSystemService() API. Bug: 249093790 Test: builds Test: atest --test-mapping packages/modules/Virtualization:avf-presubmit Change-Id: I488c275343753f2a3af6270cbad2ab02f33f203f
-rw-r--r--core/api/system-current.txt1
-rw-r--r--core/java/android/app/SystemServiceRegistry.java2
-rw-r--r--core/java/android/content/Context.java15
3 files changed, 18 insertions, 0 deletions
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index fe66952ab3f9..ec2689960a0f 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -3146,6 +3146,7 @@ package android.content {
field public static final String TRANSLATION_MANAGER_SERVICE = "translation";
field public static final String UI_TRANSLATION_SERVICE = "ui_translation";
field public static final String UWB_SERVICE = "uwb";
+ field public static final String VIRTUALIZATION_SERVICE = "virtualization";
field public static final String VR_SERVICE = "vrmanager";
field public static final String WALLPAPER_EFFECTS_GENERATION_SERVICE = "wallpaper_effects_generation";
field public static final String WEARABLE_SENSING_SERVICE = "wearable_sensing";
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java
index 68579840d339..e54a0841dd26 100644
--- a/core/java/android/app/SystemServiceRegistry.java
+++ b/core/java/android/app/SystemServiceRegistry.java
@@ -210,6 +210,7 @@ import android.service.oemlock.OemLockManager;
import android.service.persistentdata.IPersistentDataBlockService;
import android.service.persistentdata.PersistentDataBlockManager;
import android.service.vr.IVrManager;
+import android.system.virtualmachine.VirtualizationFrameworkInitializer;
import android.telecom.TelecomManager;
import android.telephony.MmsManager;
import android.telephony.TelephonyFrameworkInitializer;
@@ -1566,6 +1567,7 @@ public final class SystemServiceRegistry {
NearbyFrameworkInitializer.registerServiceWrappers();
OnDevicePersonalizationFrameworkInitializer.registerServiceWrappers();
DeviceLockFrameworkInitializer.registerServiceWrappers();
+ VirtualizationFrameworkInitializer.registerServiceWrappers();
} finally {
// If any of the above code throws, we're in a pretty bad shape and the process
// will likely crash, but we'll reset it just in case there's an exception handler...
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 0b20078bdb5f..fcdf4403902d 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -3939,6 +3939,7 @@ public abstract class Context {
DISPLAY_HASH_SERVICE,
CREDENTIAL_SERVICE,
DEVICE_LOCK_SERVICE,
+ VIRTUALIZATION_SERVICE,
})
@Retention(RetentionPolicy.SOURCE)
public @interface ServiceName {}
@@ -6114,6 +6115,20 @@ public abstract class Context {
public static final String DEVICE_LOCK_SERVICE = "device_lock";
/**
+ * Use with {@link #getSystemService(String)} to retrieve a
+ * {@link android.system.virtualmachine.VirtualMachineManager}.
+ *
+ * <p>On devices without {@link PackageManager#FEATURE_VIRTUALIZATION_FRAMEWORK} system feature
+ * the {@link #getSystemService(String)} will return {@code null}.
+ *
+ * @see #getSystemService(String)
+ * @see android.system.virtualmachine.VirtualMachineManager
+ * @hide
+ */
+ @SystemApi
+ public static final String VIRTUALIZATION_SERVICE = "virtualization";
+
+ /**
* Determine whether the given permission is allowed for a particular
* process and user ID running in the system.
*