Android - Audio Manager setSpeakerphoneOn - doesn't work on Huawei - android-audiomanager

Hy everybody,
I have a problem with Audio Manager on Huawei phones. I have an app, which can route the voice of calls to earpiece or loudspeaker from bluetooth headset during the call. It works fine on all of the phones except Huawei phones.
I added all permissons what is needed.
Anybody have similar situation?
<permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" android:protectionLevel="signature"/>
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.PROCESS_INCOMING_CALLS" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
This part of code does not do anything on Huawei. A tried try/catch, but no exception comes.
private static void switch_to_earpiece () {
m_amAudioManager = (AudioManager) fa.getSystemService(fa.AUDIO_SERVICE);
m_amAudioManager.setMode(AudioManager.MODE_IN_CALL);
m_amAudioManager.stopBluetoothSco();
m_amAudioManager.setBluetoothScoOn(false);
m_amAudioManager.setSpeakerphoneOn(false);
}

Related

How to start companion app on mobile from smartwatch using RemoteIntent

I have an android wear app, in which I want to have a continue on device button which launches the companion app on the mobile device.
When the App is already launched I can "restart" it using this Remote Intent.
How can I start the companion app from a standstill?
Intent intentAndroid = new Intent(Intent.ACTION_VIEW)
.addCategory(Intent.CATEGORY_BROWSABLE)
.setData(Uri.parse("myApplication"));
RemoteIntent.startRemoteActivity(context, intentAndroid, null);
Thanks in advance.
I finally figured it out.
I missed adding an intent filter in the android manifest for the activity I wanted to start.
For example:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myAppName" android:host="MainActivity" />
</intent-filter>
Then you can start it from the watch using:
Intent intentAndroid = new Intent(Intent.ACTION_VIEW)
.addCategory(Intent.CATEGORY_BROWSABLE)
.setData(Uri.parse("myAppName://MainActivity"));
RemoteIntent.startRemoteActivity(context, intentAndroid, null);

Android Things Rasperry PI GPS and Bluetooth Error

