@Override
          public void onReceive(Context context, Intent intent) {
            boolean redraw = false;
            if (intent.getAction().equals(Intent.ACTION_BATTERY_CHANGED))
              redraw = updateBatteryItems(intent);
            else if (intent.getAction().equals(Intent.ACTION_TIME_TICK)) {
              redraw = updatePhoneInfo();
              redraw = updateDateTimeItems();
            } else if (intent.getAction().compareTo(Intent.ACTION_SCREEN_OFF) == 0) {
              mVisible = false;
              Phone.instance().screen().locked(true);
              redraw = true;
            } else if (intent.getAction().compareTo(Intent.ACTION_SCREEN_ON) == 0) {
              Phone.instance().screen().locked(true);
              mVisible = true;
              redraw = true;
            } else if (intent.getAction().compareTo(Intent.ACTION_USER_PRESENT) == 0) {
              updateWeatherAsync();
              Phone.instance().screen().locked(false);
              mVisible = true;
              redraw = true;
            } else if (intent.getAction().equals(Intent.ACTION_AIRPLANE_MODE_CHANGED)) {
              boolean activated = intent.getBooleanExtra("state", true);
              if (activated == false) mHandler.postDelayed(mWeatherUpdater, 30000);
            } else if (intent.getAction().equals("com.android.music.playbackcomplete")
                || intent.getAction().equals("com.android.music.playstatechanged")
                || intent.getAction().equals("com.android.music.metachanged")) {
              redraw = updateCurrentSong(intent);
            }

            if (redraw) {
              updateWallpaper();
            }
          }
Example #2
0
  public void removePhoneByNumber(String phoneNumber) {

    for (Phone phone : getPhoneSet())
      if (phone.getNr().equals(phoneNumber)) {
        removePhone(phone);
        return;
      }
  }
Example #3
0
  public void startSourceVoiceCall(String sourcePhoneNumber, String destinationPhoneNumber) {
    Phone sourcePhone = getPhone(sourcePhoneNumber);

    /* MUDAR */
    sourcePhone.checkNegativeBalance();
    // Checks if its possible to make call, sets state, and sets active call
    sourcePhone.startSentVoiceCall(new Voice(sourcePhoneNumber, destinationPhoneNumber));
  }
Example #4
0
 public Phone addPhone(Phone sorPhone) {
   MockPhoneNumber phone = new MockPhoneNumber();
   phone.setCountryCode(sorPhone.getCountryCode());
   phone.setAreaCode(sorPhone.getAreaCode());
   phone.setNumber(sorPhone.getNumber());
   phone.setExtension(sorPhone.getExtension());
   phones.add(phone);
   return phone;
 }
Example #5
0
  public static List<String> getPhonesFromPersonName(String personName)
      throws NotExistsPersonException {
    Person person = getPersonFromIdentifier(personName);

    List<Phone> phones = person.getPhones();
    List<String> result = new ArrayList<String>();

    for (Phone phone : phones) {
      result.add(phone.getPhone());
    }
    return result;
  }
  @Test
  public void testLifecycle() {
    doInJPA(
        this::entityManagerFactory,
        entityManager -> {
          Phone phone = new Phone("123-456-7890");
          PhoneDetails details = new PhoneDetails("T-Mobile", "GSM");

          phone.setDetails(details);
          entityManager.persist(phone);
          entityManager.persist(details);
        });
  }
  public void testValidateSimpleTypeException() throws Exception {
    boolean caughtException = false;

    try {
      Phone phone = new Phone();
      phone.setNumber("12345678901");
      validator.validate(phone);
    } catch (ValidationException xmlpe) {
      caughtException = true;
    } catch (Exception ex) {
    }
    assertTrue("JAXBValidator did not throw ValidationException as expected.", caughtException);
  }
  public void treatContactPickerPositiveResult(
      final Context ctxt, final String contactId, final OnPhoneNumberSelected l) {
    ArrayList<Phone> phones = getPhoneNumbers(ctxt, contactId);

    if (phones.size() == 0) {
      final AlertDialog.Builder builder = new AlertDialog.Builder(ctxt);
      builder.setPositiveButton(R.string.ok, null);
      builder.setTitle(R.string.choose_phone);
      builder.setMessage(R.string.no_phone_found);
      AlertDialog dialog = builder.create();
      dialog.show();
    } else if (phones.size() == 1) {
      if (l != null) {
        l.onTrigger(formatNumber(phones.get(0).getNumber(), phones.get(0).getType()));
      }
    } else {
      final AlertDialog.Builder builder = new AlertDialog.Builder(ctxt);

      ArrayList<String> entries = new ArrayList<String>();
      for (Phone phone : phones) {
        entries.add(formatNumber(phone.getNumber(), phone.getType()));
      }

      final ArrayAdapter<String> phoneChoiceAdapter =
          new ArrayAdapter<String>(ctxt, android.R.layout.simple_dropdown_item_1line, entries);

      builder.setTitle(R.string.choose_phone);
      builder.setAdapter(
          phoneChoiceAdapter,
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
              if (l != null) {
                l.onTrigger(phoneChoiceAdapter.getItem(which));
              }
            }
          });
      builder.setCancelable(true);
      builder.setNeutralButton(
          R.string.cancel,
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
              // Nothing to do
              dialog.dismiss();
            }
          });
      AlertDialog dialog = builder.create();
      dialog.show();
    }
  }
