Commit b33d5f07 authored by DrKLO's avatar DrKLO

Changed native lib loaded

parent abf8f6f6
...@@ -2,7 +2,7 @@ LOCAL_PATH := $(call my-dir) ...@@ -2,7 +2,7 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_PRELINK_MODULE := false 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 := -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 += -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 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 += \ ...@@ -162,10 +162,23 @@ LOCAL_SRC_FILES += \
./giflib/gifalloc.c ./giflib/gifalloc.c
LOCAL_SRC_FILES += \ LOCAL_SRC_FILES += \
./aes/aes_core.c \
./aes/aes_ige.c \ ./aes/aes_ige.c \
./aes/aes_misc.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 += \ LOCAL_SRC_FILES += \
./sqlite/sqlite3.c ./sqlite/sqlite3.c
...@@ -277,7 +290,6 @@ LOCAL_SRC_FILES += \ ...@@ -277,7 +290,6 @@ LOCAL_SRC_FILES += \
./gif.c \ ./gif.c \
./utils.c \ ./utils.c \
./image.c \ ./image.c \
./video.c \ ./video.c
./fake.c
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)
\ No newline at end of file
This diff is collapsed.
#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
#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("");
}
...@@ -23,12 +23,10 @@ import java.util.zip.ZipFile; ...@@ -23,12 +23,10 @@ import java.util.zip.ZipFile;
public class NativeLoader { public class NativeLoader {
private static final long sizes[] = new long[] { private final static int LIB_VERSION = 1;
955148, //armeabi private final static String LIB_NAME = "tmessages." + LIB_VERSION;
1041184, //armeabi-v7a private final static String LIB_SO_NAME = "lib" + LIB_NAME + ".so";
1616116, //x86 private final static String LOCALE_LIB_SO_NAME = "lib" + LIB_NAME + "loc.so";
0, //mips
};
private static volatile boolean nativeLoaded = false; private static volatile boolean nativeLoaded = false;
...@@ -50,14 +48,22 @@ public class NativeLoader { ...@@ -50,14 +48,22 @@ public class NativeLoader {
return null; 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; ZipFile zipFile = null;
InputStream stream = null; InputStream stream = null;
try { try {
zipFile = new ZipFile(context.getApplicationInfo().sourceDir); 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) { 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); stream = zipFile.getInputStream(entry);
...@@ -105,50 +111,38 @@ public class NativeLoader { ...@@ -105,50 +111,38 @@ public class NativeLoader {
try { try {
String folder = null; String folder = null;
long libSize = 0;
long libSize2 = 0;
try { try {
if (Build.CPU_ABI.equalsIgnoreCase("armeabi-v7a")) { if (Build.CPU_ABI.equalsIgnoreCase("armeabi-v7a")) {
folder = "armeabi-v7a"; folder = "armeabi-v7a";
libSize = sizes[1];
libSize2 = sizes[0];
} else if (Build.CPU_ABI.equalsIgnoreCase("armeabi")) { } else if (Build.CPU_ABI.equalsIgnoreCase("armeabi")) {
folder = "armeabi"; folder = "armeabi";
libSize = sizes[0];
libSize2 = sizes[1];
} else if (Build.CPU_ABI.equalsIgnoreCase("x86")) { } else if (Build.CPU_ABI.equalsIgnoreCase("x86")) {
folder = "x86"; folder = "x86";
libSize = sizes[2];
} else if (Build.CPU_ABI.equalsIgnoreCase("mips")) { } else if (Build.CPU_ABI.equalsIgnoreCase("mips")) {
folder = "mips"; folder = "mips";
libSize = sizes[3];
} else { } else {
folder = "armeabi"; folder = "armeabi";
libSize = sizes[0];
libSize2 = sizes[1];
FileLog.e("tmessages", "Unsupported arch: " + Build.CPU_ABI); FileLog.e("tmessages", "Unsupported arch: " + Build.CPU_ABI);
} }
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
folder = "armeabi"; folder = "armeabi";
libSize = sizes[0];
libSize2 = sizes[1];
} }
String javaArch = System.getProperty("os.arch"); String javaArch = System.getProperty("os.arch");
if (javaArch != null && javaArch.contains("686")) { if (javaArch != null && javaArch.contains("686")) {
folder = "x86"; folder = "x86";
libSize = sizes[2];
} }
File destFile = getNativeLibraryDir(context); File destFile = getNativeLibraryDir(context);
if (destFile != null) { if (destFile != null) {
destFile = new File(destFile, "libtmessages.so"); destFile = new File(destFile, LIB_SO_NAME);
if (destFile.exists() && (destFile.length() == libSize || libSize2 != 0 && destFile.length() == libSize2)) { if (destFile.exists()) {
FileLog.d("tmessages", "Load normal lib"); FileLog.d("tmessages", "Load normal lib");
try { try {
System.loadLibrary("tmessages"); System.loadLibrary(LIB_NAME);
nativeLoaded = true; nativeLoaded = true;
return; return;
} catch (Error e) { } catch (Error e) {
...@@ -157,9 +151,11 @@ public class NativeLoader { ...@@ -157,9 +151,11 @@ 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 != null && destLocalFile.exists()) {
if (destLocalFile.length() == libSize) {
try { try {
FileLog.d("tmessages", "Load local lib"); FileLog.d("tmessages", "Load local lib");
System.load(destLocalFile.getAbsolutePath()); System.load(destLocalFile.getAbsolutePath());
...@@ -168,14 +164,16 @@ public class NativeLoader { ...@@ -168,14 +164,16 @@ public class NativeLoader {
} catch (Error e) { } catch (Error e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
} else {
destLocalFile.delete(); destLocalFile.delete();
} }
}
FileLog.e("tmessages", "Library not found, arch = " + folder); FileLog.e("tmessages", "Library not found, arch = " + folder);
if (!loadFromZip(context, destLocalFile, folder)) { if (loadFromZip(context, destDir, destLocalFile, folder)) {
return;
}
/*
folder = "x86"; folder = "x86";
destLocalFile = new File(context.getFilesDir().getAbsolutePath() + "/libtmessages86.so"); destLocalFile = new File(context.getFilesDir().getAbsolutePath() + "/libtmessages86.so");
if (!loadFromZip(context, destLocalFile, folder)) { if (!loadFromZip(context, destLocalFile, folder)) {
...@@ -183,13 +181,13 @@ public class NativeLoader { ...@@ -183,13 +181,13 @@ public class NativeLoader {
folder = "armeabi"; folder = "armeabi";
loadFromZip(context, destLocalFile, folder); loadFromZip(context, destLocalFile, folder);
} }
} */
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }
try { try {
System.loadLibrary("tmessages"); System.loadLibrary(LIB_NAME);
nativeLoaded = true; nativeLoaded = true;
} catch (Error e) { } catch (Error e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
......
...@@ -33,8 +33,8 @@ import java.util.TimerTask; ...@@ -33,8 +33,8 @@ import java.util.TimerTask;
public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter { public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter {
private Context mContext; private Context mContext;
private HashMap<Integer, TLRPC.User> ignoreUsers; private HashMap<Integer, TLRPC.User> ignoreUsers;
private ArrayList<TLRPC.User> searchResult; private ArrayList<TLRPC.User> searchResult = new ArrayList<TLRPC.User>();
private ArrayList<CharSequence> searchResultNames; private ArrayList<CharSequence> searchResultNames = new ArrayList<CharSequence>();
private Timer searchTimer; private Timer searchTimer;
private boolean allowUsernameSearch; private boolean allowUsernameSearch;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
package org.telegram.ui.Cells; package org.telegram.ui.Cells;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.RectF; import android.graphics.RectF;
...@@ -46,8 +47,6 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD ...@@ -46,8 +47,6 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
public abstract void didPressedOther(ChatMediaCell cell); public abstract void didPressedOther(ChatMediaCell cell);
} }
private static Drawable placeholderInDrawable;
private static Drawable placeholderOutDrawable;
private static Drawable placeholderDocInDrawable; private static Drawable placeholderDocInDrawable;
private static Drawable placeholderDocOutDrawable; private static Drawable placeholderDocOutDrawable;
private static Drawable videoIconDrawable; private static Drawable videoIconDrawable;
...@@ -109,9 +108,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD ...@@ -109,9 +108,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
public ChatMediaCell(Context context) { public ChatMediaCell(Context context) {
super(context); super(context);
if (placeholderInDrawable == null) { if (placeholderDocInDrawable == null) {
placeholderInDrawable = getResources().getDrawable(R.drawable.photo_placeholder_in);
placeholderOutDrawable = getResources().getDrawable(R.drawable.photo_placeholder_out);
placeholderDocInDrawable = getResources().getDrawable(R.drawable.doc_blue); placeholderDocInDrawable = getResources().getDrawable(R.drawable.doc_blue);
placeholderDocOutDrawable = getResources().getDrawable(R.drawable.doc_green); placeholderDocOutDrawable = getResources().getDrawable(R.drawable.doc_green);
buttonStatesDrawables[0] = getResources().getDrawable(R.drawable.photoload); buttonStatesDrawables[0] = getResources().getDrawable(R.drawable.photoload);
...@@ -330,7 +327,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD ...@@ -330,7 +327,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
if (currentMessageObject.imagePreview != null) { if (currentMessageObject.imagePreview != null) {
photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, new BitmapDrawable(currentMessageObject.imagePreview), currentPhotoObject.photoOwner.size, false); photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, new BitmapDrawable(currentMessageObject.imagePreview), currentPhotoObject.photoOwner.size, false);
} else { } 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) { } else if (currentMessageObject.type == 8 || currentMessageObject.type == 9) {
FileLoader.getInstance().loadFile(currentMessageObject.messageOwner.media.document, true); FileLoader.getInstance().loadFile(currentMessageObject.messageOwner.media.document, true);
...@@ -511,7 +508,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD ...@@ -511,7 +508,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
double lat = messageObject.messageOwner.media.geo.lat; double lat = messageObject.messageOwner.media.geo.lat;
double lon = messageObject.messageOwner.media.geo._long; 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); 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 { } else {
if (AndroidUtilities.isTablet()) { if (AndroidUtilities.isTablet()) {
photoWidth = (int) (AndroidUtilities.getMinTabletSide() * 0.7f); photoWidth = (int) (AndroidUtilities.getMinTabletSide() * 0.7f);
...@@ -601,19 +598,19 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD ...@@ -601,19 +598,19 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
if (messageObject.imagePreview != null) { if (messageObject.imagePreview != null) {
photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, new BitmapDrawable(messageObject.imagePreview), noSize ? 0 : currentPhotoObject.photoOwner.size, false); photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, new BitmapDrawable(messageObject.imagePreview), noSize ? 0 : currentPhotoObject.photoOwner.size, false);
} else { } 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 { } else {
photoNotSet = true; photoNotSet = true;
if (messageObject.imagePreview != null) { if (messageObject.imagePreview != null) {
photoImage.setImageBitmap(messageObject.imagePreview); photoImage.setImageBitmap(messageObject.imagePreview);
} else { } else {
photoImage.setImageBitmap(messageObject.isOut() ? placeholderOutDrawable : placeholderInDrawable); photoImage.setImageBitmap((Bitmap)null);
} }
} }
} }
} else { } else {
photoImage.setImageBitmap(messageObject.isOut() ? placeholderOutDrawable : placeholderInDrawable); photoImage.setImageBitmap((Bitmap)null);
} }
} }
photoImage.setForcePreview(messageObject.isSecretPhoto()); photoImage.setForcePreview(messageObject.isSecretPhoto());
......
...@@ -22,6 +22,7 @@ import android.graphics.PixelFormat; ...@@ -22,6 +22,7 @@ import android.graphics.PixelFormat;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
...@@ -85,6 +86,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat ...@@ -85,6 +86,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
private ActionBarLayer actionBarLayer; private ActionBarLayer actionBarLayer;
private boolean isActionBarVisible = true; private boolean isActionBarVisible = true;
private static Drawable[] progressDrawables = null;
private WindowManager.LayoutParams windowLayoutParams; private WindowManager.LayoutParams windowLayoutParams;
private FrameLayoutDrawer containerView; private FrameLayoutDrawer containerView;
private FrameLayoutTouchListener windowView; private FrameLayoutTouchListener windowView;
...@@ -466,6 +469,14 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat ...@@ -466,6 +469,14 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} }
parentActivity = activity; 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); scroller = new Scroller(activity);
windowView = new FrameLayoutTouchListener(activity); windowView = new FrameLayoutTouchListener(activity);
......
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item> <item>
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<solid android:color="#e2f8ff" /> <solid android:color="#f0f0f0" />
</shape> </shape>
</item> </item>
</layer-list> </layer-list>
\ No newline at end of file
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle">
<solid android:color="#ccf7a6" />
</shape>
</item>
</layer-list>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment