How to prevent USB connection in Android? - android

I have app in KioskMode. Cannot allow user to use usb connection to remove app. Want to make sure user cannot tamper with the app at all via USB. I want to detect if user has connected via USB to the device, and if they do not have the right permissions, terminate that connection. Or not allow connection in the first place for normal users. Detecting the connection seems possible, but dont see how to prevent or terminate the connection programatically. I have not found the API to do this.
UPDATE: changing debug mode programmatically does not appear to be an option for a non-system app, SO question is can the connection be detected and then terminated?

The adb commands are only accessible in debug mode. Disable USB-Debugging and you can't execute these commands anymore.

Related

How can I enable USB Debugging and WiFi on a locked phone?

I am on a Android 4.4 'HTC One SV' Phone. I don't know the password and it has asked me for google user and pass, but the wifi is turned off and im not sure if I know the password. USB Debugging is also off and I cant access settings since it is locked.
How can I turn wifi on through ADB with USB Debugging off and no way of accessing phone. ADB is not recognising the phone which I believe is because USB Debugging is off. Please help.
USB Debugging simply can't be enabled via root. Normally OEMs put a bypass such as swiping from the swype symbol to the letter S to open Google Now via Swype Keyboard. Also, this typically means the phone was stolen and the thief used the Recovery menu to format the device.

How to permanently disable wifi?

How to permanently disable WiFi, so the users won't be able turn it on again?
This is a requirement of the customer of our special Android base devices.
I have renamed files in /data/misc/wifi/.
Then it is impossible to turn on WiFi in Settings.
But after reboot it is still possible to turn on WiFi again.
I have just entered new settings for WiFi routers.
Thanks!
Root the device or Build a custom ROM so that you can permanently disable wifi easily... I hope you won't find a better solution....

adb can't find device after failing to connect through WiFi

Essentially, my problem is that I tried connecting my device to adb over Wifi, got to adb connect xxx.xx.xx.xxx but then adb claims that it was unable to connect to xxx.xx.xx.xxx:5555.
Ok, but now I'm having trouble getting it back to listening over USB. adb usb tells me that there isn't a device attached and adb devices gives me an empty list.
I've tried killing the adb server and then restarting it, toggling the device's debugging mode and toggling the device's USB storage transfer but nothing seems to be working. This question seems very similar to my problem but I have no idea what the guy is doing in the solution.
I'm guessing the problem is that adb is still trying to listen through Wifi but since I can't connect to it over Wifi it can never go back to listening to it over USB. Idk...
For wifi, you may be able to get it to work if you first use the browser on the device to visit a webpage or something and so effectively wake up the wifi radio and its connection to the access point. You may need to keep doing this every once in a while.
(Maybe you should listen to internet radio while you work?)
Of course your access point will have to permit peer-to-peer traffic on the local subnet. In many cases that may be the norm, but I believe an access point can be configured not to support that, and some may default to such settings. There can also be issues between wired and wireless subnets sourced from the same box.
Finally, restarting the device might get it back into USB mode.

I need to debug my Android app while not plugged into my computer

So, let me start off by saying that I am 'relatively' familiar and comfortable with making Android apps and using both LogCat and DDMS to debug.
That being said, I'm encountering more of a logistical issue than anything else right now - I am making a locative app, where the GPS is fuelling and controlling other methods in my Activity, and after a while, it is crashing.
Now, because it is locative, I am walking around to test it, in order to receive different GPS locations. Because of this, I am not connected to my computer at the time that it crashes, so have no way (that I know of) to read the stack trace, etc.
In my particular instance, I am navigating through a series of activities, and finally reach the penultimate screen in my app, and while I am running the application in my studio, it runs indefinitely without issue. It is only when I take the device outside that it crashes...
I am wondering if anyone has any tips or tricks with this issue - I'm sure give the prevalence of locative apps, it must have come up, but I cant seem to find the right search terms. It could be as simple as saving the LogCat to file, and/or the stackTrace, but I'm not sure that's the answer...
Thanks in advance.
If I got you right, this is what you are looking for:
https://play.google.com/store/apps/details?id=org.jtb.alogcat&hl=de
Edit: Also there are many more apps like this. You can just browse around in Google Play Store
You can debug the app without rooting your android, unlike the other responses. start off by plugging the android into your computer, then run adb devices to make sure the device is there. Then, run tcpip 5555 to change the android to tcp mode, which will allow debugging over wifi. Disconnect the android from the computer, and connect to it by typing adb 192.168.x.xxx, replacing the x's with your android's IP address. It should connect with no issues, as long as port 5555 is open, and both the android and your computer is on the same wifi.
Simple: Wireless ADB
One of the reason that I choose to run CyanogenMod on my testing devices is that it is a stripped down version of Android that has some additional developer tools, one of those being the ability to access the wireless portion of the ADB system.
As you are probably unaware, you are able to establish an ADB connection to your device over WiFi, however, if running a stock ROM, this requires root access, as it can be potentially harmful to your device, as Wireless ADB will work even over your cellular network, meaning that you could potentially receive apps from other insert carrier here's devices.
If you wish to run WirelessADB, here is a Play Store app that will help you to enable the feature on your device. Requires ROOT
It is as simple as connecting your device to your local WiFi network, (same one the development computer is connected to), enable Wireless ADB, and then running the following command on your computer:
adb connect 192.168.1.101
Replacing 192.168.1.101 with the IP address of your android device.
By establishing this connection, you can run everything just as you would if the device was plugged in via USB Cable.
I recommend ACRA (Application Crash Reports for Android ). It allows you to send crash reports to a number of different destinations. See https://github.com/ACRA/acra/wiki/BasicSetup

Put device into offline status in adb

I have desktop application communicating with Android devices via adb. Sometimes device goes to offline state and my program does not work. Now I am trying to make workaround for it by disabling and enabling usb port programatically, but unfortunatelly I can not test it, because devices still remains in online state...
Is there any possibility to enforce offline state of device?

Categories

Resources