Android Question Issue with setting selectionStart in maskededittext

tkristensen

Member
Licensed User
Longtime User
I have a page with multiple maskedEditText controls on it.

I am having two issues with it.

First on the phone field...

B4X:
Sub configure_Etstep2Phone
    etStep2Phone.Format = "(###)###-####"
    etStep2Phone.InputType = etStep2Phone.INPUT_TYPE_PHONE
    etStep2Phone.SingleLine = True
    etStep2Phone.ForceDoneButton = True
    etStep2Phone.Color = Colors.White
    etStep2Phone.TextColor = Colors.black
    etStep2Phone.TextSize = 24
    etStep2Phone.Typeface = myTypeface
End Sub

Sub etstep2Phone_TextChanged (Old As String, New As String)
    thisSurvey.PharmPhone = New
    PCI.ContactPhone = New
    'ValidateStep2ForNext
End Sub


Sub etstep2Phone_FocusChanged(HasFocus As Boolean)
    If HasFocus Then
        Dim thisPos As Int = getLocationOfLastNumber(etStep2Phone.text)    
        If thisPos = -1 Then thisPos = 1
        etStep2Phone.SelectionStart = thisPos
    End If
End Sub


Sub getLocationOfLastNumber(thisString As String) As Int
    Dim retVal As Int = -1
    For i = thisString.Length - 1 To 0 Step -1
        If "0123456789".Contains(thisString.CharAt(i)) Then
            Return i + 1
        End If
    Next
    Return retVal
End Sub

I have added code that tries to set the position when the control is touched so that it always locates to the position after the last number. If no number is present, then it should locate to pos 1 (the first valid position for a number). When I step through it I see the cursor move exactly like you would expect it to, but as soon as it leaves the FocusChanged event the cursor position moves back to the touched position.

Second... when I move to another maskedEditText control, it fires the FocusChanged event with hasFocus set to false as you would expect, but then I get a crash with the following:

Log trace:
Microdump skipped (uninteresting)
### ### ### ### ### ### ### ### ### ### ### ### ###
Chrome build fingerprint:
72.0.3626.121
362612112
### ### ### ### ### ### ### ### ### ### ### ### ###
Fatal signal 11 (SIGSEGV), code 1, fault addr 0x1d in tid 12466 (com.PatientToc.)
debuggerd: handling request: pid=12466 uid=10073 gid=10073 tid=12466
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'OnePlus/OnePlus3/OnePlus3T:7.1.1/NMF26F/10122113:user/release-keys'
Revision: '0'
ABI: 'x86'
pid: 12466, tid: 12466, name: com.PatientToc.  >>> com.PatientToc.MedRec <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x1d
    eax 0000001d  ebx cb608e6c  ecx a776fba4  edx 00000006
    esi a776fba4  edi 00000000
    xcs 00000073  xds 0000007b  xes 0000007b  xfs 00000043  xss 0000007b
    eip cb5fe35e  ebp dfe9e1b8  esp dfe9e070  flags 00210206
