[Q] Bluetooth Stack AIDL Reflection Methods - Android Q&A, Help & Troubleshooting

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.

Related

[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] NullPointerException when trying to access MainActivity from different class

Hi!
I am trying to develop an android app with a google map v2, location service and some control buttons.
But I don't want to put all these things inside one MainActivity class. So I thought I could split all the code into some more classes. The MainActivity shall controll all the GUI things and react on map or location events...
Now I have the following problem. Inside my onCreate I instanziate the additional classes:
Code:
// Preferences as singleton
pref = Prefs.getInstance(this.getApplicationContext());
pref.loadSettings();
// Set up the location
loc = new Locations(pref);
loc.setCallback(this);
map = new MyMap(pref);
It seems to work fine. But inside the MyMap class every time I start the app a null pointer exception is thrown. When I am calling MyMap() the following code will be executed:
Code:
[...]
private Prefs pref;
private GoogleMap mMap;
[...]
public MyMap(Prefs prefs) {
pref = (Prefs) prefs;
if (mMap == null) {
FragmentManager fmanager = getSupportFragmentManager();
mMap = ((SupportMapFragment) fmanager.findFragmentById(R.id.map)).getMap();
[...]
}
The line with the findFragmentById is the one that causes the exception.
If I write
Code:
SupportMapFragment f = ((SupportMapFragment) fmanager.findFragmentById(R.id.map));
f is allways null. But how can I access the fragments and view elements defined within my MainActivity?
It works if I put the code inside my MainAcitivity.
Every class extends "android.support.v4.app.FragmentActivity"
I tried to save the application context within my Prefs() class, so that I can access it from everywhere.
But I don't know how to use it inside my additional classes.
How to share the "R" across all my classes?
Can someone help me please?
Thank you very much!!
Thorsten
Are you having trouble adding a Map to a Fragment? If so, then you may take a look at this tutorial. I haven't tried it myself since I couldn't install Google Play Services on my development device. If it helps, do write back, as I am definitely going to try it myself soon.

[Q] Where I can get a specification on MT6288 (6589) chip pins?

Hi all.
I'm looking at this part of MTK 6589 sources:
Code:
class AudioDigitalType
{
public:
enum Digital_Block {
// memmory interfrace
MEM_DL1,
MEM_DL2,
MEM_VUL,
MEM_DAI,
MEM_I2S, // currently no use
MEM_AWB,
MEM_MOD_DAI,
// connection to int main modem
MODEM_PCM_1_O ,
// connection to extrt/int modem
MODEM_PCM_2_O ,
// 1st I2S for DAC and ADC
I2S_OUT_DAC ,
I2S_IN_ADC ,
// 2nd I2S
I2S_INOUT_2 ,
// HW gain contorl
HW_GAIN1,
HW_GAIN2,
// megrge interface
MRG_I2S_OUT,
MRG_I2S_IN,
DAI_BT,
NUM_OF_DIGITAL_BLOCK,
NUM_OF_MEM_INTERFACE = MEM_MOD_DAI + 1
};
Where I can find a PDF datasheet on this chip to see more details on what these interface pins are, what are routes between them?

[Q] GPS in custom ROM using A20 SOC

Hello guys newbie warning
i am working on compiling my own android 4.2.2 system on an allwinner A20 SOC, my problem comes when i try to enable an external usb based (ttyUSB1) GPS which gives an error in logcat of "no AGPS interface in agps_data_conn_open" which i have tracked back to the com_android_server_location_GPSLocationProvider.cpp which is located in directory framework/base/services/jni/
1. i have tested the drivers provided by the vendor and they are working
2. further when i unplug the usb driver it gives a warning of missing hardware of gps therefore i know that my gps is detected atleast
3. i haved check my gps.conf to make sure i am using the right settings according to my area
below is the exact area which gives an error in the above mentioned cpp file
Code:
static void android_location_GpsLocationProvider_set_agps_server(JNIEnv* env, jobject obj,
jint type, jstring hostname, jint port)
{
if (!sAGpsInterface) {
ALOGE("no AGPS interface in agps_data_conn_open");
return;
}
const char *c_hostname = env->GetStringUTFChars(hostname, NULL);
sAGpsInterface->set_server(type, c_hostname, port);
env->ReleaseStringUTFChars(hostname, c_hostname);
}
p.s. static const AGpsInterface* sAGpsInterface;

Build can’t find dependency injection from Foursquare library in Graddle

Hello guys: I’m using the next scenario for Android native applications development:
Android Studio 3.6.2
Graddle plugin 3.6.2
Graddle version 5.6.4
Kotlin version 1.3.61
When I make this dependency injection in my build.graddle
Implementation 'com.foursquare:foursquare-android-oauth:1.1.0'
The next class: android.net.ConnectivityManager
can’t be found in the build process. Or at least it hasn't the expected properties.
I have implemented the next method to detect internet connection:
package com.example.ejoauth.networkconnection
import android.content.Context
import android.net.ConnectivityManager
import android.net.NetworkCapabilities
class NetworkConnectionStatus {
companion object {
// This code depends on the target SDK version
fun isInternetAvailable(context: Context): Boolean {
var result : Boolean = false
val connectivityManager: android.net.ConnectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as android.net.ConnectivityManager
val network : android.net.Network = connectivityManager.activeNetwork ?: return false // <---- Error
val nwCap : android.net.NetworkCapabilities = connectivityManager.getNetworkCapabilities(network) ?: return false // <---- Error
result = when {
nwCap.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> true
nwCap.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> true
nwCap.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> true
else -> false
}
return result
}
}
}
In build process, the next errors are thrown (only appears after "Foursquare" dependency injection)
D:\clcwork\kotlin\EjOauth\app\src\main\java\com\example\ejoauth\networkconnection\NetworkConnectionStatus.kt: (15, 69): Unresolved reference: activeNetwork D:\clcwork\kotlin\EjOauth\app\src\main\java\com\example\ejoauth\networkconnection\NetworkConnectionStatus.kt: (16, 79): Unresolved reference: getNetworkCapabilities
It seems like "Foursquare" libraries overwrite some clases or packages with another implementation in which attributes or methods are lost. The only solution I have found so far is not implementing this method “NetworkConnectionStatus.isInternetAvailable”. But this is not a solution. As you can see, I'm indicating packages explicitly in my code.
Can you help me, please?
Thank you in advance.

Categories

Resources