Skip to content

Commit

Permalink
Merge pull request #895 from meganz/release/v3.6.3
Browse files Browse the repository at this point in the history
Release/v3.6.3
  • Loading branch information
ygaoy authored Jul 4, 2019
2 parents 0d0eb2f + 67949a7 commit dccdab0
Show file tree
Hide file tree
Showing 137 changed files with 5,268 additions and 5,072 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "mega.privacy.android.app"
minSdkVersion 21
targetSdkVersion 27
versionCode 239
versionName "3.6.2 (239)"
versionCode 244
versionName "3.6.3 (244)"
multiDexEnabled true
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mega.privacy.android.app"
android:installLocation="internalOnly"
android:versionCode="239"
android:versionName="3.6.2 (239)" >
android:versionCode="244"
android:versionName="3.6.3 (244)" >

<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<uses-feature android:name="android.hardware.camera" android:required="false"/>
Expand Down
47 changes: 17 additions & 30 deletions app/src/main/java/mega/privacy/android/app/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import mega.privacy.android.app.utils.Util;
import nz.mega.sdk.MegaApiAndroid;
import nz.mega.sdk.MegaChatApiAndroid;
import nz.mega.sdk.MegaChatCall;
import nz.mega.sdk.MegaChatPresenceConfig;
import nz.mega.sdk.MegaChatRoom;

