[Q] USB connection - Gen8, Gen9, Gen10 Q&A, Help & Troubleshooting

Why we get this intent :
12-17 11:52:50.789: D/UsbDeviceSettingsManager(1989): usbDeviceAttached, sending Intent { act=archos.intent.action.USB_DEVICE_ATTACHED (has extras) }
instead Android API
android.hardware.usb.action.USB_DEVICE_ATTACHED
It was in HC and ICS also.
I don't remember what intent was in rooted ICS. It was short time before USB was broken.
Is it changes inside kernel possible for Google Android API standard?
Thanks,
Michael

ch_m said:
Why we get this intent :
12-17 11:52:50.789: D/UsbDeviceSettingsManager(1989): usbDeviceAttached, sending Intent { act=archos.intent.action.USB_DEVICE_ATTACHED (has extras) }
Click to expand...
Click to collapse
Nobody knows answer
Maybe someone knows answer to this question:
When we connect to USB it will
/dev/bus/usb/001/002
/dev/bus/usb/001/003 ....
If we disconnect and connect again It will not same !
It will be next
/dev/bus/usb/001/005
/dev/bus/usb/001/006 ...
If we will disconnect/ connect many times it maybe hudreds
I don't test it more that 999
because 3G USB connection not so well
If we do same in Linux it will connect to same device ...
Why is it differnt ?
Thanks,
Michael

Related

[Q] Why is my onboot broadcastreceiver activty being killed

Im new to android development, so probably be making al the old mistakes.
I created an app it runs fine.
I added an broadcast receiver to do some actions on boot of the device
On boot i want to write some data to the SDcard so ill have to wait for it to become ready.
This is how i tried to do it.
psuedo code/code snipet
Code:
public class bootActivity extends BroadcastReceiver
{
@Override
public void onReceive(final Context context, final Intent intent)
{
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction()))
{
new Thread()
{
@Override
public void run()
{
Log.d("TEST","starting");
for(;;)
{
Log.d("TEST","waitloop");
mc=Environment.getExternalStorageState();
try { Thread.sleep(10000); } catch(Exception ex) {}
if(mc.equals(Environment.MEDIA_MOUNTED)) break;
}
Log.d("TEST","do something");
// from here i write to sdcard...
}
}
}
}
In the emulator it works fine, with logcat i see
- D/TEST starting
- D/TEST waitloop (one or more)
- D/TEST do something
and the expected data gets writeen to the SDcard
On my real device i have problems, with logcat is see
- D/TEST starting
- D/TEST waitloop only once
- D/ActivityManager Kill hidden process PID: 333 with NAME test.test.test
Q1) Why is my broadcast activity being killed during boot
(and why does it work in the emulator and not on the real devices)
Q2) If case i'm doing everything wrong
What is the correct/better way to get the same result ?
First you'll want to confirm your process isn't crashing (look for a stack trace in your logcat view in Eclipse or on your phone using the alogcat app).
Besides that, Android is known to kill services if it runs low on memory. This is likely to happen during bootup when a lot of programs are run in sequence. By defining your service a certain way in your androidmanifest you can have the OS re-send intents if the service is killed. There's also a way to make your service a so called foreground service, which Android will think twice about killing. In either case, it's always safe to assume the OS may kill your service at any time so you'll have to pick up where you left off.
Hit up the reference on Services for more info.
- chris
Thanx for the heads up
I checked, my process is not crashing, (no stacktrace or any other errors in logcat)
I wil try to find out what to add to the manifest file
- to have the intents resend
- and how to get a higher dont kill me rank
Thanx
I redid my app doding the SDcard stuf in a service witch is reapplied/restarted if killed and start the service from the bootactivity.
It works fine

[Q] [ROOT] Embed 3th party activity in my Activity

Hi,
Please let me know if this is in the wrong sub-forum or not.
I'm developing an app, which should display the activity of another app (e.g. youtube) in its content.
I'm using the following code to get the activity of a 3th party application:
Code:
public View LoadActivity(String uniqueString) {
LocalActivityManager mgr = getLocalActivityManager();
Intent i = new Intent(this, SomeActivity.class);
Window w = mgr.startActivity("unique_per_activity_string", i);
View wd = w != null ? w.getDecorView() : null;
return wd;
}
However, due Security Restrictions, I'm receiving the following error:
java.lang.SecurityException: Requesting code from com.google.android.youtube (with uid 10065) to be run in process com.xxx.xxx.
Now i'm wondering if there is any way I can avoid this by rooting my device or doing some shell commands.
Regards,
XverhelstX

[Q] Bluetooth Stack AIDL Reflection Methods

