Chromecast SDK Disconnects Connected Bluetooth Device - android

I've implemented an app that streams audio and video. The app also has chromecast support. Here's my issue: If I'm streaming audio to a connected bluetooth device, then I browse to an activity that attempts to discover chromecast devices, the bluetooth connection gets into a bad state (playback switches back to my device but the bluetooth connection says the bluetooth device is still connected). If I comment out the code that does chromecast device discovery, the bluetooth connection is fine. Here's the line of code that, when uncommented, causes the connect to terminate:
mMediaRouter.addCallback(mMediaRouteSelector, mMediaRouterCallback,
MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY);
Here's what I'm seeing in the logs:
10-29 18:30:31.098 843-10255/? D/NetlinkSocketObserver﹕ NeighborEvent{elapsedMs=1128444524, 10.0.0.1, [CCA4620B2A21], RTM_NEWNEIGH, NUD_REACHABLE}
10-29 18:30:31.429 843-1680/? W/ActivityManager﹕ Permission Denial: Accessing service ComponentInfo{com.google.android.music/com.google.android.music.dial.DialMediaRouteProviderService} from pid=12704, uid=10386 that is not exported from uid 10060
10-29 18:30:31.436 1805-1805/? I/Keyboard.Facilitator﹕ onFinishInput()
10-29 18:30:31.450 198-14249/? I/bt_a2dp_hw﹕ out_set_parameters: state 1
10-29 18:30:31.450 198-14249/? I/str_params﹕ key: 'routing' value: '128'
10-29 18:30:31.450 198-14249/? I/str_params﹕ key: 'a2dp_sink_address' value: 'BC:85:56:38:15:B2'
10-29 18:30:31.459 12704-13205/com.testapp.android W/AudioTrack﹕ dead IAudioTrack, PCM, creating a new one from obtainBuffer()
10-29 18:30:31.470 198-835/? D/audio_hw_primary﹕ out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
10-29 18:30:31.480 198-834/? D/audio_hw_primary﹕ select_devices: out_snd_device(2: speaker) in_snd_device(0: none)
10-29 18:30:31.480 198-834/? D/msm8974_platform﹕ platform_send_audio_calibration: sending audio calibration for snd_device(2) acdb_id(15)
10-29 18:30:31.480 198-834/? D/audio_hw_primary﹕ enable_snd_device: snd_device(2: speaker)
10-29 18:30:31.483 198-834/? D/audio_hw_primary﹕ enable_audio_route: apply and update mixer path: low-latency-playback
10-29 18:30:31.535 843-1911/? W/AudioTrack﹕ dead IAudioTrack, PCM, creating a new one from processAudioBuffer()
10-29 18:30:31.565 198-835/? D/audio_hw_primary﹕ out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
10-29 18:30:31.961 14798-14798/? D/ChimeraCfgMgr﹕ Loading module com.google.android.gms.cast from APK com.google.android.gms
10-29 18:30:31.966 14798-14340/? D/MdnsClient﹕ Multicast lock held. Releasing
10-29 18:30:31.967 14798-14340/? D/MdnsClient﹕ #acquireLock. Multicast lock not held. Acquiring
10-29 18:30:33.424 12704-13190/com.testapp.android D/com.testapp.android.sqlite.LocalPlaybackPositionTableHelper﹕ - updated playback position to 23
10-29 18:30:34.530 198-14249/? I/bt_a2dp_hw﹕ suspend_audio_datapath: state 1
10-29 18:30:34.533 14175-14200/? E/bt_btif﹕ bta_av_str_stopped:audio_open_cnt=1, p_data ab20aea4
10-29 18:30:34.533 14175-14200/? W/bt_btif﹕ bta_dm_rm_cback:2, status:6
10-29 18:30:34.576 14175-14200/? W/bt_btif﹕ bta_dm_rm_cback:2, status:6
10-29 18:30:34.584 198-14249/? I/bt_a2dp_hw﹕ skt_disconnect: fd 25
10-29 18:30:34.584 14175-14214/? E/bt_btif﹕ warning : no command pending, ignore ack
10-29 18:30:34.584 14175-14214/? W/bt_btif﹕ pcm bytes per tick 3528
10-29 18:30:34.584 14175-14193/? I/BluetoothA2dpServiceJni﹕ bta2dp_audio_state_callback
10-29 18:30:34.585 14175-14213/? D/A2dpStateMachine﹕ Connected process message: 101
10-29 18:30:34.585 14175-14213/? D/A2dpStateMachine﹕ A2DP Playing state : device: BC:85:56:38:15:B2 State:10->11
I'm testing on a Nexus 5 running Android 6.0. Any ideas? Thanks in advance!

UPDATE: So after a bunch of tests I found out that I was erroneously doing the following if no media route was selected:
mMediaRouter.selectRoute(mMediaRouter.getDefaultRoute());
This was causing the bluetooth connection to be lost.

Related

ACTION_VOICE_COMMAND doesn't do anything

