Android development with no screen - android

I have a hobby android app idea that basically just uses Android's sensors and logs them long term for several days (external battery). The sensors needed are in $200 phones, and I can get ones for under $100 if the screen doesnt work.
My question is, is it pretty easy to make an app that starts and loads via debugging, keeps running when disconnected and when I connect I can extract the log file, or would this so be difficult I would be ahead just to spend the extra $100?

As mentioned, turning on USB debugging without the screen isn't possible. You can't enable USB debugging over USB for security reasons, so your only option would be to use hardware commands to put the device in firmware download mode (presumably it will have a way to do that), then load a custom OS which allows USB debugging by default.
Personally I think that's more than $100 worth of work, so I'd just go with the working device. Then you can use it for other stuff down the line.
Alternately, you can probably get a replacement screen for not too much, and for most devices changing the screen is relatively easy. I'd look into that option as well.

The first barrier you may find is that you must activate the Developer Options in the settings and the USB Debugging. And when you connect to the computer, you must accept that cumputer as the Debugger.
I don't know if it's possible to do it without a working screen.

App will keep running & yes you can can extract the log file when connecting again.
But the problem is in the first step. if your screen if not working, then how would you add your workstation as a trusted device in your "display not working device". I doubt if there is such way, because we need to do several things like switching on developer options, usb debugging etc.
I hope you got your answer.

Related

Android Management API - boot device when power is conncted

So, as the title describes, I'm looking for a way to boot an Android device when the power charger is connected. We are making dedicated devices, in kiosk mode, and are using the Android Management API to setup everything on the device.
This covers most of our requirements, like preinstalling apps, disabling everything else, hooking it up to Managed Google Play, getting device reports etc... But for this power thing, I can't find any solutions in the docs.
The problem is that the physical power button isn't accessible to the user (don't ask my why :)), and when the battery drains they have to be able to power it up again, without unscrewing the case to get to the physical button.
I know this can be done in different ways, but I can't find anything that would work with Android Management API. I'm looking at this "fastboot" approach, since it seems pretty simple https://source.android.com/devices/bootloader/unlock-trusty#off-mode-charging
Initially, I though I could run this somehow using the devices/issueCommand endpoint https://developers.google.com/android/management/reference/rest/v1/enterprises.devices/issueCommand, but that seems to support only some predefined commands like: LOCK, RESET_PASSWORD and REBOOT.
Maybe I'm just missing something. If someone has another approach in mind, please share.
If it's any help, we also have the Android Management API hooked up to the PubSub API, and a topic there that the pulls the reports of the devices. Theoretically, I could listed to the "power connected" event there, and run some command on the device. But again, the problem is how to run this command on the device remotely.
Maybe a solution would be to make another app that will run as a background process that runs this command. I guess I would need to add it as "receiverActivity" in the policy. But the same problem remains... how to invoke this activity from the Android Management API.
The bottom line is that this needs to be fully automated. Running this command on each device manually is not an option.
Also, worth mentioning, this is an Ionic app. Although it's probably not impossible, we would like to keep this logic outside of the app itself. Ideal solution would be just to run some adb command remotely using the Android Management API.
Or maybe there is a good 3rd party app that does this, and I could install that app in the policy and invoke it somehow.
All suggestions are welcome. Maybe there is a simple solution that I've missed.
UPDATE AFTER COMMENTS: I'm not looking how the actual app can do this. I'm looking for a way to execute some "native" command when the device is initially setup from the Android Management API policy. So it should execute only once. When it sets up everything initially. It should edit some file on the device (or run some command) to enable this feature. Later, it shouldn't care if the device is turned on or not, or what apps are running on it. There are a few different ways how to do this suggested here https://android.stackexchange.com/questions/20021/automatically-power-on-android-when-the-charger-is-connected. I'm looking for a way to trigger one of these commands when the device is setup initially (only once). In other words, this should execute only when the device is enrolled. It shouldn't care about any apps running on the device.
So the "free" way to do this is using the fastboot commands. But from the AMA API this is currently not (and most likely ever) possible. This problem will always be hardware specific, since the bootloader is controlling the boot process, and the bootloader is custom made for each device.
There are options for different manufacturers though. Look into OEMConfig apps (which you can get in the Play Store for Work or from the manufacturer themselves).
Samsung has it's KNOX API, and the paid ProKiosk mode supports controlling Power Control.
Regarding the post in your question solving the problem, you will not be able to modify any files in the system since that's restricted to root. This will also never work for Managed Devices.
You could "half-automate" the process by setting up a raspberry pi or some other device with a script that waits for fastboot devices to get connected and executing the command. That way you just visit every device and put it into fastboot and plug in the device and you're off to the next one.
For clarification: adb and fastboot are two entirely different things. Fastboot is running while the device is in it's bootloader. Adb is running while the device has started android. It should technically be not possible to execute fastboot commands while android is started since the bootloader has already exited.

