Пример #1
0
  /**
   * Add RCS service notification
   *
   * @param state Service state (ON|OFF)
   * @param label Label
   */
  public static void addRcsServiceNotification(boolean state, String label) {
    // Create notification
    Intent intent = new Intent(ClientApiIntents.RCS_SETTINGS);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent contentIntent =
        PendingIntent.getActivity(AndroidFactory.getApplicationContext(), 0, intent, 0);
    int iconId;
    if (state) {
      iconId = R.drawable.rcs_core_notif_on_icon;
    } else {
      iconId = R.drawable.rcs_core_notif_off_icon;
    }
    Notification notif = new Notification(iconId, "", System.currentTimeMillis());
    notif.flags = Notification.FLAG_NO_CLEAR | Notification.FLAG_FOREGROUND_SERVICE;
    notif.setLatestEventInfo(
        AndroidFactory.getApplicationContext(),
        AndroidFactory.getApplicationContext().getString(R.string.rcs_core_rcs_notification_title),
        label,
        contentIntent);

    // Send notification
    NotificationManager notificationManager =
        (NotificationManager)
            AndroidFactory.getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(SERVICE_NOTIFICATION, notif);
  }
Пример #2
0
  /**
   * Receive a new geoloc sharing invitation
   *
   * @param session Geoloc sharing session
   */
  public void receiveGeolocSharingInvitation(GeolocTransferSession session) {
    if (logger.isActivated()) {
      logger.info("Receive geoloc sharing invitation from " + session.getRemoteContact());
    }

    // Extract number from contact
    String number = PhoneUtils.extractNumberFromUri(session.getRemoteContact());

    // Add session in the list
    GeolocSharingImpl sessionApi = new GeolocSharingImpl(session);
    GeolocSharingServiceImpl.addGeolocSharingSession(sessionApi);

    // Broadcast intent related to the received invitation
    Intent intent = new Intent(GeolocSharingIntent.ACTION_NEW_INVITATION);
    intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
    intent.putExtra(GeolocSharingIntent.EXTRA_CONTACT, number);
    intent.putExtra(GeolocSharingIntent.EXTRA_DISPLAY_NAME, session.getRemoteDisplayName());
    intent.putExtra(GeolocSharingIntent.EXTRA_SHARING_ID, session.getSessionID());
    AndroidFactory.getApplicationContext().sendBroadcast(intent);

    // Notify geoloc sharing invitation listeners
    synchronized (lock) {
      final int N = listeners.beginBroadcast();
      for (int i = 0; i < N; i++) {
        try {
          listeners.getBroadcastItem(i).onNewGeolocSharing(session.getSessionID());
        } catch (Exception e) {
          if (logger.isActivated()) {
            logger.error("Can't notify listener", e);
          }
        }
      }
      listeners.finishBroadcast();
    }
  }
Пример #3
0
  /**
   * Receive a new geoloc sharing invitation
   *
   * @param session Geoloc sharing session
   */
  public void receiveGeolocSharingInvitation(GeolocTransferSession session) {
    if (logger.isActivated()) {
      logger.info("Receive geoloc sharing invitation from " + session.getRemoteContact());
    }

    // Extract number from contact
    String number = PhoneUtils.extractNumberFromUri(session.getRemoteContact());

    // Update rich call history
    RichCall.getInstance()
        .addCall(
            number,
            session.getSessionID(),
            RichCallData.EVENT_INCOMING,
            session.getContent(),
            RichCallData.STATUS_STARTED);

    // Add session in the list
    GeolocSharingSession sessionApi = new GeolocSharingSession(session);
    addGeolocSharingSession(sessionApi);

    // Broadcast intent related to the received invitation
    Intent intent = new Intent(RichCallApiIntents.GEOLOC_SHARING_INVITATION);
    intent.putExtra("contact", number);
    intent.putExtra("contactDisplayname", session.getRemoteDisplayName());
    intent.putExtra("sessionId", session.getSessionID());
    AndroidFactory.getApplicationContext().sendBroadcast(intent);
  }
