extend wake lock scope to screen to avoid sound system from going to standby
This commit is contained in:
parent
838be51880
commit
d83152c489
6 changed files with 71 additions and 13 deletions
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="org.linphone"
|
package="org.linphone"
|
||||||
android:versionCode="106"
|
android:versionCode="107"
|
||||||
android:versionName="1.06">
|
android:versionName="1.07">
|
||||||
<uses-sdk android:minSdkVersion="3" />
|
<uses-sdk android:minSdkVersion="3" />
|
||||||
<application android:icon="@drawable/linphone2" android:label="@string/app_name" android:debuggable = "true">
|
<application android:icon="@drawable/linphone2" android:label="@string/app_name" android:debuggable = "true">
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -88,6 +88,8 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
||||||
private SharedPreferences mPref;
|
private SharedPreferences mPref;
|
||||||
|
|
||||||
String PREF_CHECK_CONFIG = "pref_check_config";
|
String PREF_CHECK_CONFIG = "pref_check_config";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return null if not ready yet
|
* @return null if not ready yet
|
||||||
|
@ -103,13 +105,15 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
||||||
mAddress.setText(aContact);
|
mAddress.setText(aContact);
|
||||||
mDisplayName = aDisplayName;
|
mDisplayName = aDisplayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.dialer);
|
setContentView(R.layout.dialer);
|
||||||
mAudioManager = ((AudioManager)getSystemService(Context.AUDIO_SERVICE));
|
mAudioManager = ((AudioManager)getSystemService(Context.AUDIO_SERVICE));
|
||||||
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
|
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
|
||||||
mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"Linphone");
|
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK|PowerManager.ON_AFTER_RELEASE,"Linphone");
|
||||||
mPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
mPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
@ -208,23 +212,42 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
||||||
mInCallControlRow = (TableRow) findViewById(R.id.IncallControlRow);
|
mInCallControlRow = (TableRow) findViewById(R.id.IncallControlRow);
|
||||||
mAddressLayout = (LinearLayout) findViewById(R.id.Addresslayout);
|
mAddressLayout = (LinearLayout) findViewById(R.id.Addresslayout);
|
||||||
mInCallAddressLayout = (LinearLayout) findViewById(R.id.IncallAddressLayout);
|
mInCallAddressLayout = (LinearLayout) findViewById(R.id.IncallAddressLayout);
|
||||||
|
mMute = (ToggleButton)findViewById(R.id.mic_mute_button);
|
||||||
|
mSpeaker = (ToggleButton)findViewById(R.id.speaker_button);
|
||||||
|
|
||||||
mInCallControlRow.setVisibility(View.GONE);
|
mInCallControlRow.setVisibility(View.GONE);
|
||||||
mInCallAddressLayout.setVisibility(View.GONE);
|
mInCallAddressLayout.setVisibility(View.GONE);
|
||||||
mDecline.setEnabled(false);
|
mDecline.setEnabled(false);
|
||||||
if (LinphoneService.isready()) {
|
if (LinphoneService.isready()) {
|
||||||
if (LinphoneService.instance().getLinphoneCore().isIncall()) {
|
LinphoneCore lLinphoenCore = LinphoneService.instance().getLinphoneCore();
|
||||||
|
if (lLinphoenCore.isIncall()) {
|
||||||
mCall.setEnabled(false);
|
mCall.setEnabled(false);
|
||||||
mHangup.setEnabled(!mCall.isEnabled());
|
mHangup.setEnabled(!mCall.isEnabled());
|
||||||
mCallControlRow.setVisibility(View.GONE);
|
mCallControlRow.setVisibility(View.GONE);
|
||||||
mInCallControlRow.setVisibility(View.VISIBLE);
|
mInCallControlRow.setVisibility(View.VISIBLE);
|
||||||
mAddressLayout.setVisibility(View.GONE);
|
mAddressLayout.setVisibility(View.GONE);
|
||||||
mInCallAddressLayout.setVisibility(View.VISIBLE);
|
mInCallAddressLayout.setVisibility(View.VISIBLE);
|
||||||
|
mMute.setChecked(!lLinphoenCore.isMicMuted());
|
||||||
|
mMute.setCompoundDrawablesWithIntrinsicBounds(0
|
||||||
|
, mMute.isChecked()?R.drawable.mic_active:R.drawable.mic_muted
|
||||||
|
, 0
|
||||||
|
, 0);
|
||||||
|
String DisplayName = lLinphoenCore.getRemoteAddress().getDisplayName();
|
||||||
|
if (DisplayName!=null) {
|
||||||
|
mDisplayNameView.setText(DisplayName);
|
||||||
|
} else {
|
||||||
|
mDisplayNameView.setText(lLinphoenCore.getRemoteAddress().getUserName());
|
||||||
|
}
|
||||||
|
if ((Integer.parseInt(Build.VERSION.SDK) <=4 && mAudioManager.getMode() == AudioManager.MODE_NORMAL)
|
||||||
|
|| Integer.parseInt(Build.VERSION.SDK) >4 &&mAudioManager.isSpeakerphoneOn()) {
|
||||||
|
mSpeaker.setChecked(true);
|
||||||
|
}
|
||||||
|
mWakeLock.acquire();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
mMute = (ToggleButton)findViewById(R.id.mic_mute_button);
|
|
||||||
mMute.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
mMute.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
@ -241,7 +264,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
mSpeaker = (ToggleButton)findViewById(R.id.speaker_button);
|
|
||||||
mSpeaker.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
mSpeaker.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
@ -306,6 +329,12 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
super.onDestroy();
|
||||||
|
if (mWakeLock.isHeld()) mWakeLock.release();
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
@ -368,6 +397,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GSTATE_CALL_OUT_INVITE: {
|
case GSTATE_CALL_OUT_INVITE: {
|
||||||
|
mWakeLock.acquire();
|
||||||
enterIncalMode(lc);
|
enterIncalMode(lc);
|
||||||
routeAudioToReceiver();
|
routeAudioToReceiver();
|
||||||
break;
|
break;
|
||||||
|
@ -383,6 +413,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GSTATE_CALL_ERROR: {
|
case GSTATE_CALL_ERROR: {
|
||||||
|
if (mWakeLock.isHeld()) mWakeLock.release();
|
||||||
Toast toast = Toast.makeText(this
|
Toast toast = Toast.makeText(this
|
||||||
,String.format(getString(R.string.call_error),lc.getRemoteAddress())
|
,String.format(getString(R.string.call_error),lc.getRemoteAddress())
|
||||||
, Toast.LENGTH_LONG);
|
, Toast.LENGTH_LONG);
|
||||||
|
@ -404,7 +435,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enterIncalMode(LinphoneCore lc) {
|
private void enterIncalMode(LinphoneCore lc) {
|
||||||
mWakeLock.acquire();
|
|
||||||
mCallControlRow.setVisibility(View.GONE);
|
mCallControlRow.setVisibility(View.GONE);
|
||||||
mInCallControlRow.setVisibility(View.VISIBLE);
|
mInCallControlRow.setVisibility(View.VISIBLE);
|
||||||
mAddressLayout.setVisibility(View.GONE);
|
mAddressLayout.setVisibility(View.GONE);
|
||||||
|
@ -435,7 +466,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
||||||
mMute.setChecked(true);
|
mMute.setChecked(true);
|
||||||
mSpeaker.setChecked(false);
|
mSpeaker.setChecked(false);
|
||||||
mDecline.setEnabled(false);
|
mDecline.setEnabled(false);
|
||||||
mWakeLock.release();
|
if (mWakeLock.isHeld())mWakeLock.release();
|
||||||
}
|
}
|
||||||
private void routeAudioToSpeaker() {
|
private void routeAudioToSpeaker() {
|
||||||
if (Integer.parseInt(Build.VERSION.SDK) <= 4 /*<donut*/) {
|
if (Integer.parseInt(Build.VERSION.SDK) <= 4 /*<donut*/) {
|
||||||
|
|
|
@ -48,6 +48,8 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
|
||||||
private static LinphoneActivity theLinphoneActivity;
|
private static LinphoneActivity theLinphoneActivity;
|
||||||
private SensorManager mSensorManager;
|
private SensorManager mSensorManager;
|
||||||
private FrameLayout mMainFrame;
|
private FrameLayout mMainFrame;
|
||||||
|
|
||||||
|
private static String SCREEN_IS_HIDDEN ="screen_is_hidden";
|
||||||
protected static LinphoneActivity instance()
|
protected static LinphoneActivity instance()
|
||||||
{
|
{
|
||||||
if (theLinphoneActivity == null) {
|
if (theLinphoneActivity == null) {
|
||||||
|
@ -56,10 +58,18 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
|
||||||
return theLinphoneActivity;
|
return theLinphoneActivity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
protected void onSaveInstanceState (Bundle outState) {
|
||||||
|
if (mMainFrame.getVisibility() == View.INVISIBLE) {
|
||||||
|
outState.putBoolean(SCREEN_IS_HIDDEN, true);
|
||||||
|
} else {
|
||||||
|
outState.putBoolean(SCREEN_IS_HIDDEN, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
|
|
||||||
theLinphoneActivity = this;
|
theLinphoneActivity = this;
|
||||||
// start linphone as background
|
// start linphone as background
|
||||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||||
|
@ -105,7 +115,9 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
|
||||||
lTabHost.addTab(spec);
|
lTabHost.addTab(spec);
|
||||||
|
|
||||||
lTabHost.setCurrentTabByTag("dialer");
|
lTabHost.setCurrentTabByTag("dialer");
|
||||||
|
if (savedInstanceState !=null && savedInstanceState.getBoolean(SCREEN_IS_HIDDEN,false)) {
|
||||||
|
hideScreen(true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,15 +222,21 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
|
||||||
public void onSensorChanged(SensorEvent event) {
|
public void onSensorChanged(SensorEvent event) {
|
||||||
if (LinphoneService.isready() == false) return; //nop nothing to do
|
if (LinphoneService.isready() == false) return; //nop nothing to do
|
||||||
|
|
||||||
WindowManager.LayoutParams lAttrs =getWindow().getAttributes();
|
|
||||||
if (LinphoneService.instance().getLinphoneCore().isIncall() && event.values[0] == 0) {
|
if (LinphoneService.instance().getLinphoneCore().isIncall() && event.values[0] == 0) {
|
||||||
|
hideScreen(true);
|
||||||
|
} else if (mMainFrame.getVisibility() != View.VISIBLE && event.values[0] == 1) {
|
||||||
|
hideScreen(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void hideScreen(boolean isHidden) {
|
||||||
|
WindowManager.LayoutParams lAttrs =getWindow().getAttributes();
|
||||||
|
if (isHidden) {
|
||||||
lAttrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
lAttrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
||||||
mMainFrame.setVisibility(View.INVISIBLE);
|
mMainFrame.setVisibility(View.INVISIBLE);
|
||||||
} else if (mMainFrame.getVisibility() != View.VISIBLE && event.values[0] == 1) {
|
} else {
|
||||||
lAttrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
lAttrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
mMainFrame.setVisibility(View.VISIBLE);
|
mMainFrame.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
getWindow().setAttributes(lAttrs);
|
getWindow().setAttributes(lAttrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,6 +153,11 @@ public interface LinphoneCore {
|
||||||
* @param isMuted
|
* @param isMuted
|
||||||
*/
|
*/
|
||||||
public void muteMic(boolean isMuted);
|
public void muteMic(boolean isMuted);
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return true is mic is muted
|
||||||
|
*/
|
||||||
|
public boolean isMicMuted();
|
||||||
/**
|
/**
|
||||||
* Build an address according to the current proxy config. In case destination is not a sip uri, the default proxy domain is automatically appended
|
* Build an address according to the current proxy config. In case destination is not a sip uri, the default proxy domain is automatically appended
|
||||||
* @param destination
|
* @param destination
|
||||||
|
|
|
@ -56,6 +56,7 @@ class LinphoneCoreImpl implements LinphoneCore {
|
||||||
private native void inviteAddress(long nativePtr,long to);
|
private native void inviteAddress(long nativePtr,long to);
|
||||||
private native void sendDtmf(long nativePtr,char dtmf);
|
private native void sendDtmf(long nativePtr,char dtmf);
|
||||||
private native void clearCallLogs(long nativePtr);
|
private native void clearCallLogs(long nativePtr);
|
||||||
|
private native boolean isMicMuted(long nativePtr);
|
||||||
|
|
||||||
|
|
||||||
LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException {
|
LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException {
|
||||||
|
@ -190,4 +191,7 @@ class LinphoneCoreImpl implements LinphoneCore {
|
||||||
public void clearCallLogs() {
|
public void clearCallLogs() {
|
||||||
clearCallLogs(nativePtr);
|
clearCallLogs(nativePtr);
|
||||||
}
|
}
|
||||||
|
public boolean isMicMuted() {
|
||||||
|
return isMicMuted(nativePtr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue