@Override
  public void onReceive(final Context context, Intent intent) {
    Log.v(TAG, "onReceive");

    // start components
    SharedPreferences settings =
        context.getSharedPreferences(Mobility.MOBILITY, Context.MODE_PRIVATE);
    if (settings.getBoolean(MobilityControl.MOBILITY_ON, false)) {
      //			Intent MobilityServiceIntent = new Intent(context, MobilityService.class);
      //			context.stopService(MobilityServiceIntent);
      //			context.startService(MobilityServiceIntent);
      //			context.startService(new Intent(context, Mobility.class));
      Log.v(TAG, "Boot receiver called start!");
      Mobility.start(context.getApplicationContext());
    }
  }
示例#2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    UserPreferencesHelper preferencesHelper = new UserPreferencesHelper(this);

    if (preferencesHelper.isUserDisabled()) {
      ((OhmageApplication) getApplication()).resetAll();
    }

    if (!AccountHelper.accountExists()) {
      Log.v(TAG, "no credentials saved, so launch Login");
      startActivity(AccountHelper.getLoginIntent(this));
      finish();
      return;
    }
  }
  /**
   * Checks if the passed condition is true based on the passed list of node responses. If the id
   * does not exist in the responses, assume the response is NULL.
   *
   * @param condition The condition to check.
   * @param previousResponses The List of previous responses.
   * @return Whether or not the condition is true.
   */
  public static boolean evaluateCondition(String condition, List<DataPoint> previousResponses) {
    // Blank conditions are always valid
    if (!"".equals(condition)) {
      start s = null;

      try {
        // The API is odd, we have to instantiate an object just to use its static methods below,
        // we do not actually need to keep the object around for any reason
        if (!conditionParserInitialized) {
          new ConditionParser(new StringReader(condition));
          conditionParserInitialized = true;
        } else {
          ConditionParser.ReInit(new StringReader(condition));
        }
        // Call start statically even though we have to instantiate the object above
        s = ConditionParser.start();

        ConditionDepthFirst<Boolean, Boolean> visitor =
            new ConditionDepthFirst<Boolean, Boolean>(previousResponses);
        // Check the condition against the previous responses
        Boolean conditionValue = visitor.visit(s, null);

        /*if (DataPointConditionEvaluator._logger.isDebugEnabled()) {
            DataPointConditionEvaluator._logger.debug("Condition [" + condition + "] evaluated as " + conditionValue.toString());
        }*/
        Log.v(TAG, "Condition [" + condition + "] evaluated as " + conditionValue.toString());

        return conditionValue.booleanValue();

      } catch (ParseException pe) {

        throw new IllegalArgumentException(
            "Condition failed to parse, should have been checked in the XML validator: "
                + condition);
      }
    }

    return true;
  }