Пример #4
0
  /**
   * Receive a new video sharing invitation
   *
   * @param session Video sharing session
   */
  public void receiveVideoSharingInvitation(VideoStreamingSession session) {
    if (logger.isActivated()) {
      logger.info("Receive video sharing invitation from " + session.getRemoteContact());
    }

    // Extract number from contact
    String number = PhoneUtils.extractNumberFromUri(session.getRemoteContact());
    VideoContent content = (VideoContent) session.getContent();

    // Update rich call history
    RichCall.getInstance()
        .addCall(
            number,
            session.getSessionID(),
            RichCallData.EVENT_INCOMING,
            content,
            RichCallData.STATUS_STARTED);

    // Add session in the list
    VideoSharingSession sessionApi = new VideoSharingSession(session);
    addVideoSharingSession(sessionApi);

    // Broadcast intent related to the received invitation
    Intent intent = new Intent(RichCallApiIntents.VIDEO_SHARING_INVITATION);
    intent.putExtra("contact", number);
    intent.putExtra("contactDisplayname", session.getRemoteDisplayName());
    intent.putExtra("sessionId", session.getSessionID());
    intent.putExtra("videotype", content.getEncoding());
    intent.putExtra("videowidth", content.getWidth());
    intent.putExtra("videoheight", content.getHeight());
    AndroidFactory.getApplicationContext().sendBroadcast(intent);
  }
  private void analysisAttribute() {
    long videoId = -1;
    String whereClause = MediaStore.Video.Media.DISPLAY_NAME + "='" + mFileName + "'";
    ContentResolver cr = AndroidFactory.getApplicationContext().getContentResolver();
    Cursor cursor = null;
    try {
      cursor =
          cr.query(
              MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
              new String[] {
                MediaStore.Video.VideoColumns._ID, MediaStore.Video.VideoColumns.DURATION
              },
              whereClause,
              null,
              null);
      if (cursor != null && cursor.getCount() != 0) {
        cursor.moveToFirst();
        videoId = cursor.getLong(cursor.getColumnIndex(MediaStore.Video.VideoColumns._ID));
        int duration = cursor.getInt(cursor.getColumnIndex(MediaStore.Video.VideoColumns.DURATION));
        setDuration(duration);
      } else {
        Logger.w(TAG, "analysisAttribute(), cursor is null!");
      }
    } finally {
      if (cursor != null) {
        cursor.close();
        cursor = null;
      }
    }

    if (videoId != -1) {
      whereClause = android.provider.MediaStore.Video.Thumbnails.VIDEO_ID + "='" + videoId + "'";
      try {
        cursor =
            cr.query(
                android.provider.MediaStore.Video.Thumbnails.EXTERNAL_CONTENT_URI,
                new String[] {android.provider.MediaStore.Video.Thumbnails.DATA},
                whereClause,
                null,
                null);
        if (cursor != null && cursor.getCount() != 0) {
          cursor.moveToFirst();
          String thumbnailPath =
              cursor.getString(
                  cursor.getColumnIndex(android.provider.MediaStore.Video.Thumbnails.DATA));
          setThumbPath(thumbnailPath);
        } else {
          Logger.w(TAG, "analysisAttribute(), cursor is null!");
        }
      } finally {
        if (cursor != null) {
          cursor.close();
          cursor = null;
        }
      }
    } else {
      Logger.w(TAG, "analysisAttribute(), have no this image!");
    }
  }
  /**
   * Receive an instant message (SIP MESSAGE)
   *
   * @param intent Resolved intent
   * @param message Instant message request
   */
  public void receiveSipInstantMessage(Intent intent, SipRequest message) {
    // Broadcast intent related to the received invitation
    String contact = SipUtils.getAssertedIdentity(message);
    String number = PhoneUtils.extractNumberFromUri(contact);
    String displayName = SipUtils.getDisplayNameFromUri(message.getFrom());
    intent.putExtra(MultimediaMessageIntent.EXTRA_CONTACT, number);
    intent.putExtra(MultimediaMessageIntent.EXTRA_DISPLAY_NAME, displayName);
    intent.putExtra(MultimediaMessageIntent.EXTRA_CONTENT, message.getRawContent());

    // Broadcast intent related to the received invitation
    AndroidFactory.getApplicationContext().sendBroadcast(intent);
  }
  /**
   * Receive a new SIP session invitation
   *
   * @param intent Resolved intent
   * @param session SIP session
   */
  public void receiveSipSessionInvitation(Intent intent, GenericSipSession session) {
    // Add session in the list
    MultimediaSessionImpl sessionApi = new MultimediaSessionImpl(session);
    MultimediaSessionServiceImpl.addSipSession(sessionApi);

    // Broadcast intent related to the received invitation
    String number = PhoneUtils.extractNumberFromUri(session.getRemoteContact());
    intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
    intent.putExtra(MultimediaSessionIntent.EXTRA_CONTACT, number);
    intent.putExtra(MultimediaSessionIntent.EXTRA_DISPLAY_NAME, session.getRemoteDisplayName());
    intent.putExtra(MultimediaSessionIntent.EXTRA_SESSION_ID, session.getSessionID());

    // Broadcast intent related to the received invitation
    AndroidFactory.getApplicationContext().sendBroadcast(intent);
  }
  /**
   * Receive a new video sharing invitation
   *
   * @param session Video sharing session
   */
  public void receiveVideoSharingInvitation(VideoStreamingSession session) {
    if (logger.isActivated()) {
      logger.info("Receive video sharing invitation from " + session.getRemoteContact());
    }

    // Extract number from contact
    String number = PhoneUtils.extractNumberFromUri(session.getRemoteContact());

    // Update rich call history
    VideoContent content = (VideoContent) session.getContent();
    RichCallHistory.getInstance()
        .addVideoSharing(
            number,
            session.getSessionID(),
            VideoSharing.Direction.INCOMING,
            content,
            VideoSharing.State.INVITED);

    // Add session in the list
    VideoSharingImpl sessionApi = new VideoSharingImpl(session);
    VideoSharingServiceImpl.addVideoSharingSession(sessionApi);

    // Broadcast intent related to the received invitation
    Intent intent = new Intent(VideoSharingIntent.ACTION_NEW_INVITATION);
    intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
    intent.putExtra(VideoSharingIntent.EXTRA_CONTACT, number);
    intent.putExtra(VideoSharingIntent.EXTRA_DISPLAY_NAME, session.getRemoteDisplayName());
    intent.putExtra(VideoSharingIntent.EXTRA_SHARING_ID, session.getSessionID());
    intent.putExtra(VideoSharingIntent.EXTRA_ENCODING, content.getEncoding());
    intent.putExtra(VideoSharingIntent.EXTRA_WIDTH, session.getVideoWidth());
    intent.putExtra(VideoSharingIntent.EXTRA_HEIGHT, session.getVideoHeight());
    AndroidFactory.getApplicationContext().sendBroadcast(intent);

    // Notify video sharing invitation listeners
    synchronized (lock) {
      final int N = listeners.beginBroadcast();
      for (int i = 0; i < N; i++) {
        try {
          listeners.getBroadcastItem(i).onNewVideoSharing(session.getSessionID());
        } catch (Exception e) {
          if (logger.isActivated()) {
            logger.error("Can't notify listener", e);
          }
        }
      }
      listeners.finishBroadcast();
    }
  }