I work at a small company that fields autonomous android devices which programmatically connect to bluetooth telemetry devices. These devices require pins, so we need to automatically create a pairing in order to connect to the bluetooth devices. We DO have root access.
Since the new Bluetooth Stack in Android 4.2, I have been unable to use this common AIDL bluetooth reflection method in our private utility app:
Code:
public IBluetooth getIBluetooth() {
IBluetooth ibt = null;
try {
Class c2 = Class.forName("android.os.ServiceManager");
Method m2 = c2.getDeclaredMethod("getService",String.class);
IBinder b = (IBinder) m2.invoke(null, "bluetooth");
Class c3 = Class.forName("android.bluetooth.IBluetooth");
Class[] s2 = c3.getDeclaredClasses();
Class c = s2[0];
Method m = c.getDeclaredMethod("asInterface",IBinder.class);
m.setAccessible(true);
ibt = (IBluetooth) m.invoke(null, b);
} catch (Exception e) {
}
return ibt;
}
The issue about this strategy no longer working is documented here. I previously used the setPin method as well as the createBond method from this Interface, and now I cannot.
Is there anyway to manually create a bluetooth pair profile under Android 4.2? Is there a database file where the profiles are stored that we can use root and sqlite3 to access?
Jelly Bean (Android 4.2) access to hidden methods.
I posted this on Stack Overflow:
http://stackoverflow.com/questions/14705167/how-connect-paired-bluetooth-a2dp-device-on-android-4-2-using-reflection/16003953#16003953
It explains how I got it working. This open source project:
http://code.google.com/p/a2dp-connect2/
Implemented this approach and it works on API 17. Mt project only accesses methods through IBluetoothA2dp and IBluetooth but others should work in a similar fashion.

[Q] Fatal Signal 11 when reading from MTP device

Firstly of all apologises if this is not the best place to ask a DEV question, but I have no access to the developer forum pages for Android.
My App is reading the images from Nikon camera plugged into the USB OTG port on a Samsung S4 phone running Android 4.2.2 (JDQ39.i9505xxubmea).
I am getting an Fatal signal 11 (SIGSEGV) at 0x74564000 (code=1), when trying to call getStorageIds in approx 1 in 10 attempts.
The biggest problem being I can't stop the app from crashing in the most undignified mannner.
In the LogCat I can see messages from the Android MtpDevice class, saying "readResponse failed" and "got response packet instead of data packet", however the mtpDevice open() still gives back a non-null value.
The whole block of code is wrapped up in a try/catch, but it as it appears to be an error in the native library rather than a Java exception, so unsurprisingly it's never thrown.
If can somehow detect that the device wasn't being read properly, then I could abort before calling the getstorageIds method. It has clearly found the device, as it reported the make/model and serial number of the camera.
Any ideas very much appreciated.
Thankyou
Code:
if (!mtpDevice.open(usbDeviceConnection)) {
tvStatus.setText("Open MTP device failed!");
return;
}
Log.d(TAG, "mtpDevice is open! " + mtpDevice.getDeviceName() );
MtpDeviceInfo info = mtpDevice.getDeviceInfo();
if (info == null) {
Log.d(TAG, "info is null!");
usbDeviceConnection.close();
mtpDevice.close();
return;
}
int[] storageIds = mtpDevice.getStorageIds(); // this where it stops![/QUOTE][/QUOTE]

Enable Bluetooth on Android VM

Hi everybody,
I have installed Android-x86 on a Virtual Box VM. I'm trying now to activate bluetooth capability on it.
I plugged-in my usb bluetooth dongle, I mounted it in my VM. Everything is ok so far.
On Android side, I can detect my dongle through the hciconfig and scan with it with hcitool.
The problem appears when I try to enable it in the graphic interface. It always shows me Bluetooth as off.
When I try to move the button on the right to activate it - nothing happens... It completely ignores my attitude.
It is also not possible to enable it through the applications: when an app asks me for an authorization to allow bluetooth, I authorize it to do so but it doesn't succeed.
The error I observe through the adb logs is as follows:
723338-01-21 11:02:23.948 1378 2327 D BluetoothManagerService: enable(com.android.systemui): mBluetooth =null mBinding = false mState = OFF
723474-01-21 11:02:23.948 1378 2327 D BluetoothManagerService: enable returning
723549-01-21 11:02:23.949 1378 1415 D BluetoothManagerService: MESSAGE_ENABLE(0): mBluetooth = null
723644:01-21 11:02:23.949 1378 1415 E BluetoothManagerService: Fail to bind to: Intent { act=android.bluetooth.IBluetooth }
But it doesn't help me much...
Please, if you have any idea how to solve this issue or progress in locating the problem, it would be great.
Thanks in advance for your time!

Categories

Resources