Skip to content

Commit 4c5c2a3

Browse files
authored
Merge pull request #9693 from Redirion/accelerometerfix
Orientation is locked if there is no sensor for it
2 parents ca421c2 + 9ecd5df commit 4c5c2a3

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

app/src/main/java/org/schabi/newpipe/player/helper/PlayerHelper.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import android.annotation.SuppressLint;
1515
import android.content.Context;
1616
import android.content.SharedPreferences;
17+
import android.content.pm.PackageManager;
1718
import android.provider.Settings;
1819
import android.view.accessibility.CaptioningManager;
1920

@@ -382,8 +383,11 @@ public static void setScreenBrightness(@NonNull final Context context,
382383
public static boolean globalScreenOrientationLocked(final Context context) {
383384
// 1: Screen orientation changes using accelerometer
384385
// 0: Screen orientation is locked
386+
// if the accelerometer sensor is missing completely, assume locked orientation
385387
return android.provider.Settings.System.getInt(
386-
context.getContentResolver(), Settings.System.ACCELEROMETER_ROTATION, 0) == 0;
388+
context.getContentResolver(), Settings.System.ACCELEROMETER_ROTATION, 0) == 0
389+
|| !context.getPackageManager()
390+
.hasSystemFeature(PackageManager.FEATURE_SENSOR_ACCELEROMETER);
387391
}
388392

389393
public static int getProgressiveLoadIntervalBytes(@NonNull final Context context) {

0 commit comments

Comments
 (0)