Skip to content

Commit

Permalink
Orientation is locked if there is no sensor for it
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin committed Jan 16, 2023
1 parent aa41fec commit 9ecd5df
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 9ecd5df

Please sign in to comment.