How to debug remotely

I have a situation:
1. Samsung 7 has a strange bug in my app.
2. This device is 10000 miles away from me.
What are the opportunities for debugging this device remotely.
When tester on the other side can do everything.
I tried adb tcpip <port>
but device ip can be only local(192.168.....)
The rude way is to get Android Studio there and install team viewer on the phone. It's not working every time.
And when we have 1 hour intersection it's difficult to support.
Is there any other way?
Have your user enable Developer Options on the device. You should already know how to do that.
See whether the device has Take Bug Report and/or Bug Report Shortcut settings. If you enabled Bug Report Shortcut a Take Bug Report option will appear when pressing/holding the power button.
Instruct your user to take a bug report -- either through Developer Options, or from the power menu -- as soon as your app crashes.
As for the APK you send to your user, make sure debugging is enabled, so you get all your log messages. If you obfuscate the APK, be sure you keep your mapping files handy.
If you have some idea of where the bug is happening, an option could be to set up something like http://www.acra.ch/ and send your tester a new apk.
This way when the bug is provoked, given you set up useful log events, you will receive information about the crash or bug. ACRA lets you include the LogCat as well, which is pretty useful.
There are several options:
-Build APK and send it to the phone. Install and check/try again.
-Create Android Virtual Device identical to the model located remotely, install Samsung Android firmware.
There is no clear solution about debugging out of local network.
You could try something like LogmeIn for Android - this way both devices will be in the same network.
Once done, just do usual adb connect ipadress If t refuses to do so first, try enabling ADB over WiFi option

Debugging directly on the device

I don't expect you to correct my code, since it should be working, at least works on emulator. Unfortunately gives different output on the devices. My question is:
How to debug in such cases, when the device is not working as the emulator, and what could cause that (device model, a custom ROM?)
I heard some rumors some time ago, about possibility using the device instead an emulator somehow connected to the SDK. Could you also confirm or deny that?
You'll find it's not uncommon to find little quirks between devices. Many developers will have several physical devices to test their software on.
You can find information on using a physical device for debugging (including using it inside Eclipse, just as you would the emulator) on the Android website: http://developer.android.com/guide/developing/device.html
Yes you can do that. Just put your device into debugging mode, and connect it to the computer with the micro-usb port on the device. You will also need to download the drivers from the manufactures website.

Unable to work with Android on a Corporate Network with WPA/WPA2 security. Always disconnects?

