PageRenderTime 56ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/bbb-android/src/org/sipdroid/sipua/SipdroidEngine.java

https://github.com/deniszgonjanin/mconf-mobile
Java | 599 lines | 492 code | 76 blank | 31 comment | 163 complexity | d6b27a7beebc54b2ed6fa35f1ef5b58e MD5 | raw file
Possible License(s): LGPL-3.0, GPL-3.0, BSD-3-Clause, Apache-2.0
  1. /*
  2. * Copyright (C) 2009 The Sipdroid Open Source Project
  3. * Copyright (C) 2008 Hughes Systique Corporation, USA (http://www.hsc.com)
  4. *
  5. * This file is part of Sipdroid (http://www.sipdroid.org)
  6. *
  7. * Sipdroid is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This source code is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this source code; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. package org.sipdroid.sipua;
  22. import java.io.IOException;
  23. import java.net.UnknownHostException;
  24. import org.mconf.bbb.android.R;
  25. import org.sipdroid.net.KeepAliveSip;
  26. import org.sipdroid.sipua.ui.ChangeAccount;
  27. import org.sipdroid.sipua.ui.LoopAlarm;
  28. import org.sipdroid.sipua.ui.Receiver;
  29. import org.sipdroid.sipua.ui.Settings;
  30. import org.sipdroid.sipua.ui.Sipdroid;
  31. import org.zoolu.net.IpAddress;
  32. import org.zoolu.net.SocketAddress;
  33. import org.zoolu.sip.address.NameAddress;
  34. import org.zoolu.sip.provider.SipProvider;
  35. import org.zoolu.sip.provider.SipStack;
  36. import android.content.Context;
  37. import android.content.SharedPreferences.Editor;
  38. import android.net.Uri;
  39. import android.net.wifi.WifiManager;
  40. import android.os.Build;
  41. import android.os.PowerManager;
  42. import android.os.SystemClock;
  43. import android.preference.PreferenceManager;
  44. public class SipdroidEngine implements RegisterAgentListener {
  45. public static final int LINES = 2;
  46. public int pref;
  47. public static final int UNINITIALIZED = 0x0;
  48. public static final int INITIALIZED = 0x2;
  49. /** User Agent */
  50. public UserAgent[] uas;
  51. public UserAgent ua;
  52. /** Register Agent */
  53. private RegisterAgent[] ras;
  54. private KeepAliveSip[] kas;
  55. /** UserAgentProfile */
  56. public UserAgentProfile[] user_profiles;
  57. public SipProvider[] sip_providers;
  58. public static PowerManager.WakeLock[] wl,pwl;
  59. UserAgentProfile getUserAgentProfile(String suffix) {
  60. UserAgentProfile user_profile = new UserAgentProfile(null);
  61. user_profile.username = PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_USERNAME+suffix, Settings.DEFAULT_USERNAME); // modified
  62. user_profile.passwd = PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_PASSWORD+suffix, Settings.DEFAULT_PASSWORD);
  63. if (PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_DOMAIN+suffix, Settings.DEFAULT_DOMAIN).length() == 0) {
  64. user_profile.realm = PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_SERVER+suffix, Settings.DEFAULT_SERVER);
  65. } else {
  66. user_profile.realm = PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_DOMAIN+suffix, Settings.DEFAULT_DOMAIN);
  67. }
  68. user_profile.realm_orig = user_profile.realm;
  69. if (PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_FROMUSER+suffix, Settings.DEFAULT_FROMUSER).length() == 0) {
  70. user_profile.from_url = user_profile.username;
  71. } else {
  72. user_profile.from_url = PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_FROMUSER+suffix, Settings.DEFAULT_FROMUSER);
  73. }
  74. // MMTel configuration (added by mandrajg)
  75. user_profile.qvalue = PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_MMTEL_QVALUE, Settings.DEFAULT_MMTEL_QVALUE);
  76. user_profile.mmtel = PreferenceManager.getDefaultSharedPreferences(getUIContext()).getBoolean(Settings.PREF_MMTEL, Settings.DEFAULT_MMTEL);
  77. user_profile.pub = PreferenceManager.getDefaultSharedPreferences(getUIContext()).getBoolean(Settings.PREF_EDGE+suffix, Settings.DEFAULT_EDGE) ||
  78. PreferenceManager.getDefaultSharedPreferences(getUIContext()).getBoolean(Settings.PREF_3G+suffix, Settings.DEFAULT_3G);
  79. return user_profile;
  80. }
  81. public boolean StartEngine() {
  82. PowerManager pm = (PowerManager) getUIContext().getSystemService(Context.POWER_SERVICE);
  83. if (wl == null) {
  84. if (!PreferenceManager.getDefaultSharedPreferences(getUIContext()).contains(org.sipdroid.sipua.ui.Settings.PREF_KEEPON)) {
  85. Editor edit = PreferenceManager.getDefaultSharedPreferences(getUIContext()).edit();
  86. edit.putBoolean(org.sipdroid.sipua.ui.Settings.PREF_KEEPON, Build.MODEL.equals("Nexus One") ||
  87. Build.MODEL.equals("Archos5") ||
  88. Build.MODEL.equals("ADR6300") ||
  89. Build.MODEL.equals("PC36100") ||
  90. Build.MODEL.equals("HTC Desire") ||
  91. Build.MODEL.equals("HTC Wildfire"));
  92. edit.commit();
  93. }
  94. wl = new PowerManager.WakeLock[LINES];
  95. pwl = new PowerManager.WakeLock[LINES];
  96. }
  97. pref = ChangeAccount.getPref(Receiver.mContext);
  98. uas = new UserAgent[LINES];
  99. ras = new RegisterAgent[LINES];
  100. kas = new KeepAliveSip[LINES];
  101. lastmsgs = new String[LINES];
  102. sip_providers = new SipProvider[LINES];
  103. user_profiles = new UserAgentProfile[LINES];
  104. user_profiles[0] = getUserAgentProfile("");
  105. for (int i = 1; i < LINES; i++)
  106. user_profiles[1] = getUserAgentProfile(""+i);
  107. SipStack.init(null);
  108. int i = 0;
  109. for (UserAgentProfile user_profile : user_profiles) {
  110. if (wl[i] == null) {
  111. wl[i] = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Sipdroid.SipdroidEngine");
  112. if (PreferenceManager.getDefaultSharedPreferences(getUIContext()).getBoolean(org.sipdroid.sipua.ui.Settings.PREF_KEEPON, org.sipdroid.sipua.ui.Settings.DEFAULT_KEEPON))
  113. pwl[i] = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "Sipdroid.SipdroidEngine");
  114. }
  115. try {
  116. SipStack.debug_level = 0;
  117. // SipStack.log_path = "/data/data/org.sipdroid.sipua";
  118. SipStack.max_retransmission_timeout = 4000;
  119. SipStack.default_transport_protocols = new String[1];
  120. SipStack.default_transport_protocols[0] = PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_PROTOCOL+(i!=0?i:""),
  121. user_profile.realm.equals(Settings.DEFAULT_SERVER)?"tcp":"udp");
  122. String version = "Sipdroid/" + Sipdroid.getVersion() + "/" + Build.MODEL;
  123. SipStack.ua_info = version;
  124. SipStack.server_info = version;
  125. IpAddress.setLocalIpAddress();
  126. sip_providers[i] = new SipProvider(IpAddress.localIpAddress, 0);
  127. user_profile.contact_url = getContactURL(user_profile.username,sip_providers[i]);
  128. if (user_profile.from_url.indexOf("@") < 0) {
  129. user_profile.from_url +=
  130. "@"
  131. + user_profile.realm;
  132. }
  133. CheckEngine();
  134. // added by mandrajg
  135. String icsi = null;
  136. if (user_profile.mmtel == true){
  137. icsi = "\"urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel\"";
  138. }
  139. uas[i] = ua = new UserAgent(sip_providers[i], user_profile);
  140. ras[i] = new RegisterAgent(sip_providers[i], user_profile.from_url, // modified
  141. user_profile.contact_url, user_profile.username,
  142. user_profile.realm, user_profile.passwd, this, user_profile,
  143. user_profile.qvalue, icsi, user_profile.pub); // added by mandrajg
  144. kas[i] = new KeepAliveSip(sip_providers[i],100000);
  145. } catch (Exception E) {
  146. }
  147. i++;
  148. }
  149. register();
  150. listen();
  151. return true;
  152. }
  153. private String getContactURL(String username,SipProvider sip_provider) {
  154. int i = username.indexOf("@");
  155. if (i != -1) {
  156. // if the username already contains a @
  157. //strip it and everthing following it
  158. username = username.substring(0, i);
  159. }
  160. return username + "@" + IpAddress.localIpAddress
  161. + (sip_provider.getPort() != 0?":"+sip_provider.getPort():"")
  162. + ";transport=" + sip_provider.getDefaultTransport();
  163. }
  164. void setOutboundProxy(SipProvider sip_provider,int i) {
  165. try {
  166. if (sip_provider != null) sip_provider.setOutboundProxy(new SocketAddress(
  167. IpAddress.getByName(PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_DNS+i, Settings.DEFAULT_DNS)),
  168. Integer.valueOf(PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_PORT+(i!=0?i:""), Settings.DEFAULT_PORT))));
  169. } catch (Exception e) {
  170. }
  171. }
  172. public void CheckEngine() {
  173. int i = 0;
  174. for (SipProvider sip_provider : sip_providers) {
  175. if (sip_provider != null && !sip_provider.hasOutboundProxy())
  176. setOutboundProxy(sip_provider,i);
  177. i++;
  178. }
  179. }
  180. public Context getUIContext() {
  181. return Receiver.mContext;
  182. }
  183. public int getRemoteVideo() {
  184. return ua.remote_video_port;
  185. }
  186. public int getLocalVideo() {
  187. return ua.local_video_port;
  188. }
  189. public String getRemoteAddr() {
  190. return ua.remote_media_address;
  191. }
  192. public void expire() {
  193. Receiver.expire_time = 0;
  194. int i = 0;
  195. for (RegisterAgent ra : ras) {
  196. if (ra != null && ra.CurrentState == RegisterAgent.REGISTERED) {
  197. ra.CurrentState = RegisterAgent.UNREGISTERED;
  198. Receiver.onText(Receiver.REGISTER_NOTIFICATION+i, null, 0, 0);
  199. }
  200. i++;
  201. }
  202. register();
  203. }
  204. public void unregister(int i) {
  205. if (user_profiles[i] == null || user_profiles[i].username.equals("") ||
  206. user_profiles[i].realm.equals("")) return;
  207. RegisterAgent ra = ras[i];
  208. if (ra != null && ra.unregister()) {
  209. Receiver.alarm(0, LoopAlarm.class);
  210. Receiver.onText(Receiver.REGISTER_NOTIFICATION+i,getUIContext().getString(R.string.reg),R.drawable.sym_presence_idle,0);
  211. wl[i].acquire();
  212. } else
  213. Receiver.onText(Receiver.REGISTER_NOTIFICATION+i, null, 0, 0);
  214. }
  215. public void registerMore() {
  216. IpAddress.setLocalIpAddress();
  217. int i = 0;
  218. for (RegisterAgent ra : ras) {
  219. try {
  220. if (user_profiles[i] == null || user_profiles[i].username.equals("") ||
  221. user_profiles[i].realm.equals("")) {
  222. i++;
  223. continue;
  224. }
  225. user_profiles[i].contact_url = getContactURL(user_profiles[i].from_url,sip_providers[i]);
  226. if (ra != null && !ra.isRegistered() && Receiver.isFast(i) && ra.register()) {
  227. Receiver.onText(Receiver.REGISTER_NOTIFICATION+i,getUIContext().getString(R.string.reg),R.drawable.sym_presence_idle,0);
  228. wl[i].acquire();
  229. }
  230. } catch (Exception ex) {
  231. }
  232. i++;
  233. }
  234. }
  235. public void register() {
  236. IpAddress.setLocalIpAddress();
  237. int i = 0;
  238. for (RegisterAgent ra : ras) {
  239. try {
  240. if (user_profiles[i] == null || user_profiles[i].username.equals("") ||
  241. user_profiles[i].realm.equals("")) {
  242. i++;
  243. continue;
  244. }
  245. user_profiles[i].contact_url = getContactURL(user_profiles[i].from_url,sip_providers[i]);
  246. if (!Receiver.isFast(i)) {
  247. unregister(i);
  248. } else {
  249. if (ra != null && ra.register()) {
  250. Receiver.onText(Receiver.REGISTER_NOTIFICATION+i,getUIContext().getString(R.string.reg),R.drawable.sym_presence_idle,0);
  251. wl[i].acquire();
  252. }
  253. }
  254. } catch (Exception ex) {
  255. }
  256. i++;
  257. }
  258. }
  259. public void registerUdp() {
  260. IpAddress.setLocalIpAddress();
  261. int i = 0;
  262. for (RegisterAgent ra : ras) {
  263. try {
  264. if (user_profiles[i] == null || user_profiles[i].username.equals("") ||
  265. user_profiles[i].realm.equals("") ||
  266. sip_providers[i] == null ||
  267. sip_providers[i].getDefaultTransport() == null ||
  268. sip_providers[i].getDefaultTransport().equals("tcp")) {
  269. i++;
  270. continue;
  271. }
  272. user_profiles[i].contact_url = getContactURL(user_profiles[i].from_url,sip_providers[i]);
  273. if (!Receiver.isFast(i)) {
  274. unregister(i);
  275. } else {
  276. if (ra != null && ra.register()) {
  277. Receiver.onText(Receiver.REGISTER_NOTIFICATION+i,getUIContext().getString(R.string.reg),R.drawable.sym_presence_idle,0);
  278. wl[i].acquire();
  279. }
  280. }
  281. } catch (Exception ex) {
  282. }
  283. i++;
  284. }
  285. }
  286. public void halt() { // modified
  287. long time = SystemClock.elapsedRealtime();
  288. int i = 0;
  289. for (RegisterAgent ra : ras) {
  290. unregister(i);
  291. while (ra != null && ra.CurrentState != RegisterAgent.UNREGISTERED && SystemClock.elapsedRealtime()-time < 2000)
  292. try {
  293. Thread.sleep(100);
  294. } catch (InterruptedException e1) {
  295. }
  296. if (wl[i].isHeld()) {
  297. wl[i].release();
  298. if (pwl[i] != null && pwl[i].isHeld()) pwl[i].release();
  299. }
  300. if (kas[i] != null) {
  301. Receiver.alarm(0, LoopAlarm.class);
  302. kas[i].halt();
  303. }
  304. Receiver.onText(Receiver.REGISTER_NOTIFICATION+i, null, 0, 0);
  305. if (ra != null)
  306. ra.halt();
  307. if (uas[i] != null)
  308. uas[i].hangup();
  309. if (sip_providers[i] != null)
  310. sip_providers[i].halt();
  311. i++;
  312. }
  313. }
  314. public boolean isRegistered()
  315. {
  316. for (RegisterAgent ra : ras)
  317. if (ra != null && ra.isRegistered())
  318. return true;
  319. return false;
  320. }
  321. boolean isRegistered(int i)
  322. {
  323. if (ras[i] == null)
  324. {
  325. return false;
  326. }
  327. return ras[i].isRegistered();
  328. }
  329. public void onUaRegistrationSuccess(RegisterAgent reg_ra, NameAddress target,
  330. NameAddress contact, String result) {
  331. int i = 0;
  332. for (RegisterAgent ra : ras) {
  333. if (ra == reg_ra) break;
  334. i++;
  335. }
  336. if (isRegistered(i)) {
  337. if (Receiver.on_wlan)
  338. Receiver.alarm(60, LoopAlarm.class);
  339. Receiver.onText(Receiver.REGISTER_NOTIFICATION+i,getUIContext().getString(i == pref?R.string.regpref:R.string.regclick),R.drawable.sym_presence_available,0);
  340. reg_ra.subattempts = 0;
  341. reg_ra.startMWI();
  342. Receiver.registered();
  343. } else
  344. Receiver.onText(Receiver.REGISTER_NOTIFICATION+i, null, 0,0);
  345. if (wl[i].isHeld()) {
  346. wl[i].release();
  347. if (pwl[i] != null && pwl[i].isHeld()) pwl[i].release();
  348. }
  349. }
  350. String[] lastmsgs;
  351. public void onMWIUpdate(RegisterAgent mwi_ra, boolean voicemail, int number, String vmacc) {
  352. int i = 0;
  353. for (RegisterAgent ra : ras) {
  354. if (ra == mwi_ra) break;
  355. i++;
  356. }
  357. if (i != pref) return;
  358. if (voicemail) {
  359. String msgs = getUIContext().getString(R.string.voicemail);
  360. if (number != 0) {
  361. msgs = msgs + ": " + number;
  362. }
  363. Receiver.MWI_account = vmacc;
  364. if (lastmsgs[i] == null || !msgs.equals(lastmsgs[i])) {
  365. Receiver.onText(Receiver.MWI_NOTIFICATION, msgs,android.R.drawable.stat_notify_voicemail,0);
  366. lastmsgs[i] = msgs;
  367. }
  368. } else {
  369. Receiver.onText(Receiver.MWI_NOTIFICATION, null, 0,0);
  370. lastmsgs[i] = null;
  371. }
  372. }
  373. static long lasthalt,lastpwl;
  374. /** When a UA failed on (un)registering. */
  375. public void onUaRegistrationFailure(RegisterAgent reg_ra, NameAddress target,
  376. NameAddress contact, String result) {
  377. boolean retry = false;
  378. int i = 0;
  379. for (RegisterAgent ra : ras) {
  380. if (ra == reg_ra) break;
  381. i++;
  382. }
  383. if (isRegistered(i)) {
  384. reg_ra.CurrentState = RegisterAgent.UNREGISTERED;
  385. Receiver.onText(Receiver.REGISTER_NOTIFICATION+i, null, 0, 0);
  386. } else {
  387. retry = true;
  388. Receiver.onText(Receiver.REGISTER_NOTIFICATION+i,getUIContext().getString(R.string.regfailed)+" ("+result+")",R.drawable.sym_presence_away,0);
  389. }
  390. if (retry && SystemClock.uptimeMillis() > lastpwl + 45000 && pwl[i] != null && !pwl[i].isHeld() && Receiver.on_wlan) {
  391. lastpwl = SystemClock.uptimeMillis();
  392. if (wl[i].isHeld())
  393. wl[i].release();
  394. pwl[i].acquire();
  395. register();
  396. if (!wl[i].isHeld() && pwl[i].isHeld()) pwl[i].release();
  397. } else if (wl[i].isHeld()) {
  398. wl[i].release();
  399. if (pwl[i] != null && pwl[i].isHeld()) pwl[i].release();
  400. }
  401. if (SystemClock.uptimeMillis() > lasthalt + 45000) {
  402. lasthalt = SystemClock.uptimeMillis();
  403. sip_providers[i].haltConnections();
  404. }
  405. updateDNS();
  406. reg_ra.stopMWI();
  407. WifiManager wm = (WifiManager) Receiver.mContext.getSystemService(Context.WIFI_SERVICE);
  408. wm.startScan();
  409. }
  410. public void updateDNS() {
  411. Editor edit = PreferenceManager.getDefaultSharedPreferences(getUIContext()).edit();
  412. int i = 0;
  413. for (SipProvider sip_provider : sip_providers) {
  414. try {
  415. edit.putString(Settings.PREF_DNS+i, IpAddress.getByName(PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_SERVER+(i!=0?i:""), "")).toString());
  416. } catch (UnknownHostException e1) {
  417. i++;
  418. continue;
  419. }
  420. edit.commit();
  421. setOutboundProxy(sip_provider,i);
  422. i++;
  423. }
  424. }
  425. /** Receives incoming calls (auto accept) */
  426. public void listen()
  427. {
  428. for (UserAgent ua : uas) {
  429. if (ua != null) {
  430. ua.printLog("UAS: WAITING FOR INCOMING CALL");
  431. if (!ua.user_profile.audio && !ua.user_profile.video)
  432. {
  433. ua.printLog("ONLY SIGNALING, NO MEDIA");
  434. }
  435. ua.listen();
  436. }
  437. }
  438. }
  439. public void info(char c, int duration) {
  440. ua.info(c, duration);
  441. }
  442. /** Makes a new call */
  443. public boolean call(String target_url,boolean force) {
  444. int p = pref;
  445. boolean found = false;
  446. if (isRegistered(p) && Receiver.isFast(p))
  447. found = true;
  448. else {
  449. for (p = 0; p < LINES; p++)
  450. if (isRegistered(p) && Receiver.isFast(p)) {
  451. found = true;
  452. break;
  453. }
  454. if (!found && force) {
  455. p = pref;
  456. if (Receiver.isFast(p))
  457. found = true;
  458. else for (p = 0; p < LINES; p++)
  459. if (Receiver.isFast(p)) {
  460. found = true;
  461. break;
  462. }
  463. }
  464. }
  465. if (!found || (ua = uas[p]) == null) {
  466. if (PreferenceManager.getDefaultSharedPreferences(getUIContext()).getBoolean(Settings.PREF_CALLBACK, Settings.DEFAULT_CALLBACK) &&
  467. PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_POSURL, Settings.DEFAULT_POSURL).length() > 0) {
  468. Receiver.url("n="+Uri.decode(target_url));
  469. return true;
  470. }
  471. return false;
  472. }
  473. ua.printLog("UAC: CALLING " + target_url);
  474. if (!ua.user_profile.audio && !ua.user_profile.video)
  475. {
  476. ua.printLog("ONLY SIGNALING, NO MEDIA");
  477. }
  478. return ua.call(target_url, false);
  479. }
  480. public void answercall()
  481. {
  482. Receiver.stopRingtone();
  483. ua.accept();
  484. }
  485. public void rejectcall() {
  486. ua.printLog("UA: HANGUP");
  487. ua.hangup();
  488. }
  489. public void togglehold() {
  490. ua.reInvite(null, 0);
  491. }
  492. public void transfer(String number) {
  493. ua.callTransfer(number, 0);
  494. }
  495. public void togglemute() {
  496. if (ua.muteMediaApplication())
  497. Receiver.onText(Receiver.CALL_NOTIFICATION, getUIContext().getString(R.string.menu_mute), android.R.drawable.stat_notify_call_mute,Receiver.ccCall.base);
  498. else
  499. Receiver.progress();
  500. }
  501. public void togglebluetooth() {
  502. ua.bluetoothMediaApplication();
  503. Receiver.progress();
  504. }
  505. public int speaker(int mode) {
  506. int ret = ua.speakerMediaApplication(mode);
  507. Receiver.progress();
  508. return ret;
  509. }
  510. public void keepAlive() {
  511. int i = 0;
  512. for (KeepAliveSip ka : kas) {
  513. if (ka != null && Receiver.on_wlan && isRegistered(i))
  514. try {
  515. ka.sendToken();
  516. Receiver.alarm(60, LoopAlarm.class);
  517. } catch (IOException e) {
  518. if (!Sipdroid.release) e.printStackTrace();
  519. }
  520. i++;
  521. }
  522. }
  523. }