I'm using this code snippet to activate voice command on android.
Intent newIntent = new Intent(Intent.ACTION_VOICE_COMMAND);
newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplicationContext().sendBroadcast(newIntent);
it doesn't do anything, not even an error in my log cat:
06-03 13:26:24.325 203-822/? D/audio_hw_primary: out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
06-03 13:26:24.335 203-822/? D/audio_hw_primary: select_devices: out_snd_device(2: speaker) in_snd_device(0: none)
06-03 13:26:24.335 203-822/? D/msm8974_platform: platform_send_audio_calibration: sending audio calibration for snd_device(2) acdb_id(15)
06-03 13:26:24.335 203-822/? D/audio_hw_primary: enable_snd_device: snd_device(2: speaker)
06-03 13:26:24.338 203-822/? D/audio_hw_primary: enable_audio_route: apply and update mixer path: low-latency-playback
--------- beginning of system
06-03 13:26:26.277 786-892/? D/ConnectivityService: notifyType CAP_CHANGED for NetworkAgentInfo [WIFI () - 100]
06-03 13:26:27.551 203-822/? D/audio_hw_primary: disable_audio_route: reset and update mixer path: low-latency-playback
disable_snd_device: snd_device(2: speaker)
when I run this in ADB, it brings the google assistant up:
adb shell am start -a android.intent.action.VOICE_COMMAND
which is weird, it's technically the very same thing.
is there permission i'm missing or something?
From Docs
Activity Action: Start Voice Command.
So to bring up the voice command assistant activity, Use startActivityas
getApplicationContext().startActivity(newIntent);
instead of
getApplicationContext().sendBroadcast(newIntent);
like
Intent newIntent = new Intent(Intent.ACTION_VOICE_COMMAND);
newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplicationContext().startActivity(newIntent);
// ^^^^^^^^^^^^
is there a way for the UI not to come up and cover my UI? or at least
for google assistant to go away after it listened and acted on my
voice command?
You can use Google Assistant Service sdk and here is the android quick start guide

Finding the source of ConnectionResult{statusCode=INTERNAL_ERROR, resolution=null, message=null}