backtrace:
    #00 pc 0001935e  /system/lib/libutils.so (_ZN7android6Looper9pollInnerEi+1262)
    #01 pc 00018da4  /system/lib/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+68)
    #02 pc 000d5a43  /system/lib/libandroid_runtime.so (_ZN7android18NativeMessageQueue8pollOnceEP7_JNIEnvP8_jobjecti+77)
    #03 pc 000d5ab4  /system/lib/libandroid_runtime.so
    #04 pc 738ed01c  /data/dalvik-cache/x86/system@[email protected] (offset 0x15ad000) (android.os.MessageQueue.nativePollOnce+136)
    #05 pc 738eeb2b  /data/dalvik-cache/x86/system@[email protected] (offset 0x15ad000) (android.os.MessageQueue.next+215)
    #06 pc 738e9218  /data/dalvik-cache/x86/system@[email protected] (offset 0x15ad000) (android.os.Looper.loop+324)
    #07 pc 732035ca  /data/dalvik-cache/x86/system@[email protected] (offset 0x15ad000) (android.app.ActivityThread.main+390)
    #08 pc 001096b2  /system/lib/libart.so (art_quick_invoke_static_stub+418)
    #09 pc 00113069  /system/lib/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+313)
    #10 pc 00511e95  /system/lib/libart.so (_ZN3artL18InvokeWithArgArrayERKNS_33ScopedObjectAccessAlreadyRunnableEPNS_9ArtMethodEPNS_8ArgArrayEPNS_6JValueEPKc+101)
    #11 pc 00513dd4  /system/lib/libart.so (_ZN3art12InvokeMethodERKNS_33ScopedObjectAccessAlreadyRunnableEP8_jobjectS4_S4_j+1540)
    #12 pc 00469e50  /system/lib/libart.so (_ZN3artL13Method_invokeEP7_JNIEnvP8_jobjectS3_S3_+96)
    #13 pc 70cc03dc  /data/dalvik-cache/x86/system@[email protected] (offset 0x51a000) (java.lang.reflect.Method.invoke+168)
    #14 pc 73f1e816  /data/dalvik-cache/x86/system@[email protected] (offset 0x15ad000) (com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run+114)
    #15 pc 73f1f7d3  /data/dalvik-cache/x86/system@[email protected] (offset 0x15ad000) (com.android.internal.os.ZygoteInit.main+1247)
    #16 pc 001096b2  /system/lib/libart.so (art_quick_invoke_static_stub+418)
    #17 pc 00113069  /system/lib/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+313)
    #18 pc 00511e95  /system/lib/libart.so (_ZN3artL18InvokeWithArgArrayERKNS_33ScopedObjectAccessAlreadyRunnableEPNS_9ArtMethodEPNS_8ArgArrayEPNS_6JValueEPKc+101)
    #19 pc 00511b59  /system/lib/libart.so (_ZN3art17InvokeWithVarArgsERKNS_33ScopedObjectAccessAlreadyRunnableEP8_jobjectP10_jmethodIDPc+393)
    #20 pc 003f847e  /system/lib/libart.so (_ZN3art3JNI21CallStaticVoidMethodVEP7_JNIEnvP7_jclassP10_jmethodIDPc+958)
    #21 pc 000718d1  /system/lib/libandroid_runtime.so (_ZN7_JNIEnv20CallStaticVoidMethodEP7_jclassP10_jmethodIDz+41)
    #22 pc 000756b4  /system/lib/libandroid_runtime.so (_ZN7android14AndroidRuntime5startEPKcRKNS_6VectorINS_7String8EEEb+782)
    #23 pc 00001d01  /system/bin/app_process32
    #24 pc 0001538c  /system/lib/libc.so (__libc_init+108)
    #25 pc 000014fc  /system/bin/app_process32
    #26 pc 00000004  <unknown>
pid: 12466, tid: 12466, pkg name: com.PatientToc.MedRec
Application crash has been observed.
  Force finishing activity com.PatientToc.MedRec/.main
debuggerd: resuming target 12466
Copying /data/tombstones/tombstone_05 to DropBox (SYSTEM_TOMBSTONE)
!!! FAILED BINDER TRANSACTION !!!  (parcel size = 104)
Exception thrown during pause
android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died
    at android.os.BinderProxy.transactNative(Native Method)
    at android.os.BinderProxy.transact(Binder.java:615)
    at android.app.ApplicationThreadProxy.schedulePauseActivity(ApplicationThreadNative.java:785)
    at com.android.server.am.ActivityStack.startPausingLocked(ActivityStack.java:1147)
    at com.android.server.am.ActivityStack.finishActivityLocked(ActivityStack.java:3547)
    at com.android.server.am.ActivityStack.finishTopRunningActivityLocked(ActivityStack.java:3383)
    at com.android.server.am.ActivityStackSupervisor.finishTopRunningActivityLocked(ActivityStackSupervisor.java:1897)
    at com.android.server.am.AppErrors.handleAppCrashLocked(AppErrors.java:619)
    at com.android.server.am.AppErrors.makeAppCrashingLocked(AppErrors.java:477)
    at com.android.server.am.AppErrors.crashApplicationInner(AppErrors.java:353)
    at com.android.server.am.AppErrors.crashApplication(AppErrors.java:305)
    at com.android.server.am.ActivityManagerService.handleApplicationCrashInner(ActivityManagerService.java:13723)
    at com.android.server.am.NativeCrashListener$NativeCrashReporter.run(NativeCrashListener.java:86)
