[android] Add more @Keep rules for JNI used methods

Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
Konstantin Pastbin 2022-06-15 01:00:36 +03:00
parent 49f3506206
commit 5978773ebe
9 changed files with 28 additions and 2 deletions

View file

@ -1,2 +1,9 @@
# Every JNI-called class and method should have a @Keep annotation to properly work and to avoid
# being manually added as -keep in this file.
# being manually added as -keep in this file, for details see
# https://developer.android.com/studio/build/shrink-code#keep-code
# Don't obfuscate to keep logs readable
-dontobfuscate
# TODO: ATM leads to a build failure with an ERROR:R8: java.lang.NullPointerException
-dontoptimize

View file

@ -6,6 +6,7 @@ import androidx.annotation.IntDef;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Keep;
import androidx.annotation.Size;
import com.mapswithme.maps.api.ParsedRoutingData;
import com.mapswithme.maps.api.ParsedSearchRequest;
@ -73,6 +74,7 @@ public class Framework
}
@SuppressWarnings("unused")
@Keep
public interface RoutingListener
{
@MainThread
@ -80,6 +82,7 @@ public class Framework
}
@SuppressWarnings("unused")
@Keep
public interface RoutingProgressListener
{
@MainThread

View file

@ -222,6 +222,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
runTasks();
}
@Keep
@Override
public void onRenderingInitializationFinished()
{

View file

@ -247,7 +247,8 @@ public class MwmApplication extends Application implements AppBackgroundTracker.
Counters.resetAppSessionCounters(context);
}
@SuppressWarnings("unused") @Keep
@SuppressWarnings("unused")
@Keep
void forwardToMainThread(final long taskPointer)
{
Message m = Message.obtain(mMainLoopHandler, () -> nativeProcessTask(taskPointer));

View file

@ -4,7 +4,10 @@ import android.graphics.Point;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.Keep;
// TODO consider removal and usage of platform PointF
@Keep
public class ParcelablePointD implements Parcelable
{
public double x;

View file

@ -47,6 +47,7 @@ public final class MapManager
}
@SuppressWarnings("unused")
@Keep
interface CurrentCountryChangedListener
{
void onCurrentCountryChanged(String countryId);

View file

@ -1,5 +1,6 @@
package com.mapswithme.maps.location;
import androidx.annotation.Keep;
import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
@ -8,6 +9,7 @@ import java.lang.annotation.RetentionPolicy;
public final class LocationState
{
@Keep
interface ModeChangeListener
{
@SuppressWarnings("unused")

View file

@ -2,6 +2,7 @@ package com.mapswithme.maps.search;
import android.content.Context;
import androidx.annotation.Keep;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -26,6 +27,7 @@ public enum SearchEngine implements NativeSearchListener,
private String mQuery;
@Override
@Keep
public void onResultsUpdate(@NonNull final SearchResult[] results, final long timestamp)
{
UiThread.run(
@ -38,6 +40,7 @@ public enum SearchEngine implements NativeSearchListener,
}
@Override
@Keep
public void onResultsEnd(final long timestamp)
{
UiThread.run(
@ -50,6 +53,7 @@ public enum SearchEngine implements NativeSearchListener,
}
@Override
@Keep
public void onMapSearchResults(final NativeMapSearchListener.Result[] results, final long timestamp, final boolean isLast)
{
UiThread.run(
@ -61,6 +65,7 @@ public enum SearchEngine implements NativeSearchListener,
});
}
@Keep
public void onBookmarkSearchResultsUpdate(@Nullable long[] bookmarkIds, long timestamp)
{
for (NativeBookmarkSearchListener listener : mBookmarkListeners)
@ -68,6 +73,7 @@ public enum SearchEngine implements NativeSearchListener,
mBookmarkListeners.finishIterate();
}
@Keep
public void onBookmarkSearchResultsEnd(@Nullable long[] bookmarkIds, long timestamp)
{
for (NativeBookmarkSearchListener listener : mBookmarkListeners)

View file

@ -7,6 +7,7 @@ import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.telephony.TelephonyManager;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -143,6 +144,7 @@ public enum ConnectionState implements Initializable<Context>
// Called from JNI.
@SuppressWarnings("unused")
@Keep
public static byte getConnectionState()
{
return INSTANCE.requestCurrentType().getNativeRepresentation();