* {@param procStateSeq}.
*/
public abstract void notifyNetworkPolicyRulesUpdated(int uid, long procStateSeq);
+
+ /**
+ * Called after virtual display Id is updated by
+ * {@link com.android.server.vr.CompatibilityDisplay} with a specific
+ * {@param compatibilityDisplayId}.
+ */
+ public abstract void setVrCompatibilityDisplayId(int vrCompatibilityDisplayId);
}
import static android.provider.Settings.System.FONT_SCALE;
import static android.service.voice.VoiceInteractionSession.SHOW_SOURCE_APPLICATION;
import static android.view.Display.DEFAULT_DISPLAY;
+import static android.view.Display.INVALID_DISPLAY;
import static com.android.internal.util.XmlUtils.readBooleanAttribute;
import static com.android.internal.util.XmlUtils.readIntAttribute;
import static com.android.internal.util.XmlUtils.readLongAttribute;
}
};
+ // VR Compatibility Display Id.
+ int mVrCompatibilityDisplayId = INVALID_DISPLAY;
+
// Whether we should use SCHED_FIFO for UI and RenderThreads.
private boolean mUseFifoUiScheduling = false;
}
}
}
+
+ /**
+ * Called after virtual display Id is updated by
+ * {@link com.android.server.vr.CompatibilityDisplay} with a specific
+ * {@param vrCompatibilityDisplayId}.
+ */
+ @Override
+ public void setVrCompatibilityDisplayId(int vrCompatibilityDisplayId) {
+ if (DEBUG_STACK) {
+ Slog.d(TAG, "setVrCompatibilityDisplayId called for: " +
+ vrCompatibilityDisplayId);
+ }
+ synchronized (ActivityManagerService.this) {
+ mVrCompatibilityDisplayId = vrCompatibilityDisplayId;
+ }
+ }
}
/**
import com.android.internal.app.HeavyWeightSwitcherActivity;
import com.android.internal.app.IVoiceInteractor;
+import com.android.server.LocalServices;
import com.android.server.am.ActivityStackSupervisor.PendingActivityLaunch;
import com.android.server.pm.InstantAppResolver;
+import com.android.server.vr.VrManagerInternal;
import com.android.server.wm.WindowManagerService;
import java.util.ArrayList;
private IVoiceInteractionSession mVoiceSession;
private IVoiceInteractor mVoiceInteractor;
+ private boolean mUsingVrCompatibilityDisplay;
+
private void reset() {
mStartActivity = null;
mIntent = null;
mVoiceSession = null;
mVoiceInteractor = null;
+
+ mUsingVrCompatibilityDisplay = false;
}
ActivityStarter(ActivityManagerService service, ActivityStackSupervisor supervisor) {
mService = service;
mSupervisor = supervisor;
mInterceptor = new ActivityStartInterceptor(mService, mSupervisor);
+ mUsingVrCompatibilityDisplay = false;
}
final int startActivityLocked(IApplicationThread caller, Intent intent, Intent ephemeralIntent,
mVoiceSession = voiceSession;
mVoiceInteractor = voiceInteractor;
- mSourceDisplayId = sourceRecord != null ? sourceRecord.getDisplayId() : INVALID_DISPLAY;
- if (mSourceDisplayId == INVALID_DISPLAY) {
- mSourceDisplayId = DEFAULT_DISPLAY;
- }
+ mSourceDisplayId = getSourceDisplayId(mSourceRecord, mStartActivity);
mLaunchBounds = getOverrideBounds(r, options, inTask);
}
/**
+ * Returns the ID of the display to use for a new activity. If the source activity has
+ * a explicit display ID set, use that to launch the activity. If not and the device is in VR
+ * mode, then return the Vr mode's virtual display ID.
+ */
+ private int getSourceDisplayId(ActivityRecord sourceRecord, ActivityRecord startingActivity) {
+ int displayId = sourceRecord != null ? sourceRecord.getDisplayId() : INVALID_DISPLAY;
+ // If the activity has a displayId set explicitly, launch it on the same displayId.
+ if (displayId != INVALID_DISPLAY) {
+ return displayId;
+ }
+
+ // Check if the Activity is a VR activity. If so, the activity should be launched in
+ // main display.
+ if (startingActivity != null && startingActivity.requestedVrComponent != null) {
+ return DEFAULT_DISPLAY;
+ }
+
+ // Get the virtual display id from ActivityManagerService.
+ displayId = mService.mVrCompatibilityDisplayId;
+ if (displayId != INVALID_DISPLAY) {
+ if (DEBUG_STACK) {
+ Slog.d(TAG, "getSourceDisplayId :" + displayId);
+ }
+ mUsingVrCompatibilityDisplay = true;
+ return displayId;
+ }
+ return DEFAULT_DISPLAY;
+ }
+
+ /**
* Figure out which task and activity to bring to front when we have found an existing matching
* activity record in history. May also clear the task if needed.
* @param intentActivity Existing matching activity.
return mSupervisor.getValidLaunchStackOnDisplay(launchDisplayId, r);
}
- if ((launchFlags & FLAG_ACTIVITY_LAUNCH_ADJACENT) == 0
- || mSourceDisplayId != DEFAULT_DISPLAY) {
+ // If we are using Vr compatibility display, find the virtual display stack.
+ if (mUsingVrCompatibilityDisplay) {
+ ActivityStack as = mSupervisor.getValidLaunchStackOnDisplay(mSourceDisplayId, r);
+ if (DEBUG_STACK) {
+ Slog.v(TAG, "Launch stack for app: " + r.toString() +
+ ", on virtual display stack:" + as.toString());
+ }
+ return as;
+ }
+
+ if (((launchFlags & FLAG_ACTIVITY_LAUNCH_ADJACENT) == 0)
+ || mSourceDisplayId != DEFAULT_DISPLAY) {
return null;
}
// Otherwise handle adjacent launch.
import static android.view.Display.INVALID_DISPLAY;
+import android.app.ActivityManagerInternal;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
private final static String DEBUG_EXTRA_SURFACE =
"com.android.server.vr.CompatibilityDisplay.EXTRA_SURFACE";
+ private final ActivityManagerInternal mActivityManagerInternal;
private final DisplayManager mDisplayManager;
private final IVrManager mVrManager;
private final Object mVdLock = new Object();
private boolean mIsVrModeOverrideEnabled;
private boolean mIsVrModeEnabled;
- public CompatibilityDisplay(DisplayManager displayManager, IVrManager vrManager) {
+ public CompatibilityDisplay(DisplayManager displayManager,
+ ActivityManagerInternal activityManagerInternal, IVrManager vrManager) {
mDisplayManager = displayManager;
+ mActivityManagerInternal = activityManagerInternal;
mVrManager = vrManager;
}
mVirtualDisplay = mDisplayManager.createVirtualDisplay("VR 2D Display", WIDTH, HEIGHT,
DPI, null /* Surface */, 0 /* flags */);
+
+ if (mVirtualDisplay != null) {
+ mActivityManagerInternal.setVrCompatibilityDisplayId(
+ mVirtualDisplay.getDisplay().getDisplayId());
+ } else {
+ Log.w(TAG, "Virtual display id is null after createVirtualDisplay");
+ mActivityManagerInternal.setVrCompatibilityDisplayId(INVALID_DISPLAY);
+ return;
+ }
}
if (DEBUG) {
} else {
Log.i(TAG, "Stopping Virtual Display");
synchronized (mVdLock) {
+ mActivityManagerInternal.setVrCompatibilityDisplayId(INVALID_DISPLAY);
setSurfaceLocked(null); // clean up and release the surface first.
if (mVirtualDisplay != null) {
mVirtualDisplay.release();
import static android.view.Display.INVALID_DISPLAY;
import android.Manifest;
+import android.app.ActivityManagerInternal;
import android.app.ActivityManager;
import android.app.AppOpsManager;
import android.app.NotificationManager;
import android.util.SparseArray;
import com.android.internal.R;
+import com.android.server.LocalServices;
import com.android.server.SystemConfig;
import com.android.server.SystemService;
import com.android.server.utils.ManagedApplicationService.PendingEvent;
DisplayManager dm =
(DisplayManager) getContext().getSystemService(Context.DISPLAY_SERVICE);
- mCompatibilityDisplay = new CompatibilityDisplay(dm, mVrManager);
+ ActivityManagerInternal ami = LocalServices.getService(ActivityManagerInternal.class);
+ mCompatibilityDisplay = new CompatibilityDisplay(dm, ami, mVrManager);
mCompatibilityDisplay.init(getContext());
} else if (phase == SystemService.PHASE_THIRD_PARTY_APPS_CAN_START) {
synchronized (mLock) {