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

Short explanation on Gradle, minSdkVersion, maxSdkVersion, compileSdkVersion and targetSdkVersion in Android

Gradle : The Android build system compiles app resources and source code, and packages them into APKs that you can test, deploy, sign, and distribute. Android Studio uses Gradle . The Android plugin for Gradle works with the build toolkit to provide processes and configurable settings that are specific to building and testing Android applications. Gradle and the Android plugin run independent of Android Studio. Gradle architecture is shown below. Example: android { compileSdkVersion 27 buildToolsVersion “26.0.2” defaultConfig { applicationId “com.example.checkyourtargetsdk" minSdkVersion 15 targetSdkVersion 27 versionCode 1 versionName “1.0” } } minSdkVersion : minSdkVersion is the lower bound for your app . The minSdkVersion is one of the signals the Google Play Store uses to determine which of a user’s devices an app can be installed on.  your app’s minSdkVersion must be at least as high as your dependencies’ minSdkVe

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 applications are packed into an .apk (Android Package) file by the program "aapt" (Android Asset Packaging Tool) To simplify development Google provides the Android Development Tools (ADT) for Eclipse. The ADT performs automatically the conversion f