Draw all the touching points on full devices (android 6.0+) - android

I tried to make an app can draw all the touching points when users touching their own device. (it's mean that even outside the app.)
At first, I add a view overlay on the device. But if I fetch the touch points on the top of screen, it seems to block the entire screen and I can't let the touch get through the view to touch other unit under the view.
At second, I write "show_touches" settings of system, then I can see all the touch points.
The second way worked fine until android 6.0 release. Above 6.0, I need to request permission again in the app. But when the permission granted, I still get a crash "You cannot change private secure settings".
Is there any way to get secure settings permission? Or another way to draw touch points on the top of screen?
I need an answer without rooted, can anyone help me figure it out?
this is my stacktrace:
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.morshues.mytestapp, PID: 31194
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=45487, result=-1, data=Intent { (has extras) }} to activity {com.morshues.mytestapp/com.morshues.mytestapp.SecondActivity}: java.lang.IllegalArgumentException: You cannot change private secure settings.
at android.app.ActivityThread.deliverResults(ActivityThread.java:3988)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4038)
at android.app.ActivityThread.access$1400(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1443)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
Caused by: java.lang.IllegalArgumentException: You cannot change private secure settings.
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:165)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
at android.content.ContentProviderProxy.call(ContentProviderNative.java:646)
at android.provider.Settings$NameValueCache.putStringForUser(Settings.java:1400)
at android.provider.Settings$System.putStringForUser(Settings.java:1769)
at android.provider.Settings$System.putIntForUser(Settings.java:1874)
at android.provider.Settings$System.putInt(Settings.java:1868)
at com.morshues.FullRecorder.start(FullRecorder.java:238)
at com.morshues.FullRecorder.onActivityResult(FullRecorder.java:132)
at com.morshues.mytestapp.onActivityResult(MainCenter.java:130)
at com.morshues.mytestapp.SecondActivity.onActivityResult(SecondActivity.java:91)
at android.app.Activity.dispatchActivityResult(Activity.java:6439)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3984)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4038) 
at android.app.ActivityThread.access$1400(ActivityThread.java:150) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1443) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:168) 
at android.app.ActivityThread.main(ActivityThread.java:5845) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687) 

Related

Can not perform this action after onSaveInstanceState using a BottomsheetDialogFragment?

I am using BottomsheetDialogFragment and recently getting crash reports on crashlytics, the stacktrace is -
Fatal Exception: java.lang.IllegalStateException: Can not perform this
action after onSaveInstanceState
at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:2044)
at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:2067)
at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:680)
at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:634)
at android.support.v4.app.DialogFragment.dismissInternal(DialogFragment.java:205)
at android.support.v4.app.DialogFragment.dismiss(DialogFragment.java:171)
at com.khaalijeb.inkdrops.ListBanks.onSuccessResponse(ListBanks.java:322)
at com.khaalijeb.inkdrops.App.onSuccessResponse(App.java:800)
at com.olive.upi.OliveUpiManager.onSuccessResponse(Unknown Source:970)
at com.olive.upi.transport.d$33.onResponse(Unknown Source:16)
at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:68)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:169)
at android.app.ActivityThread.main(ActivityThread.java:6595)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
I don't know what caused this error since it is not happening in some device and not all of them. Did anyone face this problem earlier and how to overcome it?
I have tested this particular code 1000 times but never got one but in the production world, I am getting this error in around 2 3 devices.
How to call commitAllowingStateLoss();? will this fixed the problem?
There is BottomsheetDialogFragment#dismissAllowingStateLoss method in the material library that will allow you to fix this problem

Android 8.1/9.0 removeView(View) is not supported in AdapterView