Example #9
0
  public void sendSMS(String sourceNumber, String destinationNumber, String message) {

    if (message == null) throw new SMSInvalidTextException(sourceNumber, destinationNumber);

    Phone senderPhone = this.getPhone(sourceNumber);

    boolean sameOperator = sameOperator(sourceNumber, destinationNumber);
    int smsCost = senderPhone.getOperator().getPlan().calcCostSMS(message, sameOperator);
    senderPhone.checkCostAndBalance(smsCost);
    senderPhone.decreaseBalanceBy(smsCost);

    SMS sms = new SMS(sourceNumber, destinationNumber, message, smsCost);
    senderPhone.addSentSMS(sms);
  }
Example #10
0
  public void endDestinationVoiceCall(
      String sourcePhoneNumber, String destinationPhoneNumber, int duration) {

    if (duration < 0) throw new InvalidDurationException(sourcePhoneNumber, destinationPhoneNumber);

    Phone destinationPhone = getPhone(destinationPhoneNumber);

    Voice activeCommunication =
        (Voice)
            destinationPhone.checkActiveCommunication(
                sourcePhoneNumber, destinationPhoneNumber, AnacomData.CommunicationType.VOICE);
    activeCommunication.setDuration(duration);

    destinationPhone.endReceivedVoiceCall(activeCommunication);
  }
Example #11
0
  // ***** Class Methods
  public PhoneProxy(Phone phone) {
    mActivePhone = phone;
    mResetModemOnRadioTechnologyChange =
        SystemProperties.getBoolean(TelephonyProperties.PROPERTY_RESET_ON_RADIO_TECH_CHANGE, false);
    mIccSmsInterfaceManagerProxy =
        new IccSmsInterfaceManagerProxy(phone.getIccSmsInterfaceManager());
    mIccPhoneBookInterfaceManagerProxy =
        new IccPhoneBookInterfaceManagerProxy(phone.getIccPhoneBookInterfaceManager());
    mPhoneSubInfoProxy = new PhoneSubInfoProxy(phone.getPhoneSubInfo());
    mCommandsInterface = ((PhoneBase) mActivePhone).mCM;

    mCommandsInterface.registerForRilConnected(this, EVENT_RIL_CONNECTED, null);
    mCommandsInterface.registerForOn(this, EVENT_RADIO_ON, null);
    mCommandsInterface.registerForVoiceRadioTechChanged(this, EVENT_VOICE_RADIO_TECH_CHANGED, null);
  }
