本文整理汇总了Java中org.thoughtcrime.securesms.crypto.DecryptingPartInputStream类的典型用法代码示例。如果您正苦于以下问题:Java DecryptingPartInputStream类的具体用法?Java DecryptingPartInputStream怎么用?Java DecryptingPartInputStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DecryptingPartInputStream类属于org.thoughtcrime.securesms.crypto包,在下文中一共展示了DecryptingPartInputStream类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readAt
import org.thoughtcrime.securesms.crypto.DecryptingPartInputStream; //导入依赖的package包/类
@Override
public int readAt(long position, byte[] bytes, int offset, int length) throws IOException {
DecryptingPartInputStream inputStream = new DecryptingPartInputStream(mediaFile, masterSecret);
byte[] buffer = new byte[4096];
long headerRemaining = position;
while (headerRemaining > 0) {
int read = inputStream.read(buffer, 0, Util.toIntExact(Math.min((long)buffer.length, headerRemaining)));
if (read == -1) return -1;
headerRemaining -= read;
}
int returnValue = inputStream.read(bytes, offset, length);
inputStream.close();
return returnValue;
}
示例2: readAt
import org.thoughtcrime.securesms.crypto.DecryptingPartInputStream; //导入依赖的package包/类
@Override
public int readAt(long position, byte[] bytes, int offset, int length) throws IOException {
InputStream inputStream = DecryptingPartInputStream.createFor(masterSecret, mediaFile);
byte[] buffer = new byte[4096];
long headerRemaining = position;
while (headerRemaining > 0) {
int read = inputStream.read(buffer, 0, Util.toIntExact(Math.min((long)buffer.length, headerRemaining)));
if (read == -1) return -1;
headerRemaining -= read;
}
int returnValue = inputStream.read(bytes, offset, length);
inputStream.close();
return returnValue;
}
示例3: getDataStream
import org.thoughtcrime.securesms.crypto.DecryptingPartInputStream; //导入依赖的package包/类
@VisibleForTesting
protected @Nullable InputStream getDataStream(MasterSecret masterSecret, AttachmentId attachmentId, String dataType)
{
File dataFile = getAttachmentDataFile(attachmentId, dataType);
try {
if (dataFile != null) return new DecryptingPartInputStream(dataFile, masterSecret);
else return null;
} catch (FileNotFoundException e) {
Log.w(TAG, e);
return null;
}
}
示例4: getSize
import org.thoughtcrime.securesms.crypto.DecryptingPartInputStream; //导入依赖的package包/类
@Override
public long getSize() throws IOException {
DecryptingPartInputStream inputStream = new DecryptingPartInputStream(mediaFile, masterSecret);
byte[] buffer = new byte[4096];
long size = 0;
int read;
while ((read = inputStream.read(buffer)) != -1) {
size += read;
}
return size;
}
示例5: getDataStream
import org.thoughtcrime.securesms.crypto.DecryptingPartInputStream; //导入依赖的package包/类
@VisibleForTesting
protected @Nullable InputStream getDataStream(MasterSecret masterSecret, AttachmentId attachmentId, String dataType)
{
File dataFile = getAttachmentDataFile(attachmentId, dataType);
try {
if (dataFile != null) return DecryptingPartInputStream.createFor(masterSecret, dataFile);
else return null;
} catch (IOException e) {
Log.w(TAG, e);
return null;
}
}
示例6: getSize
import org.thoughtcrime.securesms.crypto.DecryptingPartInputStream; //导入依赖的package包/类
@Override
public long getSize() throws IOException {
InputStream inputStream = DecryptingPartInputStream.createFor(masterSecret, mediaFile);
byte[] buffer = new byte[4096];
long size = 0;
int read;
while ((read = inputStream.read(buffer)) != -1) {
size += read;
}
return size;
}
示例7: getStream
import org.thoughtcrime.securesms.crypto.DecryptingPartInputStream; //导入依赖的package包/类
public @NonNull InputStream getStream(MasterSecret masterSecret, long id) throws IOException {
final byte[] cached = cache.get(id);
return cached != null ? new ByteArrayInputStream(cached)
: new DecryptingPartInputStream(getFile(id), masterSecret);
}
示例8: getStream
import org.thoughtcrime.securesms.crypto.DecryptingPartInputStream; //导入依赖的package包/类
public @NonNull InputStream getStream(MasterSecret masterSecret, long id) throws IOException {
final byte[] cached = cache.get(id);
return cached != null ? new ByteArrayInputStream(cached)
: DecryptingPartInputStream.createFor(masterSecret, getFile(id));
}
示例9: getPartInputStream
import org.thoughtcrime.securesms.crypto.DecryptingPartInputStream; //导入依赖的package包/类
private InputStream getPartInputStream(MasterSecret masterSecret, File path)
throws FileNotFoundException
{
Log.w(TAG, "Getting part at: " + path.getAbsolutePath());
return new DecryptingPartInputStream(path, masterSecret);
}