TopActivityInfo, pkgName: com.bluestacks.appmart activityName: com.bluestacks.appmart/.MarketPageGrid callingPackage:   bstSpecialAppKeyboardHandlingEnabled = false
Sending app launch intent for appName: Apps pkgName: com.bluestacks.appmart
Sending TopActivity Info
!!! FAILED BINDER TRANSACTION !!!  (parcel size = 60)
Failed setting process group of 12466 to 1
java.lang.IllegalArgumentException: Given thread 12486 does not exist
    at android.os.Process.setThreadPriority(Native Method)
    at com.android.server.am.ActivityManagerService.applyOomAdjLocked(ActivityManagerService.java:20863)
    at com.android.server.am.ActivityManagerService.updateOomAdjLocked(ActivityManagerService.java:21390)
    at com.android.server.am.ActivityStack.resumeTopActivityInnerLocked(ActivityStack.java:2460)
    at com.android.server.am.ActivityStack.resumeTopActivityUncheckedLocked(ActivityStack.java:2133)
    at com.android.server.am.ActivityStackSupervisor.resumeFocusedStackTopActivityLocked(ActivityStackSupervisor.java:1875)
    at com.android.server.am.ActivityStackSupervisor.resumeFocusedStackTopActivityLocked(ActivityStackSupervisor.java:1865)
    at com.android.server.am.ActivityStack.startPausingLocked(ActivityStack.java:1202)
    at com.android.server.am.ActivityStack.finishActivityLocked(ActivityStack.java:3547)
    at com.android.server.am.ActivityStack.finishTopRunningActivityLocked(ActivityStack.java:3383)
    at com.android.server.am.ActivityStackSupervisor.finishTopRunningActivityLocked(ActivityStackSupervisor.java:1897)
    at com.android.server.am.AppErrors.handleAppCrashLocked(AppErrors.java:619)
    at com.android.server.am.AppErrors.makeAppCrashingLocked(AppErrors.java:477)
    at com.android.server.am.AppErrors.crashApplicationInner(AppErrors.java:353)
    at com.android.server.am.AppErrors.crashApplication(AppErrors.java:305)
    at com.android.server.am.ActivityManagerService.handleApplicationCrashInner(ActivityManagerService.java:13723)
    at com.android.server.am.NativeCrashListener$NativeCrashReporter.run(NativeCrashListener.java:86)