Пример #9
0
 @Override
 public void onCreate() {
   super.onCreate();
   AndroidFactory.setApplicationContext(getApplicationContext());
   Logger.initialize(getApplicationContext());
   Logger.v(TAG, "onCreate() entry");
   if (!ApiManager.initialize(getApplicationContext())) {
     Logger.e(TAG, "onCreate() ApiManager initialization failed!");
   }
   ContactsListManager.initialize(getApplicationContext());
   startService(new Intent(this, ApiService.class));
   // Init UnreadMessageManager
   UnreadMessageManager.getInstance();
   EmoticonsModelImpl.init(getApplicationContext());
   controlRcseComponent();
   Logger.v(TAG, "onCreate() exit");
 }
Пример #10
0
  @Override
  public void onCreate() {
    // Set application context
    AndroidFactory.setApplicationContext(getApplicationContext());

    // Instantiate the settings manager
    RcsSettings.createInstance(getApplicationContext());

    // Set the logger properties
    Logger.activationFlag = RcsSettings.getInstance().isTraceActivated();
    Logger.traceLevel = RcsSettings.getInstance().getTraceLevel();

    // Set the terminal version
    TerminalInfo.setProductVersion(AppUtils.getApplicationVersion(this));

    // Start the core
    startCore();
  }
Пример #11
0
 @Override
 public void enterChatMode(String number) {
   Logger.d(TAG, "enterChatMode() entry, number " + number);
   if (PluginUtils.getMessagingMode() == 0) {
     if (number.startsWith(IpMessageConsts.JOYN_START)) {
       number = number.substring(4);
     }
   }
   Message controllerMessage =
       PluginController.obtainMessage(
           ChatController.EVENT_SHOW_WINDOW, PhoneUtils.formatNumberToInternational(number));
   controllerMessage.sendToTarget();
   if ((PluginUtils.getMessagingMode() == 1) && (PluginUtils.translateThreadId(number) == 1)) {
     Logger.v(TAG, "enterChatMode(), open Window = " + number);
     Intent intent = new Intent(InvitationDialog.ACTION);
     intent.putExtra(RcsNotification.CONTACT, number);
     intent.putExtra(InvitationDialog.KEY_STRATEGY, InvitationDialog.STRATEGY_IPMES_SEND_BY_SMS);
     intent.putExtra("showDialog", true);
     intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
     AndroidFactory.getApplicationContext().startActivity(intent);
   }
   super.enterChatMode(number);
 }
