Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
[Android] Implement ScreenOrientation.unlock align with spec
Browse files Browse the repository at this point in the history
This is for compliance with ScreenOrientation
(https://w3c.github.io/screen-orientation).

When unlock screen orientation, it should lock the orientation
to default orientation.
Previous implementation is to set the orientation to "unspecified",
which is not fully aligned with spec.

Instead, read the configuration from the activity metadata in
AndroidManifest.xml and set the orientation accordingly.

BUG=394214

Review URL: https://codereview.chromium.org/399553002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284396 0039d316-1c4b-4281-b951-d872f2087c98
(cherry picked from commit 11420f5)
  • Loading branch information
[email protected] authored and darktears committed Aug 26, 2014
1 parent 6a269ac commit b959b96
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ Sevan Janiyan <[email protected]>
ShankarGanesh K <[email protected]>
Shez Baig <[email protected]>
Shiliu Wang <[email protected]>
Shiliu Wang <[email protected]>
Shouqun Liu <[email protected]>
Shreyas VA <[email protected]>
Simon Arlott <[email protected]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.util.Log;

import com.google.common.annotations.VisibleForTesting;
Expand Down Expand Up @@ -74,7 +75,17 @@ void unlockOrientation() {
return;
}

activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
int defaultOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;

try {
ActivityInfo info = activity.getPackageManager().getActivityInfo(
activity.getComponentName(), PackageManager.GET_META_DATA);
defaultOrientation = info.screenOrientation;
} catch (PackageManager.NameNotFoundException e) {
// Do nothing, defaultOrientation should be SCREEN_ORIENTATION_UNSPECIFIED.
} finally {
activity.setRequestedOrientation(defaultOrientation);
}
}

private ScreenOrientationProvider() {
Expand Down

0 comments on commit b959b96

Please sign in to comment.