I'm getting a "removeView(View) is not supported in AdapterView" exception when running my app in Android version 8.1 and 9.0. In previous versions it runs fine. Although the error is consistent it doesn't happen 100% of the time (which makes me suspect it's a threading issue) nor is it specific to a particular adapter or list view. For instance, I access the same code from multiple actives and it works fine for some and always fails for others. I should also point out that I'm not calling removeView in any of the situations where I get the error. Below is the LogCat output for the exception:
java.lang.UnsupportedOperationException: removeView(View) is not supported in AdapterView
at android.widget.AdapterView.removeView(AdapterView.java:531)
at android.view.ViewOverlay$OverlayViewGroup.add(ViewOverlay.java:195)
at android.view.ViewGroupOverlay.add(ViewGroupOverlay.java:72)
at android.transition.TransitionUtils.createViewBitmap(TransitionUtils.java:170)
at android.transition.TransitionUtils.copyViewImage(TransitionUtils.java:104)
at android.transition.Visibility.onDisappear(Visibility.java:380)
at android.transition.Visibility.createAnimator(Visibility.java:249)
at android.transition.Transition.createAnimators(Transition.java:732)
at android.transition.TransitionSet.createAnimators(TransitionSet.java:396)
at android.transition.Transition.playTransition(Transition.java:1779)
at android.transition.TransitionManager$MultiListener.onPreDraw(TransitionManager.java:315)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:977)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2349)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1392)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6752)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
at android.view.Choreographer.doCallbacks(Choreographer.java:723)
at android.view.Choreographer.doFrame(Choreographer.java:658)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Can anyone point me towards a solution?
I ended up subclassing ListView and overrode removeView and addView with empty methods. I doubt this is the correct way to fix this problem but it worked.

NullPointerException: int android.widget.Editor$SelectionModifierCursorController.getMinTouchOffset()

It's a very strange Xiaomi device's OS exception. Even if I do have logs available from Fabric, the stack trace doesn't refer any of my code.
A crash details are below as reported in crashalytics(Fabric),
21K crashes
All crashes on Xiaomi devices
Crashes on Android OS version 6, 7 and 8
Crash Log:
# OS Version: 8.1.0
# Device: Redmi Note 5 pro
# RAM Free: 30.1%
# Disk Free: 74.2%
#0. Crashed: main
at android.widget.Editor.touchPositionIsInSelection(Editor.java:1084)
at android.widget.Editor.performLongClick(Editor.java:1205)
at android.widget.TextView.performLongClick(TextView.java:10908)
at android.view.View.performLongClick(View.java:6360)
at android.view.View$CheckForLongPress.run(View.java:24768)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:171)
at android.app.ActivityThread.main(ActivityThread.java:6606)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:518)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
--
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.widget.Editor$SelectionModifierCursorController.getMinTouchOffset()' on a null object reference
at android.widget.Editor.touchPositionIsInSelection(Editor.java:1084)
at android.widget.Editor.performLongClick(Editor.java:1205)
at android.widget.TextView.performLongClick(TextView.java:10908)
at android.view.View.performLongClick(View.java:6360)
at android.view.View$CheckForLongPress.run(View.java:24768)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:171)
at android.app.ActivityThread.main(ActivityThread.java:6606)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:518)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
#0. Crashed: main
at android.widget.Editor.touchPositionIsInSelection(Editor.java:1084)
at android.widget.Editor.performLongClick(Editor.java:1205)
at android.widget.TextView.performLongClick(TextView.java:10908)
at android.view.View.performLongClick(View.java:6360)
at android.view.View$CheckForLongPress.run(View.java:24768)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:171)
at android.app.ActivityThread.main(ActivityThread.java:6606)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:518)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Similar Reference:
https://issuetracker.google.com/issues/37127697
java.lang.NullPointerException with Nougat
Also asked on Xiaomi official forum http://en.miui.com/forum.php?mod=viewthread&tid=4595164
Please do provide any working solution as soon as possible. As users must not be happy with these crashes.
Thanks in advance.
1)  First of all, only if required, set one of these.
textView.setMovementMethod(LinkMovementMethod.getInstance());
or 
setAutoLinkMask(Linkify.ALL);
or
Linkify.addLinks(textView, Linkify.PHONE_NUMBERS | Linkify.EMAIL_ADDRESSES | Linkify.MAP_ADDRESSES);
2) Secondly, set a long click listener for TextView and it must return true.
textView.setOnLongClickListener(new View.OnLongClickListener() {
#Override
public boolean onLongClick(View v) {
// do soemthing if needed
return true;
}
});
There is some internal crashing issue on Xiaomi devices. If you override setOnLongClickListener(reference) first and then follow the step one, it will use internal implementation and that will keep on crashing. So it is import to follow above steps in sequence.
I am open to other solutions, however by following this approach I don't see crash reports anymore.
Do you have a custom TextView in your app? Is it perhaps resizeable or has additional functionality?
Xiaomi's Android skin is likely interfering with that, and causing crashes. I suggest trying to long click all TextViews in your app.
It happen when user doing long click on all selected text.
Just define longClickListener:
edit_text.setOnLongClickListener {
doSomething()
true
}
and later you can remove it
edit_text.setOnLongClickListener(null)
For me this crash happened when TextView contained link and setAutoLinkMask(Linkify.ALL); was called for the view. In this case Android handles all clicks (including long clicks) by this view. On devices of other brands link was opened after long click, but on Xiaomi device crash happened. It seems, that they have a bit different logic of handling onTouchEvent inside the TextView. I've played a bit around and found, that setting android:textIsSelectable="false" for the TextView in layout file solves the problem.
I know, that it's not scalable solution, but for my case it was perfect, so I stopped investigating further. Maybe it will give a hint to someone else.