Example #12
0
  @Override
  protected FeatureSet _getFeatureSet() {
    FeatureSet retVal = new FeatureSet();
    retVal.union(firstPhone.getFeatureSet());
    retVal.union(secondPhone.getFeatureSet());

    // when the same consonant, add the long feature
    if (retVal.hasFeature("c")
        && firstPhone.getBasePhone() != null
        && firstPhone.getBasePhone().equals(secondPhone.getBasePhone())) {
      retVal.addFeature("long");
    }

    return retVal;
  }
  public static void list(String unitId) {

    Http.Header hd = new Http.Header();

    hd.name = "Access-Control-Allow-Origin";
    hd.values = new ArrayList<String>();
    hd.values.add("*");

    Http.Response.current().headers.put("Access-Control-Allow-Origin", hd);

    if (unitId == null) badRequest();

    Phone p = Phone.find("unitId = ?", unitId).first();

    if (p == null) badRequest();

    List<TripPattern> patterns = TripPattern.find("route.phone = ?", p).fetch();

    Gson gson =
        new GsonBuilder()
            .registerTypeAdapter(TripPattern.class, new TripPatternSerializer())
            .serializeSpecialFloatingPointValues()
            .serializeNulls()
            .create();

    renderJSON(gson.toJson(patterns));
  }
    @Override
    public void onSurfaceChanged(SurfaceHolder surfaceHolder, int format, int width, int height) {
      super.onSurfaceChanged(surfaceHolder, format, width, height);

      Phone.instance().screen().updateWindow(width, height, format);
      draw();
    }
    private void draw() {
      final SurfaceHolder surfaceHolder = getSurfaceHolder();
      Canvas canvas = null;

      try {
        canvas = surfaceHolder.lockCanvas();
        if (canvas != null) {
          canvas.save();

          mBackground.draw(canvas);

          if (Phone.instance().screen().isLocked() == false || mHide == false) {
            for (int i = 0; i < mInfoList.size(); ++i) {
              mInfoList.get(i).draw(canvas);
            }
          }

          canvas.restore();
        }
      } finally {
        if (canvas != null) {
          surfaceHolder.unlockCanvasAndPost(canvas);
          canvas = null;
        }
      }
    }
    @Override
    public void onOffsetsChanged(
        float offsetX, float offsetY, float stepX, float stepY, int pixelsX, int pixelsY) {
      Phone.instance().screen().setOffset(offsetX, offsetY, stepX, stepY, pixelsX, pixelsY);

      if (mBackground.setOffset(offsetX) || mInfoOnAllScreens == false) {
        updateWallpaper();
      }
    }
Example #17
0
  private void deleteAndCreatePhone(int newVoiceRadioTech) {

    String outgoingPhoneName = "Unknown";
    Phone oldPhone = mActivePhone;

    if (oldPhone != null) {
      outgoingPhoneName = ((PhoneBase) oldPhone).getPhoneName();
    }

    logd(
        "Switching Voice Phone : "
            + outgoingPhoneName
            + " >>> "
            + (ServiceState.isGsm(newVoiceRadioTech) ? "GSM" : "CDMA"));

    if (oldPhone != null) {
      CallManager.getInstance().unregisterPhone(oldPhone);
      logd("Disposing old phone..");
      oldPhone.dispose();
    }

    // Give the garbage collector a hint to start the garbage collection
    // asap NOTE this has been disabled since radio technology change could
    // happen during e.g. a multimedia playing and could slow the system.
    // Tests needs to be done to see the effects of the GC call here when
    // system is busy.
    // System.gc();

    if (ServiceState.isCdma(newVoiceRadioTech)) {
      mActivePhone = PhoneFactory.getCdmaPhone();
    } else if (ServiceState.isGsm(newVoiceRadioTech)) {
      mActivePhone = PhoneFactory.getGsmPhone();
    }

    if (oldPhone != null) {
      oldPhone.removeReferences();
    }

    if (mActivePhone != null) {
      CallManager.getInstance().registerPhone(mActivePhone);
    }

    oldPhone = null;
  }
Example #18
0
  /**
   * Add a phone to the correct operator responsible by his prefix
   *
   * @param phoneNumber The phone object to be added
   */
  public void addPhone(String operatorPrefix, String phoneNumber, AnacomData.PhoneType phoneGen) {

    Operator operator = this.getOperatorByPrefix(operatorPrefix);

    String phonePrefix = getPhonePrefixByNumber(phoneNumber);

    if (!(operator.getPrefix().equals(phonePrefix)))
      throw new PhoneAndOperatorPrefixDoNotMatchException(operator.getPrefix(), phonePrefix);

    if (phoneGen == AnacomData.PhoneType.GEN2) {
      Phone phone = new OldGenPhone(phoneNumber);
      operator.addPhone(phone);
      phone.setOperator(operator);
    } else if (phoneGen == AnacomData.PhoneType.GEN3) {
      Phone phone = new NewGenPhone(phoneNumber);
      operator.addPhone(phone);
      phone.setOperator(operator);
    }
  }