Пример #12
0
  /**
   * A new presence sharing notification has been received
   *
   * @param contact Contact
   * @param status Status
   * @param reason Reason
   */
  public void handlePresenceSharingNotification(String contact, String status, String reason) {
    if (logger.isActivated()) {
      logger.debug(
          "Handle event presence sharing notification for "
              + contact
              + " ("
              + status
              + ":"
              + reason
              + ")");
    }

    try {
      // Check if its a notification for a contact or for the end user
      String me = ImsModule.IMS_USER_PROFILE.getPublicUri();
      if (PhoneUtils.compareNumbers(me, contact)) {
        // End user notification
        if (logger.isActivated()) {
          logger.debug("Presence sharing notification for me: by-pass it");
        }
      } else {
        // Update contacts database
        ContactsManager.getInstance().setContactSharingStatus(contact, status, reason);

        // Broadcast intent
        Intent intent = new Intent(PresenceApiIntents.PRESENCE_SHARING_CHANGED);
        intent.putExtra("contact", contact);
        intent.putExtra("status", status);
        intent.putExtra("reason", reason);
        AndroidFactory.getApplicationContext().sendBroadcast(intent);
      }
    } catch (Exception e) {
      if (logger.isActivated()) {
        logger.error("Internal exception", e);
      }
    }
  }
