Skip to content

Commit

Permalink
Merge pull request #9693 from Redirion/accelerometerfix
Browse files Browse the repository at this point in the history
Orientation is locked if there is no sensor for it
  • Loading branch information
Stypox authored Feb 7, 2023
2 parents ca421c2 + 9ecd5df commit 4c5c2a3
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.provider.Settings;
import android.view.accessibility.CaptioningManager;

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

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

0 comments on commit 4c5c2a3

Please sign in to comment.