How to obtain Firmware version of Android programmatically? - android

The following screenshot of a generic tablet shows an example of Firmware version:
We have tried pretty much everything of Android Build, none of them is the firmware version.

Firmware is the operating software available on an Android device, and it is available in different versions designed by different manufacturers. Basically it's the device-specific part of the software. For example, you may have Android 4.2.2 running on your phone, but have a firmware number that looks completely different because it relates to more details than just Operating System. The firmware number consists of several elements, all of which are essential for the functioning of the phone:
PDA: Android operating system and your customizations.
Phone: the actual identifier of your device.
CSC (Country Exit Code): the languages and country-specific parameters.
Bootloader: the boot loader program that runs at startup to all unit processes.
Software Build Version is basically the Firmware Version.
See android.os.Build.VERSION. SDK or SDK in contain the API version. android.os.Build.VERSION_CODES contains the relevant constants.
String deviceSoftwareVersion=telephonyManager.getDeviceSoftwareVersion();
Refer to this Build.VERSION
Procedure to use it in code.
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD) {
// only for gingerbread and newer versions
}
This can be also checked by through code
System.out.println("button press on device name = "+android.os.Build.MODEL +" brand = "+android.os.Build.BRAND +" OS version = "+android.os.Build.VERSION.RELEASE + " SDK version = " +android.os.Build.VERSION.SDK_INT);
UPDATE
Try this one -
android.os.Build.FINGERPRINT
android.os.Build.BOARD
Build.HOST
Build.ID
Build.SERIAL
Check the following Code.
FINAL UPDATE
String mString = "";
mString.concat("VERSION.RELEASE {" + Build.VERSION.RELEASE + "}");
mString.concat("\nVERSION.INCREMENTAL {" + Build.VERSION.INCREMENTAL + "}");
mString.concat("\nVERSION.SDK {" + Build.VERSION.SDK + "}");
mString.concat("\nBOARD {" + Build.BOARD + "}");
mString.concat("\nBRAND {" + Build.BRAND + "}");
mString.concat("\nDEVICE {" + Build.DEVICE + "}");
mString.concat("\nFINGERPRINT {" + Build.FINGERPRINT + "}");
mString.concat("\nHOST {" + Build.HOST + "}");
mString.concat("\nID {" + Build.ID + "}");
((TextView) findViewById(R.id.textView1)).setText(mString);
You can also useBuild.DISPLAY
A build ID string meant for displaying to the user

I used following code to get firmware version of my device:
public String getFirmwareVersion() {
try {
Class cls = Class.forName("android.os.SystemProperties");
Method method = cls.getMethod("get", String.class);
method.setAccessible(true);
return (String) method.invoke(cls, FIRMWARE_VERSION_PROPERTY);
} catch (Exception e) {
return null;
}
}
As FIRMWARE_VERSION_PROPERTY I used "ro.product.version"
I've got this property address from the device manufacturer.
This address can vary for different devices and manufacturers, so it's advisable to contact manufacturer's tech support to get the correct one.

Related

String objects with various Hyperlinks in Textview?

I have a String objects that contain hyperlinks which I'm trying to make clickable in a Textview, here's an example:
String descrption = "\"Cardano is a decentralised platform" +
" that will allow complex programmable transfers of" +
" value in a secure and scalable fashion. It is one" +
" of the first blockchains to be built in the highly" +
" secure Haskell programming language. Cardano is developing" +
" a smart contract platform" +
" which seeks to deliver more advanced features than any protocol previously developed." +
" It is the first blockchain platform to evolve out of a scientific philosophy and a research-first driven approach." +
" The development team consists of a large global collective of expert engineers and researchers.\\r\\n\\r\\n" +
"The Cardano project is different from other blockchain projects as it openly addresses the need for regulatory oversight whilst maintaining" +
" consumer privacy and protections through an innovative software architecture.";
TextView textView = findViewById(R.id.description_textview);
Linkify.addLinks(textView, Linkify.WEB_URLS);
But this is how it comes out:
How can I get the hyperlinks to format correctly?
I've managed to get it working with the following code:
descrption= descrption.replaceAll("\\r\\n", "<p>");
Spanned spanned= Html.fromHtml(descrption);
textView .setText(spanned);
textView.setMovementMethod(LinkMovementMethod.getInstance());

PJSIP Android TLS --Unable to generate suitable Contact header for registration: Unsupported transport (PJSIP_EUNSUPTRANSPORT)