Example #19
0
  public void endSourceVoiceCall(
      String sourcePhoneNumber, String destinationPhoneNumber, int duration) {
    if (duration < 0) throw new InvalidDurationException(sourcePhoneNumber, destinationPhoneNumber);

    Phone sourcePhone = getPhone(sourcePhoneNumber);

    Voice activeCommunication =
        (Voice)
            sourcePhone.checkActiveCommunication(
                sourcePhoneNumber, destinationPhoneNumber, AnacomData.CommunicationType.VOICE);

    boolean sameOperator = sameOperator(sourcePhoneNumber, destinationPhoneNumber);
    int cost = sourcePhone.getOperator().getPlan().calcCostVoice(duration, sameOperator);

    sourcePhone.decreaseBalanceBy(cost);

    activeCommunication.setCost(cost);
    activeCommunication.setDuration(duration);

    sourcePhone.endSentVoiceCall(activeCommunication);
  }
  public static void view(String unitId) {

    if (unitId == null) index(true);

    Phone p = Phone.find("unitId = ?", unitId).first();

    if (p == null) index(true);

    List<TripPattern> patterns = TripPattern.find("route.phone = ?", p).fetch();

    render(p, patterns);
  }
Example #21
0
  public static void main(String[] args) {
    Phone tel1 = new CellPhone();
    tel1.call();
    tel1.message();
    Phone tel2 = new SmartPhone();
    tel2.call();
    tel2.message();

    Game game1 = new SmartPhone();
    game1.playGame();
    Game game2 = new PSP();
    game2.playGame();

    /* 使用匿名内部类实现接口方法 */
    Game game3 =
        new Game() {
          @Override
          public void playGame() {
            System.out.println("interface used in unnamed class ");
          }
        };
    game3.playGame();

    /* 直接new实现接口函数 */
    new Game() {
      @Override
      public void playGame() {
        System.out.println("interface used by new");
      }
    }.playGame();
  }
Example #22
0
 public void setCallForwardingOption(
     int commandInterfaceCFReason,
     int commandInterfaceCFAction,
     String dialingNumber,
     int timerSeconds,
     Message onComplete) {
   mActivePhone.setCallForwardingOption(
       commandInterfaceCFReason,
       commandInterfaceCFAction,
       dialingNumber,
       timerSeconds,
       onComplete);
 }
    // Phone Info
    private boolean updatePhoneInfo() {
      Phone.instance().update(getBaseContext());

      boolean redraw = false;
      for (int i = 0; i < mInfoList.size(); ++i) {
        if (mInfoList.get(i).isType(InfoItem.TYPE_PHONESTATUS)) {
          redraw = true;
          mInfoList.get(i).update(InfoItem.TYPE_PHONESTATUS, null);
        }
      }

      return redraw;
    }
Example #24
0
 public static Customer example1() {
   Customer customer = new Customer();
   customer.address = Address.example1();
   customer.email = org.eclipse.persistence.testing.models.events.EmailAccount.example1();
   customer.phoneNumber = Phone.example1();
   ((Vector) customer.orders.getValue()).add(Order.example2());
   ((Vector) customer.orders.getValue()).add(Order.example1());
   customer.associations.add("Mickey Mouse Club");
   customer.associations.add("Canadian Penitentiary System");
   customer.name = "John Lancy";
   customer.creditCard = new CreditCard();
   customer.creditCard.number = "346556544565";
   customer.creditCard.expiry = "04/03";
   return customer;
 }