My Nexus One (Gingerbread) and Samsung Galaxy Tab (Honeycomb) both stopped connecting to my corporate network that uses WPA/WPA2 wireless connections. What is strange is that, both the devices worked for at least 2-3 weeks before both of them (at different times) started going through a strange Scanning->Authenticating->Connecting->Disconnected phase. After the last phase, it shows Disabled, secured with 802.1x EAP.
Upon Googling, there seems to be a number of open tickets (e.g. here, here and at least 5 others) related to this problem. Because both my devices were working before this, I was wondering what could have gone wrong. Obviously, long-pressing on the wireless point and selecting Forget Network and then re-entering the network details is not helping so there must be some other way of doing this (possibly an application?). Any suggestions?
What I can do:
My Nexus One is rooted so I can probably delete any .conf files. The only problem is that my wpa_supplicant.conf does not have any connection specific information
What I cannot do:
Change anything related to the access point because it is not under my control. This problem is definitely a client-side problem from all the bug reports that I've read.
Finally, after two months of banging my head, here's a solution that worked for me.
The following assumes that your WiFi connection is not working but you have a data cable that you can use to transfer files. You may not have the exact screen as shown in the screenshots. That's because I am using a different ROM for my device but the overall steps will not change.
Step 1: Get an alternate WiFi configuration editor
I used WiFi Advanced Configuration Editor, which is an open source project available here. Install from the Android Market here
Step 2: Modify the WiFi settings
Open WiFi Advanced Configuration Editor
Select your WiFi network
Select Key Management
You will probably see that WPA_EAP and IEEE8021X are set to Enabled or ON. Let WPA_EAP stay as it is but turn off IEEE8021X. In the end, it should look like the following:
Hit the Back button on your device to go back one screen. DO NOT QUIT THE APPLICATION YET!
Step 3: Re-enter your password
In the screen that you selected Key Management from, select Enterprise Configuration.
Select Password and enter your password and hit OK to save it
Hit the Back button on your device three times to exit the application.
And that's it! If it works, congratulations and welcome to the bug-skipped bandwagon. If it didn't, sorry for taking your time. But hopefully, Google will fix this nasty bug soon.

How to set the Usb connection mode?

I'm writing an application which is supposed to dump data on the SD card and then another application on a pc which should read the data when the device is connected to the pc (in disc drive mode).
On my HTC Legend there is a dialog to choose between: Charge only, HTC Sync, Disk drive..
Is there a possibility to set the mode with which the device is connecting to the pc
or at least an intent to ask the user to switch the mode?
I haven't found a way of setting the mode programmatically, but I believe you can bring up the settings menu programmatically by invoking the same activity that the system invokes from the notification area. Unfortunately this appears to be manufacturer-specific: on my phone it is com.htc.android.psclient.SwitchUsbSettings.
On HTC devices, open the ConnectToPC service (whilst USB is not plugged in) in Manage Apps (ICS - probably applies to Gingerbread too; don't remember), and hit Clear Data. Then, plug the USB back again, and you should have the option to "Don't ask again" available. Select your desired mode, check the box, and accept.
CompanionLink does this when you request a USB sync in their android app: it flushes data to SD, then exports the SD as storage (a "disk drive") on the USB, then waits for the user to manually signal the android app when the PC is finished using the SD, and then undoes the SD export to USB again. Though the CompanionLink app can be very frustrating to use, at least this part of it is (largely) reliable.
Unfortunately I don't know the technical details, may well need to figure them out myself one of these months. If you can't get any traction with android docs, perhaps you could study what CompanionLink does on android to implement this. The sequence I describe above is when it is configured to sync over USB against a (PC-based) Palm Desktop.
As an aside, it appears that the reason for this highly-convoluted process is that the SD card's FS is accessed directly and at least the presently-used card FAT FS can only support a single client: the phone itself or USB. imo it would be extremely helpful if concurrent shared access to the SD were possible, but this would likely require deep android changes.
For anyone having this issue with an HTC One M8, this is a bit off the wall, but makes the point to think outside the box. A USB connection resulted in the device charging, that was it.
The solution was the combination of a different USB cable, uninstalling an application called Battery Doctor (which apparently likes to manage everything around your battery), AND USB Network Setting - turn ON Smart Network Sharing...Seemingly unrelated...but this combination got my connected with MobileGo for Android to manage and back up files,contacts and settings.
Hope this helps someone.
Yes .In Android there is a way to change the behaviour of the devices`s USB mode when the device is connected with the PC.
I used a Motorola Milestone[running 2.1] and i was able to switch between the following modes :
PC Suite[developed by Motorola],MemoryCardAccess and Charge alone.
If you need to access phone memory I think you should turn ON "USB Debugging Mode " in your device.Am not sure about it though,I feel it may be handy !!

Categories

Resources