I am trying to make call using pjsip TLS in android.As per pjsip guidelines i built the pjsip library with openssl commands.
I have included following in my config_site.h
define PJSIP_HAS_TLS_TRANSPORT 1
define PJ_HAS_SSL_SOCK 1
I can see while building the library OpenSSL included.
OpenSSL library found, SSL support enabled
I sucessfully created TLS transportusing below command
ep.transportCreate(pjsip_transport_type_e.PJSIP_TRANSPORT_TLS,
sipTpTLSConfig);
I can see TLS Listener started on my local ip address.
But when i try to register it gives me error
Unable to generate suitable Contact header for registration:
Unsupported transport (PJSIP_EUNSUPTRANSPORT)
Java Code
String sipid = sipURI + username + "#" + switch_ip + ":" + switch_port;
String registrar = sipURI + switch_ip + ":" + switch_port+addTransportTLS;
String proxy = sipURI + switch_ip + ":" + switch_port;
AccountConfig accCfg = new AccountConfig();
accCfg.setIdUri(sipid);
accCfg.getRegConfig().setRegistrarUri(registrar);
accCfg.getRegConfig().setRetryIntervalSec(60);
accCfg.getNatConfig().setIceEnabled(false);
app.addAcc(accCfg);
I did the following as per pjsip docs and added ;transport=tls to my registrar address. But I still get this error.
Registration of sip account should be done as code below shows. Also, you have to set port in TransportConfig by setting sipTpTLSConfig.setPort(your_sip_port);
AccountConfig accCfg = new AccountConfig();
accCfg.getSipConfig().getProxies().add("sip:" + your_sip_server_host + ";hide;transport=tls");
accCfg.setIdUri("sip:" + your_sip_username + "#" + your_sip_domain);
accCfg.getRegConfig().setRegistrarUri("sip:" + your_sip_domain);
AuthCredInfoVector creds = accCfg.getSipConfig().getAuthCreds();
creds.add(new AuthCredInfo("Digest", "*", your_sip_username, 0, your_sip_password));
app.addAcc(accCfg);
You can keep your code for setting registration interval and disable ice.
I was facing the same issue in a iOS app we are developing today. I found that I was 'cause we were using TCP as transport, but UDP was the right network transport to use with my Asterisk.
So, I just used UDP instead of TCP and everything worked fine.
Good luck!

How to get the device Model Name? [duplicate]

This question already has answers here:
Get Android Phone Model programmatically , How to get Device name and model programmatically in android?
(16 answers)
Closed 6 years ago.
How to get the device model name ? I have a Yuphoria 5010 which displays YU5010 in device Model Number, I want to fetch the full name of the device? I want the fetch the exact string given below:
Yuphoria 5010 6.0 Marshmallow
It was really simple, just call:
String model = Build.MODEL;
Update: This code will print the exact string you requested:
String reqString = Build.MANUFACTURER
+ " " + Build.MODEL + " " + Build.VERSION.RELEASE
+ " " + Build.VERSION_CODES.class.getFields()[android.os.Build.VERSION.SDK_INT].getName();
Prints:
Samsung Note 4 6.0 MARSHMALLOW
LGE LG-D410 4.4.2 KITKAT
On many popular devices the market name of the device is not available. For example, on the Samsung Galaxy S6 the value of Build.MODEL could be "SM-G920F", "SM-G920I", or "SM-G920W8".
So for getting full device name you can use a library which is available on github . Link of AndroidDeviceLibrary is here https://github.com/shubhamsharmacs/AndroidDeviceNames
Now how to use these library :-
put these in your build.gradle file
compile 'com.jaredrummler:android-device-names:1.0.9'
Now these operations are :
Get the name of the current device:
String deviceName = DeviceName.getDeviceName();
The above code will get the correct device name for the top 600 Android devices. If the device is unrecognized, then Build.MODEL is returned. This can be executed from the UI thread.
Get the name of a device using the device's codename:
// Retruns "Moto X Style"
DeviceName.getDeviceName("clark", "Unknown device");
Get information about the device:
DeviceName.with(context).request(new DeviceName.Callback() {
#Override public void onFinished(DeviceName.DeviceInfo info, Exception error) {
String manufacturer = info.manufacturer; // "Samsung"
String name = info.marketName; // "Galaxy S7 Edge"
String model = info.model; // "SAMSUNG-SM-G935A"
String codename = info.codename; // "hero2lte"
String deviceName = info.getName(); // "Galaxy S7 Edge"
// FYI: We are on the UI thread.
}
});
The above code loads JSON from a generated list of device names based on Google's maintained list. It will be up-to-date with Google's supported device list so that you will get the correct name for new or unknown devices. This supports over 10,000 devices.
This will only make a network call once. The value is saved to SharedPreferences for future calls.
You can get the device details by using the below code.
String s="Debug-infos:\n";
s += "OS Version: " + System.getProperty("os.version") + "(" + android.os.Build.VERSION.INCREMENTAL + ")\n";
s += "OS API Level: " + android.os.Build.VERSION.RELEASE + "(" + android.os.Build.VERSION.SDK_INT + ")\n";
s += "Device: " + android.os.Build.DEVICE + "\n";
s += "Model (and Product): " + android.os.Build.MODEL + " ("+ android.os.Build.PRODUCT + ")\n";
USe this code for get device Model
import android.os.Build;
String deviceModel = Build.MODEL;
if you want get this info in android 6.0 Marshmellow so before this get info give the run time permission
Manifest.permission.READ_PHONE_STATE