Пример #13
0
  /**
   * A new presence info notification has been received for a given contact
   *
   * @param contact Contact
   * @param presense Presence info document
   */
  public void presenceInfoNotificationForContact(String contact, PidfDocument presence) {
    if (logger.isActivated()) {
      logger.debug("Presence info notification for contact " + contact);
    }

    try {
      // Extract number from contact
      String number = PhoneUtils.extractNumberFromUri(contact);

      // Get the current presence info
      ContactInfo currentContactInfo = ContactsManager.getInstance().getContactInfo(contact);
      ContactInfo newContactInfo = currentContactInfo;
      if (currentContactInfo == null) {
        if (logger.isActivated()) {
          logger.warn("Contact " + contact + " not found in EAB: by-pass the notification");
        }
        return;
      }
      PresenceInfo newPresenceInfo = currentContactInfo.getPresenceInfo();
      if (newPresenceInfo == null) {
        newPresenceInfo = new PresenceInfo();
        newContactInfo.setPresenceInfo(newPresenceInfo);
      }

      // Update the current capabilities
      Capabilities capabilities = new Capabilities();
      Vector<Tuple> tuples = presence.getTuplesList();
      for (int i = 0; i < tuples.size(); i++) {
        Tuple tuple = (Tuple) tuples.elementAt(i);

        boolean state = false;
        if (tuple.getStatus().getBasic().getValue().equals("open")) {
          state = true;
        }

        String id = tuple.getService().getId();
        if (id.equalsIgnoreCase(PresenceUtils.FEATURE_RCS2_VIDEO_SHARE)) {
          capabilities.setVideoSharingSupport(state);
        } else if (id.equalsIgnoreCase(PresenceUtils.FEATURE_RCS2_IMAGE_SHARE)) {
          capabilities.setImageSharingSupport(state);
        } else if (id.equalsIgnoreCase(PresenceUtils.FEATURE_RCS2_FT)) {
          capabilities.setFileTransferSupport(state);
        } else if (id.equalsIgnoreCase(PresenceUtils.FEATURE_RCS2_CS_VIDEO)) {
          capabilities.setCsVideoSupport(state);
        } else if (id.equalsIgnoreCase(PresenceUtils.FEATURE_RCS2_CHAT)) {
          capabilities.setImSessionSupport(state);
        }
      }
      newContactInfo.setCapabilities(capabilities);

      // Update presence status
      String presenceStatus = PresenceInfo.UNKNOWN;
      Person person = presence.getPerson();
      OverridingWillingness willingness = person.getOverridingWillingness();
      if (willingness != null) {
        if ((willingness.getBasic() != null) && (willingness.getBasic().getValue() != null)) {
          presenceStatus = willingness.getBasic().getValue();
        }
      }
      newPresenceInfo.setPresenceStatus(presenceStatus);

      // Update the presence info
      newPresenceInfo.setTimestamp(person.getTimestamp());
      if (person.getNote() != null) {
        newPresenceInfo.setFreetext(person.getNote().getValue());
      }
      if (person.getHomePage() != null) {
        newPresenceInfo.setFavoriteLink(new FavoriteLink(person.getHomePage()));
      }

      // Update geoloc info
      if (presence.getGeopriv() != null) {
        Geoloc geoloc =
            new Geoloc(
                presence.getGeopriv().getLatitude(),
                presence.getGeopriv().getLongitude(),
                presence.getGeopriv().getAltitude());
        newPresenceInfo.setGeoloc(geoloc);
      }
      newContactInfo.setPresenceInfo(newPresenceInfo);

      // Update contacts database
      ContactsManager.getInstance().setContactInfo(newContactInfo, currentContactInfo);

      // Get photo Etag values
      String lastEtag = ContactsManager.getInstance().getContactPhotoEtag(contact);
      String newEtag = null;
      if (person.getStatusIcon() != null) {
        newEtag = person.getStatusIcon().getEtag();
      }

      // Test if the photo has been removed
      if ((lastEtag != null) && (person.getStatusIcon() == null)) {
        if (logger.isActivated()) {
          logger.debug("Photo has been removed for " + contact);
        }

        // Update contacts database
        ContactsManager.getInstance().setContactPhotoIcon(contact, null);

        // Broadcast intent
        Intent intent = new Intent(PresenceApiIntents.CONTACT_PHOTO_CHANGED);
        intent.putExtra("contact", number);
        AndroidFactory.getApplicationContext().sendBroadcast(intent);
      } else
      // Test if the photo has been changed
      if ((person.getStatusIcon() != null) && (newEtag != null)) {
        if ((lastEtag == null) || (!lastEtag.equals(newEtag))) {
          if (logger.isActivated()) {
            logger.debug("Photo has changed for " + contact + ", download it in background");
          }

          // Download the photo in background
          downloadPhotoForContact(contact, presence.getPerson().getStatusIcon().getUrl(), newEtag);
        }
      }

      // Broadcast intent
      Intent intent = new Intent(PresenceApiIntents.CONTACT_INFO_CHANGED);
      intent.putExtra("contact", number);
      getApplicationContext().sendBroadcast(intent);
    } catch (Exception e) {
      if (logger.isActivated()) {
        logger.error("Internal exception", e);
      }
    }
  }