fix: disable File Shuttle on Android Go devices

* Those won't work with SYSTEM_ALERT_WINDOW
This commit is contained in:
Peter Cai 2020-09-08 20:55:32 +08:00
parent f35f125c7d
commit 172522f3f9
No known key found for this signature in database
GPG key ID: 71F5FB4E4F3FD54F

View file

@ -1,5 +1,7 @@
package net.typeblog.shelter.ui;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
@ -90,6 +92,14 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Prefer
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.Q) {
mPrefCrossProfileFileChooser.setEnabled(false);
}
// Disable FileShuttle for Android Go
// as it requires SYSTEM_ALERT_WINDOW which
// is not allowed on Go devices
ActivityManager am = (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE);
if (am.isLowRamDevice()) {
mPrefCrossProfileFileChooser.setEnabled(false);
}
}
@Override