Details
-
Type:
Improvement
-
Status: Closed
-
Priority:
Low
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: Release 9.3.0
-
Component/s: Android
-
Sprint:2020 Sprint 23, 2020 Sprint 24
Description
Summary:
Android 9.0 and newer OS versions will log a warning if the app's code accesses a hidden/private API.
Titanium is accessing Google's private getCompatibilityInfo() method in our TiPlatformHelper.java source file. We need to replace its usage with a public API.
Steps to reproduce:
1. Build and run a Titanium app on Android.
2. Observe the log on app startup.
Result:
The following warning message is triggered by Titanium's code.
[WARN] W/tor.kitchensin: Accessing hidden method Landroid/content/res/Resources;->getCompatibilityInfo()Landroid/content/res/CompatibilityInfo; (light greylist, reflection)
|
Note:
There are other hidden API warnings logged as well, but they do not come from Titanium.
The following warnings come from Google's AndroidX libraries.
[WARN] W/tor.kitchensin: Accessing hidden field Landroid/content/res/CompatibilityInfo;->applicationScale:F (light greylist, reflection)
|
[WARN] W/tor.kitchensin: Accessing hidden method Landroid/graphics/drawable/Drawable;->getOpticalInsets()Landroid/graphics/Insets; (light greylist, linking)
|
[WARN] W/tor.kitchensin: Accessing hidden field Landroid/graphics/Insets;->left:I (light greylist, linking)
|
[WARN] W/tor.kitchensin: Accessing hidden field Landroid/graphics/Insets;->right:I (light greylist, linking)
|
[WARN] W/tor.kitchensin: Accessing hidden field Landroid/graphics/Insets;->top:I (light greylist, linking)
|
[WARN] W/tor.kitchensin: Accessing hidden field Landroid/graphics/Insets;->bottom:I (light greylist, linking)
|
[WARN] W/tor.kitchensin: Accessing hidden method Landroid/widget/TextView;->getTextDirectionHeuristic()Landroid/text/TextDirectionHeuristic; (light greylist, linking)
|
[WARN] W/tor.kitchensin: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection)
|
[WARN] W/tor.kitchensin: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection)
|
See Google's ticket here:
https://issuetracker.google.com/issues/123699881#comment12
The following come from Google's WebView.
[WARN] W/tor.kitchensin: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker;-><init>(Landroid/content/Context;I)V (light greylist, reflection)
|
[WARN] W/tor.kitchensin: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker;->logEvent(Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;)V (light greylist, reflection)
|
[WARN] W/tor.kitchensin: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionStarted(I)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
|
[WARN] W/tor.kitchensin: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(II)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
|
[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)
|
[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)
|
[WARN] W/tor.kitchensin: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionAction(III)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
|
[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)
|
The following warnings come from AndroidX version of Google maps.
[WARN] W/lerator.testin: Accessing hidden method Lsun/misc/Unsafe;->arrayBaseOffset(Ljava/lang/Class;)I (greylist,core-platform-api, reflection, allowed)
|
[WARN] W/lerator.testin: Accessing hidden method Lsun/misc/Unsafe;->arrayIndexScale(Ljava/lang/Class;)I (greylist, reflection, allowed)
|
[WARN] W/lerator.testin: Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, reflection, allowed)
|
[WARN] W/lerator.testin: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, reflection, allowed)
|
[WARN] W/lerator.testin: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed)
|
Unfortunately, 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.
Recommended Solution:
For the getCompatibilityInfo() hidden method usage on our end, we need to update our code here to acquire the applicationScaleFactor as shown below... which matches the behavior shown in Google's code here.
if ((activity.getApplicationInfo().flags & ApplicationInfo.FLAG_SUPPORTS_SCREEN_DENSITIES) != 0) { |
applicationScaleFactor = 1.0f; |
} else { |
DisplayMetrics displayMetrics = new DisplayMetrics(); |
activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
applicationScaleFactor = displayMetrics.densityDpi / (float) DisplayMetrics.DENSITY_DEFAULT; |
}
|
Some 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
For 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 class since the Android OS will log these warnings based on the "AndroidManifest.xml" <application android:debuggable="true"/> attribute (won't be set for production/release builds).
Attachments
Issue Links
- relates to
-
TIMOB-27722 Android: V8 warnings in latest master
-
- Closed
-