summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2016-03-17 10:32:18 +0100
committerArne Schwabe <arne@rfc2549.org>2016-03-22 10:13:12 +0100
commita7d9f82ace6abc19dbc4b9a390a91f70dd76d1bc (patch)
treedac12bb5f37b192b8530fc67a52753dde8261b2d
parentbe658960e04d363b9551581dbf34b74f7e8472e4 (diff)
Add test for doze disabling
-rw-r--r--main/src/main/AndroidManifest.xml7
-rw-r--r--main/src/main/java/de/blinkt/openvpn/activities/MainActivity.java20
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/LogFileHandler.java1
3 files changed, 24 insertions, 4 deletions
diff --git a/main/src/main/AndroidManifest.xml b/main/src/main/AndroidManifest.xml
index 235f0924..2fb4629a 100644
--- a/main/src/main/AndroidManifest.xml
+++ b/main/src/main/AndroidManifest.xml
@@ -14,6 +14,7 @@
<!-- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+ <!-- <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" /> -->
<!-- <uses-permission android:name="com.android.vending.BILLING" /> -->
@@ -66,7 +67,7 @@
<service
android:name=".core.OpenVPNService"
- android:permission="android.permission.BIND_VPN_SERVICE">
+ android:permission="android.permission.BIND_VPN_SERVICE" >
<intent-filter>
<action android:name="android.net.VpnService" />
</intent-filter>
@@ -102,8 +103,8 @@
<activity
android:name=".activities.ConfigConverter"
- android:label="Convert Config File"
android:excludeFromRecents="true"
+ android:label="Convert Config File"
android:taskAffinity=".ConfigConverter"
android:uiOptions="splitActionBarWhenNarrow"
tools:ignore="ExportedActivity">
@@ -145,8 +146,8 @@
android:name=".LaunchVPN"
android:autoRemoveFromRecents="true"
android:excludeFromRecents="true"
- android:noHistory="true"
android:label="@string/vpn_launch_title"
+ android:noHistory="true"
android:taskAffinity=".LaunchVPN"
android:theme="@style/blinkt.dialog"
tools:ignore="ExportedActivity">
diff --git a/main/src/main/java/de/blinkt/openvpn/activities/MainActivity.java b/main/src/main/java/de/blinkt/openvpn/activities/MainActivity.java
index e04e5f21..8f1eca5b 100644
--- a/main/src/main/java/de/blinkt/openvpn/activities/MainActivity.java
+++ b/main/src/main/java/de/blinkt/openvpn/activities/MainActivity.java
@@ -8,9 +8,13 @@ package de.blinkt.openvpn.activities;
import android.annotation.TargetApi;
import android.app.ActionBar;
import android.app.Activity;
+import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.net.Uri;
import android.os.Build;
+import android.os.PowerManager;
+import android.provider.Settings;
import android.support.v4n.view.ViewPager;
import android.view.Menu;
import android.view.MenuItem;
@@ -67,8 +71,24 @@ public class MainActivity extends BaseActivity {
TabBarView tabs = (TabBarView) findViewById(R.id.sliding_tabs);
tabs.setViewPager(mPager);
+
+ // requestDozeDisable();
}
+ @TargetApi(Build.VERSION_CODES.M)
+ private void requestDozeDisable() {
+ Intent intent = new Intent();
+ String packageName = getPackageName();
+ PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
+ if (pm.isIgnoringBatteryOptimizations(packageName))
+ intent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
+ else {
+ intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
+ intent.setData(Uri.parse("package:" + packageName));
+ }
+ startActivity(intent);
+ }
+
private static final String FEATURE_TELEVISION = "android.hardware.type.television";
private static final String FEATURE_LEANBACK = "android.software.leanback";
diff --git a/main/src/main/java/de/blinkt/openvpn/core/LogFileHandler.java b/main/src/main/java/de/blinkt/openvpn/core/LogFileHandler.java
index 2ba16d39..77bb26dc 100644
--- a/main/src/main/java/de/blinkt/openvpn/core/LogFileHandler.java
+++ b/main/src/main/java/de/blinkt/openvpn/core/LogFileHandler.java
@@ -85,7 +85,6 @@ class LogFileHandler extends Handler {
}
}
-
private void writeLogItemToDisk(VpnStatus.LogItem li) throws IOException {
Parcel p = Parcel.obtain();
li.writeToParcel(p, 0);