I'm currently running into a problem where the code
googleApiClient = new GoogleApiClient.Builder(activity, this,this)
.addApi(Games.API).addScope(Games.SCOPE_GAMES)
.build();
works just fine, but
googleApiClient = new GoogleApiClient.Builder(activity, this,this)
.addApi(Drive.API)
.build();
doesn't want to connect, only returning
ConnectionResult{statusCode=INTERNAL_ERROR, resolution=null, message=null}
There seems to be a lot of questions on this, but most of them only adress a specific scenario. So far it seems like my scenario would be unique, and therefore off-topic on this site. My product name is set in the developer console, the package matches and the signature is correct. The required apis are enabled, and no suggestion given in any topic seems to help out. It seems like only time, trial and error will solve this problem in my case.
Now the question arises however, how does one debug this problem? It seems to be such a common problem without a common resolution, so what steps would one take to find out how to resolve the problem?
Edit:
To get a bit more specific on this scenario, it seems like the problem lies somewhere with the com.google.android.gms service. That one crashes every time. Below this is the logcat of the following code:
new AsyncTask<Void,Void,Void>() {
#Override
protected Void doInBackground(Void... voids) {
Log.d("Snapshot", "3");
googleApiClient.blockingConnect();
Log.d("Snapshot", "4");
return null;
}
}.execute();
The errors in this logcat are consistent and occur every time, Of course with varying timestamps and process ID's, and some of this is probably unrelated to the issue, but to me it's near impossible to filter this out.
07-03 16:05:52.025 23176-24251/nl.dvandenberg.energymonitor D/Snapshot: 3
--------- beginning of system
07-03 16:05:52.026 891-6829/? W/AppOps: Bad call: specified package com.google.android.gms under uid 10252 but it is really 10010
07-03 16:05:52.043 335-1227/? D/AudioPolicyManager: startOutput()--
07-03 16:05:52.043 335-1227/? I/AudioFlinger: vl# new track,stream:1,masterVolume:1.000000,typeVolume:0.501188,vlf:0.501160,vrf:0.501160
07-03 16:05:52.046 335-987/? D/audio_hw_primary: start_output_stream: enter: stream(0xb59a3640)usecase(1: low-latency-playback) devices(0x2)
07-03 16:05:52.046 335-987/? D/audio_hw_primary: select_devices: out_snd_device(2: speaker) in_snd_device(0: )
07-03 16:05:52.046 335-987/? D/hardware_info: hw_info_append_hw_type : device_name = speaker
07-03 16:05:52.046 335-987/? D/ACDB-LOADER: ACDB -> send_audio_cal, acdb_id = 15, path = 0
07-03 16:05:52.051 335-987/? E/msm8974_platform: wdd add mixer_path low-latency-playback i2s prop_value 15055
07-03 16:05:52.052 335-987/? D/audio_hw_primary: select_devices: done
07-03 16:05:52.175 891-1864/? D/ConnectivityService: listenForNetwork for NetworkRequest [ id=3904, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
07-03 16:05:52.175 891-1245/? D/ConnectivityService: handleRegisterNetworkRequest checking NetworkAgentInfo [WIFI () - 382]
07-03 16:05:52.175 891-1245/? D/ConnectivityService: apparently satisfied. currentScore=60
07-03 16:05:52.176 891-1245/? D/ConnectivityService: sending notification AVAILABLE for NetworkRequest [ id=3904, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
07-03 16:05:52.177 26026-26135/? D/ConnectivityManager.CallbackHandler: CM callback handler got msg 524290
07-03 16:05:52.311 26026-26136/? W/DriveInitializer: Background init thread started
07-03 16:05:52.331 26141-26141/? D/StatusBar.MSimNetworkController: refreshViews phoneId =0mMSimDataConnected =false
07-03 16:05:52.331 26141-26141/? D/StatusBar.MSimNetworkController: refreshViews mMSimDataActivity =0
07-03 16:05:52.334 26141-26141/? D/StatusBar.MSimNetworkController: refreshViews: Data not connected!! Set no data type icon / Roaming for phoneId: 0
07-03 16:05:52.335 335-985/? D/AudioPolicyManager: stopOutput() output 4, stream 1, session 785
07-03 16:05:52.335 335-985/? D/AudioPolicyManager: stopOutput()--
07-03 16:05:52.360 26026-26137/? I/DynamiteModule: Considering local module com.google.android.gms.googlecertificates:1 and remote module com.google.android.gms.googlecertificates:1
07-03 16:05:52.360 26026-26137/? I/DynamiteModule: Selected remote version of com.google.android.gms.googlecertificates, version >= 1
07-03 16:05:52.391 26026-26137/? D/ChimeraFileApk: Primary ABI of requesting process is armeabi-v7a
07-03 16:05:52.393 26026-26137/? D/ChimeraFileApk: Classloading successful. Optimized code found.
07-03 16:05:52.393 26026-26137/? I/asset: Success to oxygen resources /system/framework/oxygen-framework-res.apk
07-03 16:05:52.398 26026-26137/? D/GoogleCertificates: com.google.android.gms.googlecertificates module is loaded
07-03 16:05:52.455 26026-26139/? I/GCore-Chimera-Crash: Cg0KB3ZJbmZyYTQQor84Gl8KHWNvbS5nb29nbGUuYW5kcm9pZC
5wbGF5LmdhbWVzEhQzLjcuMjMgKDI4Njc2MzctMDM4KRjWq-AR
IiMKHGNvbS5nb29nbGUuYW5kcm9pZC5nbXMuZ2FtZXMQsKvgEQ
==
GCore-Chimera-Crash
--------- beginning of crash
07-03 16:05:52.458 26026-26139/? E/AndroidRuntime: FATAL EXCEPTION: highpool[0]
Process: com.google.android.gms, PID: 26026
java.lang.NullPointerException: Attempt to read from field 'kau jwg.a' on a null object reference
at jzf.a(:com.google.android.gms:336)
at kip.a(:com.google.android.gms:11149)
at kip.b(:com.google.android.gms:415)
at kiq.run(:com.google.android.gms:1054)
at loq.run(:com.google.android.gms:53)
at itt.run(:com.google.android.gms:453)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at iyg.run(:com.google.android.gms:17)
at java.lang.Thread.run(Thread.java:818)
07-03 16:05:52.460 26026-26139/? E/AndroidRuntime: Error reporting crash
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
at android.os.Handler.<init>(Handler.java:200)
at android.os.Handler.<init>(Handler.java:114)
at android.content.AsyncQueryHandler.<init>(AsyncQueryHandler.java:125)
at net.oneplus.odm.insight.tracker.AbstractTracker$TrackerAsyncQueryHandler.<init>(AbstractTracker.java:110)
at net.oneplus.odm.insight.tracker.AbstractTracker.<init>(AbstractTracker.java:60)
at net.oneplus.odm.insight.tracker.AppTracker.<init>(AppTracker.java:24)
at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:99)
at icd.uncaughtException(:com.google.android.gms:54)
at ibx.uncaughtException(:com.google.android.gms:62)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
07-03 16:05:52.463 26026-26139/? I/Process: Sending signal. PID: 26026 SIG: 9
07-03 16:05:52.489 891-3957/? I/ActivityManager: Process com.google.android.gms (pid 26026) has died
07-03 16:05:52.489 891-5403/? E/WifiService: Multicaster binderDied
07-03 16:05:52.489 891-1250/? D/ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ id=3904, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ], android.os.BinderProxy#d4be6da)
07-03 16:05:52.490 891-1245/? D/ConnectivityService: releasing NetworkRequest NetworkRequest [ id=3904, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
07-03 16:05:52.490 891-1245/? D/ConnectivityService: sending notification RELEASED for NetworkRequest [ id=3904, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
07-03 16:05:52.491 891-1245/? E/ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ id=3904, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
07-03 16:05:52.492 19485-19485/? V/GAV3: Thread[main,5,main]: service disconnected: ComponentInfo{com.google.android.gms/com.google.android.gms.analytics.service.AnalyticsService}
07-03 16:05:52.492 19485-19485/? V/GAV3: Thread[main,5,main]: Unexpected disconnect.
07-03 16:05:52.493 19485-19485/? V/GAV3: Thread[main,5,main]: service disconnected: ComponentInfo{com.google.android.gms/com.google.android.gms.analytics.service.AnalyticsService}
07-03 16:05:52.493 19485-19485/? V/GAV3: Thread[main,5,main]: Unexpected disconnect.
07-03 16:05:52.496 891-3957/? W/ActivityManager: Scheduling restart of crashed service com.google.android.gms/com.google.android.location.places.service.GeoDataService in 1000ms
07-03 16:05:52.496 891-3957/? W/ActivityManager: Scheduling restart of crashed service com.google.android.gms/.drive.api.ApiService in 11000ms
07-03 16:05:52.496 891-3957/? W/ActivityManager: Scheduling restart of crashed service com.google.android.gms/.analytics.service.AnalyticsService in 21000ms
07-03 16:05:52.497 891-3957/? W/ActivityManager: Scheduling restart of crashed service com.google.android.gms/.signin.service.SignInAsyncService in 31000ms
07-03 16:05:52.497 891-3957/? W/ActivityManager: Scheduling restart of crashed service com.google.android.gms/.measurement.service.MeasurementBrokerService in 31000ms
07-03 16:05:52.497 891-3957/? W/ActivityManager: Scheduling restart of crashed service com.google.android.gms/.signin.service.SignInBrokerService in 41000ms
07-03 16:05:52.497 891-3957/? W/ActivityManager: Scheduling restart of crashed service com.google.android.gms/.cast.media.CastMediaRouteProviderService in 51000ms
07-03 16:05:52.508 23176-23176/nl.dvandenberg.energymonitor D/Snapshot: Connection failed: ConnectionResult{statusCode=INTERNAL_ERROR, resolution=null, message=null}
07-03 16:05:52.513 23176-23176/nl.dvandenberg.energymonitor I/AppCompatDelegate: The Activity's LayoutInflater already has a Factory installed so we can not install AppCompat's
07-03 16:05:52.529 891-5403/? V/WindowManager: not Base app: Adding window Window{3ad0e9e8 u0 nl.dvandenberg.energymonitor/nl.dvandenberg.energymonitor.SplashActivity} at 23 of 29
07-03 16:05:52.540 23176-24251/nl.dvandenberg.energymonitor D/Snapshot: 4
Edit 2:
I have managed to solve my own problem, by adding .addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN) to the builder. I've got no idea as to why this works or is needed, but as long as it works I'll take it.
I'm not posting this as an answer, as in this question I'd like to focus on how to find the source of this issue, not on making a list of possible solutions.

Using bluetooth create_bond_out_of_band()

I need to force an Android phone to use oob data for pairing. That means I want the Android phone to have the "OOB Data Flag" being set, when the phone sends a Pairing Request to a device.
What I've tried so far: I've identified platform/system/bt to be the current (6.0.1) Android Bluetooth implementation and platform/packages/apps/Bluetooth being a Java wrapper around BT.
platform/system/bt exposes it's interface through a bt_interface_t structure. That structure contains a function named create_bond_out_of_bandthat should do what I need. Unfortunately, that function is not exposed by the Java Wrapper.
First I've tried to use the JNI function const bt_interface_t* android::getBluetoothInterface() from libbluetooth_jni.so. I managed to lookup that function during runtime, but when I call it, it returns 0. At that point, the app used already a lot of the bluetooth API.
This led me to the conclusion, that either, the shared object was loaded a second time, or that the bluetooth library is not part of my application, but somehow implemented in a different process.
Second, I've tried to use the Android libhardware API. I've managed to get the BT module, a BT device and finally call the create_bond_out_of_band() from the bt_interface_t. The function returns 0, which indicates success, but no Pairing Request is send out. I see following messages in the logs:
02-02 15:24:38.083 5791-5824/? E/bt_btif: btif_hh_virtual_unplug: Error, device C4:BE:84:BA:DA:0B not opened.
02-02 15:24:38.083 5791-5791/? E/Gatt: createBondOutOfBand: create_bond_out_of_band(0)
02-02 15:24:38.086 490-2881/? D/audio_hw_primary: out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
02-02 15:24:38.101 490-2881/? D/audio_hw_primary: select_devices: out_snd_device(2: speaker) in_snd_device(0: none)
02-02 15:24:38.101 490-2881/? D/msm8974_platform: platform_send_audio_calibration: sending audio calibration for snd_device(2) acdb_id(101)
02-02 15:24:38.101 490-2881/? I/soundtrigger: audio_extn_sound_trigger_update_device_status: device 0x2 of type 0 for Event 1
02-02 15:24:38.108 490-2881/? D/msm8974_platform: platform_send_audio_calibration: sending audio calibration for snd_device(69) acdb_id(102)
02-02 15:24:38.108 490-2881/? D/audio_hw_primary: enable_snd_device: snd_device(69: vi-feedback)
02-02 15:24:38.108 490-2881/? D/audio_hw_primary: enable_audio_route: apply and update mixer path: spkr-vi-record
02-02 15:24:38.132 490-2881/? D/msm8974_platform: platform_send_audio_calibration: sending audio calibration for snd_device(27) acdb_id(4)
02-02 15:24:38.132 490-2881/? I/ACDB-LOADER: ACDB AFE returned = -19
02-02 15:24:38.133 490-2881/? D/audio_hw_primary: enable_audio_route: apply and update mixer path: low-latency-playback
02-02 15:24:38.672 490-2881/? D/audio_hw_primary: disable_audio_route: reset and update mixer path: low-latency-playback
02-02 15:24:38.674 490-2881/? D/audio_hw_primary: disable_snd_device: snd_device(2: speaker)
02-02 15:24:38.690 600-600/? E/QCALOG: [MessageQ] ProcessNewMessage: [LOWI-SERVER] unknown deliver target [OS-Agent]
02-02 15:24:38.693 490-2881/? D/audio_hw_primary: disable_snd_device: snd_device(69: vi-feedback)
02-02 15:24:38.693 490-2881/? D/audio_hw_primary: disable_audio_route: reset and update mixer path: spkr-vi-record
02-02 15:24:38.696 490-2881/? I/soundtrigger: audio_extn_sound_trigger_update_device_status: device 0x2 of type 0 for Event 0
C4:BE:84:BA:DA:0B is the device, I try to pair with.
Any ideas? How I can archive my goal or at least some pointers to where an active Android community can be found?
Thanks in advance,
Torsten

Phonegap on Samsung S4 Errors - Canvas not working well

My app is working well on other phones without errors.
I recently tested my app on an actual Samsung S4 and all of my canvas drawings are messed up. Some times they draw and sometimes they don't, it seems completely random. No errors are thrown regarding the canvas draw commands. I am not using any transitions.
After reading many posts I disabled hardware acceleration by using
super.appView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
And I also used the following to ensure the viewport wouldn't be skewed due to the higher resolution
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, target-densitydpi=medium-dpi, user-scalable=0" />
Now when I run the app I do see some strange errors that are not seen when testing on other phones. I searched the net but didn't learn too much about them.
E/SELinux(23616): selinux_android_seapp_context_reload: seapp_contexts file is loaded from /seapp_contexts
E/ViewRootImpl(23616): sendUserActionEvent() mView == null
E/SpannableStringBuilder(23616): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
E/SpannableStringBuilder(23616): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
I have no idea what these errors mean. sendUserActionEvent? I am not sending any action events. SPAN_EXCLUSIVE_EXCLUSIVE? I do not have any spans...
Are there any other tips on getting Phonegap to run well on the S4???
Here is my full log
10-29 19:11:22.189:
E/SELinux(23616): selinux_android_seapp_context_reload: seapp_contexts file is loaded from /seapp_contexts
10-29 19:11:22.189: D/dalvikvm(23616): Late-enabling CheckJNI
10-29 19:11:22.279: D/CordovaActivity(23616): Setting integer properties in CordovaActivity will be deprecated in 3.0 on July 2013, please use config.xml
10-29 19:11:22.289: I/CordovaLog(23616): Changing log level to DEBUG(3)
10-29 19:11:22.289: D/CordovaActivity(23616): CordovaActivity.onCreate()
10-29 19:11:22.289: D/CordovaActivity(23616): Setting integer properties in CordovaActivity will be deprecated in 3.0 on July 2013, please use config.xml
10-29 19:11:22.349: I/webclipboard(23616): clipservice: android.sec.clipboard.ClipboardExManager#422752e8
10-29 19:11:22.379: D/CordovaWebView(23616): CordovaWebView is running on device made by: samsung
10-29 19:11:22.389: D/JsMessageQueue(23616): Set native->JS mode to 2
10-29 19:11:22.389: D/CordovaActivity(23616): CordovaActivity.init()
10-29 19:11:22.409: V/webkit(23616): BrowserFrame constructor: this=Handler (android.webkit.BrowserFrame) {4226f018}
10-29 19:11:22.459: D/dalvikvm(23616): GC_FOR_ALLOC freed 325K, 8% free 18099K/19532K, paused 25ms, total 25ms
10-29 19:11:22.459: I/dalvikvm-heap(23616): Grow heap (frag case) to 21.387MB for 2764816-byte allocation
10-29 19:11:22.479: D/dalvikvm(23616): GC_FOR_ALLOC freed 3K, 7% free 20796K/22236K, paused 13ms, total 13ms
10-29 19:11:22.489: D/dalvikvm(23616): GC_CONCURRENT freed 1K, 7% free 20807K/22236K, paused 3ms+2ms, total 17ms
10-29 19:11:22.499: D/CordovaWebView(23616): loadUrlIntoView(file:///android_asset/www/splash.html, 10000)
10-29 19:11:22.499: D/CordovaActivity(23616): onMessage(splashscreen,show)
10-29 19:11:22.499: D/CordovaWebView(23616): >>> loadUrl(file:///android_asset/www/splash.html)
10-29 19:11:22.499: D/PluginManager(23616): init()
10-29 19:11:22.509: D/CordovaWebView(23616): >>> loadUrlNow()
10-29 19:11:22.509: D/WebView(23616): loadUrlImpl: called
10-29 19:11:22.509: D/webcore(23616): CORE loadUrl: called
10-29 19:11:22.509: D/webkit(23616): Firewall not null
10-29 19:11:22.509: D/webkit(23616): euler: isUrlBlocked = false
10-29 19:11:22.509: I/CordovaLog(23616): Found start page location: splash.html
10-29 19:11:22.509: I/CordovaLog(23616): Changing log level to DEBUG(3)
10-29 19:11:22.509: D/CordovaActivity(23616): Resuming the App
10-29 19:11:22.509: D/CordovaActivity(23616): CB-3064: The errorUrl is null
10-29 19:11:22.549: D/libEGL(23616): loaded /system/lib/egl/libEGL_adreno200.so
10-29 19:11:22.549: D/libEGL(23616): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
10-29 19:11:22.549: D/libEGL(23616): loaded /system/lib/egl/libGLESv2_adreno200.so
10-29 19:11:22.549: I/Adreno200-EGL(23616): <qeglDrvAPI_eglInitialize:265>: EGL 1.4 QUALCOMM build: (CL3579225)
10-29 19:11:22.549: I/Adreno200-EGL(23616): Build Date: 04/22/13 Mon
10-29 19:11:22.549: I/Adreno200-EGL(23616): Local Branch: adreno_sba_20130419
10-29 19:11:22.549: I/Adreno200-EGL(23616): Remote Branch:
10-29 19:11:22.549: I/Adreno200-EGL(23616): Local Patches:
10-29 19:11:22.549: I/Adreno200-EGL(23616): Reconstruct Branch:
10-29 19:11:22.619: D/OpenGLRenderer(23616): Enabling debug mode 0
10-29 19:11:22.619: D/SoftKeyboardDetect(23616): Ignore this event
10-29 19:11:22.629: D/WebView(23616): onSizeChanged - w:1080 h:1920
10-29 19:11:22.629: D/CordovaActivity(23616): onMessage(onPageStarted,file:///android_asset/www/splash.html)
10-29 19:11:22.760: D/SoftKeyboardDetect(23616): Ignore this event
10-29 19:11:22.770: D/SoftKeyboardDetect(23616): Ignore this event
10-29 19:11:23.400: I/Web Console(23616): BUILD TITLE: height: 480 width: 1080:135
10-29 19:11:23.410: D/skia(23616): new locale
10-29 19:11:23.420: I/GATE(23616): <GATE-M>DEV_ACTION_COMPLETED</GATE-M>
10-29 19:11:23.420: D/CordovaWebViewClient(23616): onPageFinished(file:///android_asset/www/splash.html)
10-29 19:11:23.420: D/CordovaActivity(23616): onMessage(onPageFinished,file:///android_asset/www/splash.html)
10-29 19:11:23.470: D/CordovaActivity(23616): onMessage(spinner,stop)
10-29 19:11:23.470: D/CordovaNetworkManager(23616): Connection Type: wifi
10-29 19:11:23.480: D/TilesManager(23616): Starting TG #0, 0x6d237b38
10-29 19:11:23.480: D/TilesManager(23616): new EGLContext from framework: 40fc0920
10-29 19:11:23.480: D/GLWebViewState(23616): Reinit shader
10-29 19:11:23.490: D/CordovaActivity(23616): onMessage(splashscreen,hide)
10-29 19:11:23.490: I/App(23616): WARNING: Back Button Default Behaviour will be overridden. The backbutton event will be fired!
10-29 19:11:23.680: D/GLWebViewState(23616): Reinit transferQueue
10-29 19:11:23.721: D/CordovaNetworkManager(23616): Connection Type: wifi
10-29 19:11:23.721: D/CordovaActivity(23616): onMessage(networkconnection,wifi)
10-29 19:11:23.821:
E/ViewRootImpl(23616): sendUserActionEvent() mView == null
E/SpannableStringBuilder(23616): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
E/SpannableStringBuilder(23616): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
10-29 19:11:25.432: D/CordovaActivity(23616): onMessage(spinner,stop)
10-29 19:12:00.266: D/CordovaActivity(23616): Paused the application!
10-29 19:12:00.266: D/CordovaWebView(23616): Handle the pause
10-29 19:12:00.266: D/WebView(23616): loadUrlImpl: called
10-29 19:12:00.266: D/webcore(23616): CORE loadUrl: called
10-29 19:12:00.266: D/webkit(23616): Firewall not null
10-29 19:12:00.266: D/webkit(23616): euler: isUrlBlocked = false
10-29 19:12:00.837: W/IInputConnectionWrapper(23616): setComposingText on inactive InputConnection

Connection timed out after changing connection type

I use the following code in my app:
if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
...
Normally it works fine, but after switching from wifi to 3G I get the following exception:
21:04:21.358: I/WifiService(2277): setShowAccessPointListDialog():false
21:04:21.368: I/WifiService(2277): setWifiEnabledDialog(): false
21:04:21.393: I/WifiHW(2277): wifi_stop_supplicant: Enter
21:04:21.393: I/WifiHW(2277): wifi_stop_supplicant: connecting supplicant is done
21:04:21.393: I/WifiHW(2277): wifi_stop_supplicant: status of supplicant(connected), count(49)
21:04:21.393: I/wpa_supplicant(22752): CTRL-EVENT-TERMINATING - signal 15 received
21:04:21.393: I/wpa_supplicant(22752): CTRL-EVENT-TERMINATING - signal 0 received
21:04:21.393: I/WifiMonitor(2277): Event [CTRL-EVENT-TERMINATING - signal 15 received]
21:04:21.393: V/WifiStateTracker(2277): Connection to supplicant lost
21:04:21.418: I/wpa_supplicant(22752): CTRL-EVENT-STATE-CHANGE id=1 state=0 BSSID=00:00:00:00:00:00
21:04:22.443: I/dhcpcd(22766): received SIGTERM, stopping
21:04:22.508: I/WifiHW(2277): wifi_stop_supplicant: exit normally
21:04:22.508: D/WifiStateTracker(2277): Reset connections and stopping DHCP
21:04:22.513: I/WifiHW(2277): wifi_close_supplicant_connection: enter
21:04:22.513: I/WifiHW(2277): wifi_close_supplicant_connection: exit
21:04:22.528: D/NetworkStateTracker(2277): setDetailed state, old =CONNECTED and new state=DISCONNECTED
21:04:22.528: D/ConnectivityService(2277): ConnectivityChange for WIFI: DISCONNECTED/DISCONNECTED
21:04:22.528: D/ConnectivityService(2277): getMobileDataEnabled returning true
21:04:22.533: D/DataConnectionTracker(2332): setEnabled(0, true) with old state = false and enabledCount = 0
21:04:22.558: V/ConnectivityService(2277): Attempting to switch to mobile
21:04:22.578: D/MobileDataStateTracker(2277): default Received state= DISCONNECTED, old= DISCONNECTED, reason= apnSwitched, apnTypeList= default
21:04:22.583: D/Tethering(2277): Tethering got CONNECTIVITY_ACTION
21:04:22.583: D/Tethering(2277): MasterInitialState.processMessage what=3
21:04:22.583: E/HierarchicalStateMachine(2277): TetherMaster - unhandledMessage: msg.what=3
21:04:22.618: D/MobileDataStateTracker(2277): default Received state= DISCONNECTED, old= DISCONNECTED, reason= apnSwitched, apnTypeList= default
21:04:22.638: D/GpsLocationProvider(2277): updateNetworkState available info: NetworkInfo: type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), roaming: false, failover: false, isAvailable: false
21:04:22.658: D/WifiStateTracker(2277): Disabling interface
21:04:22.658: I/WifiHW(2277): wifi_unload_driver: enter
21:04:22.663: D/MobileDataStateTracker(2277): default Received state= DISCONNECTED, old= DISCONNECTED, reason= apnSwitched, apnTypeList= default
21:04:22.723: D/MobileDataStateTracker(2277): default Received state= CONNECTING, old= DISCONNECTED, reason= apnSwitched, apnTypeList= default,supl
21:04:22.723: D/NetworkStateTracker(2277): setDetailed state, old =DISCONNECTED and new state=CONNECTING
21:04:22.728: D/ConnectivityService(2277): ConnectivityChange for mobile: CONNECTING/CONNECTING
21:04:22.773: I/GTalkService(22533): [ServiceAutoStarter] --- connectivity changed
21:04:22.773: I/GTalkService(22533): [ServiceAutoStarter] --- start GTalk service ---
21:04:22.883: D/NetworkLocationProvider(2277): onDataConnectionStateChanged 3
21:04:22.888: D/NetworkLocationProvider(2277): onDataConnectionStateChanged 3
21:04:22.893: D/NetworkLocationProvider(2277): onDataConnectionStateChanged 3
21:04:22.893: D/NetworkLocationProvider(2277): onDataConnectionStateChanged 3
21:04:23.453: E/WifiHW(2277): [WIFI] Unload Driver
21:04:23.453: I/WifiHW(2277): wifi_unload_driver: exit
21:04:23.493: I/DBG_WSS_DM(22809): [wssStartService.java Line:1413] ProtoIsWIFIConnected WiFi DisConnected
21:04:23.588: I/DBG_WSS_DM(22809): [wssTelephonyData.java Line:131] getInstance PHONE_TYPE_GSM
21:04:23.758: V/SettingsProvider(2277): secure <- value=0 name=wifi_on
21:04:23.758: V/SettingsProvider(2277): property: sys.settings_secure_version=42
21:04:23.768: V/SettingsProvider(2277): notifying: content://settings/secure/wifi_on
21:04:24.483: D/Tethering(2277): pdp0 is not a tetherable iface, ignoring
21:04:24.538: E/DataRouter(2171): [*] Received suspend/ resume event but DUN is not up so neglect
21:04:24.548: D/MobileDataStateTracker(2277): replacing old mInterfaceName (pdp0) with pdp0 for hipri
21:04:24.553: D/MobileDataStateTracker(2277): replacing old mInterfaceName (pdp0) with pdp0 for supl
21:04:24.553: D/MobileDataStateTracker(2277): default Received state= CONNECTED, old= CONNECTING, reason= apnSwitched, apnTypeList= default,supl
21:04:24.563: D/MobileDataStateTracker(2277): CONNECTED interface name pdp0
21:04:24.563: D/MobileDataStateTracker(2277): -> net.pdp0.gw: 100.97.40.1
21:04:24.563: D/MobileDataStateTracker(2277): -> mDefaultGatewayAddr: 19423588
21:04:24.563: D/MobileDataStateTracker(2277): -------------------------
21:04:24.563: D/MobileDataStateTracker(2277): #net.pdp0.gw: 100.97.40.1
21:04:24.563: D/MobileDataStateTracker(2277): #net.pdp1.gw:
21:04:24.563: D/MobileDataStateTracker(2277): #net.pdp2.gw:
21:04:24.563: D/MobileDataStateTracker(2277): -------------------------
21:04:24.568: D/NetworkStateTracker(2277): setDetailed state, old =CONNECTING and new state=CONNECTED
21:04:24.568: V/NetworkStateTracker(2277): Setting TCP values: [4094,87380,110208,4096,16384,110208] which comes from [net.tcp.buffersize.umts]
21:04:24.568: D/ConnectivityService(2277): ConnectivityChange for mobile: CONNECTED/CONNECTED
21:04:24.598: I/DBG_WSS_DM(22809): [wssTelephonyData.java Line:131] getInstance PHONE_TYPE_GSM
21:04:24.598: D/ConnectivityService(2277): adding dns 10.74.210.210 for mobile
21:04:24.608: D/NetworkStateTracker(2277): addDefaultRoute for mobile(pdp0), GatewayAddr=19423588 mDefaultRouteSet=false
21:04:24.608: D/NetworkStateTracker(2277): addDefaultRoute for mobile (pdp0), GatewayAddr=19423588
21:04:24.608: D/ConnectivityService(2277): adding dns 10.74.210.211 for mobile
21:04:24.623: D/Tethering(2277): Tethering got CONNECTIVITY_ACTION
21:04:24.628: D/Tethering(2277): MasterInitialState.processMessage what=3
21:04:24.628: E/HierarchicalStateMachine(2277): TetherMaster - unhandledMessage: msg.what=3
21:04:24.733: D/Smack(22533): [XMPPConn] close connection, notifyClosed=false
21:04:24.748: D/GpsLocationProvider(2277): updateNetworkState available info: NetworkInfo: type: mobile[UMTS], state: CONNECTED/CONNECTED, reason: apnSwitched, extra: internet.t-mobile, roaming: false, failover: false, isAvailable: true
21:04:24.798: I/DBG_WSS_TP(22809): [wssHttpAdapter.java Line:1722] getIsConnected connect status is false
21:04:24.808: I/DBG_WSS_DM(22809): [wssStartService.java Line:1413] ProtoIsWIFIConnected WiFi DisConnected
21:04:24.808: D/NetworkLocationProvider(2277): onDataConnectionStateChanged 3
21:04:24.923: W/Smack/Packet(22533): notify conn break (IOEx), close connection
21:04:24.928: I/GTalkService(22533): [ServiceAutoStarter] --- connectivity changed
21:04:24.928: I/GTalkService(22533): [ServiceAutoStarter] --- start GTalk service ---
21:04:32.948: I/DBG_WSS_TP(22809): [wssHttpAdapter.java Line:1722] getIsConnected connect status is false
21:04:32.988: D/NetworkLocationProvider(2277): onDataConnectionStateChanged 3
21:04:36.008: I/DBG_WSS_TP(22809): [wssHttpAdapter.java Line:1722] getIsConnected connect status is false
21:04:36.013: D/NetworkLocationProvider(2277): onDataConnectionStateChanged 3
21:04:41.868: V/MyAppIntentService(22454): MyAppIntentService
21:04:41.943: V/MyAppIntentService(22454): myAppUpdate isOnline
21:04:42.003: V/MyAppIntentService(22454): myAppUpdate moveToNext
21:05:12.493: W/IInputConnectionWrapper(22454): getExtractedText on inactive InputConnection
21:05:12.498: W/IInputConnectionWrapper(22454): getExtractedText on inactive InputConnection
21:05:17.643: D/GoogleLoginService(22533): onBind: Intent { act=android.accounts.AccountAuthenticator cmp=com.google.android.gsf/.loginservice.GoogleLoginService }
21:06:56.483: D/NativeCrypto(22533): Freeing OpenSSL session
21:26:51.628: W/System.err(22454): java.net.SocketException: Connection timed out
21:26:51.668: W/System.err(22454): at org.apache.harmony.luni.platform.OSNetworkSystem.readSocketImpl(Native Method)
21:26:51.673: W/System.err(22454): at org.apache.harmony.luni.platform.OSNetworkSystem.read(OSNetworkSystem.java:358)
21:26:51.683: W/System.err(22454): at org.apache.harmony.luni.net.PlainSocketImpl.read(PlainSocketImpl.java:561)
21:26:51.688: W/System.err(22454): at org.apache.harmony.luni.net.SocketInputStream.read(SocketInputStream.java:61)
21:26:51.703: W/System.err(22454): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.readln(HttpURLConnectionImpl.java:1279)
21:26:51.708: W/System.err(22454): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.readServerResponse(HttpURLConnectionImpl.java:1351)
21:26:51.718: W/System.err(22454): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.sendRequest(HttpURLConnectionImpl.java:1339)
21:26:51.728: W/System.err(22454): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.doRequestInternal(HttpURLConnectionImpl.java:1656)
21:26:51.733: W/System.err(22454): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.doRequest(HttpURLConnectionImpl.java:1649)
21:26:51.743: W/System.err(22454): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:1374)
21:26:51.748: W/System.err(22454): at com.dummy.myApp.MyAppIntentService.myAppUpdate(MyAppIntentService.java:117)
21:26:51.753: W/System.err(22454): at com.dummy.myApp.MyAppIntentService.onHandleIntent(MyAppIntentService.java:85)
21:26:51.758: W/System.err(22454): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:59)
21:26:51.768: W/System.err(22454): at android.os.Handler.dispatchMessage(Handler.java:99)
21:26:51.773: W/System.err(22454): at android.os.Looper.loop(Looper.java:123)
21:26:51.783: W/System.err(22454): at android.os.HandlerThread.run(HandlerThread.java:60)
21:26:51.783: V/MyAppIntentService(22454): myAppUpdate moveToNext
21:26:53.943: I/DBG_WSS_TP(22809): [wssHttpAdapter.java Line:1722] getIsConnected connect status is false
21:26:53.948: D/NetworkLocationProvider(2277): onDataConnectionStateChanged 3
21:26:55.723: V/MyAppIntentService(22454): myAppUpdate HTTP_OK
21:26:56.583: V/MyAppIntentService(22454): myAppUpdate moveToNext
21:26:57.943: V/MyAppIntentService(22454): myAppUpdate HTTP_OK
21:26:58.773: V/MyAppIntentService(22454): myAppUpdate moveToNext
21:26:59.983: V/MyAppIntentService(22454): myAppUpdate HTTP_OK
21:27:00.893: V/MyAppIntentService(22454): myAppUpdate moveToNext
21:27:02.253: V/MyAppIntentService(22454): myAppUpdate HTTP_OK
Why it doesn't work after changing the connection type from wifi to 3G? When switching from 3G to wifi everything works fine.
After the exception it works fine (HTTP_OK). It works also fine, when I kill MyAppIntentService before the exception happens and restart again.
might be your carrier is blocking the connection. test to get the resource with a browser.
or your connection is really slow, try to alter:
HttpConnectionParams.setConnectionTimeout(httpParameters, CONNECTION_TIMEOUT);
I've found a solution here. After adding the described workaround it works:
...
httpConnection.setRequestProperty("connection", "close");
if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
...

Categories

Resources