diff --git a/res/layout/frag_call.xml b/res/layout/frag_call.xml index 813438d2ca6af2150859c57e48a5c3b7677fdf1d..cea330f3a5126e7c0341a16c905650bd1840d596 100644 --- a/res/layout/frag_call.xml +++ b/res/layout/frag_call.xml @@ -50,6 +50,15 @@ android:layout_marginRight="10dp" android:background="#00000000" android:src="@drawable/ic_action_dial_pad_light" /> + + <ToggleButton + android:id="@+id/toggle_speaker" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:layout_centerHorizontal="true" + android:text="Speaker" /> + </RelativeLayout> <org.sflphone.model.BubblesView diff --git a/src/org/sflphone/client/HomeActivity.java b/src/org/sflphone/client/HomeActivity.java index b2049e0f2ae299d6b80a4a3b02a83fbe8a1db0c3..7c435fc4e3b0caf5d9db96ba1ff6964722fc6d2c 100644 --- a/src/org/sflphone/client/HomeActivity.java +++ b/src/org/sflphone/client/HomeActivity.java @@ -31,7 +31,12 @@ */ package org.sflphone.client; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; import java.io.InvalidObjectException; +import java.io.OutputStream; import java.util.Timer; import java.util.TimerTask; @@ -62,12 +67,14 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; +import android.content.res.AssetManager; import android.content.res.Configuration; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; +import android.preference.PreferenceManager; import android.provider.ContactsContract; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.CommonDataKinds.SipAddress; @@ -236,10 +243,66 @@ public class HomeActivity extends Activity implements DialingFragment.Callbacks, @Override protected void onStart() { Log.i(TAG, "onStart"); + + if (!PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("installed", false)) { + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putBoolean("installed", true).commit(); + + copyAssetFolder(getAssets(), "ringtones", getFilesDir().getAbsolutePath() + "/ringtones"); + } + super.onStart(); } + private static boolean copyAssetFolder(AssetManager assetManager, String fromAssetPath, String toPath) { + try { + String[] files = assetManager.list(fromAssetPath); + new File(toPath).mkdirs(); + Log.i(TAG, "Creating :" + toPath); + boolean res = true; + for (String file : files) + if (file.contains(".")) { + Log.i(TAG, "Copying file :" + fromAssetPath + "/" + file + " to " + toPath + "/" + file); + res &= copyAsset(assetManager, fromAssetPath + "/" + file, toPath + "/" + file); + } else { + Log.i(TAG, "Copying folder :" + fromAssetPath + "/" + file + " to " + toPath + "/" + file); + res &= copyAssetFolder(assetManager, fromAssetPath + "/" + file, toPath + "/" + file); + } + return res; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + private static boolean copyAsset(AssetManager assetManager, String fromAssetPath, String toPath) { + InputStream in = null; + OutputStream out = null; + try { + in = assetManager.open(fromAssetPath); + new File(toPath).createNewFile(); + out = new FileOutputStream(toPath); + copyFile(in, out); + in.close(); + in = null; + out.flush(); + out.close(); + out = null; + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + private static void copyFile(InputStream in, OutputStream out) throws IOException { + byte[] buffer = new byte[1024]; + int read; + while ((read = in.read(buffer)) != -1) { + out.write(buffer, 0, read); + } + } + /* user gets back to the activity, e.g. through task manager */ @Override protected void onRestart() { diff --git a/src/org/sflphone/fragments/CallFragment.java b/src/org/sflphone/fragments/CallFragment.java index 58ebebd69f52c29605ede52c704f4a57d8c86a09..3f680673ce4e95e23bfca3417470a6b25ea2d16c 100644 --- a/src/org/sflphone/fragments/CallFragment.java +++ b/src/org/sflphone/fragments/CallFragment.java @@ -68,8 +68,11 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.view.inputmethod.InputMethodManager; +import android.widget.CompoundButton; +import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.ImageButton; import android.widget.TextView; +import android.widget.ToggleButton; public class CallFragment extends Fragment implements Callback { @@ -84,6 +87,8 @@ public class CallFragment extends Fragment implements Callback { private TextView callStatusTxt; private TextView codecNameTxt; + + private ToggleButton speakers; private BubblesView view; private BubbleModel model; @@ -246,6 +251,21 @@ public class CallFragment extends Fragment implements Callback { codecNameTxt = (TextView) rootView.findViewById(R.id.codec_name_txt); callStatusTxt = (TextView) rootView.findViewById(R.id.call_status_txt); call_icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_action_call); + + speakers = (ToggleButton) rootView.findViewById(R.id.toggle_speaker); + + speakers.setOnCheckedChangeListener(new OnCheckedChangeListener() { + + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + try { + mCallbacks.getService().toggleSpeakerPhone(isChecked); + } catch (RemoteException e) { + e.printStackTrace(); + } + + } + }); ((ImageButton) rootView.findViewById(R.id.dialpad_btn)).setOnClickListener(new OnClickListener() { @@ -373,7 +393,7 @@ public class CallFragment extends Fragment implements Callback { return contact_bubble; } - contact_bubble = new BubbleUser(getActivity(), CallContact.ContactBuilder.buildUserContact(getActivity().getContentResolver()), conf, x, y, BUBBLE_SIZE); + contact_bubble = new BubbleUser(getActivity(), CallContact.ContactBuilder.buildUserContact(getActivity().getContentResolver()), conf, x, y, BUBBLE_SIZE * 1.3f); try { ((BubbleUser) contact_bubble).setMute(mCallbacks.getService().isCaptureMuted()); diff --git a/src/org/sflphone/receivers/IncomingReceiver.java b/src/org/sflphone/receivers/IncomingReceiver.java index 6c9b8d2b8ef7c2aa9ae4bda052a681e0063ece34..7d41b737cb7edcd78e2a085e10670b7df93c495a 100644 --- a/src/org/sflphone/receivers/IncomingReceiver.java +++ b/src/org/sflphone/receivers/IncomingReceiver.java @@ -21,6 +21,7 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.os.RemoteException; +import android.os.SystemClock; import android.util.Log; public class IncomingReceiver extends BroadcastReceiver { @@ -83,7 +84,13 @@ public class IncomingReceiver extends BroadcastReceiver { SipCall newCall = callBuilder.build(); toSend.putExtra("newcall", newCall); HashMap<String, String> callDetails = (HashMap<String, String>) mBinder.getCallDetails(b.getString("CallID")); - newCall.setTimestamp_start(Long.parseLong(callDetails.get(ServiceConstants.call.TIMESTAMP_START))); + + String stamp = callDetails.get(ServiceConstants.call.TIMESTAMP_START); + + if(stamp.length() > 0) + newCall.setTimestamp_start(Long.parseLong(stamp)); + else + newCall.setTimestamp_start(System.currentTimeMillis() / 1000); callback.getCurrent_calls().put(newCall.getCallId(), newCall); callback.sendBroadcast(toSend); diff --git a/src/org/sflphone/service/ISipService.aidl b/src/org/sflphone/service/ISipService.aidl index 18831411eba0052ce4916cbe7a8b8c08650b5427..c1718d31fefda976d2260ac15b52b0cffdca6b08 100644 --- a/src/org/sflphone/service/ISipService.aidl +++ b/src/org/sflphone/service/ISipService.aidl @@ -33,8 +33,7 @@ interface ISipService { // FIXME - List getAudioInputDeviceList(); - List getAudioOutputDeviceList(); + void toggleSpeakerPhone(in boolean toggle); /* History */ List getHistory(); diff --git a/src/org/sflphone/service/SipService.java b/src/org/sflphone/service/SipService.java index 123759aebde178266fc3491ceb9a2b2c5a31d0ca..107d5b41e412de5ca25f3895473d901c6edf0bc4 100644 --- a/src/org/sflphone/service/SipService.java +++ b/src/org/sflphone/service/SipService.java @@ -51,6 +51,7 @@ import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.media.AudioManager; import android.os.Bundle; import android.os.Handler; import android.os.HandlerThread; @@ -124,8 +125,6 @@ public class SipService extends Service { notificationManager.onServiceCreate(); mediaManager.startService(); - - } @@ -300,7 +299,7 @@ public class SipService extends Service { @Override public void run() { try { - if(isPjSipStackStarted) + if (isPjSipStackStarted) obj = doRun(); done = true; } catch (SameThreadException e) { @@ -378,6 +377,7 @@ public class SipService extends Service { protected void doRun() throws SameThreadException { Log.i(TAG, "SipService.hangUp() thread running..."); callManagerJNI.hangUp(callID); + mediaManager.abandonAudioFocus(); } }); } @@ -592,7 +592,6 @@ public class SipService extends Service { AddAccount runInstance = new AddAccount(swigmap); getExecutor().execute(runInstance); while (!runInstance.isDone()) { - // Log.e(TAG, "Waiting for Nofing"); } String accountId = (String) runInstance.getVal(); @@ -925,10 +924,10 @@ public class SipService extends Service { protected Boolean doRun() throws SameThreadException { Log.i(TAG, "SipService.toggleRecordingCall() thread running..."); boolean result = callManagerJNI.toggleRecording(id); - - if(getCurrent_calls().containsKey(id)){ + + if (getCurrent_calls().containsKey(id)) { getCurrent_calls().get(id).setRecording(result); - } else if(getCurrent_confs().containsKey(id)){ + } else if (getCurrent_confs().containsKey(id)) { getCurrent_confs().get(id).setRecording(result); } else { // A call in a conference has been put on hold @@ -993,9 +992,9 @@ public class SipService extends Service { protected void doRun() throws SameThreadException, RemoteException { Log.i(TAG, "SipService.sendTextMessage() thread running..."); callManagerJNI.sendTextMessage(callID, message.comment); - if(getCurrent_calls().get(callID) != null) + if (getCurrent_calls().get(callID) != null) getCurrent_calls().get(callID).addSipMessage(message); - else if(getCurrent_confs().get(callID) != null) + else if (getCurrent_confs().get(callID) != null) getCurrent_confs().get(callID).addSipMessage(message); } }); @@ -1020,7 +1019,7 @@ public class SipService extends Service { // if (results.get(active_payloads.get(i)) != null) { // results.get(active_payloads.get(i)).setEnabled(true); - + IntVect payloads = configurationManagerJNI.getAudioCodecList(); for (int i = 0; i < payloads.size(); ++i) { @@ -1309,53 +1308,13 @@ public class SipService extends Service { }); } - /** - * Not working yet - */ @Override - public List getAudioInputDeviceList() throws RemoteException { - class AudioInputDevices extends SipRunnableWithReturn { - - @Override - protected List doRun() throws SameThreadException { - Log.i(TAG, "SipService.getCredentials() thread running..."); - StringVect map = configurationManagerJNI.getAudioInputDeviceList(); - ArrayList<HashMap<String, String>> result = new ArrayList<HashMap<String,String>>(); - return result; - } - } - - AudioInputDevices runInstance = new AudioInputDevices(); - getExecutor().execute(runInstance); - while (!runInstance.isDone()) { - } - return (List) runInstance.getVal(); + public void toggleSpeakerPhone(boolean toggle) throws RemoteException { + if (toggle) + mediaManager.RouteToSpeaker(); + else + mediaManager.RouteToInternalSpeaker(); } - /** - * Not working yet - */ - @Override - public List getAudioOutputDeviceList() throws RemoteException { - class AudioOutputDevices extends SipRunnableWithReturn { - - @Override - protected List doRun() throws SameThreadException { - Log.i(TAG, "SipService.getCredentials() thread running..."); - StringVect map = configurationManagerJNI.getAudioOutputDeviceList(); - ArrayList<HashMap<String, String>> result = new ArrayList<HashMap<String,String>>(); - return result; - } - } - - AudioOutputDevices runInstance = new AudioOutputDevices(); - getExecutor().execute(runInstance); - while (!runInstance.isDone()) { - } - return (List) runInstance.getVal(); - } - - - }; -} +} diff --git a/src/org/sflphone/utils/Compatibility.java b/src/org/sflphone/utils/Compatibility.java index 7a4a800d9bd80e4cbf29429f46dedbe5184fafe8..fb3ab00a3bd9398319731998b5ee71f72881cda5 100644 --- a/src/org/sflphone/utils/Compatibility.java +++ b/src/org/sflphone/utils/Compatibility.java @@ -68,15 +68,13 @@ public final class Compatibility { } /** - * Get the stream id for in call track. Can differ on some devices. Current - * device for which it's different : + * Get the stream id for in call track. Can differ on some devices. Current device for which it's different : * * @return */ public static int getInCallStream(boolean requestBluetooth) { /* Archos 5IT */ - if (android.os.Build.BRAND.equalsIgnoreCase("archos") - && android.os.Build.DEVICE.equalsIgnoreCase("g7a")) { + if (android.os.Build.BRAND.equalsIgnoreCase("archos") && android.os.Build.DEVICE.equalsIgnoreCase("g7a")) { // Since archos has no voice call capabilities, voice call stream is // not implemented // So we have to choose the good stream tag, which is by default @@ -92,8 +90,7 @@ public final class Compatibility { } public static boolean shouldUseRoutingApi() { - Log.d(THIS_FILE, "Current device " + android.os.Build.BRAND + " - " - + android.os.Build.DEVICE); + Log.d(THIS_FILE, "Current device " + android.os.Build.BRAND + " - " + android.os.Build.DEVICE); // HTC evo 4G if (android.os.Build.PRODUCT.equalsIgnoreCase("htc_supersonic")) { @@ -121,14 +118,12 @@ public final class Compatibility { public static boolean shouldUseModeApi() { // ZTE blade et joe - if (android.os.Build.DEVICE.equalsIgnoreCase("blade") - || android.os.Build.DEVICE.equalsIgnoreCase("joe")) { + if (android.os.Build.DEVICE.equalsIgnoreCase("blade") || android.os.Build.DEVICE.equalsIgnoreCase("joe")) { return true; } // Samsung GT-S5360 GT-S5830 GT-S6102 ... probably all.. - if (android.os.Build.DEVICE.toUpperCase().startsWith("GT-") || - android.os.Build.PRODUCT.toUpperCase().startsWith("GT-") || - android.os.Build.DEVICE.toUpperCase().startsWith("YP-")) { + if (android.os.Build.DEVICE.toUpperCase().startsWith("GT-") || android.os.Build.PRODUCT.toUpperCase().startsWith("GT-") + || android.os.Build.DEVICE.toUpperCase().startsWith("YP-")) { return true; } @@ -141,8 +136,7 @@ public final class Compatibility { return true; } // LG-E720(b) - if (android.os.Build.MODEL.toUpperCase().startsWith("LG-E720") - && !Compatibility.isCompatible(9)) { + if (android.os.Build.MODEL.toUpperCase().startsWith("LG-E720") && !Compatibility.isCompatible(9)) { return true; } // LG-LS840 @@ -151,11 +145,9 @@ public final class Compatibility { } // Huawei - if (android.os.Build.DEVICE.equalsIgnoreCase("U8150") || - android.os.Build.DEVICE.equalsIgnoreCase("U8110") || - android.os.Build.DEVICE.equalsIgnoreCase("U8120") || - android.os.Build.DEVICE.equalsIgnoreCase("U8100") || - android.os.Build.PRODUCT.equalsIgnoreCase("U8655")) { + if (android.os.Build.DEVICE.equalsIgnoreCase("U8150") || android.os.Build.DEVICE.equalsIgnoreCase("U8110") + || android.os.Build.DEVICE.equalsIgnoreCase("U8120") || android.os.Build.DEVICE.equalsIgnoreCase("U8100") + || android.os.Build.PRODUCT.equalsIgnoreCase("U8655")) { return true; } @@ -210,17 +202,14 @@ public final class Compatibility { return Integer.toString(0x7); } /* - * Too risky in terms of regressions else if (isCompatible(4)) { // - * VOICE_CALL return 0x4; } + * Too risky in terms of regressions else if (isCompatible(4)) { // VOICE_CALL return 0x4; } */ /* - * if(android.os.Build.MODEL.equalsIgnoreCase("X10i")) { // VOICE_CALL - * return Integer.toString(0x4); } + * if(android.os.Build.MODEL.equalsIgnoreCase("X10i")) { // VOICE_CALL return Integer.toString(0x4); } */ /* - * Not relevant anymore, atrix I tested sounds fine with that - * if(android.os.Build.DEVICE.equalsIgnoreCase("olympus")) { //Motorola - * atrix bug // CAMCORDER return Integer.toString(0x5); } + * Not relevant anymore, atrix I tested sounds fine with that if(android.os.Build.DEVICE.equalsIgnoreCase("olympus")) { //Motorola atrix bug + * // CAMCORDER return Integer.toString(0x5); } */ return Integer.toString(AudioSource.DEFAULT); @@ -290,26 +279,18 @@ public final class Compatibility { } // All htc except.... - if (android.os.Build.PRODUCT.toLowerCase().startsWith("htc") - || android.os.Build.BRAND.toLowerCase().startsWith("htc") + if (android.os.Build.PRODUCT.toLowerCase().startsWith("htc") || android.os.Build.BRAND.toLowerCase().startsWith("htc") || android.os.Build.PRODUCT.toLowerCase().equalsIgnoreCase("inc") /* - * For - * Incredible + * For Incredible */ || android.os.Build.DEVICE.equalsIgnoreCase("passion") /* N1 */) { if (android.os.Build.DEVICE.equalsIgnoreCase("hero") /* HTC HERO */ || android.os.Build.DEVICE.equalsIgnoreCase("magic") /* - * Magic - * Aka - * Dev - * G2 + * Magic Aka Dev G2 */ || android.os.Build.DEVICE.equalsIgnoreCase("tatoo") /* Tatoo */ || android.os.Build.DEVICE.equalsIgnoreCase("dream") /* - * Dream - * Aka - * Dev - * G1 + * Dream Aka Dev G1 */ || android.os.Build.DEVICE.equalsIgnoreCase("legend") /* Legend */ @@ -331,16 +312,13 @@ public final class Compatibility { } // Dell streak - if (android.os.Build.BRAND.toLowerCase().startsWith("dell") && - android.os.Build.DEVICE.equalsIgnoreCase("streak")) { + if (android.os.Build.BRAND.toLowerCase().startsWith("dell") && android.os.Build.DEVICE.equalsIgnoreCase("streak")) { return true; } // Motorola milestone 1 and 2 & motorola droid & defy not under 2.3 - if ((android.os.Build.DEVICE.toLowerCase().contains("milestone2") || - android.os.Build.BOARD.toLowerCase().contains("sholes") || - android.os.Build.PRODUCT.toLowerCase().contains("sholes") || - android.os.Build.DEVICE.equalsIgnoreCase("olympus") || - android.os.Build.DEVICE.toLowerCase().contains("umts_jordan")) && !isCompatible(9)) { + if ((android.os.Build.DEVICE.toLowerCase().contains("milestone2") || android.os.Build.BOARD.toLowerCase().contains("sholes") + || android.os.Build.PRODUCT.toLowerCase().contains("sholes") || android.os.Build.DEVICE.equalsIgnoreCase("olympus") || android.os.Build.DEVICE + .toLowerCase().contains("umts_jordan")) && !isCompatible(9)) { return true; } // Moto defy mini @@ -357,9 +335,8 @@ public final class Compatibility { } private static boolean needToneWorkaround() { - if (android.os.Build.PRODUCT.toLowerCase().startsWith("gt-i5800") || - android.os.Build.PRODUCT.toLowerCase().startsWith("gt-i5801") || - android.os.Build.PRODUCT.toLowerCase().startsWith("gt-i9003")) { + if (android.os.Build.PRODUCT.toLowerCase().startsWith("gt-i5800") || android.os.Build.PRODUCT.toLowerCase().startsWith("gt-i5801") + || android.os.Build.PRODUCT.toLowerCase().startsWith("gt-i9003")) { return true; } return false; @@ -369,8 +346,7 @@ public final class Compatibility { if (isCompatible(9)) { return false; } - if (android.os.Build.DEVICE.toUpperCase().startsWith("GT-I9000") || - android.os.Build.DEVICE.toUpperCase().startsWith("GT-P1000")) { + if (android.os.Build.DEVICE.toUpperCase().startsWith("GT-I9000") || android.os.Build.DEVICE.toUpperCase().startsWith("GT-P1000")) { return true; } return false; @@ -395,8 +371,7 @@ public final class Compatibility { public static boolean shouldSetupAudioBeforeInit() { // Setup for GT / GS samsung devices. - if (android.os.Build.DEVICE.toLowerCase().startsWith("gt-") - || android.os.Build.PRODUCT.toLowerCase().startsWith("gt-")) { + if (android.os.Build.DEVICE.toLowerCase().startsWith("gt-") || android.os.Build.PRODUCT.toLowerCase().startsWith("gt-")) { return true; } return false; @@ -404,8 +379,7 @@ public final class Compatibility { private static boolean shouldFocusAudio() { /* HTC One X */ - if (android.os.Build.DEVICE.toLowerCase().startsWith("endeavoru") || - android.os.Build.DEVICE.toLowerCase().startsWith("evita")) { + if (android.os.Build.DEVICE.toLowerCase().startsWith("endeavoru") || android.os.Build.DEVICE.toLowerCase().startsWith("evita")) { return false; } @@ -415,39 +389,34 @@ public final class Compatibility { return true; } -// private static int getDefaultAudioImplementation() { -// // Acer A510 -// if (android.os.Build.DEVICE.toLowerCase().startsWith("picasso")) { -// return SipConfigManager.AUDIO_IMPLEMENTATION_JAVA; -// } -// if (Compatibility.isCompatible(11)) { -// return SipConfigManager.AUDIO_IMPLEMENTATION_OPENSLES; -// } -// if (android.os.Build.DEVICE.equalsIgnoreCase("ST25i") && Compatibility.isCompatible(10)) { -// return SipConfigManager.AUDIO_IMPLEMENTATION_OPENSLES; -// } -// if (android.os.Build.DEVICE.equalsIgnoreCase("u8510") && Compatibility.isCompatible(10)) { -// return SipConfigManager.AUDIO_IMPLEMENTATION_OPENSLES; -// } -// return SipConfigManager.AUDIO_IMPLEMENTATION_JAVA; -// } - - + // private static int getDefaultAudioImplementation() { + // // Acer A510 + // if (android.os.Build.DEVICE.toLowerCase().startsWith("picasso")) { + // return SipConfigManager.AUDIO_IMPLEMENTATION_JAVA; + // } + // if (Compatibility.isCompatible(11)) { + // return SipConfigManager.AUDIO_IMPLEMENTATION_OPENSLES; + // } + // if (android.os.Build.DEVICE.equalsIgnoreCase("ST25i") && Compatibility.isCompatible(10)) { + // return SipConfigManager.AUDIO_IMPLEMENTATION_OPENSLES; + // } + // if (android.os.Build.DEVICE.equalsIgnoreCase("u8510") && Compatibility.isCompatible(10)) { + // return SipConfigManager.AUDIO_IMPLEMENTATION_OPENSLES; + // } + // return SipConfigManager.AUDIO_IMPLEMENTATION_JAVA; + // } public static boolean useFlipAnimation() { - if (android.os.Build.BRAND.equalsIgnoreCase("archos") - && android.os.Build.DEVICE.equalsIgnoreCase("g7a")) { + if (android.os.Build.BRAND.equalsIgnoreCase("archos") && android.os.Build.DEVICE.equalsIgnoreCase("g7a")) { return false; } return true; } - public static Intent getContactPhoneIntent() { Intent intent = new Intent(Intent.ACTION_PICK); /* - * intent.setAction(Intent.ACTION_GET_CONTENT); - * intent.setType(Contacts.Phones.CONTENT_ITEM_TYPE); + * intent.setAction(Intent.ACTION_GET_CONTENT); intent.setType(Contacts.Phones.CONTENT_ITEM_TYPE); */ if (isCompatible(5)) { // Don't use constant to allow backward compat simply @@ -460,7 +429,6 @@ public final class Compatibility { return intent; } - public static boolean isTabletScreen(Context ctxt) { boolean isTablet = false; @@ -499,11 +467,9 @@ public final class Compatibility { PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0); ApplicationInfo ai = pi.applicationInfo; return (ai.flags & 0x00040000 /* - * ApplicationInfo. - * FLAG_EXTERNAL_STORAGE + * ApplicationInfo. FLAG_EXTERNAL_STORAGE */) == 0x00040000 /* - * ApplicationInfo. - * FLAG_EXTERNAL_STORAGE + * ApplicationInfo. FLAG_EXTERNAL_STORAGE */; } catch (NameNotFoundException e) { // ignore diff --git a/src/org/sflphone/utils/MediaManager.java b/src/org/sflphone/utils/MediaManager.java index b637b04639880e722228f5dad7cf1391369c8cb2..d2fb12c737978ef7bdab2015ae3ab666745a793a 100644 --- a/src/org/sflphone/utils/MediaManager.java +++ b/src/org/sflphone/utils/MediaManager.java @@ -8,7 +8,7 @@ import android.media.AudioManager.OnAudioFocusChangeListener; import android.os.Handler; import android.util.Log; -public class MediaManager implements OnAudioFocusChangeListener{ +public class MediaManager implements OnAudioFocusChangeListener { private static final String TAG = MediaManager.class.getSimpleName(); private SipService mService; @@ -41,8 +41,21 @@ public class MediaManager implements OnAudioFocusChangeListener{ @Override public void onAudioFocusChange(int arg0) { - // TODO Stub de la méthode généré automatiquement - + + } + + public void abandonAudioFocus() { + mAudioManager.abandonAudioFocus(this); + if (mAudioManager.isSpeakerphoneOn()) { + mAudioManager.setSpeakerphoneOn(false); + } } + public void RouteToSpeaker() { + mAudioManager.setSpeakerphoneOn(true); + } + + public void RouteToInternalSpeaker() { + mAudioManager.setSpeakerphoneOn(false); + } }