Android Test Cases - Android Q&A, Help & Troubleshooting

I am starting my Master Thesis which is more or less focussed on Android development and testing. Right now my question is, say I have developed an android application and have certain users who are already using my application. Is there a way where in I can push my custom test cases only to a specific set of users. For example, I have 300 users, I want to send the test cases only to people who are using Android 5.0, or only to users residing in Europe something like that. I have tried searching for this over the internet but unfortunately wasn't successful.

in your app somewhere include line of code that checks what version the os is? something like this
Check android.os.Build.VERSION.
CODENAME: The current development codename, or the string "REL" if this is a release build.
INCREMENTAL: The internal value used by the underlying source control to represent this build.
RELEASE: The user-visible version string.
Click to expand...
Click to collapse
Code:
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD) {
// only for gingerbread and newer versions
}
and same with where user lives, just check whats user location is with some line of code
i got those from stackoverflow but im not allowed to post links so youll just have to google something like: android java check for android version

Related

[Q] AOSP and Android SDK

How does the AOSP and the Android SDK relate?
If I repo the AOSP do I by default now have the SDK?
Do I have to download it separately?
Or can I/Should I compile it from the AOSP?
I ask because after following the instructions up until: source.android.com/source/building.html. I successfully compiled full-eng and ran the emulator and everything works just fine. It also seems like adb is installed which from what I understand is a part of the SDK. I can't seem to find an answer to this.
So I am going to do my best at answering my own questions and posting for the benefit of anyone else who may be confused; if any of the statements I make are wrong feel free to correct me. This is just from my experience. There seems to be little information regarding how the two relate excepting the build/core/build-system.html, and sdk/docs/howto_build_SDK.txt included with AOSP and airtower.wordpress.com/2010/07/25/building-the-android-sdk/ and of course, trial and error.
NB: jindroid.com/2009/06/08/howto-build-sdk-from-android-source-code/ points to documentation that has since moved to the above location it seems. At least it wasn't there for me as of the most recent repo sync against master.
rpowell8 said:
How does the AOSP and the Android SDK relate?
Click to expand...
Click to collapse
The android SDK is a subset of the ADT (Android Developer Toolkit). The SDK as you download it today is basically just a few binarys for getting the actual content SDK.
I think the best way to describe the SDK is that it is divided into to parts tools, and libraries. The tools are for managing the sdk (tools/android) and misc tools to build apk's, align them, emulate an api etc, and then there are the tools in platform-tools which allow you to perform operations on your device (adb fastboot etc). The "libraries" are a set of API's , system images (file for running an android virtual device (emulator)), and documentation for each release of Android. These seem to reside under platform/
You can either download the above components from the command line, or from eclipse. Eclipse is actually included in the ADT as well with the plugin for android apps preloaded. If you don't have the plugin, you can get it vie Help/Install New Software. This launches what seems to be a front end for the android SDK Manager which allows you to graphically choose which platforms you want to support and emulate.
Now, how does the SDK (the tools and libraries) relate to the AOSP as you repo init/sync from the master repository? It seems you can't build apps from the code downloaded from the AOSP git repo (I'm not sure about this but doesn't seem like it). Instead, what you do, is you use the AOSP to build the SDK (NB: when you use the SDK Manager as mentioned above, you are getting prebuild SDKs, if you want to build the SDK yourself you use the AOSP code) as described in the above mentioned howto. Once the build for the Android SDK is complete it is located in out/host/linux-x86/sdk or similar directory. You can actually point the eclipse plugin to this directory as the location for the SDK...but I recommend using the .zip file that is in that directory and putting it somewhere other than the out directory. Reason being if you decide to do a lunch full-eng after you did the lunch sdk-eng, and then proceed to make, it will force a make cleaninstall and that will basically do a rm -rf on the out directory, deleting all of your SDK and any other platforms you downloaded through the sdk manager.
After you've built the sdk, you now have the necessary tools and API's to build for the platform you repo'd. A word of warning is that it seems if you repo the master branch, it is labeled as "AOSP" for the version indicating to Eclipse that the minimum platform required is the one you just built and so if you want to run it on your device you'll need the full platform loaded onto it or it will show you are running a version earlier than AOSP (also called 'Preview'). Example, as of this writing the version of AOSP is 4.2.1 and the API level is 17 (An API level is just a set of functions/datastructures available for a particular release of Android OS, so for Level 17 it corresponds to 4.2, You can use a higher API than your target (accept in the case of AOSP Preview) and still make sure you are compatible, but you can't use a lower API and expect to have functions/datastructures that were only implemented in later versions of Android). If you have downloaded the Android SDK for API level 17 it will be 4.2, not 4.2.1. You will not be able to run your app that you built using the API level 17 "Preview" based on 4.2.1...on your 4.2 emulator (or device for that matter). You will need to use the emulator based on the AOSP Preview build.
So in short the AOSP contains the sources to build the SDK, but you can also get prebuilt SDK's if you don't want to go through and build each API level.
rpowell8 said:
If I repo the AOSP do I by default now have the SDK?
Click to expand...
Click to collapse
No, you have the components to /build/ the SDK
rpowell8 said:
Do I have to download it separately?
Click to expand...
Click to collapse
No, you can either build it from the AOSP, or you can download it separately.
rpowell8 said:
Or can I/Should I compile it from the AOSP?
Click to expand...
Click to collapse
Probably should if you're building against the latest android development, but I don't see the need if you are building apps for already released API levels.

[XPOSED][MODULE][4.4.2+] FrankerFaceZ V2

This is a simple module that adds the framework of FrankerFaceZ to the Twitch.TV mobile Android app. This module is available to Android 4.4.2 users and up.
I have another Thread, however, I thought that due to the complete re-write that is happening, as well as the fact that the old was for a different version of Android, I will be re-posting a new version here listed as V2. This thread can be used as a discussion thread, or a bug report thread, so feel free to provide commentary, request features, or report bugs .
In post 2 below, I will also be talking about my findings when decompiling and exploring the source code behind the app that may be used in future updates.
Install the App
Enabled it
Reboot
???
See FrankerFaceZ emotes
Profit
Package Name: com.stdsbot.FrankerFaceZ
Module Name: FrankerFaceZ
Version Name: 2.0.0
Version Code: 1
The module has not yet been released, this is just a pre-release post in-case people have ideas or feedback before completing the first build.
Questions? Comments? Concerns? Bugs?
Post them here and I will see what I can do.​
Known Bugs
None
FAQ
You say you update an Emote or <insert X resource here>, but I don't see the change....
The way twitch caches images, you will need to clear the app cache through your settings.
*Please note, this is my SECOND Xposed module, and as such, I expect things to go wrong sometimes.*
Change Log
2.0.0 - Initial Release
Source Discovery
RESERVED
One of the first things I noticed is that Twitch now has an array set for / commands that are not going to be posted in chat. This will allow me to make togglable features such as Emote display, but also POSSIBLE dark chat on mobile?!?!?!

[MOD][XPOSED][OMAPI] Override SIM Secure Element Access Control

Hi!
This module may be mainly interesting for developers. This module alone does nothing if not properly used together or within another app. Only use it if you know what you are doing.
Overview:
I created a Xposed module which overrides the Access Rule Checks within the SIMalliance Open Mobile API. These checks normally determine which app is allowed to access a SIM-card based Secure Element (SE) and which is not. Normally within the Secure Element (SIM card) there exists a special "Access Rule File" (also called "ARF") or a special card applet called "Access Rule Application Master" (also called "ARA-M") which has the AID A00000015141434C00) and (basically) contains application signatures and according access rules. So the maintainer of the Secure Element can define (and also update) the access rules with these mechanisms: which app is allowed to access the SE and which not. (see reference [1] for details below).
So while the access rules are securely stored in the hardware module (SE) the enforcement of these rules is done in software (within the Open Mobile "SmartcardService.apk"). And this is where this Xposed module hooks into. By using this module (or by integrating it into your app) you may access the SIM-card-based Secure Element with your app, even if the access rules within the SE would not allow it.
Here's the code:
https://github.com/johnzweng/XposedOMAPIOverrideSEAccessRules
This module does not globally disable the access rule checks but instead only grants full access to a single package name (app) which you manually have to define in code as TARGET_APPLICATION_PACKAGE_NAME.
More details and background story:
A few months ago the banks here in Austria started to roll out NFC-based tap'n'pay solutions which allow you to pay with your Android smartphone worldwide at every NFC-capable payment terminal. In contrast to Android Pay this is not a cloud-based software solution (using Host Card Emulation) but instead really uses a hardware-based secure element (like the chips used within EMV (chip'n'pin) plastic NFC banking cards). Austrian Banks decided to use Secure Elements located within the SIM-card (which is basically the same technology as your banking-card chip) so they don't need cooperations with all the phone manufacturers (and also not with Google), but only with the three mobile network operators (MNOs) here in Austria (which control all the SIM cards).
Unfortunately Google has not included an API in current Android which allows accessing SIM-card-based Secure Elements from an app (I guess they don't want banks and MNOs to develop their own independent payment solutions but instead want to push Android Pay). For this reason one of the largest smartcard manufacturers (Giesecke & Devrient - G&D) started to work on a third-party system API which is nowadays known as SIMalliance OpenMobile API (OMAPI). The SIMalliance is a group of industry players which want to push the use of Secure Elements in mobile phones. See also: Members of SIMalliance.
As this API is not part of official Android API the phone manufacturers (OEMs) have to include this API additionally on the phones. A lot of manufacturers do this already. You can check on your phone if this 3rd-party API exists by looking for these files:
/system/etc/permissions/org.simalliance.openmobileapi.xml
/system/framework/org.simalliance.openmobileapi.jar
/system/priv-app/SmartcardService/ (which hosts "SmartcardService.apk")
(and optionally in newer versions: /system/priv-app/UiccTerminal/)
As Google currently doesn't support this type of access to the SIM-card Secure Element you will not find this API on the Nexus phones. One exception was the Nexus 6 running Lollipop where Google included the SIMalliance Open Mobile API because they supported the Softcard (formerly Isis Mobile) wallet. After Google has acquired Softcard in 2015 they removed again the OpenMobile API from Nexus 6 in Android 6.
As I personally used a LG Nexus 5 and now use the Motorola Nexus 6 I started to work on integrating the Open Mobile API myself (which should be possible now on every phone since Android Lollipop (API level 21) as the TelephonyManager system class has got a few interesting new methods including one for sending APDUs over a logical channel to the SIM card: iccOpenLogicalChannel(String AID). As every phone running Android 5 or newer must implement this API you now can get the OMAPI working on every phone running Android 5 or newer (with minor restrictions). (Also the phone needs to have a special hardware wiring between the SIM card and the NFC chip - see "Single Wire Protocol" for details - to get a NFC payment working). But this is a different story which doesn't belong in this thread. For the interested, look at my Github repo which contains a fork of OMAPI working on unmodified Android versions (and two pre-built releases for OMAPI 2.05 and OMAPI 3.0 under the "releases" section - including a short How-To). This worked for me on a Nexus 5 and a Nexus 6.
But back to this topic:
After I had worked out the integration of OMAPI into Android 6.0.1 I finally was able to use tap'n'pay with my Nexus 6 using the banking card within my SIM card Secure Element. But as I am curious I was also interested in exploring my banking-card within the SIM Secure Element using a self-written app. This was when I realized that there is some kind of access control within the Secure Element which blocks my own test-app but not the app of my bank. (See reference [1] for details on these access rules.) To circumvent this I wrote this Xposed module and voilá, now we also have the possibility to talk with the Secure Element over OMAPI.
Final notes:
This Xposed module will only work if your device has the SIMalliance Open Mobile API (OMAPI) installed
This Xposed module may not work if the OMAPI on your device has been compiled using code obfuscation or was modified otherwise by your phone OEM (as the OMAPI is not part of official Android, every OEM may include its own version)
This Xposed module also may not work on other versions of OMAPI (it was tested with OMAPI v2.05 and should also work with OMAPI V3.0)
I hope this might be useful for someone. Have a nice day.
References:
[1] GlobalPlatform Device Technology - Secure Element Access Control (PDF)
[2] Open Mobile API specification - V2.05 (PDF)
[3] Open Mobile API specification - V3.0 (PDF)
[4] my Github repository for this Xposed module: XposedOMAPIOverrideSEAccessRules
[5] my Github repository with OMAPI fork for working on unmodified Android 5 or newer
I'm very impressed! Love your 'investigations'
I installed OMAPI 2.05 with adb on my xperia sp with cyanogenmod 13 (android 6.0.1).
After that I installed the elba-pay app, but it's not working. May you help me?
polo_joe said:
I installed OMAPI 2.05 with adb on my xperia sp with cyanogenmod 13 (android 6.0.1).
After that I installed the elba-pay app, but it's not working. May you help me?
Click to expand...
Click to collapse
Hi polo_joe:
This doesn't directly match the topic of this thread. But send me a PM then we can continue to communicate on a different channel (email, etc.). Most interesting would be a output of "logcat":
On your computer enter the command: "adb logcat -v time > logcat_debug.txt" in a terminal window then try to start the ELBA Pay app and afterwards look in the "logcat_debug.txt" logfile for errors.
john
androcheck said:
Hi polo_joe:
This doesn't directly match the topic of this thread. But send me a PM then we can continue to communicate on a different channel (email, etc.). Most interesting would be a output of "logcat":
On your computer enter the command: "adb logcat -v time > logcat_debug.txt" in a terminal window then try to start the ELBA Pay app and afterwards look in the "logcat_debug.txt" logfile for errors.
john
Click to expand...
Click to collapse
thanks, will do!

Google Chrome User Agent Android 7.x

Hi,
how can i Set Chrome User Agent to Desktop or chromebook on Android 7.x ?
Old User Agent Apps won't work on 7.x
I need to Set Chrome to Desktop view always on
Put a file in Data/Local called 'chrome-command-line', put this text in
chrome --user-agent="Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36" -force-device-scale-factor=2
Permissions 644, you can change the scale-factor to suit.
Sorry but this is Not working anymore on 7.x
Nobody ?
Just wanted to bump this as I'm also looking for a solution.
This has been bugging me for for a few days, very frustrating, seems like Chrome doesn't read the command line files in Nougat no matter where they are located, what they are called, or how you invoke the application. So I did the next best thing...
I grabbed the latest Chromium source code and modified user_agent.cc so it spits out a desktop UA instead. Cross compiling was a bit of a lengthy process, around 4 hours, but it works perfectly. The code alteration was quite trivial, I know this doesn't really help anyone here with a quick fix, and I really can't see Google adding a permanent desktop mode any time ever.
To make the change, just edit the following and rebuild:
<path>/src/content/common/user_agent.cc
PHP:
std::string BuildUserAgentFromOSAndProduct(const std::string& os_info,
const std::string& product) {
// Derived from Safari's UA string.
// This is done to expose our product name in a manner that is maximally
// compatible with Safari, we hope!!
std::string user_agent;
// base::StringAppendF(
// &user_agent,
// "Mozilla/5.0 (%s) AppleWebKit/%d.%d (KHTML, like Gecko) %s Safari/%d.%d",
// os_info.c_str(),
// WEBKIT_VERSION_MAJOR,
// WEBKIT_VERSION_MINOR,
// product.c_str(),
// WEBKIT_VERSION_MAJOR,
// WEBKIT_VERSION_MINOR);
// return user_agent;
return "<Insert desired user agent here>";
}
dtchky said:
This has been bugging me for for a few days, very frustrating, seems like Chrome doesn't read the command line files in Nougat no matter where they are located, what they are called, or how you invoke the application. So I did the next best thing...
I grabbed the latest Chromium source code and modified user_agent.cc so it spits out a desktop UA instead. Cross compiling was a bit of a lengthy process, around 4 hours, but it works perfectly. The code alteration was quite trivial, I know this doesn't really help anyone here with a quick fix, and I really can't see Google adding a permanent desktop mode any time ever.
To make the change, just edit the following and rebuild:
<path>/src/content/common/user_agent.cc
PHP:
std::string BuildUserAgentFromOSAndProduct(const std::string& os_info,
const std::string& product) {
// Derived from Safari's UA string.
// This is done to expose our product name in a manner that is maximally
// compatible with Safari, we hope!!
std::string user_agent;
// base::StringAppendF(
// &user_agent,
// "Mozilla/5.0 (%s) AppleWebKit/%d.%d (KHTML, like Gecko) %s Safari/%d.%d",
// os_info.c_str(),
// WEBKIT_VERSION_MAJOR,
// WEBKIT_VERSION_MINOR,
// product.c_str(),
// WEBKIT_VERSION_MAJOR,
// WEBKIT_VERSION_MINOR);
// return user_agent;
return "<Insert desired user agent here>";
}
Click to expand...
Click to collapse
Would it be possible for you to share the apk? This is frustrating me beyond belief after I moved to Nougat.
Found a solution for this problem, it was caused by a SELinux context which blocked read access to the command line file.
Download this script and copy it on the SDCard.
Install Android Terminal Emulator, then enter:
Code:
su
sh /sdcard/chrome.sh
- Testing 7.x fix. https://play.google.com/store/apps/details?id=com.linuxjet.apps.ChromeUA
jpeterson said:
- Testing 7.x fix. https://play.google.com/store/apps/details?id=com.linuxjet.apps.ChromeUA
Click to expand...
Click to collapse
Thank you. Is this working for anyone?
cobram3 said:
Thank you. Is this working for anyone?
Click to expand...
Click to collapse
It is available on the play store. I can not guarantee this will work, but I have tested it on my 7.x devices and 8.x devices and it is working on them.
Does not work on my OnePlus 5T on Android 8.0 rooted with Magisk.
Neither does the script posted above.
Any other ideas? I'm sick of manually selecting "view non crippled site" every time I open any webpage.
"Mobile" sites need to die!
EDIT: I figured it out, I needed to set the /data/local directory to be readable by all. (The script above already got the file permissions right for the chrome-command-line file, just not the directory it lived in). After that the user agent string seems to be working as it should and I can actually view useful webpages again!
Well, so much for that.
I wiped my phone and started over, and the same steps I used last time have no effect this time. I'm stuck in mobile website hell.
Anyone with any idea how to fix this?
EDIT: This seems to be related to the file permissions issue still, but I'm not sure how to fix it. When I'm not root, I get permission denied when I do an ls on the /data/local directory, despite that directory, and all the ones above it, being set 755. So whatever is blocking me from being able to ls that directory is also likely blocking the ability for chrome to read that file and behave like a useful web browser instead of a completely crippled one.
ve6rah said:
Does not work on my OnePlus 5T on Android 8.0 rooted with Magisk.
Neither does the script posted above.
Any other ideas? I'm sick of manually selecting "view non crippled site" every time I open any webpage.
"Mobile" sites need to die!
EDIT: I figured it out, I needed to set the /data/local directory to be readable by all. (The script above already got the file permissions right for the chrome-command-line file, just not the directory it lived in). After that the user agent string seems to be working as it should and I can actually view useful webpages again!
Click to expand...
Click to collapse
You can create a "chrome desktop"widget with that app,only by this way,it seems to work.
Unfortunately that only works for opening the browser and does nothing for links clicked in our applications.
Why do developers of websites hate mobile users? This isn't 1998 anymore, people want to access websites from their phones! We shouldn't have to resort to such ridiculous lengths to enable such basic functionality as a working web browser!
https://forum.xda-developers.com/showthread.php?t=1811101&page=13 #128
That helps quite a bit.
Now of course I've run in to another problem. AMP. google assistant and related products love to push AMP pages instead of websites, and chrome won't open them in desktop mode, only in mobile mode. I wonder if there's some way to convince Google assistant to behave and link to real webpages?
*sigh* it's amazing how far companies are willing to go to cripple their websites!
EDIT: Found it! DeAMPify in the play store translates all those external programs (like the google feed) to non amp versions before passing them to the browser.
With enough steps and work-arounds you too can have a functioning web-browser on your smartphone!
I'm here to confirm Wootever's script working on [ROM][8.1.0][STABLE][OFFICIAL][TREBLE] AospExtended ROM V5.4 [Z2 PRO]. I had already created the chrome-command-line file via file explorer and set permissions to 755, but it wasn't working. Customized the UA string to my liking, btw (X11; Linux Arm64).
The way G00gl€ is developing Chrome is fLIck1ng annoying, this is basic functionality being set aside because fLIck you. Latest Android Chrome versions (63 to 66) are a piece of sh1t imho.
Cheers
Wootever said:
Found a solution for this problem, it was caused by a SELinux context which blocked read access to the command line file.
Download this script and copy it on the SDCard.
Install Android Terminal Emulator, then enter:
Code:
su
sh /sdcard/chrome.sh
Click to expand...
Click to collapse
Does anyone still have this file?
Reupload
Reupload ulozto.sk/file/R55e4UbG3ppA/chrome-sh

Android studio emulator engineering build

I'm looking for a Android studio emulator engineering GSI build so I can develop (debug) system apps that use android:sharedUserId="android.uid.system" on the manifest. Where can I download them and how do I create a AVD to be used in android studio ? I'm looking for Android 8 or 9.
xjpmauricio said:
I'm looking for a Android studio emulator engineering GSI build.........
Click to expand...
Click to collapse
All I did was Google "Android studio emulator engineering GSI" as reflected on the following link...
https://www.google.com/search?q=Android+studio+emulator+engineering+GSI
... and the very first result was to the following link...
https://source.android.com/setup/build/gsi
... and if you go to that link, and scroll down a bit, you'll see the category "Downloading GSIs" that provides you with what your looking for.
If it's not on that page, then it's not available (yet) but, It looks like it is available.
Good Luck!
~~~~~~~~~~~~~~~
UNLESS asked to do so, PLEASE don't PM me regarding support. Sent using The ClaRetoX Forum App on my Enigma Machine {aenigma = Latin for "Riddle" AND Nickname for "My Ex-Wife"}.
I had already looked at that page but the information is confusing. There's a page containing various userdebug builds for download for android pie:
https://ci.android.com/builds/branches/aosp-pie-gsi/grid?
There are three types of builds: eng, userdebug, and user; I'm looking for the eng type, which uses the platform test keys.
The other problem, is that if you follow one of the links you'll land on a artifacts page containing many files that can only be downloaded one by one: https://ci.android.com/builds/submitted/5467499/aosp_arm64-userdebug/latest/
I haven't found an engineering build, only userdebug and I have no ideia on how to download all the files in the artifacts page, but the main problem is that I found no instructions on how to setup an AVD that can be used on Android Studio and Windows 10.
xjpmauricio said:
I had already looked at that page but the information is confusing.........
Click to expand...
Click to collapse
Hmm... I've never, personally, looked into this using this type/specific avenue before myself.
I'm just thinking that, maybe/possibly, either @Qui Peccavit, @Droidriven or even @osm0sis may be able to provide a better answer/guidance to help you out with this.
I do wish you the best of luck with this!
~~~~~~~~~~~~~~~
UNLESS asked to do so, PLEASE don't PM me regarding support. Sent using The ClaRetoX Forum App on my Enigma Machine {aenigma = Latin for "Riddle" AND Nickname for "My Ex-Wife"}.
Out of my wheelhouse, unfortunately. @phhusson is the GSI master.
I think that userdebug builds built by ci.android.com are signed with AOSP test keys, so that's good enough for you?
I don't really know how to plug in Android Studio with it though, but I heard it's quite easy
@phhusson, I just confirmed that a userdebug build uses the platform test keys; I unpacked a system.img from a userdebug build, checked the SystemUI.apk certificate, using keytool -printcert and the SHA1 is: 27:19:6E:38:6B:87:5E:76:AD:F7:00:E7:EA:84:E4:C6:EE:E3:3D:FA (the sha1 from the google platform test keys)
So...all I need to know is, using these files: https://ci.android.com/builds/submitted/5467499/aosp_arm64-userdebug/latest/
How do I create a AVD that I can use on Android Studio in Windows ? Any ideias?
@phhusson, you were right: its easy to get a userdebug build signed with AOSP test keys, they are available for download on Android Studio in the AVD manager section:
Go to Tools > AVD Manager > + Create Virtual Device > Select Phone, Nexus 5X > Next > Select X86 Images > Select Pie, Api Level 28, ABI x86_64, Target Android 9.0. > Next, etc, download and install.
All builds signed with AOSP test keys are identified by having a target name of Android 9.0, Android 8.1, etc. If you select an image, look at the panel on the right; it should say Android Open Source Project, etc.
All of the other builds of target user are identified with Target "Android 9.0 (Google APi's)" or "Android 9.0 (Google Play)", etc, and those are signed with dev keys, not test keys.
Thanks.

Categories

Resources