@@ -308,6 +308,43 @@ If for some reason Gradle does not pick up these rules automatically,
308308copy/paste them from the ``` proguard.txt ``` file into your own ProGuard
309309ruleset.
310310
311+ ## Restrictions on non-SDK interfaces
312+
313+ Android 9.0 (Pie, API 28) introduces restrictions on the use of non-SDK
314+ interfaces, whether directly, via reflection, or via JNI. See [ this page
315+ on the Android site] ( https://developer.android.com/about/versions/pie/restrictions-non-sdk-interfaces )
316+ for details.
317+
318+ We do use non-SDK interfaces in the part of the code that runs as root,
319+ and currently it seems this is exempt from the restrictions. My
320+ preliminary interpretation of the relevant sources in AOSP is that
321+ this only applies to code running in a process spawned from Zygote,
322+ which our code running as root isn't.
323+
324+ It appears to currently (November 2018) be implemented as runtime
325+ checks only. It may create some problems if these checks in the future
326+ are also done at the ahead-of-time (AOT) compilation stage at app
327+ install. There is currently no indication if that is or isn't likely to
328+ happen (but if it does I expect the runtime checks to remain as well).
329+
330+ In my experiments so far, if API 28 is targeted and you use a non-SDK
331+ call in a normal app, a warning is written to the logs. If you go one
332+ step further and enable strict-mode, a full stack-trace is logged:
333+
334+ ```
335+ StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
336+ .detectNonSdkApiUsage()
337+ .build());
338+ }
339+ ```
340+
341+ However, making a non-SDK call from the code running as root doesn't
342+ seem to trigger anything, either with or without explicitly enabling
343+ strict mode. So it appears for now we are safe.
344+
345+ TODO: This needs further investigation and monitoring, especially when
346+ an Android 10 preview comes out!
347+
311348## Gradle
312349
313350```
0 commit comments