ARCore android scenform :Cannot use the same ViewRenderable with multiple SceneViews

My application does image detection using arcore augmentedimages and shows a viewrenderable once the image detected. If i close the app after the image has been detected and viewrenderable is shown, then reopen the application, the app crashes once the image is detected, throwing
IllegalStateException: Cannot use the same ViewRenderable with
multiple SceneViews
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.techaffinity.arroutertroubleshoot, PID: 4313
java.lang.IllegalStateException: Cannot use the same ViewRenderable with multiple SceneViews.
at com.google.ar.sceneform.rendering.RenderViewToExternalTexture.attachView(RenderViewToExternalTexture.java:131)
at com.google.ar.sceneform.rendering.ViewRenderable.attachToRenderer(ViewRenderable.java:303)
at com.google.ar.sceneform.rendering.RenderableInstance.attachToRenderer(RenderableInstance.java:81)
at com.google.ar.sceneform.Node.activate(Unknown Source)
at com.google.ar.sceneform.Node.updateActiveStatusRecursively(Unknown Source)
at com.google.ar.sceneform.Node.setEnabled(Unknown Source)
at com.techaffinity.arroutertroubleshoot.augmentedImage.HighlightNode.setVisible(HighlightNode.java:65)
at com.techaffinity.arroutertroubleshoot.augmentedImage.ModelNode.setChildVisible(ModelNode.java:69)
at com.techaffinity.arroutertroubleshoot.augmentedImage.ARTroubleshootActivity.yesPressed(ARTroubleshootActivity.java:178)
at com.techaffinity.arroutertroubleshoot.augmentedImage.ARTroubleshootActivity.lambda$TWxn4Gt1IyJ444bAiIcNiVnU0ng(ARTroubleshootActivity.java)
at com.techaffinity.arroutertroubleshoot.augmentedImage.-$$Lambda$ARTroubleshootActivity$TWxn4Gt1IyJ444bAiIcNiVnU0ng.onClick(lambda)
at android.view.View.performClick(View.java:5640)
at android.view.View$PerformClick.run(View.java:22455)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6165)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)
crash occurs at onUpdateFrame method at
node.setRenderable(viewRenderableCF);
arFragment.getArSceneView().getScene().addChild(node);
where 'viewRenderableCF' is CompletableFuture of type ViewRenderable
I am currently overcoming this problem by calling System.exit(0) in ondestroy() method.
Is there any better way to do this(clearing app from memory like swiping away the app preview in recent apps list)?
or
Is there any code related to arcore to clear out the instance of SceneView?
try call this onDestroy/OnPause
arFragment.getArSceneView().getScene().onRemoveChild(node);
Making the CompletableFuture null in the onDestroy() callback of the activity solves the problem. Even after the finish method is called the CompletableFuture of type ViewRenderable is still in the memory. When I go to the same activity again, the ViewRenderable is created from the old CompletableFuture. This is also the case for CompletableFuture of type ModelRenderable but for reasons I don't know, setting modelrenderable to the node doesn't cause this crash.

Set OnePlus 3t alert slider to all/vibrate/silent

