Exemplo n.º 1
0
 public static void execute(Context ctx, String command, String phoneNumber) {
   String secretKey = SMSUtil.getSecretKey(command);
   String email = PreyConfig.getPreyConfig(ctx).getEmail();
   boolean isPasswordOk = false;
   PreyTelephonyManager preyTelephony = PreyTelephonyManager.getInstance(ctx);
   PreyConnectivityManager preyConnectivity = PreyConnectivityManager.getInstance(ctx);
   boolean connection = false;
   int i = 0;
   try {
     while (!connection && i < 5) {
       connection = preyTelephony.isDataConnectivityEnabled() || preyConnectivity.isConnected();
       if (!connection) {
         PreyLogger.d("Phone doesn't have internet connection now. Waiting 10 secs for it");
         Thread.sleep(10000);
       }
     }
   } catch (Exception e) {
     PreyLogger.e("Error, because:" + e.getMessage(), e);
   }
   try {
     isPasswordOk = PreyWebServices.getInstance().checkPassword(ctx, email, secretKey);
   } catch (Exception e) {
     PreyLogger.e("Error, because:" + e.getMessage(), e);
   }
   try {
     if (isPasswordOk) {
       List<JSONObject> jsonList = SMSParser.getJSONListFromText(command, phoneNumber);
       ActionsController.getInstance(ctx).runActionJson(ctx, jsonList);
     }
   } catch (Exception e) {
     PreyLogger.e("Error, because:" + e.getMessage(), e);
   }
 }
Exemplo n.º 2
0
  @Override
  protected void onHandleIntent(Intent intent) {
    JSONArray jsonArray = new JSONArray();
    List<String> listExclude = new ArrayList<String>();
    PreyLogger.i("start report");
    List<HttpDataService> listData = new ArrayList<HttpDataService>();
    Context ctx = this;

    jsonArray = new JSONArray();
    if (!listExclude.contains("picture")) jsonArray.put(new String("picture"));
    if (!listExclude.contains("location")) jsonArray.put(new String("location"));
    if (!listExclude.contains("access_points_list"))
      jsonArray.put(new String("access_points_list"));

    try {
      List<ActionResult> lista = new ArrayList<ActionResult>();
      for (int i = 0; i < jsonArray.length(); i++) {
        String nameAction = jsonArray.getString(i);
        PreyLogger.d("nameAction:" + nameAction);
        String methodAction = "report";
        JSONObject parametersAction = null;
        listData =
            ClassUtil.execute(ctx, lista, nameAction, methodAction, parametersAction, listData);
      }
    } catch (Exception e) {
    }

    int parms = 0;
    for (int i = 0; listData != null && i < listData.size(); i++) {
      HttpDataService httpDataService = listData.get(i);
      parms = parms + httpDataService.getDataAsParameters().size();
      if (httpDataService.getEntityFiles() != null) {
        for (int j = 0; j < httpDataService.getEntityFiles().size(); j++) {
          EntityFile entity = httpDataService.getEntityFiles().get(j);
          if (entity != null && entity.getLength() > 0) {
            parms = parms + 1;
          }
        }
      }
    }

    if (PreyConfig.getPreyConfig(ctx).isConnectionExists()) {
      if (parms > 0) {
        PreyHttpResponse response = PreyWebServices.getInstance().sendPreyHttpReport(ctx, listData);
        if (response != null) {
          PreyConfig.getPreyConfig(ctx).setLastEvent("report_send");
          PreyLogger.d("response.getStatusLine():" + response.getStatusLine());
          if (200 != response.getStatusLine().getStatusCode()) {
            PreyConfig.getPreyConfig(ctx).setMissing(false);
            PreyConfig.getPreyConfig(ctx).setIntervalReport("");
            ReportScheduled.getInstance(ctx).reset();
          }
        }
      }
    }

    stopSelf();
  }
 @Override
 public void onPasswordSucceeded(Context context, Intent intent) {
   PreyConfig preyConfig = PreyConfig.getPreyConfig(context);
   if (preyConfig.isLockSet()) {
     PreyLogger.d("Password was entered successfully");
     ArrayList<String> modulesList = new ArrayList<String>();
     modulesList.add(LockAction.DATA_ID);
     PreyWebServices.getInstance().deactivateModules(context, modulesList);
     preyConfig.setLock(false);
     FroyoSupport.getInstance(context).changePasswordAndLock("", false);
   }
 }
  public static void unhide(Context ctx, List<ActionResult> lista, JSONObject options) {
    PreyLogger.i("started unhide");
    PreyWebServices.getInstance()
        .sendNotifyActionResultPreyHttp(
            ctx, UtilJson.makeMapParam("stop", "camouflage", "stopped"));
    PreyConfig.getPreyConfig(ctx).setCamouflageSet(false);

    ComponentName componentToEnabled =
        new ComponentName("com.prey", "com.prey.activities.LoginActivity");
    PackageManager pm = ctx.getApplicationContext().getPackageManager();
    pm.setComponentEnabledSetting(
        componentToEnabled,
        PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
        PackageManager.DONT_KILL_APP);
    PreyLogger.i("stopped unhide");
    PreyConfig.getPreyConfig(ctx).setLastEvent("camouflage_unhide");
  }
Exemplo n.º 5
0
  public static void hide(Context ctx, List<ActionResult> lista, JSONObject parameters) {
    PreyLogger.i("started hide");
    String messageId = null;
    try {
      messageId = parameters.getString(PreyConfig.MESSAGE_ID);
    } catch (Exception e) {
    }
    PreyWebServices.getInstance()
        .sendNotifyActionResultPreyHttp(
            ctx, UtilJson.makeMapParam("start", "camouflage", "started", null));
    PreyConfig.getPreyConfig(ctx).setCamouflageSet(true);

    ComponentName componentToDisabled =
        new ComponentName("com.prey", "com.prey.activities.LoginActivity");
    PackageManager pm = ctx.getPackageManager();
    pm.setComponentEnabledSetting(
        componentToDisabled,
        PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
        PackageManager.DONT_KILL_APP);
    PreyLogger.i("stopped hide");
    PreyConfig.getPreyConfig(ctx).setLastEvent("camouflage_hide");
  }
Exemplo n.º 6
0
 public void unregisterC2dm(boolean updatePrey) {
   if (updatePrey) PreyWebServices.getInstance().setPushRegistrationId(ctx, "");
   Intent unregIntent = new Intent("com.google.android.c2dm.intent.UNREGISTER");
   unregIntent.putExtra("app", PendingIntent.getBroadcast(this.ctx, 0, new Intent(), 0));
   this.ctx.startService(unregIntent);
 }