mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 02:35:19 +08:00
Changed: Use PermissionUtils to request disabling battery optimizations in TermuxService
This commit is contained in:
@@ -302,18 +302,8 @@ public final class TermuxService extends Service implements AppShell.AppShellCli
|
|||||||
mWifiLock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, TermuxConstants.TERMUX_APP_NAME.toLowerCase());
|
mWifiLock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, TermuxConstants.TERMUX_APP_NAME.toLowerCase());
|
||||||
mWifiLock.acquire();
|
mWifiLock.acquire();
|
||||||
|
|
||||||
String packageName = getPackageName();
|
if (!PermissionUtils.checkIfBatteryOptimizationsDisabled(this)) {
|
||||||
if (!pm.isIgnoringBatteryOptimizations(packageName)) {
|
PermissionUtils.requestDisableBatteryOptimizations(this);
|
||||||
Intent whitelist = new Intent();
|
|
||||||
whitelist.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
|
|
||||||
whitelist.setData(Uri.parse("package:" + packageName));
|
|
||||||
whitelist.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
|
|
||||||
try {
|
|
||||||
startActivity(whitelist);
|
|
||||||
} catch (ActivityNotFoundException e) {
|
|
||||||
Logger.logStackTraceWithMessage(LOG_TAG, "Failed to call ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateNotification();
|
updateNotification();
|
||||||
|
Reference in New Issue
Block a user