Skip to content

Commit

Permalink
The device name is sent
Browse files Browse the repository at this point in the history
The device name is sent
  • Loading branch information
oaliaga committed Mar 20, 2023
1 parent 74af0e9 commit 5b44314
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/src/main/java/com/prey/json/actions/Location.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
import org.json.JSONObject;

import android.content.Context;
import android.provider.Settings;

import com.prey.PreyConfig;
import com.prey.PreyLogger;
import com.prey.PreyUtils;
import com.prey.actions.HttpDataService;
import com.prey.actions.aware.AwareConfig;
import com.prey.actions.aware.AwareController;
Expand Down Expand Up @@ -70,6 +72,20 @@ public List<HttpDataService> get(Context ctx, List<ActionResult> list, JSONObje
ArrayList<HttpDataService> dataToBeSent = new ArrayList<HttpDataService>();
dataToBeSent.add(data);
PreyWebServices.getInstance().sendPreyHttpData(ctx, dataToBeSent);
try {
String nameDevice = Settings.Secure.getString(ctx.getContentResolver(), "bluetooth_name");
if (nameDevice != null && !"".equals(nameDevice)) {
PreyLogger.d(String.format("nameDevice: %s", nameDevice));
PreyWebServices.getInstance().sendPreyHttpDataName(ctx, nameDevice);
String nameDeviceInfo = PreyWebServices.getInstance().getNameDevice(ctx);
if (nameDeviceInfo != null && !"".equals(nameDeviceInfo)) {
PreyLogger.d(String.format("nameDeviceInfo: %s", nameDeviceInfo));
PreyConfig.getPreyConfig(ctx).setDeviceName(nameDeviceInfo);
}
}
} catch (Exception e) {
PreyLogger.d(String.format("Data wasn't send: %s", e.getMessage()));
}
return dataToBeSent;
}

Expand Down
16 changes: 16 additions & 0 deletions app/src/main/java/com/prey/net/PreyWebServices.java
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,22 @@ public PreyHttpResponse sendPreyHttpData(Context ctx, ArrayList<HttpDataService>
return preyHttpResponse;
}

public PreyHttpResponse sendPreyHttpDataName(Context ctx, String nameDevice) {
Map<String, String> parameters = new HashMap<String, String>();
PreyHttpResponse preyHttpResponse = null;
parameters.put("name", nameDevice);
try {
String url = getDataUrlJson(ctx);
if (UtilConnection.isInternetAvailable(ctx)) {
preyHttpResponse = PreyRestHttpClient.getInstance(ctx).postAutentication(url, parameters);
PreyLogger.d("Data sent_: " + (preyHttpResponse == null ? "" : preyHttpResponse.getResponseAsString()));
}
} catch (Exception e) {
PreyLogger.e("Data wasn't send", e);
}
return preyHttpResponse;
}

public PreyVerify verifyUsers(Context ctx) throws Exception {
String apiKey= PreyConfig.getPreyConfig(ctx).getApiKey();
String apiv2 = FileConfigReader.getInstance(ctx).getApiV2();
Expand Down

0 comments on commit 5b44314

Please sign in to comment.