Example #1
0
 public void onCreate() {
   super.onCreate();
   Log.m11091e("dddd", "Call SipLibService onCreate");
   Log.m11095i(START_LINPHONE_LOGS);
   this.mNM = (NotificationManager) getSystemService("notification");
   LinphoneManager.createAndStart(this, this);
   this.mWifiManager = (WifiManager) getSystemService("wifi");
   if (Version.sdkAboveOrEqual(12)) {
     startWifiLock();
   }
   instance = this;
   if (Version.sdkStrictlyBelow(5)) {
     try {
       getClass().getMethod("setForeground", mSetFgSign);
     } catch (Throwable e) {
       Log.m11090e(e, "Couldn't find foreground method");
     }
   } else {
     try {
       getClass().getMethod("startForeground", mStartFgSign);
       getClass().getMethod("stopForeground", mStopFgSign);
     } catch (Throwable e2) {
       Log.m11090e(e2, "Couldn't find startGoreground or stopForeground");
     }
   }
   if (!this.mTestDelayElapsed) {
     this.mHandler.postDelayed(new C27971(), 5000);
   }
   this.mKeepAlivePendingIntent =
       PendingIntent.getBroadcast(
           this, IC_LEVEL_ORANGE, new Intent(this, KeepAliveHandler.class), 1073741824);
   ((AlarmManager) getSystemService("alarm"))
       .setRepeating(2, SystemClock.elapsedRealtime() + 1000, 60000, this.mKeepAlivePendingIntent);
 }
  static {
    // FFMPEG (audio/video)
    loadOptionalLibrary("avutil");
    loadOptionalLibrary("swscale");
    loadOptionalLibrary("avcore");

    System.loadLibrary("neon");

    if (!hasNeonInCpuFeatures()) {
      boolean noNeonLibrariesLoaded = loadOptionalLibrary("avcodecnoneon");
      if (!noNeonLibrariesLoaded) {
        loadOptionalLibrary("avcodec");
      }
    } else {
      loadOptionalLibrary("avcodec");
    }

    // OPENSSL (cryptography)
    // lin prefix avoids collision with libs in /system/lib
    loadOptionalLibrary("lincrypto");
    loadOptionalLibrary("linssl");

    // Secure RTP and key negotiation
    loadOptionalLibrary("srtp");
    loadOptionalLibrary("zrtpcpp"); // GPLv3+

    // Tunnel
    loadOptionalLibrary("tunnelclient");

    // g729 A implementation
    loadOptionalLibrary("bcg729");

    // Main library
    if (!hasNeonInCpuFeatures()) {
      try {
        if (!isArmv7() && !Version.isX86()) {
          System.loadLibrary("linphonearmv5");
        } else {
          System.loadLibrary("linphonenoneon");
        }
        Log.w("linphone", "No-neon liblinphone loaded");
      } catch (UnsatisfiedLinkError ule) {
        Log.w("linphone", "Failed to load no-neon liblinphone, loading neon liblinphone");
        System.loadLibrary("linphone");
      }
    } else {
      System.loadLibrary("linphone");
    }

    Version.dumpCapabilities();
  }
Example #3
0
 public synchronized void onDestroy() {
   instance = null;
   LinphoneManager.destroy();
   if (Version.sdkAboveOrEqual(12)) {
     this.mWifiLock.release();
   }
   ((AlarmManager) getSystemService("alarm")).cancel(this.mKeepAlivePendingIntent);
   super.onDestroy();
 }