public class BaseActivity extends AppCompatActivity {
Expand Down Expand Up @@ -77,24 +79,7 @@ protected void onResume() {

checkMegaApiObjects();

if(megaChatApi != null){
if(megaChatApi.getPresenceConfig()==null){
delaySignalPresence = true;
}
else{
if(megaChatApi.getPresenceConfig().isPending()==true){
delaySignalPresence = true;
}
else{
delaySignalPresence = false;
retryConnectionsAndSignalPresence();
}
}
}
else{
delaySignalPresence = false;
retryConnectionsAndSignalPresence();
}
retryConnectionsAndSignalPresence();
}

@Override
Expand Down Expand Up @@ -150,7 +135,7 @@ public void onReceive(Context context, Intent intent) {
@Override
public void onReceive(Context context, Intent intent) {
if (intent != null) {
log("****BROADCAST TO SEND SIGNAL PRESENCE");
log("BROADCAST TO SEND SIGNAL PRESENCE");
if(delaySignalPresence && megaChatApi != null && megaChatApi.getPresenceConfig() != null && megaChatApi.getPresenceConfig().isPending()==false){
delaySignalPresence = false;
retryConnectionsAndSignalPresence();
Expand Down Expand Up @@ -225,33 +210,35 @@ public void onClick(View v) {
sslErrorDialog.show();
}

public void retryConnectionsAndSignalPresence(){
protected void retryConnectionsAndSignalPresence(){
log("retryConnectionsAndSignalPresence");
try{
if (megaApi != null){
megaApi.retryPendingConnections();
}

if(Util.isChatEnabled()){
if (megaChatApi != null){
if(Util.isChatEnabled()) {
if (megaChatApi != null) {
megaChatApi.retryPendingConnections(false, null);
}

if(!(this instanceof ChatCallActivity)){
log("Send signal presence if needed");
if(megaChatApi != null && megaChatApi.isSignalActivityRequired()){
megaChatApi.signalPresenceActivity();
if(megaChatApi.getPresenceConfig() != null && megaChatApi.getPresenceConfig().isPending() == false){
delaySignalPresence = false;
if(!(this instanceof ChatCallActivity) && megaChatApi.isSignalActivityRequired()){
log("Send signal presence");
megaChatApi.signalPresenceActivity();
}
}
else {
delaySignalPresence = true;
}
}
}
}
catch (Exception e){
log("retryPendingConnections:Exception: "+e.getMessage());
log("retryConnectionsAndSignalPresence:Exception: " + e.getMessage());
}
}



@Override
public void onBackPressed() {
retryConnectionsAndSignalPresence();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ private int shouldRun(){
if (ret == MegaChatApi.INIT_NO_CACHE)
{
log("shouldRun: condition ret == MegaChatApi.INIT_NO_CACHE");
megaChatApi.enableGroupChatCalls(true);

}
else if (ret == MegaChatApi.INIT_ERROR)
Expand All @@ -378,7 +377,6 @@ else if (ret == MegaChatApi.INIT_ERROR)
}
else{
log("shouldRun: Chat correctly initialized");
megaChatApi.enableGroupChatCalls(true);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -752,8 +752,9 @@ public UserCredentials getCredentials(){

String selectQuery = "SELECT * FROM " + TABLE_CREDENTIALS;
try{
Cursor cursor = db.rawQuery(selectQuery, null);
if (cursor.moveToFirst()) {
Cursor cursor = db.rawQuery(selectQuery, null);
//get the credential of last login
if (cursor.moveToLast()) {
int id = Integer.parseInt(cursor.getString(0));
String email = decrypt(cursor.getString(1));
String session = decrypt(cursor.getString(2));
Expand Down
15 changes: 11 additions & 4 deletions app/src/main/java/mega/privacy/android/app/DownloadService.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ public class DownloadService extends Service implements MegaTransferListenerInte
MegaNode offlineNode;

boolean isLoggingIn = false;
private long lastUpdated;

@SuppressLint("NewApi")
@SuppressLint("NewApi")
@Override
public void onCreate(){
super.onCreate();
Expand Down Expand Up @@ -259,7 +260,6 @@ protected void onHandleIntent(final Intent intent) {
chatSettings = dbH.getChatSettings();
if (ret == MegaChatApi.INIT_NO_CACHE) {
log("condition ret == MegaChatApi.INIT_NO_CACHE");
megaChatApi.enableGroupChatCalls(true);
} else if (ret == MegaChatApi.INIT_ERROR) {
log("condition ret == MegaChatApi.INIT_ERROR");
if (chatSettings == null) {
Expand All @@ -274,7 +274,6 @@ protected void onHandleIntent(final Intent intent) {
megaChatApi.logout(this);
} else {
log("Chat correctly initialized");
megaChatApi.enableGroupChatCalls(true);
}
}
}
Expand Down Expand Up @@ -1191,7 +1190,6 @@ else if (MimeTypeList.typeForName(currentFile.getName()).isURL()) {
*/
@SuppressLint("NewApi")
private void updateProgressNotification() {

int pendingTransfers = megaApi.getNumPendingDownloads() + megaApiFolder.getNumPendingDownloads();
int totalTransfers = megaApi.getTotalDownloads() + megaApiFolder.getTotalDownloads();

Expand All @@ -1217,6 +1215,15 @@ private void updateProgressNotification() {
}

if(update){
//refresh UI every 1 seconds to avoid too much workload on main thread
if(!isOverquota) {
long now = System.currentTimeMillis();
if (now - lastUpdated > 1000) {
lastUpdated = now;
} else {
return;
}
}
int progressPercent = (int) Math.round((double) totalSizeTransferred / totalSizePendingTransfer * 100);
log("updateProgressNotification: "+progressPercent);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.webrtc.SurfaceTextureHelper;
import org.webrtc.VideoCapturer;

import java.io.File;
import java.util.ArrayList;
import java.util.Locale;

Expand All @@ -60,6 +61,7 @@
import mega.privacy.android.app.lollipop.megachat.BadgeIntentService;
import mega.privacy.android.app.lollipop.megachat.calls.ChatCallActivity;
import mega.privacy.android.app.receivers.NetworkStateReceiver;
import mega.privacy.android.app.utils.CacheFolderManager;
import mega.privacy.android.app.utils.Constants;
import mega.privacy.android.app.utils.TimeUtils;
import mega.privacy.android.app.utils.Util;
Expand Down Expand Up @@ -98,7 +100,7 @@
public class MegaApplication extends MultiDexApplication implements MegaGlobalListenerInterface, MegaChatRequestListenerInterface, MegaChatNotificationListenerInterface, MegaChatCallListenerInterface, NetworkStateReceiver.NetworkStateReceiverListener, MegaChatListenerInterface {
final String TAG = "MegaApplication";

static final public String USER_AGENT = "MEGAAndroid/3.6.2_239";
static final public String USER_AGENT = "MEGAAndroid/3.6.3_244";

DatabaseHandler dbH;
MegaApiAndroid megaApi;
Expand Down Expand Up @@ -568,7 +570,8 @@ public void onFailed(@Nullable Throwable throwable) {
});
}
EmojiCompat.init(config);

// clear the cache files stored in the external cache folder.
CacheFolderManager.clearPublicCache(this);

// initializeGA();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ protected void onCreate(Bundle savedInstanceState){
long handle = MegaApiAndroid.base64ToHandle(s[1].trim());
Intent inviteContact = new Intent(this, ManagerActivityLollipop.class);
inviteContact.setAction(Constants.ACTION_OPEN_CONTACTS_SECTION);
inviteContact.putExtra("handle", handle);
inviteContact.putExtra(Constants.CONTACT_HANDLE, handle);
startActivity(inviteContact);
finish();
} else {
Expand Down
66 changes: 22 additions & 44 deletions app/src/main/java/mega/privacy/android/app/ShareInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
import android.annotation.SuppressLint;
import android.content.ClipData;
import android.content.ContentProviderClient;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.RemoteException;
import android.provider.ContactsContract;
import android.provider.MediaStore;
import android.text.TextUtils;

import java.io.BufferedOutputStream;
import java.io.File;
Expand Down Expand Up @@ -243,7 +239,10 @@ private void processUri(Uri uri, Context context) {
inputStream = null;
try {
inputStream = context.getContentResolver().openInputStream(uri);
} catch (Exception e) {
} catch (FileNotFoundException fileNotFound) {
log("FileNotFoundException, can't find uri: " + uri);
return;
} catch (Exception e) {
log("inputStream EXCEPTION!");
log(""+e);
String path = uri.getPath();
Expand Down Expand Up @@ -309,44 +308,23 @@ private void processUri(Uri uri, Context context) {
return;
}

if (context.getExternalCacheDir() != null){
if (title != null){
if (title.contains("../") || title.contains(("..%2F"))){
log("External path traversal: " + title);
return;
}
log("External No path traversal: " + title);
if (context instanceof PdfViewerActivityLollipop){
log("context of PdfViewerActivityLollipop");
if (!title.endsWith(".pdf")){
title += ".pdf";
}
}
file = new File(context.getExternalCacheDir(), title);
}
else{
return;
}
}
else{
if (title != null){
if (title.contains("../") || title.contains(("..%2F"))){
log("Internal path traversal: " + title);
return;
}
log("Internal No path traversal: " + title);
if (context instanceof PdfViewerActivityLollipop){
log("context of PdfViewerActivityLollipop");
if (!title.endsWith(".pdf")){
title += ".pdf";
}
}
file = new File(context.getCacheDir(), title);
}
else{
return;
}
}
if (title == null) {
log("title is null, return!");
return;
}
if (title.contains("../") || title.contains(("..%2F"))) {
log("Internal path traversal: " + title);
return;
}
log("Internal No path traversal: " + title);
if (context instanceof PdfViewerActivityLollipop) {
log("context of PdfViewerActivityLollipop");
if (!title.endsWith(".pdf")) {
title += ".pdf";
}
}
file = new File(context.getCacheDir(), title);

log("Start copy to: "+file.getAbsolutePath());

try {
Expand Down Expand Up @@ -428,7 +406,7 @@ private void processContent(Uri uri, Context context) {
Cursor cursor = null;
try {
cursor = client.query(uri, null, null, null, null);
} catch (RemoteException e1) {
} catch (Exception e1) {
log("cursor EXCEPTION!!!");
}
if(cursor!=null){
Expand Down
Loading

0 comments on commit dccdab0

Please sign in to comment.