How to get android device properties - android

how can i get android device's platformId,deviceUser,deviceName,deviceModel, deviceOperatingSystem,deviceOSVersion from my program.
Edit: i have already used that Build class and got device id, model and user but for my requirement i need device OS, OS version and platform id.so how can i get them??
thanks
venu

Use android.os.Build.

Here's an example:
StringBuffer buf = new StringBuffer();
buf.append("VERSION.RELEASE {"+Build.VERSION.RELEASE+"}");
buf.append("\nVERSION.INCREMENTAL {"+Build.VERSION.INCREMENTAL+"}");
buf.append("\nVERSION.SDK_INT {"+Build.VERSION.SDK_INT+"}");
buf.append("\nFINGERPRINT {"+Build.FINGERPRINT+"}");
buf.append("\nBOARD {"+Build.BOARD+"}");
buf.append("\nBRAND {"+Build.BRAND+"}");
buf.append("\nDEVICE {"+Build.DEVICE+"}");
buf.append("\nMANUFACTURER {"+Build.MANUFACTURER+"}");
buf.append("\nMODEL {"+Build.MODEL+"}");
Complete android.os.Build documentation is at http://developer.android.com/reference/android/os/Build.html
Note that VERSION.SDK is marked as deprecated, so VERSION.SDK_INT was used instead.

Extending to what CommonsWare suggested, I think here's what you need:
Build.VERSION_CODES: Enumeration of the currently known SDK version codes. These are the values that can be found in SDK. Version numbers increment monotonically with each official platform release.
DONUT : Constant Value: 4 (0x00000004)
ECLAIR : Constant Value: 5 (0x00000005)
ECLAIR_0_1 : Constant Value: 6 (0x00000006)
ECLAIR_MR1 : Constant Value: 7 (0x00000007)
FROYO : Constant Value: 8 (0x00000008)
GINGERBREAD : Constant Value: 9 (0x00000009)
Build class: Information about the current build, extracted from system properties.
Build.MODEL
Build.PRODUCT
Build.VERSION:
Various version strings.
Build.VERSION.RELEASE
Build.VERSION.SDK_INT

Related

AndroidKeyStore no such provider

I'm just trying to get a basic example of the Android Key Store system to generate a symmetric key. I followed the example in the tutorial (using Kotlin) but I get an error like so:
java.security.NoSuchProviderException: no such provider: AndroidKeyStore
Below is my code where the compiler is throwing an error:
val kpg: KeyGenerator = KeyGenerator.getInstance("DES", "AndroidKeyStore")
On my Gradle, I am using compileSdkVersion and targetSdkVersion to 28. I'm also have a minSdkVersion of 25. All of which should satisfy the Android's doc on using the AndroidKeyStore (min API level 18).
If I remove the provider, everything works like planned, since I'm assuming it goes to the default provider. The same goes for the KeyPairGenerator and KeyStore classes when I try the AndroidKeyStore provider.
Am I using the wrong provider keyword? Or is there some additional setup that I'm supposed to be doing?
Thanks,
Update 1 - So I kept searching and found that you can get a list of available providers on my system. Here's my code below:
for (p in Security.getProviders()) {
//Log.d(TAG, String.format("== %s ==", p.getName()))
println(String.format("== %s ==", p.getName()))
println(String.format("%s", p.info))
// for (s in p.getServices()) {
// //Log.d(TAG, String.format("- %s", s.getAlgorithm()))
// println(String.format("- %s", s.getAlgorithm()))
// }
}
Also, the results match what's in my $JAVA_HOME/jre/lib/security.java.security file:
security.provider.1=sun.security.provider.Sun
security.provider.2=sun.security.rsa.SunRsaSign
security.provider.3=sun.security.ec.SunEC
security.provider.4=com.sun.net.ssl.internal.ssl.Provider
security.provider.5=com.sun.crypto.provider.SunJCE
security.provider.6=sun.security.jgss.SunProvider
security.provider.7=com.sun.security.sasl.Provider
security.provider.8=org.jcp.xml.dsig.internal.dom.XMLDSigRI
security.provider.9=sun.security.smartcardio.SunPCSC
security.provider.10=apple.security.AppleProvider
So I guess my option is to add the AndroidKeyStore provider to this. I'll update this when I've tried that.
I found out that there's a bug at the moment with using the AndroidKeyStore with unit tests, which I didn't mention in my original question.
See here:
https://github.com/robolectric/robolectric/issues/1518

Titanium Hyperloop access to android.os.SystemProperties

I have been trying a ( i hope) simple bit of Android hyperloop code directly within a titanium project (using SDK 7.0.1.GA and hyperloop 3).
var sysProp = require('android.os.SystemProperties');
var serialNumber = sysProp.get("sys.serialnumber", "none");
But when the app is run it reports
Requested module not found:android.os.SystemProperties
I think this maybe due to the fact that when compiling the app (using the cli) it reports
hyperloop:generateSources: Skipping Hyperloop wrapper generation, no usage found ...
I have similar code in a jar and if I use this then it does work, so I am wondering why the hyperloop generation is not being triggered, as I assume that is the issue.
Sorry should have explained better.
This is the jar source that I use, the extraction of the serial number was just an example (I need access to other info manufacturer specific data as well), I wanted to see if I could replicate the JAR functionality using just hyperloop rather that including the JAR file. Guess if it's not broke don't fix it, but was curious to see if it could be done.
So with the feedback from #miga and a bit of trial and error, I have come up with a solution that works really well and will do the method reflection that is required. My new Hyperloop function is
function getData(data){
var result = false;
var Class = require("java.lang.Class");
var String = require("java.lang.String");
var c = Class.forName("android.os.SystemProperties");
var get = c.getMethod("get", String.class, String.class);
result = get.invoke(c, data, "Error");
return result;
}
Where data is a string of the system property I want.
I am using it to extract and match a serial number from a Samsung device that is a System Property call "ril.serialnumber" or "sys.serialnumber". Now I can use the above function to do what I was using the JAR file for. Just thought I'd share in case anyone else needed something similar.
It is because android.os.SystemProperties is not class you can import. Check the android documentation at https://developer.android.com/reference/android/os/package-summary.html
You could use
var build = require('android.os.Build');
console.log(build.SERIAL);
to access the serial number.

Select android os name based on version number

First of all, nice day to everyone!
My code needs to detect which android version is being used on by means of getprop ro.build.version.release. I do so using systems with root and python for android.
For the time being the devices I tested the code things were working nice but partially of course because I haven't taking into consideration the updates in between new os versions. I just added the new version I was testing on to a dictionary.
So let's say I have this dictionary:
VersionName = {'4.0':"Ice Cream Sandwich", '4.0.4':"Ice Cream Sandwich", '4.1':"Jelly Bean", '4.2':"Jelly Bean", '4.3':"Jelly Bean", '4.4':"KitKat", '5.0':"Lollipop", '5.1':'Lollipop', '6.0':"Marshmallow", '7.1.1':"Nougat"}
I would add:
'4.4.2':'KitKat'
To save and detect the new version I was working on but that's not going to work. To overcome this I just simply made a search to select the first and the last release of an android version.
VersionName = {'Ice Cream Sandwich':['4.0', '4.0.4'], 'Jelly Bean':['4.1', '4.3.1'], 'KitKat':['4.4', '4.4.4'], 'Lollipop':['5.0', '5.1.1'], 'Marshmallow':['6.0', '6.0.1'], 'Nougat':['7.0', '7.1.1']}
The problems comes if the update version is in between the two values.
Given {'KitKat':['4.4', '4.4.4']} and device version 4.4.2 how can I detect if it's part of KitKat
maybe store the min and max as two variables, then do if os(version)> (min value):
then check if os(version) < (max value)
This is how I would approach the problem with the help provided! There are better ways I know that much so if anyone has another method please share.
def DroidName(ReleaseVersion):
# ReleaseVersion = '4.4.2'
VersionValue = {'Ice Cream Sandwich':['4.0', '4.0.4'], 'Jelly Bean':['4.1', '4.3.1'], 'KitKat':['4.4', '4.4.4'], 'Lollipop':['5.0', '5.1.1'], 'Marshmallow':['6.0', '6.0.1'], 'Nougat':['7.0', '7.1.1']}
for i in VersionValue.items():
AndroidName = i[0]
MinimalValue = i[1][0]
MaximunValue = i[1][1]
if ReleaseVersion >= MinimalValue and ReleaseVersion <= MaximunValue:
print AndroidName, ReleaseVersion
break

Titanium SDK 5.4.0.GA is showing too many logs at console on Android platform

