Merge "Allow for SDK 26 Activities to specify orientation when not fullscreen." into oc-dev

This commit is contained in:
Bryce Lee
2017-05-11 20:06:20 +00:00
committed by Android (Google) Code Review
3 changed files with 4 additions and 4 deletions

View File

@@ -976,7 +976,7 @@ public class Activity extends ContextThemeWrapper
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
if (DEBUG_LIFECYCLE) Slog.v(TAG, "onCreate " + this + ": " + savedInstanceState); if (DEBUG_LIFECYCLE) Slog.v(TAG, "onCreate " + this + ": " + savedInstanceState);
if (getApplicationInfo().targetSdkVersion >= O && mActivityInfo.isFixedOrientation()) { if (getApplicationInfo().targetSdkVersion > O && mActivityInfo.isFixedOrientation()) {
final TypedArray ta = obtainStyledAttributes(com.android.internal.R.styleable.Window); final TypedArray ta = obtainStyledAttributes(com.android.internal.R.styleable.Window);
final boolean isTranslucentOrFloating = ActivityInfo.isTranslucentOrFloating(ta); final boolean isTranslucentOrFloating = ActivityInfo.isTranslucentOrFloating(ta);
ta.recycle(); ta.recycle();

View File

@@ -2180,7 +2180,7 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
void setRequestedOrientation(int requestedOrientation) { void setRequestedOrientation(int requestedOrientation) {
if (ActivityInfo.isFixedOrientation(requestedOrientation) && !fullscreen if (ActivityInfo.isFixedOrientation(requestedOrientation) && !fullscreen
&& appInfo.targetSdkVersion >= O) { && appInfo.targetSdkVersion > O) {
throw new IllegalStateException("Only fullscreen activities can request orientation"); throw new IllegalStateException("Only fullscreen activities can request orientation");
} }

View File

@@ -1248,11 +1248,11 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
*/ */
@Override @Override
int getOrientation(int candidate) { int getOrientation(int candidate) {
// We do not allow non-fullscreen apps to influence orientation at and beyond O. While we do // We do not allow non-fullscreen apps to influence orientation beyond O. While we do
// throw an exception in {@link Activity#onCreate} and // throw an exception in {@link Activity#onCreate} and
// {@link Activity#setRequestedOrientation}, we also ignore the orientation here so that // {@link Activity#setRequestedOrientation}, we also ignore the orientation here so that
// other calculations aren't affected. // other calculations aren't affected.
if (!fillsParent() && mTargetSdk >= O) { if (!fillsParent() && mTargetSdk > O) {
// Can't specify orientation if app doesn't fill parent. // Can't specify orientation if app doesn't fill parent.
return SCREEN_ORIENTATION_UNSET; return SCREEN_ORIENTATION_UNSET;
} }