android


Android USSD Code to access hidden testing menu

The following USSD code once dialed and called as a phone number, will give you access to a hidden testing menu for Android devices.

*#*#4636#*#*

Unstructured Supplementary Service Data (USSD), sometimes referred to as “Quick Codes” or “Feature codes,” is a communications protocol used by GSM cellular telephones to communicate with the mobile network operator’s computers. USSD can be used for WAP browsing, prepaid callback service, mobile-money services, location-based content services, menu-based information services, and as part of configuring the phone on the network.

From: https://en.wikipedia.org/wiki/Unstructured_Supplementary_Service_Data

How to Disable Google Ad ID Tracking on Android

The key that permits the majority of third-party tracking on mobile devices is the ad identifier, also known as “IDFA” on iOS or “AAID” on Android. Disabling it will reduce the quantity of your personal data that is available for sale and make it much more difficult for advertisers and data brokers to monitor and profile you.

Here’s how you may immediately deny trackers access to your ad ID using Android:
With the introduction of Android 12, Google started enabling consumers to permanently erase their ad IDs. You can launch the Settings app on a device with this feature enabled and go to Privacy > Ads. On the following page, touch “Delete advertising ID” once more for confirmation. Any app on your phone won’t be able to access it again after doing this.


Gaming with PlayStation Controllers of Android

Recently we decided to try and game on Android (specifically on a OnePlus 6T) using the controllers of Sony Playstation (Sony DualShock 4 wireless controller and Sony Dualsense wireless controller).

Sony DualShock 4 wireless controller

To use the Sony DualShock 4 wireless controller (https://www.playstation.com/en-us/accessories/dualshock-4-wireless-controller/), we paired the device using Bluetooth technology. To do so, we pressed the PlayStation logo button and the Share button to set the controller into pairing mode. Then, from our Android device, we paired the new device that appeared to have the name Wireless Controller.

We tried to play the game of Doom which worked like a charm! We had all functionality and the button mapping seemed very convenient.

Sony Dualsense wireless controller

To use the Sony Dualsense wireless controller (https://www.playstation.com/en-us/accessories/dualsense-wireless-controller/), we paired the device using Bluetooth technology again. To do so, we pressed the PlayStation logo button and the Create button to set the controller into pairing mode. Then, from our Android device, we paired the new device that appeared to have the name Wireless Controller.

To our disappointment, when we loaded the game of Doom we realized that the button mapping was very weird and not functional. The Slayer would spin all the time (you could prevent it by spinning in the other direction) and there was no button mapped to firing.

Conclusion

Sony DualShock 4 wireless controller worked like a charm on Android while Sony Dualsense wireless controller had some weird button mapping configuration making it unusable to play.

More results

After some additional investigation, we post the following:
We could not get the Dualsense controller to work as expected on any version of Android.
On the other hand, the Dualshock controller worked correctly on the following configurations:

  • OnePlus 6T + Android version 11
  • Samsung Galaxy S9 + Android version 9
  • Samsung Galaxy S9 + Android version 10

The Sony Dualshock controller failed as well on the following setup

  • Samsung Galaxy S9 + Android version 8

From these results, we can assume something was created or fixed in Android 9 and higher that allows Sony Dualshock wireless controller to work properly on Android devices.


Monkey Problems 2

Recently, we tried to user monkeyrunner on an Ubuntu 18.04 LTS. We installed Android Studio through snap and we setup the Android SDK in ~/Andoid. monkeyrunner was installed in ~/Android/Sdk/tools/bin. To our immeasurable disappointment we found out that when we tried to execute monkeyrunner, it would give the following error:

$ ./monkeyrunner
-Djava.ext.dirs=/home/tux/Android/Sdk/tools/lib:/home/tux/Android/Sdk/tools/lib/x86_64 is not supported. Use -classpath instead.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

At first, we had no idea what that meant, so we used file command on monkeyrunner and we found out that monkeyrunner is a bash script.

$ file monkeyrunner
monkeyrunner: POSIX shell script, ASCII text executable

After reading the code, we read the following at the last lines:

#need to use "java.ext.dirs" because "-jar" causes classpath to be ignored
#might need more memory, e.g. -Xmx128M
exec java -Xmx128M $os_opts $java_debug -Djava.ext.dirs="$frameworkdir:$swtpath" -Djava.library.path="$libdir" -Dcom.android.monkeyrunner.bindir="$progdir" -jar "$jarpath" "$@"

First thing we did was to find the java version that was used, since the command that was giving the problem was that. We found out that we had version 11.

$ java -version
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1)
OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1, mixed mode, sharing)

After reading a bit, we found out that after Java version 8 the command line directive -Djava.ext.dirs it was deprecated and the recommendation to use -classpath was added. In the past, java.ext.dirs was used to instruct the JRE from where to load additional class and jar files. Since we had Java version 11 we had to try the recommendation to remove the -Djava.ext.dirs directive and use -classpath instead. So, we edited the file monkeyrunner and changed the last line as follows:

exec java -Xmx128M $os_opts $java_debug -classpath "$frameworkdir/*:$swtpath" -Djava.library.path="$libdir" -Dcom.android.monkeyrunner.bindir="$progdir" -jar "$jarpath" "$@"

We tried executing the newly updated monkeyrunner again, only to hit another wall!

$ ./monkeyrunner
Exception in thread "main" java.lang.NoClassDefFoundError: com/android/chimpchat/ChimpChat
at com.android.monkeyrunner.MonkeyRunnerStarter.(MonkeyRunnerStarter.java:60)
at com.android.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter.java:188)
Caused by: java.lang.ClassNotFoundException: com.android.chimpchat.ChimpChat
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
… 2 more

It turns out that when you use the -jar directive, JRE will ignore the -classpath directive and so it will again not be able to load any external class or jar files…

Solution

Instead of reinventing the wheel (We tried, we failed, it was painful. Still worth the shot!) we decided to install Java version 8 on Ubuntu 18.04 LTS side by side with Java version 11 and just used that.

First, we checked the list of installed jvm on our machine using the following command:

update-java-alternatives --list;

Where we got the following:

$ update-java-alternatives --list
java-1.11.0-openjdk-amd64 1111 /usr/lib/jvm/java-1.11.0-openjdk-amd64
java-1.8.0-openjdk-amd64 1081 /usr/lib/jvm/java-1.8.0-openjdk-amd64

It turned out we already had Java version 8 but if we didn’t we would install it as follows:

sudo apt install openjdk-8-jdk;

and then it would again appear in the list mentioned above.

Then, we switched to the Java version 8 using the following command and selecting the appropriate option:

sudo update-alternatives --config java;

$ sudo update-alternatives --config java
[sudo] password for tux:
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
0 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 auto mode
1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 manual mode
2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode
Press to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java to provide /usr/bin/java (java) in manual mode

After switching Java to Version 8 monkeyrunner was working as expected!!