Skip to content

Commit 739e893

Browse files
author
David Gräff
committed
improve add device dialog; add initial device auto configuration; fix bug device query abort if no existing devices; add debug option to disable/enable energy save mode; fix bugs caused by own fragment backstack
1 parent b1c4d14 commit 739e893

File tree

84 files changed

+3354
-1554
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+3354
-1554
lines changed

.idea/inspectionProfiles/Project_Default.xml

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

+1,103-503
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/app.iml

+61-23
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
<component name="FacetManager">
44
<facet type="android" name="Android">
55
<configuration>
6-
<option name="SELECTED_BUILD_VARIANT" value="debug" />
7-
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
8-
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugJava" />
9-
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
10-
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
6+
<option name="SELECTED_BUILD_VARIANT" value="vanillaDebug" />
7+
<option name="ASSEMBLE_TASK_NAME" value="assembleVanillaDebug" />
8+
<option name="COMPILE_JAVA_TASK_NAME" value="compileVanillaDebugJava" />
9+
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleVanillaDebugTest" />
10+
<option name="SOURCE_GEN_TASK_NAME" value="generateVanillaDebugSources" />
1111
<option name="ALLOW_USER_CONFIGURATION" value="false" />
1212
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
1313
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
@@ -22,19 +22,40 @@
2222
</facet>
2323
</component>
2424
<component name="NewModuleRootManager" inherit-compiler-output="false">
25-
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
25+
<output url="file://$MODULE_DIR$/build/intermediates/classes/vanilla/debug" />
2626
<exclude-output />
2727
<content url="file://$MODULE_DIR$">
28-
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
29-
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
30-
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
31-
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
32-
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
33-
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" />
34-
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" />
35-
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" />
36-
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" />
37-
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />
28+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/vanilla/debug" isTestSource="false" generated="true" />
29+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/vanilla/debug" isTestSource="false" generated="true" />
30+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/vanilla/debug" isTestSource="false" generated="true" />
31+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/vanilla/debug" isTestSource="false" generated="true" />
32+
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/vanilla/debug" type="java-resource" />
33+
<sourceFolder url="file://$MODULE_DIR$/src/vanillaDebug/res" type="java-resource" />
34+
<sourceFolder url="file://$MODULE_DIR$/src/vanillaDebug/resources" type="java-resource" />
35+
<sourceFolder url="file://$MODULE_DIR$/src/vanillaDebug/aidl" isTestSource="false" />
36+
<sourceFolder url="file://$MODULE_DIR$/src/vanillaDebug/assets" isTestSource="false" />
37+
<sourceFolder url="file://$MODULE_DIR$/src/vanillaDebug/java" isTestSource="false" />
38+
<sourceFolder url="file://$MODULE_DIR$/src/vanillaDebug/jni" isTestSource="false" />
39+
<sourceFolder url="file://$MODULE_DIR$/src/vanillaDebug/rs" isTestSource="false" />
40+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/vanilla/debug" isTestSource="true" generated="true" />
41+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/vanilla/debug" isTestSource="true" generated="true" />
42+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/vanilla/debug" isTestSource="true" generated="true" />
43+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/vanilla/debug" isTestSource="true" generated="true" />
44+
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/vanilla/debug" type="java-test-resource" />
45+
<sourceFolder url="file://$MODULE_DIR$/src/vanilla/res" type="java-resource" />
46+
<sourceFolder url="file://$MODULE_DIR$/src/vanilla/resources" type="java-resource" />
47+
<sourceFolder url="file://$MODULE_DIR$/src/vanilla/aidl" isTestSource="false" />
48+
<sourceFolder url="file://$MODULE_DIR$/src/vanilla/assets" isTestSource="false" />
49+
<sourceFolder url="file://$MODULE_DIR$/src/vanilla/java" isTestSource="false" />
50+
<sourceFolder url="file://$MODULE_DIR$/src/vanilla/jni" isTestSource="false" />
51+
<sourceFolder url="file://$MODULE_DIR$/src/vanilla/rs" isTestSource="false" />
52+
<sourceFolder url="file://$MODULE_DIR$/src/androidTestVanilla/res" type="java-test-resource" />
53+
<sourceFolder url="file://$MODULE_DIR$/src/androidTestVanilla/resources" type="java-test-resource" />
54+
<sourceFolder url="file://$MODULE_DIR$/src/androidTestVanilla/aidl" isTestSource="true" />
55+
<sourceFolder url="file://$MODULE_DIR$/src/androidTestVanilla/assets" isTestSource="true" />
56+
<sourceFolder url="file://$MODULE_DIR$/src/androidTestVanilla/java" isTestSource="true" />
57+
<sourceFolder url="file://$MODULE_DIR$/src/androidTestVanilla/jni" isTestSource="true" />
58+
<sourceFolder url="file://$MODULE_DIR$/src/androidTestVanilla/rs" isTestSource="true" />
3859
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
3960
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
4061
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
@@ -56,17 +77,34 @@
5677
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
5778
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
5879
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
59-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates" />
80+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
81+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
82+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
83+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
84+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
85+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
86+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
87+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
88+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
89+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
90+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
91+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
92+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
93+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
94+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
95+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
96+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
97+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
98+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
6099
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
61100
</content>
62101
<orderEntry type="jdk" jdkName="Android API 20 Platform" jdkType="Android SDK" />
63102
<orderEntry type="sourceFolder" forTests="false" />
64-
<orderEntry type="library" exported="" name="support-annotations-21.0.0-rc1" level="project" />
65-
<orderEntry type="library" exported="" name="play-services-4.4.52" level="project" />
66-
<orderEntry type="library" exported="" name="support-v4-21.0.0-rc1" level="project" />
67-
<orderEntry type="library" exported="" name="library-0.9.9" level="project" />
68-
<orderEntry type="library" exported="" name="library-0.4.0" level="project" />
69-
<orderEntry type="library" exported="" name="support-v13-21.0.0-rc1" level="project" />
103+
<orderEntry type="library" exported="" name="support-v13-20.0.0" level="project" />
104+
<orderEntry type="library" exported="" name="library-0.9" level="project" />
105+
<orderEntry type="library" exported="" name="support-annotations-20.0.0" level="project" />
106+
<orderEntry type="library" exported="" name="support-v4-20.0.0" level="project" />
107+
<orderEntry type="library" exported="" name="play-services-5.0.89" level="project" />
70108
<orderEntry type="library" exported="" name="acra-4.5.0" level="project" />
71109
<orderEntry type="library" exported="" name="library-1.5.1" level="project" />
72110
</component>