Example #4
0
 public void onCallStateChanged(LinphoneCall linphoneCall, State state, String str) {
   if (instance == null) {
     Log.m11095i("Service not ready, discarding call state change to ", state.toString());
     return;
   }
   if (state == State.IncomingReceived) {
     onIncomingReceived();
   }
   if (state == State.CallUpdatedByRemote) {
     boolean videoEnabled = linphoneCall.getRemoteParams().getVideoEnabled();
     boolean videoEnabled2 = linphoneCall.getCurrentParamsCopy().getVideoEnabled();
     boolean shouldAutomaticallyAcceptVideoRequests =
         LinphonePreferences.instance().shouldAutomaticallyAcceptVideoRequests();
     if (!(!videoEnabled
         || videoEnabled2
         || shouldAutomaticallyAcceptVideoRequests
         || LinphoneManager.getLc().isInConference())) {
       try {
         LinphoneManager.getLc().deferCallUpdate(linphoneCall);
       } catch (Throwable e) {
         C1104b.m6368b((Object) this, e);
       }
     }
   }
   if (state == State.StreamsRunning) {
     if (getResources().getBoolean(C1134b.enable_call_notification)) {}
     if (Version.sdkAboveOrEqual(12)) {
       this.mWifiLock.acquire();
     }
   } else if (getResources().getBoolean(C1134b.enable_call_notification)) {
   }
   if ((state == State.CallEnd || state == State.Error)
       && LinphoneManager.getLc().getCallsNb() < 1
       && Version.sdkAboveOrEqual(12)) {
     this.mWifiLock.release();
   }
   this.mHandler.post(new C28015(linphoneCall, state, str));
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    instance = this;

    getWindow()
        .addFlags(
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
                | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    setContentView(R.layout.incall);

    isTransferAllowed = getApplicationContext().getResources().getBoolean(R.bool.allow_transfers);
    isSpeakerEnabled = LinphoneManager.getLcIfManagerNotDestroyedOrNull().isSpeakerEnabled();

    if (Version.sdkAboveOrEqual(Version.API11_HONEYCOMB_30)) {
      if (!BluetoothManager.getInstance().isBluetoothHeadsetAvailable()) {
        BluetoothManager.getInstance().initBluetooth();
      } else {
        isSpeakerEnabled = false;
      }
    }

    isAnimationDisabled =
        getApplicationContext().getResources().getBoolean(R.bool.disable_animations)
            || !LinphonePreferences.instance().areAnimationsEnabled();

    mListener =
        new LinphoneCoreListenerBase() {
          @Override
          public void callState(
              LinphoneCore lc, final LinphoneCall call, LinphoneCall.State state, String message) {
            if (LinphoneManager.getLc().getCallsNb() == 0) {
              finish();
              return;
            }

            if (state == State.IncomingReceived) {
              startIncomingCallActivity();
              return;
            }

            if (state == State.StreamsRunning) {
              LinphoneManager.getLc().enableSpeaker(isSpeakerEnabled);

              isMicMuted = LinphoneManager.getLc().isMicMuted();
              enableAndRefreshInCallActions();

              if (status != null) {
                status.refreshStatusItems(call);
              }
            }

            refreshInCallActions();

            refreshCallList(getResources());

            if (state == State.CallUpdatedByRemote) {
              acceptCallUpdate();
              return;
            }

            transfer.setEnabled(LinphoneManager.getLc().getCurrentCall() != null);
          }
        };

    if (findViewById(R.id.fragmentContainer) != null) {

      initUI();

      if (LinphoneManager.getLc().getCallsNb() > 0) {
        LinphoneCall call = LinphoneManager.getLc().getCalls()[0];

        if (LinphoneUtils.isCallEstablished(call)) {
          enableAndRefreshInCallActions();
        }
      }

      if (savedInstanceState != null) {
        // Fragment already created, no need to create it again (else it will generate a memory leak
        // with duplicated fragments)
        isSpeakerEnabled = savedInstanceState.getBoolean("Speaker");
        isMicMuted = savedInstanceState.getBoolean("Mic");
        refreshInCallActions();
        return;
      }

      audioCallFragment = new AudioCallFragment();

      if (BluetoothManager.getInstance().isBluetoothHeadsetAvailable()) {
        BluetoothManager.getInstance().routeAudioToBluetooth();
      }

      audioCallFragment.setArguments(getIntent().getExtras());
      getSupportFragmentManager()
          .beginTransaction()
          .add(R.id.fragmentContainer, audioCallFragment)
          .commitAllowingStateLoss();
    }
  }
Example #6
0
  @Override
  public void onCreate() {
    super.onCreate();

    android.util.Log.d("LinphoneService", "onCreate()");

    // In case restart after a crash. Main in LinphoneActivity
    LinphonePreferenceManager.getInstance(this);

    // Set default preferences
    PreferenceManager.setDefaultValues(this, R.get("xml", "preferences"), true);

    //		mNotificationTitle = getString(R.get("string", "app_name"));

    // Dump some debugging information to the logs
    Log.i(START_LINPHONE_LOGS);
    dumpDeviceInformation();
    dumpInstalledLinphoneInformation();

    //		mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    //		mNM.cancel(INCALL_NOTIF_ID); // in case of crash the icon is not removed
    //		mNotif = new Notification(R.get("drawable", "status_level"), "",
    // System.currentTimeMillis());
    //		mNotif.iconLevel=IC_LEVEL_ORANGE;
    //		mNotif.flags |= Notification.FLAG_ONGOING_EVENT;

    //		Intent notifIntent = new Intent();
    //		notifIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    //		notifIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
    // Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    //		notifIntent.setClassName(ALModuleProxy.PKG_NAME, ALModuleProxy.PKG_NAME + "." +
    // ALModuleProxy.ACT_NAME);
    //		notifIntent.setAction(Intent.ACTION_MAIN);
    //		mNotifContentIntent = PendingIntent.getActivity(this, 0, notifIntent, 0);
    //		mNotif.setLatestEventInfo(this, mNotificationTitle,"", mNotifContentIntent);

    LinphoneManager.createAndStart(this, this);
    LinphoneManager.getLc().setPresenceInfo(0, null, OnlineStatus.Online);
    mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    mWifiLock =
        mWifiManager.createWifiLock(
            WifiManager.WIFI_MODE_FULL_HIGH_PERF, this.getPackageName() + "-wifi-call-lock");
    mWifiLock.setReferenceCounted(false);
    instance = this; // instance is ready once linphone manager has been created

    // Retrieve methods to publish notification and keep Android
    // from killing us and keep the audio quality high.
    if (Version.sdkStrictlyBelow(Version.API05_ECLAIR_20)) {
      try {
        mSetForeground = getClass().getMethod("setForeground", mSetFgSign);
      } catch (NoSuchMethodException e) {
        Log.e(e, "Couldn't find foreground method");
      }
    } else {
      try {
        mStartForeground = getClass().getMethod("startForeground", mStartFgSign);
        mStopForeground = getClass().getMethod("stopForeground", mStopFgSign);
      } catch (NoSuchMethodException e) {
        Log.e(e, "Couldn't find startGoreground or stopForeground");
      }
    }

    //		startForegroundCompat(NOTIF_ID, mNotif);

    LinphoneManager.setOnTextReceivedListener(this);

    if (!mTestDelayElapsed) {
      // Only used when testing. Simulates a 5 seconds delay for launching service
      mHandler.postDelayed(
          new Runnable() {
            @Override
            public void run() {
              mTestDelayElapsed = true;
            }
          },
          5000);
    }
  }