in computeScreenConfigurationLocked() -- hardKeyboardAvailable :true  mHardKeyboardAvailable :true
command: muteappplayer
in isSystemReady, isBootCompleted true External storage status: mounted  External storage dir :/storage/emulated/0  isExternalStorageRemovable:false deviceProvisioned 1
returning from waitForSystemReady,  isSystemReady = true
response: {"result":"ok"}
PgaSocketInit: opened /dev/bstpgaipc: fd = 222
Attempting to create new SOCKET connection pid = 1890, tid = 12547
PgaSocketInitClientPgaIpc: data mapped to 0xa95ad000 with size 262144
New SOCKET connection: system_server (pid 1890, tid 12547)
channel 'e432e65 com.PatientToc.MedRec/com.PatientToc.MedRec.main (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
channel 'e432e65 com.PatientToc.MedRec/com.PatientToc.MedRec.main (server)' ~ Channel is unrecoverably broken and will be disposed!
channel 'd719c9 com.PatientToc.MedRec/com.PatientToc.MedRec.main (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
channel 'd719c9 com.PatientToc.MedRec/com.PatientToc.MedRec.main (server)' ~ Channel is unrecoverably broken and will be disposed!
ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ LISTEN id=61, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ], android.os.BinderProxy@6e4d824)
ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ LISTEN id=60, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ], android.os.BinderProxy@9232f8d)
Buffer count: 3
Process 12466 exited due to signal (11)
RemoteException caught trying to send a callback msg for NetworkRequest [ LISTEN id=61, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ]
RemoteException caught trying to send a callback msg for NetworkRequest [ LISTEN id=60, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ]
command: guestorientation 0
Host orientation handler Angle0
setOrientation(0)
Raising orientation notification
response: {"result":"ok"}
Long monitor contention with owner NativeCrashReport (12547) at android.graphics.Bitmap com.android.server.wm.WindowManagerService.screenshotApplicationsInner(android.os.IBinder, int, int, int, boolean, float, android.graphics.Bitmap$Config, boolean)(WindowManagerService.java:6580) waiters=0 in void com.android.server.wm.WindowAnimator$1.doFrame(long) for 117ms
WIN DEATH: Window{e432e65 u0 com.PatientToc.MedRec/com.PatientToc.MedRec.main}
Attempted to unregister already unregistered input channel 'e432e65 com.PatientToc.MedRec/com.PatientToc.MedRec.main (server)'
isVisibleLw false for win : Window{d719c9 u0 com.PatientToc.MedRec/com.PatientToc.MedRec.main}
WIN DEATH: Window{d719c9 u0 com.PatientToc.MedRec/com.PatientToc.MedRec.main}
Attempted to unregister already unregistered input channel 'd719c9 com.PatientToc.MedRec/com.PatientToc.MedRec.main (server)'
Long monitor contention with owner NativeCrashReport (12547) at void com.android.server.am.AppErrors.crashApplicationInner(com.android.server.am.ProcessRecord, android.app.ApplicationErrorReport$CrashInfo)(AppErrors.java:324) waiters=0 in int com.android.server.am.ActivityManagerService.broadcastIntent(android.app.IApplicationThread, android.content.Intent, java.lang.String, android.content.IIntentReceiver, int, java.lang.String, android.os.Bundle, java.lang.String[], int, android.os.Bundle, boolean, boolean, int) for 184ms
Long monitor contention with owner NativeCrashReport (12547) at void com.android.server.am.AppErrors.crashApplicationInner(com.android.server.am.ProcessRecord, android.app.ApplicationErrorReport$CrashInfo)(AppErrors.java:324) waiters=1 in void com.android.server.am.BroadcastQueue.processNextBroadcast(boolean) for 161ms
Process com.PatientToc.MedRec (pid 12466) has died
Long monitor contention with owner NativeCrashReport (12547) at void com.android.server.am.AppErrors.crashApplicationInner(com.android.server.am.ProcessRecord, android.app.ApplicationErrorReport$CrashInfo)(AppErrors.java:324) waiters=3 in void com.android.server.am.ActivityManagerService$3.handleMessage(android.os.Message) for 160ms
cleanUpApplicationRecord -- 12466
Scheduling restart of crashed service com.PatientToc.MedRec/.starter in 1000ms
Onresume called
InitViews called
checkAdExists() called with: context = [android.app.ReceiverRestrictedContext@7bbcc3b], hostPackageName = [com.bluestacks.appmart], ignoreOccurrence = [true], adScreenService = [null], forceLaunch = [false], doNotSendStats = [false]
topDisplayedActivityInfo, appToken: AppWindowToken{9a33ea9 token=Token{6561373 ActivityRecord{862e3e2 u0 com.bluestacks.appmart/.MarketPageGrid t1}}}
packageName=com.bluestacks.appmart, activityName=.MarketPageGrid
Telecom Service not found.
Window size has been changed. This may cause jankiness of resizing window: -1 -> -2
Unexpected CPU variant for X86 using defaults: x86
Start proc 12558:com.android.deskclock/u0a54 for broadcast com.android.deskclock/com.android.alarmclock.DigitalAppWidgetProvider
Killing 11461:com.google.process.gapps/u0a2 (adj 906): empty #5
cleanUpApplicationRecord -- 11461
KeepLiveManager ==> checkService() ==>
name  ==> com.amber.lib.applive.core.lollipop.LiveServiceL ==>
run  true ==>
name  ==> com.cleanteam.mvp.ui.notification.NotificationUiService ==>
run  true ==>
KeepLiveManager ==> checkService() ==>
name  ==> com.amber.lib.applive.core.lollipop.LiveServiceL ==>
run  true ==>
name  ==> com.cleanteam.mvp.ui.notification.NotificationUiService ==>
run  true ==>
GCM_HB_ALARM release without a matched acquire!
KeepLiveManager ==> checkService() ==>
name  ==> com.amber.lib.applive.core.lollipop.LiveServiceL ==>
run  true ==>
name  ==> com.cleanteam.mvp.ui.notification.NotificationUiService ==>
run  true ==>
LiveJobService ==> onCreate() ==>
LiveJobService ==> onStartJob() ==>
KeepLiveManager ==> checkService() ==>
name  ==> com.amber.lib.applive.core.lollipop.LiveServiceL ==>
run  true ==>
name  ==> com.cleanteam.mvp.ui.notification.NotificationUiService ==>
run  true ==>
KeepLiveManager ==> checkService() ==>
name  ==> com.amber.lib.applive.core.lollipop.LiveServiceL ==>
run  true ==>
name  ==> com.cleanteam.mvp.ui.notification.NotificationUiService ==>
run  true ==>
KeepLiveManager ==> checkService() ==>
name  ==> com.amber.lib.applive.core.lollipop.LiveServiceL ==>
run  true ==>
name  ==> com.cleanteam.mvp.ui.notification.NotificationUiService ==>
run  true ==>

any help most appreciated
 

tkristensen

Member
Licensed User
Longtime User
Here is a small test program that shows both issues.

Step through the etstep2Phone_FocusChanged event and you will see the cursor relocate...then when you step out of it, it reverts to the original position.

second just bounce between the two edittexts, sometimes it happens the firsttime sometimes a few times in, and it will error out the app with the signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x3f800000 error

It does this both on a Galaxy Tab A running android 10 and the bluestacks version 4.250 emulator. And if it matters...always running it in landscape mode.
 

Attachments

  • bugdemoprogram.zip
    89.2 KB · Views: 127
Upvote 0
Top