Merge "Add manifest attribute for VR activities." into nyc-dev
diff --git a/api/current.txt b/api/current.txt
index c738a2b..f267789 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -513,6 +513,7 @@
field public static final int elevation = 16843840; // 0x1010440
field public static final int ellipsize = 16842923; // 0x10100ab
field public static final int ems = 16843096; // 0x1010158
+ field public static final int enableVrMode = 16844072; // 0x1010528
field public static final int enabled = 16842766; // 0x101000e
field public static final int end = 16843996; // 0x10104dc
field public static final int endColor = 16843166; // 0x101019e
diff --git a/api/system-current.txt b/api/system-current.txt
index 1c7248c..5a62d98 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -617,6 +617,7 @@
field public static final int elevation = 16843840; // 0x1010440
field public static final int ellipsize = 16842923; // 0x10100ab
field public static final int ems = 16843096; // 0x1010158
+ field public static final int enableVrMode = 16844072; // 0x1010528
field public static final int enabled = 16842766; // 0x101000e
field public static final int end = 16843996; // 0x10104dc
field public static final int endColor = 16843166; // 0x101019e
diff --git a/api/test-current.txt b/api/test-current.txt
index 40505a1..25e58e2 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -513,6 +513,7 @@
field public static final int elevation = 16843840; // 0x1010440
field public static final int ellipsize = 16842923; // 0x10100ab
field public static final int ems = 16843096; // 0x1010158
+ field public static final int enableVrMode = 16844072; // 0x1010528
field public static final int enabled = 16842766; // 0x101000e
field public static final int end = 16843996; // 0x10104dc
field public static final int endColor = 16843166; // 0x101019e
diff --git a/core/java/android/content/pm/ActivityInfo.java b/core/java/android/content/pm/ActivityInfo.java
index 0f4cbbb..167befc 100644
--- a/core/java/android/content/pm/ActivityInfo.java
+++ b/core/java/android/content/pm/ActivityInfo.java
@@ -191,6 +191,13 @@
public int resizeMode;
/**
+ * Name of the VrListenerService component to run for this activity.
+ * @see android.R.attr#enableVrMode
+ * @hide
+ */
+ public String requestedVrComponent;
+
+ /**
* Bit in {@link #flags} indicating whether this activity is able to
* run in multiple processes. If
* true, the system may instantiate it in the some process as the
@@ -794,6 +801,7 @@
lockTaskLaunchMode = orig.lockTaskLaunchMode;
windowLayout = orig.windowLayout;
resizeMode = orig.resizeMode;
+ requestedVrComponent = orig.requestedVrComponent;
}
/**
@@ -896,6 +904,9 @@
+ windowLayout.heightFraction + ", " + windowLayout.gravity);
}
pw.println(prefix + "resizeMode=" + resizeModeToString(resizeMode));
+ if (requestedVrComponent != null) {
+ pw.println(prefix + "requestedVrComponent=" + requestedVrComponent);
+ }
super.dumpBack(pw, prefix, flags);
}
@@ -939,6 +950,7 @@
dest.writeInt(0);
}
dest.writeInt(resizeMode);
+ dest.writeString(requestedVrComponent);
}
public static final Parcelable.Creator<ActivityInfo> CREATOR
@@ -972,6 +984,7 @@
windowLayout = new WindowLayout(source);
}
resizeMode = source.readInt();
+ requestedVrComponent = source.readString();
}
/**
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 54091db..6502022 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -3532,6 +3532,9 @@
a.info.encryptionAware = a.info.directBootAware = sa.getBoolean(
R.styleable.AndroidManifestActivity_directBootAware,
false);
+
+ a.info.requestedVrComponent =
+ sa.getString(R.styleable.AndroidManifestActivity_enableVrMode);
} else {
a.info.launchMode = ActivityInfo.LAUNCH_MULTIPLE;
a.info.configChanges = 0;
diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml
index e040bea..cd7df87 100644
--- a/core/res/res/values/attrs_manifest.xml
+++ b/core/res/res/values/attrs_manifest.xml
@@ -552,6 +552,15 @@
should not be interrupted with other activities or notifications. -->
<attr name="immersive" format="boolean" />
+ <!-- Flag declaring that this activity will be run in VR mode, and specifying
+ the component of the VrListenerService that should be bound while this
+ Activity is visible if installed and enabled on this device. This is
+ equivalent to calling {@link android.app.Activity#setVrModeEnabled} with the
+ the given component name within this Activity. Declaring this will prevent
+ the system from leaving VR mode during an Activity transtion one VR activity
+ to another. -->
+ <attr name="enableVrMode" format="string" />
+
<!-- Specify the order in which content providers hosted by a process
are instantiated when that process is created. Not needed unless
you have providers with dependencies between each other, to make
@@ -1884,6 +1893,7 @@
For example, {@link android.R.attr#supportsPictureInPicture} activities are placed
in a task/stack that isn't focusable. This flag allows them to be focusable.-->
<attr name="alwaysFocusable" format="boolean" />
+ <attr name="enableVrMode" />
</declare-styleable>
<!-- The <code>activity-alias</code> tag declares a new
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 80b3a64..11df8e5 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -2714,6 +2714,7 @@
<public type="attr" name="contentInsetStartWithNavigation" />
<public type="attr" name="contentInsetEndWithActions" />
<public type="attr" name="numberPickerStyle" />
+ <public type="attr" name="enableVrMode" />
<public type="style" name="Theme.Material.Light.DialogWhenLarge.DarkActionBar" />
<public type="style" name="Widget.Material.SeekBar.Discrete" />
diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java
index a7f4314..a41a8ef 100755
--- a/services/core/java/com/android/server/am/ActivityRecord.java
+++ b/services/core/java/com/android/server/am/ActivityRecord.java
@@ -721,6 +721,9 @@
}
immersive = (aInfo.flags & ActivityInfo.FLAG_IMMERSIVE) != 0;
+
+ requestedVrComponent = (aInfo.requestedVrComponent == null) ?
+ null : ComponentName.unflattenFromString(aInfo.requestedVrComponent);
} else {
realActivity = null;
taskAffinity = null;
@@ -732,6 +735,7 @@
noDisplay = false;
mActivityType = APPLICATION_ACTIVITY_TYPE;
immersive = false;
+ requestedVrComponent = null;
}
}