did anyone notice that on Android - Ti SDK 5.4.0.GA is showing many output at console on all modes like Trace, Debug, Info, Warning, Error.
I have not tried it for Wi-Fi off state, but it is showing such lines every second when the device is connected to Wi-Fi and my console filled up with 100 lines in just few seconds:
[INFO] : D/StatusBar.MSimNetworkController( 1166): getNumberOfActiveSim:0
[INFO] : D/StatusBar.MSimNetworkController( 1166): getPhoneSignalIconList: mMaxLevelOfSignalStrengthIndicator = 4 inetCondition = 0
[INFO] : D/StatusBar.MSimNetworkController( 1166): getDataSignalIconId: mMaxLevelOfSignalStrengthIndicator = 4 inetCondition = 0 iconLevel = 4
[INFO] : D/StatusBar.MSimNetworkController( 1166): updateTelephonySignalStrength: iconLevel=4
Can anyone suggest any solution as this is getting quite annoying and I cannot focus on the console output from code due to too many above logs?
Update
Finally I found a solution to this problem:
https://github.com/appcelerator/titanium_mobile/pull/8754
Logs that contain a dot (or any other character besides letters) won't be caught in the don't show part!
The PR will change the RegEx rule to match any character.
Old solution:
Check the output of ti config cli.logLevel and set it to info
Might solve the problem for you.
I'm facing the same issue and I use monitor with this custom filter:
^(?!(WifiStateMachine|WIFI_UT|AppOps|GraphicsStats|RegisteredNfcid2Cache|Wifi|NotifUtils|WIFI|usbnet|Ethernet|FaceDetectTask|RecentsTaskLoadPlan|MorningBundlePlugin|SocialManagerService|PhoneApp|LoadDialerReceiver|Icing|Herrevad|Finsky|StatusBarManagerService|DropBoxEntryAddedChimeraService|ClearcutLoggerApiImpl|AlarmManager|GCoreUlr|GCoreFlp|APSAnalyticsService|QCNEJ|NetworkStats|IpReachabilityMonitor|Nfcid2RoutingManager|ls|WifiManager|libc|dex2oat|ACRA|HtcMirrorLinkAmsListener|LOWI-Scan|DownloadManagerWrapper|wpa_supplicant|QCALOG|WIFI_ICON|HtcWrapCustomizationManager|gdlights|PowerUtils|ExtremePowerSave|WifiService|FrameworkListener|MediaRouterServie|DotMatrix|PowerUI|PMS|XTCC-5.1.0.7|NetworkManagement|HtcPowerSaver|BatteryControlle|NetLinkSocketObs|WifiController|NetlinkSocketObs|BatteryService|UsbnetService|DeviceIdleControler|Keyboard.Facilit|xiaomi|qdlights|SensorService|AutoSetting|HtcWifiRssiMonitor|HtcWifiDataStallTracker|WifiAutoJoinController|HtcWLD_v5.1.0|WifiMonitor|WifiConfigStore|StatusBar.NetworkController|CwMcuSensor|BrcmNfcJni|DATA_ICON|TelephoneCallback|ContactMessageStore|HtcUPManager|ScreenOnOffReceiver|DeviceIdleController|QSPanel|NetworkPolicy|GpsLocationProvider|SensorManager|SmartNS_PSService|PhoneStatusBar|ScrimController|Settings|LocationManagerService|getVisibilityByRssi|NetworkController.WifiSignalController|GAv4|IntegrityChecker|KernelCpuSpeedReader|KernelWakelockReader|BatteryStatsImpl|WeatherUtility|WeatherTimeKeeper|PNP_UPDATERD|DsService|PathParser|StatusBarManagerServiceHtcASN_1.1|SignalClusterView|SIGNAL_ICON|HtcSystemUPManager|ConnectivityService|HtcASN_1.1|SignalClusterView|SIGNAL_ICON|HtcSystemUPManager|ConnectivityService|WSP|Babel|CityCodeHelper|TetherStatsReporting|TelephonyCallback))
Put this in by Log Tag in a new filter. My device is a HTC A9, a very log-noisy device!
If you still see rows you don't want to just put attach the tags with |tagname

android crypto implementation android 4.3

I am referring "Android crypto implementation" document. w.r.t Android 4.3 source.
In point 2 it says The framework starts up, and sees that vold.decrypt is set to "1"
But I am not able to locate the code that does things mentioned in point 2. Is anybody able to locate it? Is it somewhere related to class BackupRestoreConfirmation?
Just a simple git grep will get the all the reference to this property:
cmds/bootanimation/BootAnimation.cpp:276: property_get("vold.decrypt", decrypt, "");
services/java/com/android/server/DevicePolicyManagerService.java:1869: String state = SystemProperties.get("vold.decrypt");
services/java/com/android/server/SystemServer.java:239: String cryptState = SystemProperties.get("vold.decrypt");
services/java/com/android/server/usb/UsbDeviceManager.java:173: boolean dataEncrypted = "1".equals(SystemProperties.get("vold.decrypt"));
And I think the one you need is in DevicePolicyManagerService.java or SystemServer.java

Categories

Resources