Android: add @UsedFromNativeCode annotation for java method used in c++
To get rid of unused method warnings in Java code for methods used only from C++ code and make it more visible which methods are used by native code. This annotation would need to be added to the relevant methods in this patch or future one. Use this annotation for all methods called from native code. And along the way remove few methods that are not used anywhere. Task-number: QTBUG-118077 Change-Id: Ie493fb057f4a93aff513f85e0936bc65a9bb304c Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
This commit is contained in:
parent
09afa75752
commit
833e7c1629
@ -23,12 +23,13 @@ set(java_sources
|
||||
src/org/qtproject/qt/android/QtNative.java
|
||||
src/org/qtproject/qt/android/QtSurface.java
|
||||
src/org/qtproject/qt/android/QtThread.java
|
||||
src/org/qtproject/qt/android/extras//QtAndroidBinder.java
|
||||
src/org/qtproject/qt/android/extras/QtAndroidBinder.java
|
||||
src/org/qtproject/qt/android/extras/QtAndroidServiceConnection.java
|
||||
src/org/qtproject/qt/android/extras/QtNative.java
|
||||
src/org/qtproject/qt/android/QtConstants.java
|
||||
src/org/qtproject/qt/android/QtClipboardManager.java
|
||||
src/org/qtproject/qt/android/QtDisplayManager.java
|
||||
src/org/qtproject/qt/android/UsedFromNativeCode.java
|
||||
)
|
||||
|
||||
qt_internal_add_jar(Qt${QtBase_VERSION_MAJOR}Android
|
||||
|
@ -1129,10 +1129,6 @@ public class ExtractStyle {
|
||||
return json;
|
||||
}
|
||||
|
||||
public JSONObject extractTextAppearanceInformation(int styleName, String qtClass, AttributeSet attributeSet) {
|
||||
return extractTextAppearanceInformation(styleName, qtClass, android.R.attr.textAppearance, attributeSet);
|
||||
}
|
||||
|
||||
public JSONObject extractTextAppearanceInformation(int styleName, String qtClass) {
|
||||
return extractTextAppearanceInformation(styleName, qtClass, android.R.attr.textAppearance, null);
|
||||
}
|
||||
|
@ -298,11 +298,13 @@ public class QtActivityBase extends Activity
|
||||
QtNative.sendRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void hideSplashScreen(final int duration)
|
||||
{
|
||||
m_delegate.hideSplashScreen(duration);
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
QtActivityDelegate getActivityDelegate()
|
||||
{
|
||||
return m_delegate;
|
||||
|
@ -85,15 +85,18 @@ public class QtActivityDelegate
|
||||
return m_displayManager;
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
QtInputDelegate getInputDelegate() {
|
||||
return m_inputDelegate;
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
QtLayout getQtLayout()
|
||||
{
|
||||
return m_layout;
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void setSystemUiVisibility(int systemUiVisibility)
|
||||
{
|
||||
QtNative.runAction(new Runnable() {
|
||||
@ -163,11 +166,6 @@ public class QtActivityDelegate
|
||||
}
|
||||
}
|
||||
|
||||
public void onTerminate() {
|
||||
QtNative.terminateQt();
|
||||
QtNative.m_qtThread.exit();
|
||||
}
|
||||
|
||||
public void startNativeApplication(ArrayList<String> appParams, String mainLib)
|
||||
{
|
||||
if (m_surfaces != null)
|
||||
@ -307,6 +305,7 @@ public class QtActivityDelegate
|
||||
});
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void notifyLocationChange(int viewId)
|
||||
{
|
||||
if (m_accessibilityDelegate == null)
|
||||
@ -314,6 +313,7 @@ public class QtActivityDelegate
|
||||
m_accessibilityDelegate.notifyLocationChange(viewId);
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void notifyObjectHide(int viewId, int parentId)
|
||||
{
|
||||
if (m_accessibilityDelegate == null)
|
||||
@ -321,6 +321,7 @@ public class QtActivityDelegate
|
||||
m_accessibilityDelegate.notifyObjectHide(viewId, parentId);
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void notifyObjectFocus(int viewId)
|
||||
{
|
||||
if (m_accessibilityDelegate == null)
|
||||
@ -328,6 +329,7 @@ public class QtActivityDelegate
|
||||
m_accessibilityDelegate.notifyObjectFocus(viewId);
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void notifyValueChanged(int viewId, String value)
|
||||
{
|
||||
if (m_accessibilityDelegate == null)
|
||||
@ -335,6 +337,7 @@ public class QtActivityDelegate
|
||||
m_accessibilityDelegate.notifyValueChanged(viewId, value);
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void notifyScrolledEvent(int viewId)
|
||||
{
|
||||
if (m_accessibilityDelegate == null)
|
||||
@ -342,11 +345,13 @@ public class QtActivityDelegate
|
||||
m_accessibilityDelegate.notifyScrolledEvent(viewId);
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void notifyQtAndroidPluginRunning(boolean running)
|
||||
{
|
||||
m_isPluginRunning = running;
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void initializeAccessibility()
|
||||
{
|
||||
final QtActivityDelegate currentDelegate = this;
|
||||
@ -386,6 +391,7 @@ public class QtActivityDelegate
|
||||
}
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void resetOptionsMenu()
|
||||
{
|
||||
QtNative.runAction(new Runnable() {
|
||||
@ -396,6 +402,7 @@ public class QtActivityDelegate
|
||||
});
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void openOptionsMenu()
|
||||
{
|
||||
QtNative.runAction(new Runnable() {
|
||||
@ -414,6 +421,7 @@ public class QtActivityDelegate
|
||||
m_contextMenuVisible = true;
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void openContextMenu(final int x, final int y, final int w, final int h)
|
||||
{
|
||||
m_layout.postDelayed(new Runnable() {
|
||||
@ -439,6 +447,7 @@ public class QtActivityDelegate
|
||||
}, 100);
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void closeContextMenu()
|
||||
{
|
||||
QtNative.runAction(new Runnable() {
|
||||
@ -459,6 +468,7 @@ public class QtActivityDelegate
|
||||
m_activity.getActionBar().show();
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void insertNativeView(int id, View view, int x, int y, int w, int h) {
|
||||
QtNative.runAction(new Runnable() {
|
||||
@Override
|
||||
@ -485,6 +495,7 @@ public class QtActivityDelegate
|
||||
});
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void createSurface(int id, boolean onTop, int x, int y, int w, int h, int imageDepth) {
|
||||
QtNative.runAction(new Runnable() {
|
||||
@Override
|
||||
@ -526,6 +537,7 @@ public class QtActivityDelegate
|
||||
});
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void setSurfaceGeometry(int id, int x, int y, int w, int h) {
|
||||
QtNative.runAction(new Runnable() {
|
||||
@Override
|
||||
@ -544,6 +556,7 @@ public class QtActivityDelegate
|
||||
});
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void destroySurface(int id) {
|
||||
QtNative.runAction(new Runnable() {
|
||||
@Override
|
||||
@ -577,6 +590,7 @@ public class QtActivityDelegate
|
||||
return m_surfaces.size();
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void bringChildToFront(int id)
|
||||
{
|
||||
QtNative.runAction(new Runnable() {
|
||||
@ -597,6 +611,7 @@ public class QtActivityDelegate
|
||||
});
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void bringChildToBack(int id)
|
||||
{
|
||||
QtNative.runAction(new Runnable() {
|
||||
|
@ -59,6 +59,7 @@ public class QtClipboardManager
|
||||
}
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void clearClipData()
|
||||
{
|
||||
if (m_clipboardManager != null) {
|
||||
@ -72,6 +73,8 @@ public class QtClipboardManager
|
||||
}
|
||||
m_usePrimaryClip = false;
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void setClipboardText(Context context, String text)
|
||||
{
|
||||
if (m_clipboardManager != null) {
|
||||
@ -101,11 +104,13 @@ public class QtClipboardManager
|
||||
return false;
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public boolean hasClipboardText()
|
||||
{
|
||||
return hasClipboardMimeType("text/(.*)");
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public String getClipboardText()
|
||||
{
|
||||
try {
|
||||
@ -144,6 +149,7 @@ public class QtClipboardManager
|
||||
}
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void setClipboardHtml(Context context, String text, String html)
|
||||
{
|
||||
if (m_clipboardManager != null) {
|
||||
@ -170,11 +176,13 @@ public class QtClipboardManager
|
||||
return false;
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public boolean hasClipboardHtml()
|
||||
{
|
||||
return hasClipboardMimeType("text/html");
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public String getClipboardHtml()
|
||||
{
|
||||
try {
|
||||
@ -192,6 +200,7 @@ public class QtClipboardManager
|
||||
return "";
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void setClipboardUri(Context context, String uriString)
|
||||
{
|
||||
if (m_clipboardManager != null) {
|
||||
@ -201,11 +210,13 @@ public class QtClipboardManager
|
||||
}
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public boolean hasClipboardUri()
|
||||
{
|
||||
return hasClipboardMimeType("text/uri-list");
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
private String[] getClipboardUris()
|
||||
{
|
||||
ArrayList<String> uris = new ArrayList<>();
|
||||
|
@ -172,6 +172,7 @@ public class QtDisplayManager {
|
||||
}
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public static Display getDisplay(Context context, int displayId)
|
||||
{
|
||||
DisplayManager displayManager =
|
||||
@ -182,6 +183,7 @@ public class QtDisplayManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public static List<Display> getAvailableDisplays(Context context)
|
||||
{
|
||||
DisplayManager displayManager =
|
||||
@ -193,6 +195,7 @@ public class QtDisplayManager {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public static Size getDisplaySize(Context displayContext, Display display)
|
||||
{
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
|
||||
|
@ -139,6 +139,7 @@ public class QtInputDelegate {
|
||||
}
|
||||
|
||||
// Is the keyboard fully visible i.e. visible and no ongoing animation
|
||||
@UsedFromNativeCode
|
||||
public boolean isSoftwareKeyboardVisible()
|
||||
{
|
||||
return isKeyboardVisible() && !m_isKeyboardHidingAnimationOngoing;
|
||||
@ -182,6 +183,7 @@ public class QtInputDelegate {
|
||||
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void resetSoftwareKeyboard()
|
||||
{
|
||||
if (m_imm == null)
|
||||
@ -452,6 +454,7 @@ public class QtInputDelegate {
|
||||
});
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void updateSelection(final int selStart, final int selEnd,
|
||||
final int candidatesStart, final int candidatesEnd)
|
||||
{
|
||||
@ -466,6 +469,7 @@ public class QtInputDelegate {
|
||||
});
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public int getSelectHandleWidth()
|
||||
{
|
||||
int width = 0;
|
||||
@ -481,6 +485,7 @@ public class QtInputDelegate {
|
||||
be adjusted.
|
||||
mode is one of QAndroidInputContext::CursorHandleShowMode
|
||||
*/
|
||||
@UsedFromNativeCode
|
||||
public void updateHandles(Activity activity, QtLayout layout, int mode,
|
||||
int editX, int editY, int editButtons,
|
||||
int x1, int y1, int x2, int y2, boolean rtl)
|
||||
|
@ -55,7 +55,7 @@ public class QtMessageDialogHelper
|
||||
m_activity = activity;
|
||||
}
|
||||
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void setStandardIcon(int icon)
|
||||
{
|
||||
m_standardIcon = icon;
|
||||
@ -114,26 +114,31 @@ public class QtMessageDialogHelper
|
||||
return null;
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void setTile(String title)
|
||||
{
|
||||
m_title = Html.fromHtml(title);
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void setText(String text)
|
||||
{
|
||||
m_text = Html.fromHtml(text);
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void setInformativeText(String informativeText)
|
||||
{
|
||||
m_informativeText = Html.fromHtml(informativeText);
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void setDetailedText(String text)
|
||||
{
|
||||
m_detailedText = Html.fromHtml(text);
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void addButton(int id, String text)
|
||||
{
|
||||
if (m_buttonsList == null)
|
||||
@ -150,7 +155,7 @@ public class QtMessageDialogHelper
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void show(long handler)
|
||||
{
|
||||
m_handler = handler;
|
||||
@ -314,6 +319,7 @@ public class QtMessageDialogHelper
|
||||
});
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public void hide()
|
||||
{
|
||||
m_activity.runOnUiThread( new Runnable() {
|
||||
|
@ -59,6 +59,7 @@ public class QtNative
|
||||
return m_started && (hasActivity || hasService);
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public static ClassLoader classLoader()
|
||||
{
|
||||
return m_classLoader;
|
||||
@ -83,6 +84,7 @@ public class QtNative
|
||||
}
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public static Activity activity()
|
||||
{
|
||||
synchronized (m_mainActivityMutex) {
|
||||
@ -90,6 +92,7 @@ public class QtNative
|
||||
}
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public static Service service()
|
||||
{
|
||||
synchronized (m_mainActivityMutex) {
|
||||
@ -97,12 +100,14 @@ public class QtNative
|
||||
}
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public static Context getContext() {
|
||||
if (m_activity != null)
|
||||
return m_activity;
|
||||
return m_service;
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public static String[] getStringArray(String joinedString)
|
||||
{
|
||||
return joinedString.split(",");
|
||||
@ -154,6 +159,7 @@ public class QtNative
|
||||
}
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public static boolean openURL(Context context, String url, String mime)
|
||||
{
|
||||
final Uri uri = getUriWithValidPermission(context, url, "r");
|
||||
@ -207,6 +213,7 @@ public class QtNative
|
||||
}
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
private static void runPendingCppRunnablesOnAndroidThread()
|
||||
{
|
||||
synchronized (m_mainActivityMutex) {
|
||||
@ -228,6 +235,7 @@ public class QtNative
|
||||
}
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
private static void setViewVisibility(final View view, final boolean visible)
|
||||
{
|
||||
runAction(new Runnable() {
|
||||
@ -278,6 +286,7 @@ public class QtNative
|
||||
});
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
public static int checkSelfPermission(String permission)
|
||||
{
|
||||
synchronized (m_mainActivityMutex) {
|
||||
@ -287,6 +296,7 @@ public class QtNative
|
||||
}
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
private static byte[][] getSSLCertificates()
|
||||
{
|
||||
ArrayList<byte[]> certificateList = new ArrayList<>();
|
||||
@ -314,6 +324,7 @@ public class QtNative
|
||||
return certificateArray;
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
private static String[] listAssetContent(android.content.res.AssetManager asset, String path) {
|
||||
String [] list;
|
||||
ArrayList<String> res = new ArrayList<>();
|
||||
|
@ -0,0 +1,10 @@
|
||||
// Copyright (C) 2023 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
package org.qtproject.qt.android;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
public @interface UsedFromNativeCode { }
|
@ -324,6 +324,8 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate
|
||||
return event;
|
||||
}
|
||||
|
||||
// This can be used for debug by performActionForVirtualViewId()
|
||||
/** @noinspection unused*/
|
||||
private void dumpNodes(int parentId)
|
||||
{
|
||||
Log.i(TAG, "A11Y hierarchy: " + parentId + " parent: " + QtNativeAccessibility.parentId(parentId));
|
||||
@ -369,8 +371,8 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate
|
||||
result.setPackageName(source.getPackageName());
|
||||
result.setClassName(source.getClassName());
|
||||
|
||||
// Spit out the entire hierarchy for debugging purposes
|
||||
// dumpNodes(-1);
|
||||
// Spit out the entire hierarchy for debugging purposes
|
||||
// dumpNodes(-1);
|
||||
|
||||
if (m_activityDelegate.getSurfaceCount() != 0) {
|
||||
int[] ids = QtNativeAccessibility.childIdListForAccessibleObject(-1);
|
||||
|
@ -6,8 +6,11 @@ package org.qtproject.qt.android.extras;
|
||||
import android.os.Binder;
|
||||
import android.os.Parcel;
|
||||
|
||||
import org.qtproject.qt.android.UsedFromNativeCode;
|
||||
|
||||
public class QtAndroidBinder extends Binder
|
||||
{
|
||||
@UsedFromNativeCode
|
||||
public QtAndroidBinder(long id)
|
||||
{
|
||||
m_id = id;
|
||||
|
@ -7,8 +7,11 @@ import android.content.ComponentName;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
|
||||
import org.qtproject.qt.android.UsedFromNativeCode;
|
||||
|
||||
public class QtAndroidServiceConnection implements ServiceConnection
|
||||
{
|
||||
@UsedFromNativeCode
|
||||
public QtAndroidServiceConnection(long id)
|
||||
{
|
||||
m_id = id;
|
||||
|
Loading…
x
Reference in New Issue
Block a user