1
0
mirror of https://github.com/MGislv/NekoX.git synced 2024-06-30 10:14:04 +00:00

Changed native lib loaded

This commit is contained in:
DrKLO 2014-10-24 17:43:45 +04:00
parent abf8f6f619
commit b33d5f0786
33 changed files with 1198 additions and 71 deletions

View File

@ -2,7 +2,7 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE := tmessages
LOCAL_MODULE := tmessages.1
LOCAL_CFLAGS := -w -std=gnu99 -O2 -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64
LOCAL_CFLAGS += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -fno-math-errno
LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT
@ -162,10 +162,23 @@ LOCAL_SRC_FILES += \
./giflib/gifalloc.c
LOCAL_SRC_FILES += \
./aes/aes_core.c \
./aes/aes_ige.c \
./aes/aes_misc.c
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
LOCAL_SRC_FILES += ./aes/aes_arm.S
else
ifeq ($(TARGET_ARCH_ABI),armeabi)
LOCAL_SRC_FILES += ./aes/aes_arm.S
else
ifeq ($(TARGET_ARCH_ABI),x86)
LOCAL_SRC_FILES += ./aes/aes_core.c
else
LOCAL_SRC_FILES += ./aes/aes_core.c
endif
endif
endif
LOCAL_SRC_FILES += \
./sqlite/sqlite3.c
@ -277,7 +290,6 @@ LOCAL_SRC_FILES += \
./gif.c \
./utils.c \
./image.c \
./video.c \
./fake.c
./video.c
include $(BUILD_SHARED_LIBRARY)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,51 @@
#ifndef __ARM_ARCH_H__
#define __ARM_ARCH_H__
#if !defined(__ARM_ARCH__)
# if defined(__CC_ARM)
# define __ARM_ARCH__ __TARGET_ARCH_ARM
# if defined(__BIG_ENDIAN)
# define __ARMEB__
# else
# define __ARMEL__
# endif
# elif defined(__GNUC__)
/*
* Why doesn't gcc define __ARM_ARCH__? Instead it defines
* bunch of below macros. See all_architectires[] table in
* gcc/config/arm/arm.c. On a side note it defines
* __ARMEL__/__ARMEB__ for little-/big-endian.
*/
# if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \
defined(__ARM_ARCH_7R__)|| defined(__ARM_ARCH_7M__) || \
defined(__ARM_ARCH_7EM__)
# define __ARM_ARCH__ 7
# elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \
defined(__ARM_ARCH_6K__)|| defined(__ARM_ARCH_6M__) || \
defined(__ARM_ARCH_6Z__)|| defined(__ARM_ARCH_6ZK__) || \
defined(__ARM_ARCH_6T2__)
# define __ARM_ARCH__ 6
# elif defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) || \
defined(__ARM_ARCH_5E__)|| defined(__ARM_ARCH_5TE__) || \
defined(__ARM_ARCH_5TEJ__)
# define __ARM_ARCH__ 5
# elif defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__)
# define __ARM_ARCH__ 4
# else
# error "unsupported ARM architecture"
# endif
# endif
#endif
#ifdef OPENSSL_FIPSCANISTER
#include <openssl/fipssyms.h>
#endif
#if !__ASSEMBLER__
extern unsigned int OPENSSL_armcap_P;
#define ARMV7_NEON (1<<0)
#define ARMV7_TICK (1<<1)
#endif
#endif

View File

@ -1,6 +0,0 @@
#include <stdio.h>
void fakeFunction() {
printf("some androids has buggy native loader, so i should check size of libs in java to know that native library is correct. So each changed native library should has diffrent size in different app versions. This function will increase lib size for few bytes :)");
printf("");
}

View File

