{ "id": "174681", "key": "TIMOB-27743", "fields": { "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "21052", "description": "", "name": "Release 9.3.0", "archived": false, "released": true, "releaseDate": "2020-12-14" } ], "resolution": null, "resolutiondate": null, "created": "2020-01-30T03:58:09.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "android", "api", "hidden" ], "versions": [], "issuelinks": [ { "id": "58127", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "174634", "key": "TIMOB-27722", "fields": { "summary": "Android: V8 warnings in latest master", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "None", "id": "6" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2020-11-23T19:06:48.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "*Summary:*\r\nAndroid 9.0 and newer OS versions will log a warning if the app's code accesses a hidden/private API.\r\n\r\nTitanium is accessing Google's private {{getCompatibilityInfo()}} method in our [TiPlatformHelper.java|https://github.com/appcelerator/titanium_mobile/blob/c27b90877bf41311d74339905aff240b46febe20/android/titanium/src/java/org/appcelerator/titanium/util/TiPlatformHelper.java#L67] source file. We need to replace its usage with a public API.\r\n\r\n*Steps to reproduce:*\r\n1. Build and run a Titanium app on Android.\r\n2. Observe the log on app startup.\r\n\r\n*Result:*\r\nThe following warning message is triggered by Titanium's code.\r\n{code}\r\n[WARN] W/tor.kitchensin: Accessing hidden method Landroid/content/res/Resources;->getCompatibilityInfo()Landroid/content/res/CompatibilityInfo; (light greylist, reflection)\r\n{code}\r\n\r\n*Note:*\r\nThere are other hidden API warnings logged as well, but they do not come from Titanium.\r\n\r\nThe following warnings come from Google's AndroidX libraries.\r\n{code}\r\n[WARN] W/tor.kitchensin: Accessing hidden field Landroid/content/res/CompatibilityInfo;->applicationScale:F (light greylist, reflection)\r\n[WARN] W/tor.kitchensin: Accessing hidden method Landroid/graphics/drawable/Drawable;->getOpticalInsets()Landroid/graphics/Insets; (light greylist, linking)\r\n[WARN] W/tor.kitchensin: Accessing hidden field Landroid/graphics/Insets;->left:I (light greylist, linking)\r\n[WARN] W/tor.kitchensin: Accessing hidden field Landroid/graphics/Insets;->right:I (light greylist, linking)\r\n[WARN] W/tor.kitchensin: Accessing hidden field Landroid/graphics/Insets;->top:I (light greylist, linking)\r\n[WARN] W/tor.kitchensin: Accessing hidden field Landroid/graphics/Insets;->bottom:I (light greylist, linking)\r\n[WARN] W/tor.kitchensin: Accessing hidden method Landroid/widget/TextView;->getTextDirectionHeuristic()Landroid/text/TextDirectionHeuristic; (light greylist, linking)\r\n[WARN] W/tor.kitchensin: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection)\r\n[WARN] W/tor.kitchensin: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection)\r\n{code}\r\nSee Google's ticket here:\r\nhttps://issuetracker.google.com/issues/123699881#comment12\r\n\r\nThe following come from Google's WebView.\r\n{code}\r\n[WARN] W/tor.kitchensin: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker;->(Landroid/content/Context;I)V (light greylist, reflection)\r\n[WARN] W/tor.kitchensin: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker;->logEvent(Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;)V (light greylist, reflection)\r\n[WARN] W/tor.kitchensin: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionStarted(I)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)\r\n[WARN] W/tor.kitchensin: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(II)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)\r\n[WARN] W/tor.kitchensin: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(IILandroid/view/textclassifier/TextClassification;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)\r\n[WARN] W/tor.kitchensin: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(IILandroid/view/textclassifier/TextSelection;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)\r\n[WARN] W/tor.kitchensin: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionAction(III)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)\r\n[WARN] W/tor.kitchensin: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionAction(IIILandroid/view/textclassifier/TextClassification;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)\r\n{code}\r\n\r\nThe following warnings come from AndroidX version of Google maps.\r\n{code}\r\n[WARN] W/lerator.testin: Accessing hidden method Lsun/misc/Unsafe;->arrayBaseOffset(Ljava/lang/Class;)I (greylist,core-platform-api, reflection, allowed)\r\n[WARN] W/lerator.testin: Accessing hidden method Lsun/misc/Unsafe;->arrayIndexScale(Ljava/lang/Class;)I (greylist, reflection, allowed)\r\n[WARN] W/lerator.testin: Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, reflection, allowed)\r\n[WARN] W/lerator.testin: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, reflection, allowed)\r\n[WARN] W/lerator.testin: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed)\r\n{code}\r\n\r\nUnfortunately, there is nothing we can do about the above warnings other than to wait/hope for Google to resolve these in future updates of their libraries.\r\n\r\n*Recommended Solution:*\r\nFor the {{getCompatibilityInfo()}} hidden method usage on our end, we need to update our code [here|https://github.com/appcelerator/titanium_mobile/blob/d052cacf6d7f1648d310ea9b010bd78b4d91f4b5/android/titanium/src/java/org/appcelerator/titanium/util/TiPlatformHelper.java#L60-L81] to acquire the {{applicationScaleFactor}} as shown below... which matches the behavior shown in Google's code [here|https://github.com/aosp-mirror/platform_frameworks_base/blob/master/core/java/android/content/res/CompatibilityInfo.java].\r\n{code:java}\r\nif ((activity.getApplicationInfo().flags & ApplicationInfo.FLAG_SUPPORTS_SCREEN_DENSITIES) != 0) {\r\n\tapplicationScaleFactor = 1.0f;\r\n} else {\r\n\tDisplayMetrics displayMetrics = new DisplayMetrics();\r\n\tactivity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);\r\n\tapplicationScaleFactor = displayMetrics.densityDpi / (float) DisplayMetrics.DENSITY_DEFAULT;\r\n}\r\n{code}\r\n\r\nSome warnings are being logged by our usage of {{WebViewClient.jar}} which we need for Android 4.4 support of certificate requests in a {{Ti.UI.WebView}}. We cannot remove this JAR until Titanium 10.0.0. See ticket: [TIMOB-28241]\r\n\r\nFor all other hidden method warnings, Google's newest libraries as of November 2020 has resolved most of these warnings. Particularly in Google Maps. Unfortunately we cannot disable these warnings from being logged via the [StrictMode|https://developer.android.com/reference/android/os/StrictMode] class since the Android OS will log these warnings based on the \"AndroidManifest.xml\" {{}} attribute (won't be set for production/release builds).\r\n", "attachment": [], "flagged": false, "summary": "Android: Remove hidden API usage from SDK", "creator": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "closedSprints": [ { "id": 1210, "state": "closed", "name": "2020 Sprint 23", "startDate": "2020-11-09T17:49:00.000Z", "endDate": "2020-11-20T17:49:00.000Z", "completeDate": "2020-11-20T17:46:00.641Z", "originBoardId": 114 }, { "id": 1211, "state": "closed", "name": "2020 Sprint 24", "startDate": "2020-11-23T18:12:00.000Z", "endDate": "2020-12-07T18:12:00.000Z", "completeDate": "2020-12-04T22:07:24.313Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "456235", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "would it be possible to remove the from the info log? Especially the map part is filling up the logs quite a lot. \r\nThere is already some log filtering at https://github.com/appcelerator/titanium_mobile/blob/master/android/cli/hooks/run.js#L260 ", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2020-07-26T15:21:21.000+0000", "updated": "2020-07-26T15:21:21.000+0000" }, { "id": "456418", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "that will make the log so much cleaner already:\r\n\r\n{code}\r\nhiddenMethodLog = /Accessing hidden (method|field)/;\r\n// \r\n// add before https://github.com/appcelerator/titanium_mobile/blob/master/android/cli/hooks/run.js#L254\r\nif (hiddenMethodLog.test(line)) {reutrn;}\r\n{code}\r\n", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2020-08-11T20:08:31.000+0000", "updated": "2020-08-11T20:08:31.000+0000" }, { "id": "457149", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "+1 for removing it from the info log level.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2020-10-03T09:55:47.000+0000", "updated": "2020-10-03T09:55:47.000+0000" }, { "id": "457505", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "_(sigh)_\r\n\r\nI can't get {{StrictMode}} method [permitNonSdkApiUsage()|https://developer.android.com/reference/android/os/StrictMode.VmPolicy.Builder#permitNonSdkApiUsage()] to work at all on Android 11. The {{permitAll()}} method doesn't avoid hidden method detection either. Nor can I get [penaltyListener()|https://developer.android.com/reference/android/os/StrictMode.VmPolicy.Builder#penaltyListener(java.util.concurrent.Executor,%20android.os.StrictMode.OnVmViolationListener)] to detect the access of these hidden methods. I can get every other aspect of {{StrictMode}} to work except this. The behavior I'm seeing doesn't match what Google has documented or blogged about. Not sure what to think of this other than the Android OS simply won't let us disable this.\r\nhttps://developer.android.com/distribute/best-practices/develop/restrictions-non-sdk-interfaces#test-strictmode-api\r\n\r\nThese warning messages definitely do *NOT* appear for \"production\" builds (aka: Android \"release\" builds). The Android OS must be looking for the APK's \"AndroidManifest.xml\" {{}} attribute to do this. Doing the below via a \"build.gradle\" file setting as shown below removes the \"debuggable\" attribute and definitely gets rid of the warning messages... although I don't like this solution.\r\n{{./platform/android/build.gradle}}\r\n{code:groovy}\r\nandroid {\r\n\tbuildTypes {\r\n\t\tdebug {\r\n\t\t\tdebuggable false\r\n\t\t}\r\n\t}\r\n}\r\n{code}\r\n", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2020-11-13T02:12:36.000+0000", "updated": "2020-11-13T02:12:36.000+0000" }, { "id": "457506", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "PR (master): https://github.com/appcelerator/titanium_mobile/pull/12263", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2020-11-13T04:09:48.000+0000", "updated": "2020-11-13T04:09:48.000+0000" }, { "id": "457507", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "perhaps hiding them in the CLI output would still be an option? So they won't appear in the normal info-log (debug or trace would be fine). ", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2020-11-13T09:25:15.000+0000", "updated": "2020-11-13T09:25:15.000+0000" }, { "id": "457687", "author": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "body": "merged to master and backport PR to 9_3_X for 9.3.0 target.", "updateAuthor": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "created": "2020-11-23T19:06:48.000+0000", "updated": "2020-11-23T19:06:48.000+0000" } ], "maxResults": 7, "total": 7, "startAt": 0 } } }