EXTRA_AVAILABLE_VOICES always returns eng-GBR only. Why?

I am using the following snippet to log all available (and unavailable) voices currently on phone:
ArrayList<String> availableVoices = intent.getStringArrayListExtra(TextToSpeech.Engine.EXTRA_AVAILABLE_VOICES);
String availStr = "";
for (String lang : availableVoices)
availStr += (lang + ", ");
Log.i(String.valueOf(availableVoices.size()) + " available langs: ", availStr);
ArrayList<String> unavailableVoices = intent.getStringArrayListExtra(TextToSpeech.Engine.EXTRA_UNAVAILABLE_VOICES);
String unavailStr = "";
for (String lang : unavailableVoices)
unavailStr += (lang + ", ");
Log.w(String.valueOf(unavailableVoices.size()) + " unavailable langs: ", unavailStr);
The logged result is somehwat bewildering, since I know beyond certainty that I have multiple languages installed and I can even hear the TTS speaking in eng-USA, yet the log shows:
1 available langs: eng-GBR,
30 unavailable langs: ara-XXX, ces-CZE, dan-DNK, deu-DEU, ell-GRC,
eng-AUS, eng-GBR, eng-USA, spa-ESP, spa-MEX, fin-FIN, fra-CAN,
fra-FRA, hun-HUN, ita-ITA, jpn-JPN, kor-KOR, nld-NLD, nor-NOR,
pol-POL, por-BRA, por-PRT, rus-RUS, slk-SVK, swe-SWE, tur-TUR,
zho-HKG, zho-CHN, zho-TWN, tha-THA,
Why is this inconsistent behavior? (note that eng-GBR appears in both the available and unavailable lists...)
It turns out that as far as text-to-speech in Android 2.x goes, it's the wild west out there: Every and any installed 3rd-party TTS engine can modify the output of this EXTRA_AVAILABLE_VOICES function however they desire, regardless whether checked/unchecked or selected/unselected as default.
I just tried uninstalling all TTS engines from my phone, leaving only the hard-coded Pico, and the result match exactly what I expected:
6 available voices: deu-DEU, eng-GBR, eng-USA, spa-ESP, fra-FRA,
ita-ITA,
0 unavailable voices:
I don't mind the output of this function dynamically refer to the currently selected (i.e. default) TTS engine, but the fact is that once a 3rd party TTS engine is installed, this function's output doesn't make any sense, because it ignores any settings.
Also note that the name misleading: It's available languages, not voices!
I am posting this answer with the hope that it will help someone save the time & agony of discovering this the hard way.

Does Android TTS support Speech Synthesis Markup Language?

Passing the following SSML (Speech Synthesis Markup Language) document to the com.svox.pico TextToSpeech engine resulted in a reading of the XML body but no control from the phoneme element or the emphasis element. This result (no apparent SSML control) is the same on a Nexus One running Android 2.2 as well as on the emulator running an AVD with SDK level 8.
String text = "<?xml version=\"1.0\"?>" +
"<speak version=\"1.0\" xmlns=\"http://www.w3.org/2001/10/synthesis\" " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
"xsi:schemaLocation=\"http://www.w3.org/2001/10/synthesis " +
"http://www.w3.org/TR/speech-synthesis/synthesis.xsd\" " +
"xml:lang=\"en-US\">" +
"tomato " +
"<phoneme alphabet=\"ipa\" ph=\"t&#x259;mei&#x325;&#x27E;ou&#x325;\"> tomato </phoneme> " +
"That is a big car! " +
"That <emphasis> is </emphasis> a big car! " +
"That is a <emphasis> big </emphasis> car! " +
"That is a huge bank account! " +
"That <emphasis level=\"strong\"> is </emphasis> a huge bank account! " +
"That is a <emphasis level=\"strong\"> huge </emphasis> bank account!" +
"</speak>";
mTts.speak(text, TextToSpeech.QUEUE_ADD, null);
Does any Android TTS engine support any of the SSML elements?
I've been experimenting with SSML and it seems that the TTS engine wraps its input automaticly with the root <speak> element, so if you leave it out, then it works fine and you don't get a parser error.
Example:
String text = "Testing <phoneme alphabet=\"xsampa\" ph=\""{k.t#`\"/>.";
mTts.speak(text, TextToSpeech.QUEUE_ADD, null);
The answer seems to be "sort of". Not all the SSML tags are supported yet, but some test examples of the use of the <phoneme> tag are at https://android.googlesource.com/platform/external/svox/+/89292811b7fe82e5c14fa13942779763627e26db
Though the test examples produce the desired speech output, they also produce XML parser error messages in logcat. I've opened an issue about these seemingly incorrect error messages at the Android issue tracker (issue 11010).
It does appear that android.speech.tts at SDK level 23 supports a subset of SSML. Speech text can be wrapped in <speak> tags, and <say-as> is observed, while <break> is not. There is no documentation regarding SSML support.

Categories

Resources