Example #25
0
 public static Customer example2() {
   Customer customer = new Customer();
   customer.address = Address.example2();
   customer.email = org.eclipse.persistence.testing.models.events.EmailAccount.example2();
   customer.phoneNumber = Phone.example2();
   ((Vector) customer.orders.getValue()).add(Order.example3());
   ((Vector) customer.orders.getValue()).add(Order.example4());
   customer.associations.add("Masons");
   customer.associations.add("Illuminaty");
   customer.name = "Bobby Ore";
   customer.creditCard = new CreditCard();
   customer.creditCard.number = "456556544565";
   customer.creditCard.expiry = "03/03";
   return customer;
 }
Example #26
0
 boolean isClientRquestTimeout() {
   boolean calling = false;
   synchronized (_phone) {
     calling = _phone.isCalling();
   }
   if (calling) {
     _lastClientRequestTime = System.currentTimeMillis();
     return false;
   }
   long now = System.currentTimeMillis();
   long deff = (now - _lastClientRequestTime);
   logger.debug("Now is {},last request time {}", now, _lastClientRequestTime);
   logger.debug("deff is {} ......", deff);
   return deff > (long) _clientTimeout;
 }
  public static void export(String unitId) throws InterruptedException {

    Phone p = Phone.find("unitId = ?", unitId).first();

    List<TripPattern> tripPatterns = TripPattern.find("route.phone = ?", p).fetch();

    ArrayList<Long> patternIds = new ArrayList<Long>();

    for (TripPattern pattern : tripPatterns) {
      patternIds.add(pattern.id);
    }

    ProcessGisExport gisExport = new ProcessGisExport(patternIds, unitId.toString());
    gisExport.doJob();
    ok();
  }
    public WallpaperEngine() {
      prepareUserAgent();

      mPrefs = LiveInfoWallpaper.this.getSharedPreferences(SHARED_PREFERENCES_NAME, 0);
      mPrefs.registerOnSharedPreferenceChangeListener(this);
      onSharedPreferenceChanged(mPrefs, null);

      IntentFilter filter = new IntentFilter(Intent.ACTION_USER_PRESENT);
      filter.addAction(Intent.ACTION_SCREEN_OFF);
      filter.addAction(Intent.ACTION_SCREEN_ON);
      filter.addAction(Intent.ACTION_BATTERY_CHANGED);
      filter.addAction(Intent.ACTION_TIME_TICK);
      filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);

      registerReceiver(mReceiver, filter);

      TelephonyManager tm =
          (TelephonyManager)
              LiveInfoWallpaper.this.getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
      tm.listen(Phone.instance(), PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
    }
  public static TestSuite getInsertObjectTestSuite() {
    TestSuite suite = new TestSuite();

    suite.setName("InserfaceWithoutTablesInsertObjectTestSuite");
    suite.setDescription(
        "This suite tests the insertion of each object in the interface model (without tables).");

    suite.addTest(new InsertObjectTest(Film.example2()));
    suite.addTest(new InsertObjectTest(Secretary.example2()));
    suite.addTest(new InsertObjectTest(Company.example3()));
    suite.addTest(new InsertObjectTest(CourseDeveloper.example1()));
    suite.addTest(new InsertObjectTest(Email.example2()));
    // suite.addTest(new InsertObjectTest(Employee.example3())); Cannot use insert test on emp as
    // bi-1-1
    suite.addTest(new InsertObjectTest(PersonnelManager.example1()));
    suite.addTest(new InsertObjectTest(Phone.example1()));
    suite.addTest(new InsertObjectTest(ProductDeveloper.example3()));
    suite.addTest(new InsertObjectTest(ProductManager.example1()));
    suite.addTest(new InsertObjectTest(Receptionist.example1()));
    return suite;
  }
Example #30
0
  public void setup() {
    phone = new Phone(this);
    phone.fullscreen();

    client = new PClient(this, "www.spore.com");
    parser = new XMLParser(this);

    username = null;
    font = loadFont(FACE_PROPORTIONAL, STYLE_BOLD, SIZE_LARGE);
    highlight = loadImage("highlight.png");

    icons = new PImage[4];
    for (int i = 0; i < 4; i++) {
      icons[i] = loadImage("icon" + i + ".png");
    }

    machine = new StateMachine();
    machine.current = new Search(0);

    framerate(20);
  }