Skip to content

Commit

Permalink
ref-ing Font
Browse files Browse the repository at this point in the history
ref-ing Validator
add analytics flush
add android AppLovin placement
  • Loading branch information
irov committed Sep 10, 2023
1 parent d25c5c7 commit 3c85fa8
Show file tree
Hide file tree
Showing 219 changed files with 2,764 additions and 1,490 deletions.
6 changes: 6 additions & 0 deletions gradle/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,12 @@ if (project.hasProperty("MENGINE_APP_OPTIONS")) {
}
}

android {
defaultConfig {
buildConfigField "boolean", "ANDROID_APP_BUILD_PUBLISH", "${ANDROID_APP_BUILD_PUBLISH}"
}
}

android {
defaultConfig {
buildConfigField "String[]", "MENGINE_GRADLE_ANDROID_PLUGINS", '{' + android.ext.plugins.collect {"\"${it}\""}.join(",") + '}'
Expand Down
5 changes: 5 additions & 0 deletions gradle/app/src/org/Mengine/Project/FinalApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@ public int getVersionCode() {
public String getVersionName() {
return BuildConfig.VERSION_NAME;
}

@Override
public boolean isBuildPublish() {
return BuildConfig.ANDROID_APP_BUILD_PUBLISH;
}
}
2 changes: 2 additions & 0 deletions gradle/libraries/Mengine/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application>
<meta-data android:name="mengine.session.use_install_key" android:value="@bool/mengine_session_use_install_key"/>
<meta-data android:name="mengine.secure.allow_android_id" android:value="@bool/mengine_secure_allow_android_id"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,20 @@ static public void addContextGetterParameterString(String key, MengineAnalyticsG
MengineAnalytics.m_getter.put(key, value);
}

static public void addContextGetterParameterLong(String key, MengineAnalyticsGetter<Long> value) {
MengineAnalytics.assertContext(key);
MengineAnalytics.assertGetter(key);

MengineAnalytics.m_getter.put(key, value);
}

static public void addContextGetterParameterDouble(String key, MengineAnalyticsGetter<Double> value) {
MengineAnalytics.assertContext(key);
MengineAnalytics.assertGetter(key);

MengineAnalytics.m_getter.put(key, value);
}

static private void collapseGetter(Map<String, Object> parameters) {
for (Map.Entry<String, Object> entry : m_getter.entrySet()) {
String key = entry.getKey();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ public MengineAnalyticsEventBuilder addParameterString(String key, String value)
return this;
}

public MengineAnalyticsEventBuilder addParameterJSON(String key, String value) {
this.assertBases(key);
this.assertParameters(key);

m_parameters.put(key, value);

return this;
}

public MengineAnalyticsEventBuilder addParameterLong(String key, long value) {
this.assertBases(key);
this.assertParameters(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public class MengineApplication extends Application {
private static native void AndroidEnv_removeMengineAndroidApplicationJNI();

private static native boolean AndroidEnv_isMasterRelease();
private static native boolean AndroidEnv_isBuildPublish();
private static native String AndroidEnv_getEngineGITSHA1();
private static native String AndroidEnv_getBuildDate();
private static native String AndroidEnv_getBuildUsername();
Expand All @@ -43,7 +42,7 @@ public boolean isMasterRelease() {
}

public boolean isBuildPublish() {
return AndroidEnv_isBuildPublish();
return false;
}

public String getEngineGITSHA1() {
Expand Down Expand Up @@ -301,9 +300,9 @@ private PackageInfo getPackageInfo(PackageManager manager, String packageName) {
}

private String getSecureAndroidId() {
Context applicationContext = this.getApplicationContext();
Context context = this.getApplicationContext();

ContentResolver resolver = applicationContext.getContentResolver();
ContentResolver resolver = context.getContentResolver();
String androidId = Settings.Secure.getString(resolver, Settings.Secure.ANDROID_ID);

return androidId;
Expand Down Expand Up @@ -511,11 +510,11 @@ public void onMengineCaughtException(Throwable throwable) {
}

public SharedPreferences getPrivateSharedPreferences(@NonNull String tag) {
Context applicationContext = this.getApplicationContext();
Context context = this.getApplicationContext();

String packageName = applicationContext.getPackageName();
String packageName = context.getPackageName();

SharedPreferences settings = applicationContext.getSharedPreferences(packageName + "." + tag, MODE_PRIVATE);
SharedPreferences settings = context.getSharedPreferences(packageName + "." + tag, MODE_PRIVATE);

return settings;
}
Expand Down Expand Up @@ -565,13 +564,24 @@ public void sendEvent(MengineEvent event, Object ... args) {

@Override
public void onCreate() {
this.setState("build.debug", BuildConfig.DEBUG);
super.onCreate();

this.setState("application.init", "started");
ArrayList<MenginePluginApplicationListener> applicationListeners = this.getApplicationListeners();

super.onCreate();
for (MenginePluginApplicationListener l : applicationListeners) {
try {
l.onAppInit(this);
} catch (MenginePluginInvalidInitializeException e) {
this.invalidInitialize("invalid plugin %s onAppCreate exception: %s"
, e.getPluginName()
, e.getLocalizedMessage()
);
}
}

this.setState("application.init", "create");
this.setState("build.debug", BuildConfig.DEBUG);

this.setState("application.init", "started");

try {
SDL.loadLibrary("SDLApplication");
Expand Down Expand Up @@ -655,8 +665,8 @@ public void onCreate() {
m_sessionTimestamp = MengineUtils.getTimestamp();
m_sessionDate = MengineUtils.getDateFormat("d MMM yyyy HH:mm:ss");

String gitsha1 = this.getEngineGITSHA1();
this.setState("engine.gitsha1", gitsha1);
String build_gitsha1 = this.getEngineGITSHA1();
this.setState("engine.build_gitsha1", build_gitsha1);

String build_date = this.getBuildDate();
this.setState("engine.build_date", build_date);
Expand All @@ -676,7 +686,15 @@ public void onCreate() {

this.setState("application.init", "load");

ArrayList<MenginePluginApplicationListener> applicationListeners = this.getApplicationListeners();
MengineAnalytics.addContextGetterParameterLong("connection", new MengineAnalyticsGetter<Long>() {
@Override
public Long get() {
Context context = MengineApplication.this.getApplicationContext();
int status = MengineUtils.getConectivityStatus(context);

return Long.valueOf(status);
}
});

for (MenginePluginApplicationListener l : applicationListeners) {
try {
Expand Down Expand Up @@ -803,6 +821,14 @@ public void onMengineAnalyticsEvent(int eventType, String eventName, long timest
}
}

public void onMengineAnalyticsFlush() {
ArrayList<MenginePluginAnalyticsListener> listeners = this.getAnalyticsListeners();

for (MenginePluginAnalyticsListener l : listeners) {
l.onMengineAnalyticsFlush(this);
}
}

private void invalidInitialize(String format, Object ... args) {
String msg = MengineLog.logError(TAG, format, args);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ public interface MenginePluginAnalyticsListener extends MenginePluginInterface {
int EAET_SCREEN_VIEW = MengineAnalytics.EAET_SCREEN_VIEW;

void onMengineAnalyticsEvent(MengineApplication application, int eventType, String eventName, long timestamp, Map<String, Object> bases, Map<String, Object> parameters);

void onMengineAnalyticsFlush(MengineApplication application);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import androidx.annotation.NonNull;

public interface MenginePluginApplicationListener extends MenginePluginInterface {
default void onAppInit(MengineApplication application) throws MenginePluginInvalidInitializeException {
//Empty
}

default void onAppPrepare(MengineApplication application) throws MenginePluginInvalidInitializeException {
//Empty
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import android.app.ActivityManager;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.Uri;
import android.os.BatteryManager;
import android.os.Handler;
Expand Down Expand Up @@ -204,21 +207,21 @@ public static boolean isBatteryFull(Context context) {
}

public static long getRamTotal(Context context) {
ActivityManager actManager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
ActivityManager activityManager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);

ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
actManager.getMemoryInfo(memInfo);
activityManager.getMemoryInfo(memInfo);

long totalMemory = memInfo.totalMem;

return totalMemory;
}

public static long getRamUsage(Context context) {
ActivityManager actManager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
ActivityManager activityManager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);

ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
actManager.getMemoryInfo(memInfo);
activityManager.getMemoryInfo(memInfo);

long totalMemory = memInfo.totalMem;
long availMemory = memInfo.availMem;
Expand All @@ -228,6 +231,60 @@ public static long getRamUsage(Context context) {
return usageMemory;
}

public static int getConectivityStatus(Context context) {
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.M) {
return -2;
}

ConnectivityManager connectivityManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);

Network network = connectivityManager.getActiveNetwork();

if (network == null) {
return -1;
}

NetworkCapabilities capabilities = connectivityManager.getNetworkCapabilities(network);

if (capabilities == null) {
return -1;
}

if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) == true) {
return 1;
}

if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) == true) {
return 2;
}

if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_BLUETOOTH) == true) {
return 3;
}

if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) == true) {
return 4;
}

if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN) == true) {
return 5;
}

if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI_AWARE) == true) {
return 6;
}

if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_LOWPAN) == true) {
return 7;
}

if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_USB) == true) {
return 8;
}

return 0;
}

private static void zipFile(ZipOutputStream out, File file, int basePathLength) throws IOException {
final int BUFFER = 2048;

Expand Down
Loading

0 comments on commit 3c85fa8

Please sign in to comment.