I have a OnePlus 3t running on OOS Open Beta 15, Android 7.1.1. I want its alert slider to put my phone into all sounds/vibration only/silent mode respectively. After trying every possible combination of third party apps and Tasker profiles, I started looking into creating my own Magisk Module to change the slider's behavior.
I found out that all the alert slider logic is inside the package com.oneplus.threekey. Using
adb shell 'pm list packages' > C:\packages.txt
I go a list of all my installed packages and the only packages containing the word "oneplus" are the following ones:
package:com.oneplus
package:com.oneplus.aod
package:com.oneplus.applocker
package:com.oneplus.calculator
package:com.oneplus.camera
package:com.oneplus.camera.service
package:com.oneplus.config
package:com.oneplus.deskclock
package:com.oneplus.dirac.simplemanager
package:com.oneplus.gallery
package:com.oneplus.iconpack.dives
package:com.oneplus.iconpack.o2default
package:com.oneplus.iconpack.rifon
package:com.oneplus.ifaaservice
package:com.oneplus.opbackup
package:com.oneplus.opbugreport
package:com.oneplus.opbugreportlite
package:com.oneplus.oplocationservice
package:com.oneplus.screenshot
package:com.oneplus.sdcardservice
package:com.oneplus.security
package:com.oneplus.setupwizard
package:com.oneplus.simcontacts
package:com.oneplus.skin
package:com.oneplus.sms.smscplugger
package:com.oneplus.soundrecorder
package:com.oneplus.wallpaper
package:com.oneplus.wifiapsettings
After no getting anywhere this way, I decided to look further into my logcat output. Filtering it using "threekey" this is the output everytime I change the alert slider's position:
10-03 00:00:53.223 1407-1872/? D/ThreeKeyHw: OEM UEVENT: {SUBSYSTEM=switch, SEQNUM=11574, ACTION=change, SWITCH_STATE=3, SWITCH_NAME=tri-state-key, DEVPATH=/devices/virtual/switch/tri-state-key}
10-03 00:00:53.227 1407-1407/? D/ThreeKeyAudioPolicy: set mode ring, mVibrateFlag=false, mMuteMediaFlag=true
10-03 00:00:53.231 1407-1407/? D/ZenModeHelper: setConfigLocked reason=ThreeKeyAudioPolicy
java.lang.Throwable
at com.android.server.notification.ZenModeHelper.setConfigLocked(ZenModeHelper.java:706)
at com.android.server.notification.ZenModeHelper.setManualZenMode(ZenModeHelper.java:543)
at com.android.server.notification.ZenModeHelper.setManualZenMode(ZenModeHelper.java:503)
at com.android.server.notification.NotificationManagerService$5.setZenMode(NotificationManagerService.java:2193)
at android.app.NotificationManager.setZenMode(NotificationManager.java:422)
at com.oneplus.threekey.ThreeKeyAudioPolicy.setRing(ThreeKeyAudioPolicy.java:177)
at com.oneplus.threekey.ThreeKeyAudioPolicy.setDown(ThreeKeyAudioPolicy.java:87)
at com.oneplus.threekey.ThreeKey.setDown(ThreeKey.java:46)
at com.oneplus.threekey.ThreeKeyBase.setSwitchState(ThreeKeyBase.java:54)
at com.oneplus.threekey.ThreeKeyBase$ThreeKeyBroadcastReceiver.onReceive(ThreeKeyBase.java:80)
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:1163)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at com.android.server.SystemServer.run(SystemServer.java:367)
at com.android.server.SystemServer.main(SystemServer.java:237)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
10-03 00:00:53.298 2002-2087/? I/vol.VolumeDialogControl: s updateZenModeW zen:0 threeKeySatus:3 mVibrateWhenMute:0
10-03 00:00:53.300 1407-1407/? D/ThreeKeyAudioPolicy: settings change selfChange=false uri=content://settings/global/zen_mode
10-03 00:00:53.301 1407-1407/? D/ThreeKeyAudioPolicy: zen mode was changed, zen mode=ZEN_MODE_OFF, three key status=3
10-03 00:00:53.302 2002-2087/? I/vol.VolumeDialogControl: s updateZenModeW zen:0 threeKeySatus:3 mVibrateWhenMute:0
10-03 00:00:53.306 2002-2002/? D/VolumeUI: mZenModeObserver:zenMode=3, threeKeyStatus=3, mLastThreeKeyStatus=2
10-03 00:00:53.314 2002-2002/? D/VolumeUI: mZenModeObserver:zenMode=3, threeKeyStatus=3, mLastThreeKeyStatus=3
Here I noticed in the Throwable part that the threekey class/service (I don't really know what that is tbh) calls setZenMode, which seems to be responsible for the notification sounds. But as it turns out the setZenMode method is not documented at Android Developers and can't be called after obtaining an instance of the NotificationManager class.
At this point I am beginning to run out of ideas what to try next or where else to look. Any help to get the slider to work like it used to would be great!

Categories

Resources