Merge pull request #481 from estevez-dev/pre-release/702
Pre release/702
This commit is contained in:
commit
345301c03a
@ -50,11 +50,13 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
debug {
|
if (!System.getenv()["CI"]) {
|
||||||
keyAlias keystoreProperties['debugKeyAlias']
|
debug {
|
||||||
keyPassword keystoreProperties['debugKeyPassword']
|
keyAlias keystoreProperties['debugKeyAlias']
|
||||||
storeFile file(keystoreProperties['debugStoreFile'])
|
keyPassword keystoreProperties['debugKeyPassword']
|
||||||
storePassword keystoreProperties['debugStorePassword']
|
storeFile file(keystoreProperties['debugStoreFile'])
|
||||||
|
storePassword keystoreProperties['debugStorePassword']
|
||||||
|
}
|
||||||
}
|
}
|
||||||
release {
|
release {
|
||||||
keyAlias keystoreProperties['keyAlias']
|
keyAlias keystoreProperties['keyAlias']
|
||||||
|
@ -140,7 +140,7 @@ final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
|
|||||||
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
|
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
|
||||||
const String appName = "HA Client";
|
const String appName = "HA Client";
|
||||||
const appVersionNumber = "0.7.0";
|
const appVersionNumber = "0.7.0";
|
||||||
const appVersionAdd = "alpha2";
|
const appVersionAdd = "alpha3";
|
||||||
const appVersion = "$appVersionNumber-$appVersionAdd";
|
const appVersion = "$appVersionNumber-$appVersionAdd";
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
|
@ -66,13 +66,10 @@ class LocationManager {
|
|||||||
"httpWebHost": httpWebHost
|
"httpWebHost": httpWebHost
|
||||||
},
|
},
|
||||||
frequency: _updateInterval,
|
frequency: _updateInterval,
|
||||||
existingWorkPolicy: workManager.ExistingWorkPolicy.replace,
|
existingWorkPolicy: workManager.ExistingWorkPolicy.keep,
|
||||||
backoffPolicy: workManager.BackoffPolicy.linear,
|
backoffPolicy: workManager.BackoffPolicy.linear,
|
||||||
|
backoffPolicyDelay: _updateInterval,
|
||||||
constraints: workManager.Constraints(
|
constraints: workManager.Constraints(
|
||||||
requiresBatteryNotLow: false,
|
|
||||||
requiresCharging: false,
|
|
||||||
requiresDeviceIdle: false,
|
|
||||||
requiresStorageNotLow: false,
|
|
||||||
networkType: workManager.NetworkType.connected
|
networkType: workManager.NetworkType.connected
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -120,19 +117,20 @@ class LocationManager {
|
|||||||
|
|
||||||
void updateDeviceLocationIsolate() {
|
void updateDeviceLocationIsolate() {
|
||||||
workManager.Workmanager.executeTask((backgroundTask, data) {
|
workManager.Workmanager.executeTask((backgroundTask, data) {
|
||||||
print("[Location isolate] Started: $backgroundTask");
|
print("[Background $backgroundTask] Started");
|
||||||
|
|
||||||
print("[Location isolate] loading settings");
|
|
||||||
String webhookId = data["webhookId"];
|
String webhookId = data["webhookId"];
|
||||||
String httpWebHost = data["httpWebHost"];
|
String httpWebHost = data["httpWebHost"];
|
||||||
if (webhookId != null && webhookId.isNotEmpty) {
|
if (webhookId != null && webhookId.isNotEmpty) {
|
||||||
Logger.d("[Location isolate] Getting device location...");
|
int battery = DateTime.now().hour;
|
||||||
|
print("[Background $backgroundTask] hour=$battery");
|
||||||
|
String url = "$httpWebHost/api/webhook/$webhookId";
|
||||||
|
Map<String, String> headers = {};
|
||||||
|
headers["Content-Type"] = "application/json";
|
||||||
|
print("[Background $backgroundTask] Getting device location...");
|
||||||
Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.medium).then((location) {
|
Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.medium).then((location) {
|
||||||
Logger.d("[Location isolate] Got location: ${location.latitude} ${location.longitude}. Sending home...");
|
print("[Background $backgroundTask] Got location: ${location.latitude} ${location.longitude}");
|
||||||
int battery = DateTime.now().hour;
|
print("[Background $backgroundTask] sending data home...");
|
||||||
String url = "$httpWebHost/api/webhook/$webhookId";
|
|
||||||
Map<String, String> headers = {};
|
|
||||||
headers["Content-Type"] = "application/json";
|
|
||||||
var data = {
|
var data = {
|
||||||
"type": "update_location",
|
"type": "update_location",
|
||||||
"data": {
|
"data": {
|
||||||
@ -146,15 +144,56 @@ void updateDeviceLocationIsolate() {
|
|||||||
headers: headers,
|
headers: headers,
|
||||||
body: json.encode(data)
|
body: json.encode(data)
|
||||||
).catchError((e) {
|
).catchError((e) {
|
||||||
print("[Location isolate] Error sending data: ${e.toString()}");
|
print("[Background $backgroundTask] Error sending data: ${e.toString()}");
|
||||||
}).then((_) {
|
}).then((_) {
|
||||||
print("[Location isolate] done!");
|
print("[Background $backgroundTask] Success!");
|
||||||
});
|
});
|
||||||
}).catchError((e) {
|
}).catchError((e) {
|
||||||
print("[Location isolate] Error getting location: ${e.toString()}");
|
print("[Background $backgroundTask] Error getting current location: ${e.toString()}. Trying last known...");
|
||||||
|
Geolocator().getLastKnownPosition(desiredAccuracy: LocationAccuracy.medium).then((location){
|
||||||
|
print("[Background $backgroundTask] Got last known location: ${location.latitude} ${location.longitude}");
|
||||||
|
print("[Background $backgroundTask] sending data home...");
|
||||||
|
var data = {
|
||||||
|
"type": "update_location",
|
||||||
|
"data": {
|
||||||
|
"gps": [location.latitude, location.longitude],
|
||||||
|
"gps_accuracy": location.accuracy,
|
||||||
|
"battery": battery
|
||||||
|
}
|
||||||
|
};
|
||||||
|
http.post(
|
||||||
|
url,
|
||||||
|
headers: headers,
|
||||||
|
body: json.encode(data)
|
||||||
|
).catchError((e) {
|
||||||
|
print("[Background $backgroundTask] Error sending data: ${e.toString()}");
|
||||||
|
}).then((_) {
|
||||||
|
print("[Background $backgroundTask] Success!");
|
||||||
|
});
|
||||||
|
}).catchError((e){
|
||||||
|
print("[Background $backgroundTask] Error getting last known location: ${e.toString()}. Sending fake...");
|
||||||
|
print("[Background $backgroundTask] sending data home...");
|
||||||
|
var data = {
|
||||||
|
"type": "update_location",
|
||||||
|
"data": {
|
||||||
|
"gps": [40.34, 30.34],
|
||||||
|
"gps_accuracy": 300,
|
||||||
|
"battery": battery
|
||||||
|
}
|
||||||
|
};
|
||||||
|
http.post(
|
||||||
|
url,
|
||||||
|
headers: headers,
|
||||||
|
body: json.encode(data)
|
||||||
|
).catchError((e) {
|
||||||
|
print("[Background $backgroundTask] Error sending data: ${e.toString()}");
|
||||||
|
}).then((_) {
|
||||||
|
print("[Background $backgroundTask] Success!");
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
print("[Location isolate] No webhook id. Aborting");
|
print("[Background $backgroundTask] No webhook id. Aborting");
|
||||||
}
|
}
|
||||||
return Future.value(true);
|
return Future.value(true);
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name: hass_client
|
name: hass_client
|
||||||
description: Home Assistant Android Client
|
description: Home Assistant Android Client
|
||||||
|
|
||||||
version: 0.7.0+702
|
version: 0.7.0+703
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.0.0-dev.68.0 <3.0.0"
|
sdk: ">=2.0.0-dev.68.0 <3.0.0"
|
||||||
|
Reference in New Issue
Block a user