app/build.gradle

+17-7
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,21 @@ android {
44
compileSdkVersion 20
55
buildToolsVersion '20'
66

7+
productFlavors {
8+
vanilla {
9+
10+
}
11+
12+
old23 {
13+
minSdkVersion 8
14+
}
15+
}
16+
717
defaultConfig {
818
minSdkVersion 14
919
targetSdkVersion 20
10-
versionCode 73
11-
versionName "5.6"
20+
versionCode 80
21+
versionName "5.6.5"
1222
}
1323

1424
lintOptions {
@@ -36,10 +46,10 @@ android {
3646
}
3747

3848
dependencies {
39-
//compile fileTree(dir: 'libs', include: ['*.jar'])
40-
compile 'com.google.android.gms:play-services:4.+'
49+
//compile fileTree(dir: 'libs', include: ['*.jar']) :5.2.08
50+
compile 'com.google.android.gms:play-services:5.0.89'
4151
compile 'com.github.gabrielemariotti.changeloglib:library:1.5.1'
42-
compile 'ch.acra:acra:4+'
43-
compile 'com.android.support:support-v13:+'
44-
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:0.9+'
52+
compile 'ch.acra:acra:4.5.0'
53+
compile 'com.android.support:support-v13:20.0.0'
54+
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:0.9'
4555
}

app/src/main/AndroidManifest.xml

+18-6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,24 @@
3636
android:icon="@drawable/netpowerctrl"
3737
android:label="@string/app_name">
3838

39+
<!--android:permission="android.permission.MANAGE_DOCUMENTS"-->
40+
<provider
41+
android:name=".utils.AssetDocumentProvider"
42+
android:authorities="oly.netpowerctrl.utils.AssetDocumentProvider"
43+
android:enabled="@bool/atLeastKitKat"
44+
android:exported="true"
45+
android:grantUriPermissions="true"
46+
android:icon="@drawable/netpowerctrl"
47+
android:initOrder="1"
48+
android:label="@string/app_name"
49+
android:multiprocess="true"
50+
android:permission="android.permission.MANAGE_DOCUMENTS"
51+
android:syncable="false">
52+
<intent-filter>
53+
<action android:name="android.content.action.DOCUMENTS_PROVIDER" />
54+
</intent-filter>
55+
</provider>
56+
3957
<meta-data
4058
android:name="com.google.android.gms.version"
4159
android:value="@integer/google_play_services_version" />
@@ -124,12 +142,6 @@
124142
<service android:name="oly.netpowerctrl.widget.WidgetUpdateService" />
125143

126144
<service android:name=".backup.neighbours.NeighbourDataReceiveService" />
127-
128-
<provider
129-
android:name="oly.netpowerctrl.utils.AssetContentProvider"
130-
android:authorities="oly.netpowerctrl"
131-
android:exported="false"
132-
android:grantUriPermissions="true" />
133145
</application>
134146

135147

app/src/main/java/oly/netpowerctrl/anel/AnelBroadcastSendJob.java

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.util.List;
1212
import java.util.Set;
1313

14+
import oly.netpowerctrl.R;
1415
import oly.netpowerctrl.application_state.NetpowerctrlApplication;
1516
import oly.netpowerctrl.application_state.PluginInterface;
1617
import oly.netpowerctrl.devices.Device;
@@ -81,6 +82,10 @@ public void process(UDPSending UDPSending) {
8182
for (Device device : devices) {
8283
if (device.pluginID.equals(AnelPlugin.PLUGIN_ID)) {
8384
PluginInterface i = device.getPluginInterface();
85+
if (i == null) {
86+
device.setNotReachableAll(NetpowerctrlApplication.instance.getString(R.string.error_plugin_not_installed));
87+
continue;
88+
}
8489
for (DeviceConnection ci : device.DeviceConnections) {
8590
i.requestData(ci);
8691
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
package oly.netpowerctrl.anel;
2+
3+
import android.content.Context;
4+
import android.os.Handler;
5+
6+
import java.util.List;
7+
8+
import oly.netpowerctrl.application_state.PluginInterface;
9+
import oly.netpowerctrl.device_ports.DevicePort;
10+
import oly.netpowerctrl.devices.Device;
11+
import oly.netpowerctrl.network.DeviceObserverResult;
12+
import oly.netpowerctrl.network.DeviceQuery;
13+
import oly.netpowerctrl.network.DeviceUpdate;
14+
15+
/**
16+
* Created by david on 20.08.14.
17+
*/
18+
public class AnelCreateDevice implements DeviceObserverResult, DeviceUpdate {
19+
public final Device device;
20+
private final Context context;
21+
public AnelCreateDeviceResult listener = null;
22+
TestStates test_state = TestStates.TEST_INIT;
23+
private DeviceQuery deviceQuery;
24+
25+
public AnelCreateDevice(Device di, Context context) {
26+
this.context = context;
27+
if (di == null) {
28+
device = Device.createNewDevice(AnelUDPDeviceDiscoveryThread.anelPlugin.getPluginID());
29+
device.setPluginInterface(AnelUDPDeviceDiscoveryThread.anelPlugin);
30+
// Default values for user and password
31+
device.UserName = "admin";
32+
device.Password = "anel";
33+
} else
34+
device = di;
35+
}
36+
37+
public boolean wakeupPlugin() {
38+
PluginInterface pluginInterface = device.getPluginInterface();
39+
if (pluginInterface != null) {
40+
pluginInterface.enterFullNetworkState(device);
41+
return true;
42+
} else {
43+
return false;
44+
}
45+
}
46+
47+
@Override
48+
public void onDeviceUpdated(Device di) {
49+
onDeviceUpdated(di, false);
50+
}
51+
52+
@Override
53+
public void onDeviceUpdated(Device updated_device, boolean willBeRemoved) {
54+
if (!updated_device.equalsByUniqueID(device))
55+
return;
56+
57+
if (test_state == TestStates.TEST_REACHABLE) {
58+
// Update stored device with received values
59+
device.UniqueDeviceID = updated_device.UniqueDeviceID;
60+
// do not copy the deviceName here, just the other values
61+
device.copyValuesFromUpdated(updated_device);
62+
// Test user+password by setting a device port.
63+
test_state = TestStates.TEST_ACCESS;
64+
// Just send the current value of the first device port as target value.
65+
// Should change nothing but we will get a feedback if the credentials are working.
66+
PluginInterface pi = device.getPluginInterface();
67+
assert pi != null;
68+
if (deviceQuery != null) {
69+
deviceQuery.addDevice(device, false);
70+
}
71+
DevicePort oi = device.getFirst();
72+
if (oi != null)
73+
pi.execute(oi, oi.current_value, null);
74+
Handler handler = new Handler();
75+
// Timeout is 1,1s
76+
handler.postDelayed(new Runnable() {
77+
@Override
78+
public void run() {
79+
if (test_state == TestStates.TEST_ACCESS || test_state == TestStates.TEST_INIT) {
80+
test_state = TestStates.TEST_INIT;
81+
if (listener != null)
82+
listener.testDeviceNotReachable();
83+
}
84+
}
85+
}, 1100);
86+
} else if (test_state == TestStates.TEST_ACCESS) {
87+
if (listener != null)
88+
listener.testFinished(true);
89+
device.copyValuesFromUpdated(updated_device);
90+
test_state = TestStates.TEST_OK;
91+
}
92+
}
93+
94+
@Override
95+
public void onObserverJobFinished(List<Device> timeout_devices) {
96+
if (test_state != TestStates.TEST_REACHABLE)
97+
return;
98+
99+
for (Device di : timeout_devices) {
100+
if (!di.equalsByUniqueID(device))
101+
continue;
102+
test_state = TestStates.TEST_INIT;
103+
if (listener != null)
104+
listener.testFinished(false);
105+
break;
106+
}
107+
}
108+
109+
public boolean startTest() {
110+
test_state = TestStates.TEST_REACHABLE;
111+
112+
if (wakeupPlugin())
113+
deviceQuery = new DeviceQuery(this, device);
114+
else
115+
return false;
116+
return true;
117+
}
118+
119+
public boolean isTesting() {
120+
return test_state != TestStates.TEST_INIT && test_state != TestStates.TEST_OK;
121+
}
122+
123+
enum TestStates {TEST_INIT, TEST_REACHABLE, TEST_ACCESS, TEST_OK}
124+
125+
public interface AnelCreateDeviceResult {
126+
void testFinished(boolean success);
127+
128+
void testDeviceNotReachable();
129+
}
130+
}

0 commit comments

Comments
 (0)