I am getting an error once I load my app in Android Things on Rasperry PI, it shows a message about "Bluetooth has stopped".
This happens just after registering the GPS Driver. it does not affect the functionality and it is only at the first time.
It has already some permissions in the xml
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="com.google.android.things.permission.MANAGE_GNSS_DRIVERS" />
<uses-permission android:name="com.google.android.things.permission.USE_PERIPHERAL_IO" />
Looks like it requires to switch the port to GPS or unregister Bluetooth first... By the way I am not using bluetooth feature in the app. any idea?
thanks
if (context.checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
Log.e(TAG, "No permission");
return;
}
try {
// Register the GPS driver
mGpsDriver = new NmeaGpsDriver(context, "UART0", UART_BAUD, ACCURACY);
mGpsDriver.register();
This is a known limitation of the Raspberry Pi, as per the pinout documentation:
The Raspberry Pi has pins that are multiplexed between various board functions. Some board functions cannot be used simultaneously (for example, enabling Bluetooth and using the UART0 port for peripheral I/O).
So there may be a process running in the background which is still using Bluetooth and causing the driver to crash.

Why is ...permission.C2D_MESSAGE added to my app?

My permissions are:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
but according to Google Play developer console, when I upload my apk, the following permissions are required by my app...
android.permission.ACCESS_NETWORK_STATE
android.permission.INTERNET
android.permission.READ_EXTERNAL_STORAGE
android.permission.WAKE_LOCK
android.permission.WRITE_EXTERNAL_STORAGE
com.android.vending.BILLING
com.google.android.c2dm.permission.RECEIVE
com.myapp.appname.permission.C2D_MESSAGE
Why are wake lock, and messaging added to my app by default? Is it because I've added facebook activity/support for sharing/liking?
This did not happen when I first used Eclipse, but now that I moved it to Android Stuido it occurs.
It doesn't appear to be documented but when you add firebase to an app, these permissions are automatically added to your app:
see https://www.reddit.com/r/androiddev/comments/4kobvm/admob_firebase_and_extra_permissions/

Facebook Login AsyncTask #4 NullPointerException Crash On Launch

I've looked at 15 different threads relating to the issue I have and so far none of the solutions have worked for me. While I'm leaning towards it being an Android Manifest Configuration problem I can't seem to see or figure out what exactly I'm doing wrong there. So hoping an extra set of eyes and minds will help me out.
05-29 11:43:46.679 5265-5300/com.example.android.slidingtabsbasic E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #4
java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.containsKey(ConcurrentHashMap.java:781)
at com.facebook.internal.Utility.queryAppSettings(Utility.java:802)
at com.facebook.login.widget.LoginButton$1.run(LoginButton.java:509)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
It seems as though my app_id is returning null? Or something about a hash? I did the facebook Android Quick start and it mentioned hash stuff but I thought it was optional?
Here is my manifest.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.slidingtabsbasic"
android:versionCode="1"
android:versionName="1.0">
<!-- Min/target SDK versions (<uses-sdk>) managed by build.gradle -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application android:allowBackup="true"
android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:parentActivityName=".MainActivity"
android:label="#string/app_name">
<activity
android:name="com.facebook.LoginActivity"
android:theme="#android:style/Theme.Translucent.NoTitleBar"
android:label="#string/title_facebook_login"
/>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/app_id"/>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
The error changes up when I try on API 16 versus a more modern API, giving me AsyncTask #4 (for 16) and AsynTask #2 for (modern API).
Solved it by moving
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/>
outs side of Activity and still inside Application.

NServiceBus saga not handling messages on azure

I'm getting strange behavior of working NServiceBus sagas deployed on azure cloud service. They never get replied message, never wake up... although if it's deployed locally everything works fine, also sagas works correctly when it's on WebApi cloud service role...
public class EndpointConfiguration : IConfigureThisEndpoint, IWantCustomInitialization,
AsA_Worker, UsingTransport<AzureStorageQueue>
{
public void Init()
{
Feature.Disable<Gateway>();
Feature.Disable<SecondLevelRetries>();
Feature.Enable<TimeoutManager>();
Feature.Enable<Sagas>();
Configure.With()
.UsingContainer<AutofacContainerBuilder>()
.AzureConfigurationSource()
.AzureMessageQueue()
.QueuePerInstance()
.UseNHibernateSagaPersister()
.UseNHibernateSubscriptionPersister()
.UseNHibernateTimeoutPersister()
.UnicastBus();
}
}
that's my config for nsb
<configSections>
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
<section name="DBSubscriptionStorageConfig" type="NServiceBus.Config.DBSubscriptionStorageConfig, NServiceBus.NHibernate" />
<section name="NHibernateSagaPersisterConfig" type="NServiceBus.Config.NHibernateSagaPersisterConfig, NServiceBus.NHibernate" />
<section name="TimeoutPersisterConfig" type="NServiceBus.Config.TimeoutPersisterConfig, NServiceBus.NHibernate" />
</configSections>
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="Service.InternalMessages" Endpoint="service" />
<add Messages="Messages" Endpoint="service" />
</MessageEndpointMappings>
</UnicastBusConfig>
<DBSubscriptionStorageConfig>
<NHibernateProperties>
<add Key="connection.provider" Value="NHibernate.Connection.DriverConnectionProvider" />
<add Key="connection.driver_class" Value="NHibernate.Driver.SqlClientDriver" />
<add Key="connection.connection_string" Value="Data_Source;Connection Timeout=30;" />
<add Key="dialect" Value="NHibernate.Dialect.MsSql2008Dialect" />
<add Key="hbm2ddl.auto" Value="update" />
</NHibernateProperties>
</DBSubscriptionStorageConfig>
<NHibernateSagaPersisterConfig>
<NHibernateProperties>
<add Key="connection.provider" Value="NHibernate.Connection.DriverConnectionProvider" />
<add Key="connection.driver_class" Value="NHibernate.Driver.SqlClientDriver" />
<add Key="connection.connection_string" Value="Data_Source;Connection Timeout=30;" />
<add Key="dialect" Value="NHibernate.Dialect.MsSql2008Dialect" />
<add Key="hbm2ddl.auto" Value="update" />
</NHibernateProperties>
</NHibernateSagaPersisterConfig>
<TimeoutPersisterConfig>
<NHibernateProperties>
<add Key="connection.provider" Value="NHibernate.Connection.DriverConnectionProvider" />
<add Key="connection.driver_class" Value="NHibernate.Driver.SqlClientDriver" />
<add Key="connection.connection_string" Value="Data_Source;Connection Timeout=30;" />
<add Key="dialect" Value="NHibernate.Dialect.MsSql2008Dialect" />
<add Key="hbm2ddl.auto" Value="update" />
</NHibernateProperties>
</TimeoutPersisterConfig>
that's the configs that I'm using for persisters
NServiceBus.Hosting.Azure, NServiceBus.NHibernate, NServiceBus.Core, NServiceBus.Azure, NServiceBus all of v4.0.30319
I'm using AzureStorageQueue and also I'm sure that I have overridden ConfigureHowToFindSaga with proper ConfigureMapping and I'm replying message with all filed specified correctly...
I would be really appreciate for any ideas, thanks.
This will be an interesting one to figure out. I don't see anything obviously wrong.
So the symptoms are, it works locally (with the exact same config?) and it works when deployed in a webrole (are these the same saga's or different ones?).
Some background info on the latter: a webrole only differs from a worker role in that IIS is properly configured, that's it. This also means that in a webrole, your code is running in 2 places, in an IIS process and in the roleentrypoint process. So you may want to validate that you're actually hosting in a roleentrypoint (namespace NServiceBus.Azure.Hosting and not the default azure sdk one.)
If you're sure the initialisation is done in the right place, you may want to check if you get any errors in the azure logs?
If that doesn't give more detail, you can also enable intellitrace in your solution and download the traces to see what is going on in more detail.
And as a last option, you can also use windbg on the azure instance (RDP'd in) to debug in real time.
Hope any of the above helps!

Resources