jimu-decompiled/sources/com/tencent/mm/opensdk/modelmsg/WXFileObject.java
2025-05-13 19:24:51 +02:00

95 lines
2.9 KiB
Java

package com.tencent.mm.opensdk.modelmsg;
import android.os.Bundle;
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
import com.tencent.mm.opensdk.utils.Log;
import java.io.File;
/* loaded from: classes.dex */
public class WXFileObject implements WXMediaMessage.IMediaObject {
private static final int CONTENT_LENGTH_LIMIT = 10485760;
private static final String TAG = "MicroMsg.SDK.WXFileObject";
private int contentLengthLimit;
public byte[] fileData;
public String filePath;
public WXFileObject() {
this.contentLengthLimit = CONTENT_LENGTH_LIMIT;
this.fileData = null;
this.filePath = null;
}
public WXFileObject(String str) {
this.contentLengthLimit = CONTENT_LENGTH_LIMIT;
this.filePath = str;
}
public WXFileObject(byte[] bArr) {
this.contentLengthLimit = CONTENT_LENGTH_LIMIT;
this.fileData = bArr;
}
private int getFileSize(String str) {
if (str == null || str.length() == 0) {
return 0;
}
File file = new File(str);
if (file.exists()) {
return (int) file.length();
}
return 0;
}
@Override // com.tencent.mm.opensdk.modelmsg.WXMediaMessage.IMediaObject
public boolean checkArgs() {
String str;
String str2;
byte[] bArr = this.fileData;
if ((bArr == null || bArr.length == 0) && ((str = this.filePath) == null || str.length() == 0)) {
str2 = "checkArgs fail, both arguments is null";
} else {
byte[] bArr2 = this.fileData;
if (bArr2 == null || bArr2.length <= this.contentLengthLimit) {
String str3 = this.filePath;
if (str3 == null || getFileSize(str3) <= this.contentLengthLimit) {
return true;
}
str2 = "checkArgs fail, fileSize is too large";
} else {
str2 = "checkArgs fail, fileData is too large";
}
}
Log.e(TAG, str2);
return false;
}
@Override // com.tencent.mm.opensdk.modelmsg.WXMediaMessage.IMediaObject
public void serialize(Bundle bundle) {
bundle.putByteArray("_wxfileobject_fileData", this.fileData);
bundle.putString("_wxfileobject_filePath", this.filePath);
}
public void setContentLengthLimit(int i) {
this.contentLengthLimit = i;
}
public void setFileData(byte[] bArr) {
this.fileData = bArr;
}
public void setFilePath(String str) {
this.filePath = str;
}
@Override // com.tencent.mm.opensdk.modelmsg.WXMediaMessage.IMediaObject
public int type() {
return 6;
}
@Override // com.tencent.mm.opensdk.modelmsg.WXMediaMessage.IMediaObject
public void unserialize(Bundle bundle) {
this.fileData = bundle.getByteArray("_wxfileobject_fileData");
this.filePath = bundle.getString("_wxfileobject_filePath");
}
}