Skip to main content

Android Pi migration(28 API support)






I am here to give some inputs on android PI migration. . 

Apps must target at least API level 28 to ensure it is built on the latest APIs optimized for security and performance.

From August 2019, new apps must target at least Android 9.0 (API level 28).

The objective here is to make sure that your existing app works as-is on Android 9. Because some platform changes might affect the way your app behaves, some adjustments might be necessary, but you do not need to use new APIs or change your targetSdkVersion.

Android Service Problem

On Oreo, startService() will throw IllegalStateException. This can be fixed by changing it to startForegroundService(). but it also stops the service immediately if you don’t bind to the Notification withService.startForeground() within 5 seconds. For other background service we decided to use the WorkManager.

Implementation:


Since we have minSdkVersion 19, We migrated to workmanger for scheduled tasks and we still use JobIntentService from background service calls which is fine with our requirements.

Implementation:

I would like to explain how we solved the background service problem after android N in separate section.

Key features:

Backwards compatible up to API 14
Uses JobScheduler on devices with API 23+
Uses a combination of BroadcastReceiver + AlarmManager on devices with API 14-22
Add work constraints like network availability or charging status
Schedule asynchronous one-off or periodic tasks
Monitor and manage scheduled tasks
Chain tasks together
Ensures task execution, even if the app or device restarts
Adheres to power-saving features like Doze mode.

On Pie it is required to use HTTPS for network communication refer to Pie Behaviour Changes, so any URL that still use HTTP need to be changed to use HTTPS, 


If you still want to allow HTTP traffic follow below steps:
In your android manifest file. Application tag use below statement.
android:networkSecurityConfig="@xml/network_security_config"
Under XML folder create network_security_config
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<!--Set application-wide security config using base-config tag.-->
<base-config cleartextTrafficPermitted="true"/>
</network-security-config>

This allows to use cleartext HTTP traffic in application.

Apps needing the Build.serial identifier must now request the READ_PHONE_STATE permission and then use the new Build.getSerial() method added in Android 9.

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
        Log.d(TAG, "h/w serial: " + android.os.Build.getSerial());
} else if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) &&(Build.VERSION.SDK_INT < Build.VERSION_CODES.P)) {
       Log.d(TAG, "h/w serial: " + android.os.Build.SERIAL);
}

Please add runtime permission READ_PHONE_STATE.

Access to app’s data directory blocked by SELinux

The system enforces per-app SELinux sandboxes with per-app SELinux restrictions on each app's private data directory. Directly accessing another app’s data directory by path is now disallowed. Apps may continue to share data using IPC mechanisms, including by passing FDs.

Deprecation of Bouncy Castle ciphers

Android 9 deprecates several ciphers from the Bouncy Castle provider in favor of those provided by the Conscrypt provider. Calls to getInstance() that request the Bouncy Castle provider generate NoSuchAlgorithmExceptionerrors. To resolve the errors, do not specify a provider in getInstance() (that is, request the default implementation).

Disallowed sharing of WebView data directory

Apps can no longer share a single WebView data directory across processes. If your app has more than one process using WebView, CookieManager, or any other API in the android.webkit package, your app will crash when the second process calls a WebView method.

Foreground service permission

Apps wanting to use foreground services must now request the FOREGROUND_SERVICE permission first. This is a normal permission, so the system automatically grants it to the requesting app. Starting a foreground service without the permission throws a SecurityException.

Restrictions on non-SDK interfaces

Access to specific non-SDK interfaces is now blocked, whether the access is direct, via JNI, or via reflection. Attempts to access restricted interfaces generates errors such as NoSuchFieldException and NoSuchMethodException. See Restrictions on Non-SDK Interfaces for details.

Removal of Crypto provider

Starting in Android 9, Crypto JCA provider has been removed. Calls to SecureRandom.getInstance("SHA1PRNG", "Crypto") will throw NoSuchProviderException.

Stricter UTF-8 decoder

In Android 9, the UTF-8 decoder for Java language is stricter and follows the Unicode standard.

Access to camera, microphone, and sensors blocked for idle apps

While apps are idle, they can no longer access camera, microphone, or SensorManager sensors.

To test your app uses restricted API’s use the link below:

Download the veridex tool from the Android runtime prebuilts repository.
Extract the contents of the appcompat.tar.gz file.
In the extracted folder, locate the veridex-linux.zip file and unzip it.
Navigate to the unzipped folder and then run the following command, where your-app.apk is the APK that you want to test:
Use below command to get the reports

./appcompat.sh --dex-file=your-app.apk

You will get below report.
100 hidden API(s) used: 50 linked against, 36 through reflection
76 in greylist
4 in blacklist
0 in greylist-max-o
20 in greylist-max-p

Reference:


Comments

  1. If it is about fixing TalkTalk email cannot get access then in that case on the browser the user needs to open the settings menu from there the user should get the reset conducted on the Email the user should use the password reset option. If needed then for further information the user should get connected with the TalkTalk experts.
    TalkTalk Help Number UK

    ReplyDelete

Post a Comment

Popular posts from this blog

Google re-branded the support Android libraries to AndroidX

It is important to note, you cannot mix AppCompat and Jetpack in the same project. You must convert everything to use Jetpack if you want to upgrade. The support library artifacts are being deprecated and all future development is going into AndroidX , so there's no avoiding this migration. Alan Viverette sums this up nicely: “There won’t be a 29.0.0, so Android Q APIs will only be in AndroidX” The stable release of 28.0.0 will be the final feature release packaged as android.support . All subsequent feature releases will only be made available as androidx-packaged artifacts. Below tips will give you a clearer transition path. The current version of AppCompat (v28.x) is exactly the same as AndroidX (v1.x). In fact, the AppCompat libraries are machine generated by changing maven coordinates and package names of the AndroidX codebase. For example, android.support.v7.app.AppCompatActivity is now androidx.appcompat.app.AppCompatActivity For a complete listi...

Android Beginners Guide

                                                                                                               Android Operation System: Android is an operating system based on Linux with a Java programming interface. It provides tools, e.g. a compiler, debugger and a device emulator as well as its own Java Virtual machine (Dalvik Virtual Machine - DVM). Android is created by the Open Handset Alliance which is lead by Google. Android uses a special virtual machine, e.g. the Dalvik Virtual Machine. Dalvik uses special bytecode. Therefore you cannot run standard Java bytecode on Android. Android provides a tool "dx" which allows to convert Java Class files into "dex" (Dalvik Executable) files. Android ...

Kotlin and Android

Kotlin is now an official language on Android. It's expressive, concise, and powerful. Best of all, it's interoperable with our existing Android languages and runtime. To use Kotlin in Android Studio prior to version 3.0 you have to manually install the Kotlin plugin. To do so, start Android Studio and open Plugins from the Configure menu . In the opened dialog, search for Kotlin , select the corresponding plugin and press Install . Kotlin for Android Development: Kotlin is a great fit for developing Android applications, bringing all of the advantages of a modern language to the Android platform without introducing any new restrictions. Compatibility: Kotlin is fully compatible with JDK 6, ensuring that Kotlin applications can run on older Android devices with no issues. The Kotlin tooling is fully supported in Android Studio and compatible with the Android build system. Performance: A Kotlin application runs as fast as an equivalent Java one, thanks to ver...