Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.content.pm.ActivityInfo; | 8 import android.content.pm.ActivityInfo; |
| 9 import android.content.pm.PackageManager; | |
| 10 import android.content.pm.PackageManager.NameNotFoundException; | |
| 9 import android.util.Log; | 11 import android.util.Log; |
| 10 | 12 |
| 11 import com.google.common.annotations.VisibleForTesting; | 13 import com.google.common.annotations.VisibleForTesting; |
| 12 | 14 |
| 13 import org.chromium.base.ApplicationStatus; | 15 import org.chromium.base.ApplicationStatus; |
| 14 import org.chromium.base.CalledByNative; | 16 import org.chromium.base.CalledByNative; |
| 15 import org.chromium.base.JNINamespace; | 17 import org.chromium.base.JNINamespace; |
| 16 import org.chromium.content.common.ScreenOrientationValues; | 18 import org.chromium.content.common.ScreenOrientationValues; |
| 17 | 19 |
| 18 /** | 20 /** |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 activity.setRequestedOrientation(orientation); | 69 activity.setRequestedOrientation(orientation); |
| 68 } | 70 } |
| 69 | 71 |
| 70 @CalledByNative | 72 @CalledByNative |
| 71 void unlockOrientation() { | 73 void unlockOrientation() { |
| 72 Activity activity = ApplicationStatus.getLastTrackedFocusedActivity(); | 74 Activity activity = ApplicationStatus.getLastTrackedFocusedActivity(); |
| 73 if (activity == null) { | 75 if (activity == null) { |
| 74 return; | 76 return; |
| 75 } | 77 } |
| 76 | 78 |
| 77 activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECI FIED); | 79 try { |
| 80 ActivityInfo info = activity.getPackageManager().getActivityInfo( | |
| 81 activity.getComponentName(), PackageManager.GET_META_DATA); | |
| 82 activity.setRequestedOrientation(info.screenOrientation); | |
| 83 } catch (NameNotFoundException e) { | |
| 84 activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNS PECIFIED); | |
| 85 } | |
|
mlamouri (slow - plz ping)
2014/07/16 09:13:42
I would prefer if the try-catch was only wrapping
| |
| 78 } | 86 } |
| 79 | 87 |
| 80 private ScreenOrientationProvider() { | 88 private ScreenOrientationProvider() { |
| 81 } | 89 } |
| 82 } | 90 } |
| OLD | NEW |