@ -23,12 +23,10 @@ import java.util.zip.ZipFile;
public class NativeLoader {
private static final long sizes[] = new long[] {
955148, //armeabi
1041184, //armeabi-v7a
1616116, //x86
0, //mips
};
private final static int LIB_VERSION = 1;
private final static String LIB_NAME = "tmessages." + LIB_VERSION;
private final static String LIB_SO_NAME = "lib" + LIB_NAME + ".so";
private final static String LOCALE_LIB_SO_NAME = "lib" + LIB_NAME + "loc.so";
private static volatile boolean nativeLoaded = false;
@ -50,14 +48,22 @@ public class NativeLoader {
return null;
}
private static boolean loadFromZip(Context context, File destLocalFile, String folder) {
private static boolean loadFromZip(Context context, File destDir, File destLocalFile, String folder) {
try {
for (File file : destDir.listFiles()) {
file.delete();
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
ZipFile zipFile = null;
InputStream stream = null;
try {
zipFile = new ZipFile(context.getApplicationInfo().sourceDir);
ZipEntry entry = zipFile.getEntry("lib/" + folder + "/libtmessages.so");
ZipEntry entry = zipFile.getEntry("lib/" + folder + "/" + LIB_SO_NAME);
if (entry == null) {
throw new Exception("Unable to find file in apk:" + "lib/" + folder + "/libtmessages.so");
throw new Exception("Unable to find file in apk:" + "lib/" + folder + "/" + LIB_NAME);
}
stream = zipFile.getInputStream(entry);
@ -105,50 +111,38 @@ public class NativeLoader {
try {
String folder = null;
long libSize = 0;
long libSize2 = 0;
try {
if (Build.CPU_ABI.equalsIgnoreCase("armeabi-v7a")) {
folder = "armeabi-v7a";
libSize = sizes[1];
libSize2 = sizes[0];
} else if (Build.CPU_ABI.equalsIgnoreCase("armeabi")) {
folder = "armeabi";
libSize = sizes[0];
libSize2 = sizes[1];
} else if (Build.CPU_ABI.equalsIgnoreCase("x86")) {
folder = "x86";
libSize = sizes[2];
} else if (Build.CPU_ABI.equalsIgnoreCase("mips")) {
folder = "mips";
libSize = sizes[3];
} else {
folder = "armeabi";
libSize = sizes[0];
libSize2 = sizes[1];
FileLog.e("tmessages", "Unsupported arch: " + Build.CPU_ABI);
}
} catch (Exception e) {
FileLog.e("tmessages", e);
folder = "armeabi";
libSize = sizes[0];
libSize2 = sizes[1];
}
String javaArch = System.getProperty("os.arch");
if (javaArch != null && javaArch.contains("686")) {
folder = "x86";
libSize = sizes[2];
}
File destFile = getNativeLibraryDir(context);
if (destFile != null) {
destFile = new File(destFile, "libtmessages.so");
if (destFile.exists() && (destFile.length() == libSize || libSize2 != 0 && destFile.length() == libSize2)) {
destFile = new File(destFile, LIB_SO_NAME);
if (destFile.exists()) {
FileLog.d("tmessages", "Load normal lib");
try {
System.loadLibrary("tmessages");
System.loadLibrary(LIB_NAME);
nativeLoaded = true;
return;
} catch (Error e) {
@ -157,39 +151,43 @@ public class NativeLoader {
}
}
File destLocalFile = new File(context.getFilesDir().getAbsolutePath() + "/libtmessages.so");
File destDir = new File(context.getFilesDir(), "lib");
destDir.mkdirs();
File destLocalFile = new File(destDir, LOCALE_LIB_SO_NAME);
if (destLocalFile != null && destLocalFile.exists()) {
if (destLocalFile.length() == libSize) {
try {
FileLog.d("tmessages", "Load local lib");
System.load(destLocalFile.getAbsolutePath());
nativeLoaded = true;
return;
} catch (Error e) {
FileLog.e("tmessages", e);
}
} else {
destLocalFile.delete();
try {
FileLog.d("tmessages", "Load local lib");
System.load(destLocalFile.getAbsolutePath());
nativeLoaded = true;
return;
} catch (Error e) {
FileLog.e("tmessages", e);
}
destLocalFile.delete();
}
FileLog.e("tmessages", "Library not found, arch = " + folder);
if (!loadFromZip(context, destLocalFile, folder)) {
folder = "x86";
if (loadFromZip(context, destDir, destLocalFile, folder)) {
return;
}
/*
folder = "x86";
destLocalFile = new File(context.getFilesDir().getAbsolutePath() + "/libtmessages86.so");
if (!loadFromZip(context, destLocalFile, folder)) {
destLocalFile = new File(context.getFilesDir().getAbsolutePath() + "/libtmessagesarm.so");
folder = "armeabi";
loadFromZip(context, destLocalFile, folder);
}
}
*/
} catch (Throwable e) {
e.printStackTrace();
}
try {
System.loadLibrary("tmessages");
System.loadLibrary(LIB_NAME);
nativeLoaded = true;
} catch (Error e) {
FileLog.e("tmessages", e);

View File

@ -33,8 +33,8 @@ import java.util.TimerTask;
public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter {
private Context mContext;
private HashMap<Integer, TLRPC.User> ignoreUsers;
private ArrayList<TLRPC.User> searchResult;
private ArrayList<CharSequence> searchResultNames;
private ArrayList<TLRPC.User> searchResult = new ArrayList<TLRPC.User>();
private ArrayList<CharSequence> searchResultNames = new ArrayList<CharSequence>();
private Timer searchTimer;
private boolean allowUsernameSearch;

View File

@ -9,6 +9,7 @@
package org.telegram.ui.Cells;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
@ -46,8 +47,6 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
public abstract void didPressedOther(ChatMediaCell cell);
}
private static Drawable placeholderInDrawable;
private static Drawable placeholderOutDrawable;
private static Drawable placeholderDocInDrawable;
private static Drawable placeholderDocOutDrawable;
private static Drawable videoIconDrawable;
@ -109,9 +108,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
public ChatMediaCell(Context context) {
super(context);
if (placeholderInDrawable == null) {
placeholderInDrawable = getResources().getDrawable(R.drawable.photo_placeholder_in);
placeholderOutDrawable = getResources().getDrawable(R.drawable.photo_placeholder_out);
if (placeholderDocInDrawable == null) {
placeholderDocInDrawable = getResources().getDrawable(R.drawable.doc_blue);
placeholderDocOutDrawable = getResources().getDrawable(R.drawable.doc_green);
buttonStatesDrawables[0] = getResources().getDrawable(R.drawable.photoload);
@ -330,7 +327,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
if (currentMessageObject.imagePreview != null) {
photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, new BitmapDrawable(currentMessageObject.imagePreview), currentPhotoObject.photoOwner.size, false);
} else {
photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, currentMessageObject.isOut() ? placeholderOutDrawable : placeholderInDrawable, currentPhotoObject.photoOwner.size, false);
photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, null, currentPhotoObject.photoOwner.size, false);
}
} else if (currentMessageObject.type == 8 || currentMessageObject.type == 9) {
FileLoader.getInstance().loadFile(currentMessageObject.messageOwner.media.document, true);
@ -511,7 +508,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
double lat = messageObject.messageOwner.media.geo.lat;
double lon = messageObject.messageOwner.media.geo._long;
currentUrl = String.format(Locale.US, "https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=13&size=100x100&maptype=roadmap&scale=%d&markers=color:red|size:big|%f,%f&sensor=false", lat, lon, Math.min(2, (int)Math.ceil(AndroidUtilities.density)), lat, lon);
photoImage.setImage(currentUrl, null, messageObject.isOut() ? placeholderOutDrawable : placeholderInDrawable);
photoImage.setImage(currentUrl, null, null);
} else {
if (AndroidUtilities.isTablet()) {
photoWidth = (int) (AndroidUtilities.getMinTabletSide() * 0.7f);
@ -601,19 +598,19 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
if (messageObject.imagePreview != null) {
photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, new BitmapDrawable(messageObject.imagePreview), noSize ? 0 : currentPhotoObject.photoOwner.size, false);
} else {
photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, messageObject.isOut() ? placeholderOutDrawable : placeholderInDrawable, noSize ? 0 : currentPhotoObject.photoOwner.size, false);
photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, null, noSize ? 0 : currentPhotoObject.photoOwner.size, false);
}
} else {
photoNotSet = true;
if (messageObject.imagePreview != null) {
photoImage.setImageBitmap(messageObject.imagePreview);
} else {
photoImage.setImageBitmap(messageObject.isOut() ? placeholderOutDrawable : placeholderInDrawable);
photoImage.setImageBitmap((Bitmap)null);
}
}
}
} else {
photoImage.setImageBitmap(messageObject.isOut() ? placeholderOutDrawable : placeholderInDrawable);
photoImage.setImageBitmap((Bitmap)null);
}
}
photoImage.setForcePreview(messageObject.isSecretPhoto());

View File

@ -22,6 +22,7 @@ import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
@ -85,6 +86,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
private ActionBarLayer actionBarLayer;
private boolean isActionBarVisible = true;
private static Drawable[] progressDrawables = null;
private WindowManager.LayoutParams windowLayoutParams;
private FrameLayoutDrawer containerView;
private FrameLayoutTouchListener windowView;
@ -466,6 +469,14 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
}
parentActivity = activity;
if (progressDrawables == null) {
progressDrawables = new Drawable[4];
progressDrawables[0] = parentActivity.getDrawable(R.drawable.cancel_big);
progressDrawables[1] = parentActivity.getDrawable(R.drawable.circle_big);
progressDrawables[2] = parentActivity.getDrawable(R.drawable.load_big);
progressDrawables[3] = parentActivity.getDrawable(R.drawable.play_big);
}
scroller = new Scroller(activity);
windowView = new FrameLayoutTouchListener(activity);

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

@ -1,7 +1,7 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle">
<solid android:color="#e2f8ff" />
<solid android:color="#f0f0f0" />
</shape>
</item>
</layer-list>

View File

@ -1,7 +0,0 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle">
<solid android:color="#ccf7a6" />
</shape>
</item>
</layer-list>