Commit e23272ea authored by T Dev. D's avatar T Dev. D 😎
Browse files

Fuck NVK

parent 84aa16ce
......@@ -130,9 +130,6 @@ dependencies {
implementation 'org.bouncycastle:bcprov-jdk15on:1.55'
implementation 'com.madgag.spongycastle:prov:1.54.0.0'
implementation 'com.lambdaworks:scrypt:1.4.0'
implementation 'com.github.mjdev:libaums:0.5.5'
implementation 'de.mindpipe.android:android-logging-log4j:1.0.3'
implementation 'me.jahnen:java-fs:0.1.4'
implementation 'com.google.android.material:material:1.5.0-alpha02'
implementation 'org.hibernate:hibernate-validator:5.4.3.Final'
implementation 'com.google.code.gson:gson:2.8.6'
......
......@@ -17,23 +17,6 @@
<uses-permission
android:name="android.permission.WAKE_LOCK"
tools:node="replace" />
<!--
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
-->
<!--
<uses-feature
android:name="android.hardware.telephony"
android:required="false"
tools:node="replace" />
-->
<uses-feature
android:name="android.hardware.usb.host"
android:required="false"
tools:node="replace" />
<uses-feature
android:name="android.hardware.camera.autofocus"
android:required="false"
......@@ -153,21 +136,6 @@
android:name=".ricochet.RicochetActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name" />
<activity
android:name=".OpenDimeActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:theme="@style/Theme.Samourai.Material">
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/device_filter" />
</activity>
<activity
android:name=".PayNymCalcActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
......@@ -183,39 +151,6 @@
<activity
android:name=".RestoreSeedWalletActivity"
android:theme="@style/Theme.Samourai.Material" />
<!--
<receiver
android:name=".receivers.BootIntentReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>
<receiver
android:name=".receivers.InterceptOutgoingReceiver"
android:enabled="true"
android:exported="true">
<intent-filter android:priority="1001">
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<receiver
android:name=".receivers.SMSReceiver"
android:enabled="true"
android:exported="true">
<intent-filter android:priority="999">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
-->
<activity
android:name=".TxAnimUIActivity"
android:theme="@style/SamouraiAppTheme" />
......
package com.github.magnusja.libaums.javafs;
import android.util.Log;
import com.github.magnusja.libaums.javafs.wrapper.device.DeviceWrapper;
import com.github.magnusja.libaums.javafs.wrapper.device.FSBlockDeviceWrapper;
import com.github.magnusja.libaums.javafs.wrapper.fs.FileSystemWrapper;
import com.github.mjdev.libaums.driver.BlockDeviceDriver;
import com.github.mjdev.libaums.fs.FileSystem;
import com.github.mjdev.libaums.fs.FileSystemCreator;
import com.github.mjdev.libaums.partition.PartitionTableEntry;
import org.apache.log4j.Logger;
import org.jnode.fs.FileSystemException;
import org.jnode.fs.FileSystemType;
import org.jnode.fs.exfat.ExFatFileSystemType;
import org.jnode.fs.ext2.Ext2FileSystemType;
import org.jnode.fs.hfs.HfsWrapperFileSystemType;
import org.jnode.fs.hfsplus.HfsPlusFileSystemType;
import org.jnode.fs.iso9660.ISO9660FileSystemType;
import org.jnode.fs.jfat.FatFileSystemType;
import org.jnode.fs.ntfs.NTFSFileSystemType;
import org.jnode.fs.xfs.XfsFileSystemType;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
import de.mindpipe.android.logging.log4j.LogCatAppender;
/**
* Created by magnusja on 3/1/17.
*/
public class JavaFsFileSystemCreator implements FileSystemCreator {
private static final String TAG = JavaFsFileSystemCreator.class.getSimpleName();
private static List<FileSystemType> fsTypes = new ArrayList<>();
static {
final Logger root = Logger.getRootLogger();
final LogCatAppender logCatAppender = new LogCatAppender();
root.addAppender(logCatAppender);
fsTypes.add(new NTFSFileSystemType());
fsTypes.add(new ExFatFileSystemType());
fsTypes.add(new FatFileSystemType());
fsTypes.add(new org.jnode.fs.fat.FatFileSystemType());
fsTypes.add(new HfsPlusFileSystemType());
fsTypes.add(new HfsWrapperFileSystemType());
fsTypes.add(new Ext2FileSystemType());
fsTypes.add(new XfsFileSystemType());
fsTypes.add(new ISO9660FileSystemType());
}
@Override
public FileSystem read(PartitionTableEntry entry, BlockDeviceDriver blockDevice) throws IOException {
ByteBuffer buffer = ByteBuffer.allocate(blockDevice.getBlockSize());
blockDevice.read(0, buffer);
FSBlockDeviceWrapper wrapper = new FSBlockDeviceWrapper(blockDevice, entry);
for(FileSystemType type : fsTypes) {
if(type.supports(wrapper.getPartitionTableEntry(), buffer.array(), wrapper)) {
try {
return new FileSystemWrapper(type.create(new DeviceWrapper(blockDevice, entry), false));
} catch (FileSystemException e) {
Log.e(TAG, "error creating fs with type " + type.getName(), e);
}
}
}
return null;
}
}
package com.github.magnusja.libaums.javafs.wrapper.device;
import com.github.mjdev.libaums.driver.BlockDeviceDriver;
import com.github.mjdev.libaums.partition.PartitionTableEntry;
import org.jnode.driver.Device;
import org.jnode.driver.block.BlockDeviceAPI;
import org.jnode.driver.block.FSBlockDeviceAPI;
/**
* Created by magnusja on 2/28/17.
*/
public class DeviceWrapper extends Device {
public DeviceWrapper(BlockDeviceDriver blockDevice, PartitionTableEntry entry) {
super("");
FSBlockDeviceWrapper wrapper = new FSBlockDeviceWrapper(blockDevice, entry);
registerAPI(FSBlockDeviceAPI.class, wrapper);
registerAPI(BlockDeviceAPI.class, wrapper);
}
}
package com.github.magnusja.libaums.javafs.wrapper.device;
import android.util.Log;
import com.github.mjdev.libaums.driver.BlockDeviceDriver;
import org.jnode.driver.block.FSBlockDeviceAPI;
import org.jnode.partitions.PartitionTable;
import org.jnode.partitions.PartitionTableEntry;
import java.io.IOException;
import java.nio.ByteBuffer;
/**
* Created by magnusja on 2/28/17.
*/
public class FSBlockDeviceWrapper implements FSBlockDeviceAPI {
private static final String TAG = FSBlockDeviceWrapper.class.getSimpleName();
private BlockDeviceDriver blockDevice;
private com.github.mjdev.libaums.partition.PartitionTableEntry partitionTableEntry;
public FSBlockDeviceWrapper(BlockDeviceDriver blockDevice, com.github.mjdev.libaums.partition.PartitionTableEntry partitionTableEntry) {
this.blockDevice = blockDevice;
this.partitionTableEntry = partitionTableEntry;
}
@Override
public int getSectorSize() throws IOException {
return blockDevice.getBlockSize();
}
@Override
public PartitionTableEntry getPartitionTableEntry() {
return new PartitionTableEntry() {
@Override
public boolean isValid() {
return true;
}
@Override
public boolean hasChildPartitionTable() {
return false;
}
@Override
public PartitionTable<?> getChildPartitionTable() {
return null;
}
};
}
@Override
public long getLength() throws IOException {
return partitionTableEntry.getTotalNumberOfSectors() * blockDevice.getBlockSize();
}
@Override
public void read(long l, ByteBuffer byteBuffer) throws IOException {
blockDevice.read(l, byteBuffer);
}
@Override
public void write(long l, ByteBuffer byteBuffer) throws IOException {
blockDevice.write(l, byteBuffer);
}
@Override
public void flush() throws IOException {
}
}
package com.github.magnusja.libaums.javafs.wrapper.fs;
import android.util.Log;
import com.github.mjdev.libaums.fs.FileSystem;
import com.github.mjdev.libaums.fs.UsbFile;
import org.jnode.driver.ApiNotFoundException;
import org.jnode.driver.block.FSBlockDeviceAPI;
import java.io.IOException;
/**
* Created by magnusja on 3/1/17.
*/
public class FileSystemWrapper implements FileSystem {
private static final String TAG = FileSystemWrapper.class.getSimpleName();
private org.jnode.fs.FileSystem wrappedFs;
public FileSystemWrapper(org.jnode.fs.FileSystem wrappedFs) {
this.wrappedFs = wrappedFs;
}
@Override
public UsbFile getRootDirectory() {
try {
return new UsbFileWrapper(wrappedFs.getRootEntry());
} catch (IOException e) {
Log.e(TAG, "error getting root entry", e);
return null;
}
}
@Override
public String getVolumeLabel() {
try {
return wrappedFs.getVolumeName();
} catch (IOException e) {
Log.e(TAG, "error getting volume label", e);
return "";
}
}
@Override
public long getCapacity() {
try {
return wrappedFs.getTotalSpace();
} catch (IOException e) {
Log.e(TAG, "error getting capacity", e);
return 0;
}
}
@Override
public long getOccupiedSpace() {
try {
return wrappedFs.getTotalSpace() - wrappedFs.getFreeSpace();
} catch (IOException e) {
Log.e(TAG, "error getting total - free space", e);
return 0;
}
}
@Override
public long getFreeSpace() {
try {
return wrappedFs.getFreeSpace();
} catch (IOException e) {
Log.e(TAG, "error getting free space", e);
return 0;
}
}
@Override
public int getChunkSize() {
try {
// TODO this is wrong
return wrappedFs.getDevice().getAPI(FSBlockDeviceAPI.class).getSectorSize();
} catch (IOException e) {
Log.e(TAG, "error getting sector size", e);
return 4096;
} catch (ApiNotFoundException e) {
Log.e(TAG, "api not found (this should not happen)", e);
return 4096;
}
}
}
package com.github.magnusja.libaums.javafs.wrapper.fs;
import android.util.Log;
import com.github.mjdev.libaums.fs.AbstractUsbFile;
import com.github.mjdev.libaums.fs.UsbFile;
import org.jnode.fs.FSDirectory;
import org.jnode.fs.FSEntry;
import org.jnode.fs.FSEntryCreated;
import org.jnode.fs.FSEntryLastAccessed;
import org.jnode.fs.FSFile;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* Created by magnusja on 01/03/17.
*/
public class UsbFileWrapper extends AbstractUsbFile {
private static final String TAG = UsbFileWrapper.class.getSimpleName();
private FSEntry entry;
private FSDirectory dir;
private FSFile file;
public UsbFileWrapper(FSEntry entry) throws IOException {
this.entry = entry;
if(entry.isDirectory()) {
dir = entry.getDirectory();
} else {
file = entry.getFile();
}
}
public UsbFileWrapper(FSDirectory dir) {
this.dir = dir;
}
@Override
public boolean isDirectory() {
return dir != null;
}
@Override
public String getName() {
return entry.getName();
}
@Override
public void setName(String newName) throws IOException {
entry.setName(newName);
}
@Override
public long createdAt() {
if(entry instanceof FSEntryCreated) {
try {
return ((FSEntryCreated) entry).getCreated();
} catch (IOException e) {
Log.e(TAG, "error getting last accessed", e);
return -1;
}
}
return -2;
}
@Override
public long lastModified() {
try {
return entry.getLastModified();
} catch (IOException e) {
Log.e(TAG, "error getting last modified", e);
return -1;
}
}
@Override
public long lastAccessed() {
if(entry instanceof FSEntryLastAccessed) {
try {
return ((FSEntryLastAccessed) entry).getLastAccessed();
} catch (IOException e) {
Log.e(TAG, "error getting last accessed", e);
return -1;
}
}
return -2;
}
@Override
public UsbFile getParent() {
// TODO implement me
throw new UnsupportedOperationException("not implemented");
}
@Override
public String[] list() throws IOException {
if(dir == null) {
throw new UnsupportedOperationException("This is a file!");
}
List<String> list = new ArrayList<>();
Iterator<? extends FSEntry> iterator = dir.iterator();
while(iterator.hasNext()) {
FSEntry entry = iterator.next();
list.add(entry.getName());
}
String[] array = new String[list.size()];
array = list.toArray(array);
return array;
}
@Override
public UsbFile[] listFiles() throws IOException {
if(dir == null) {
throw new UnsupportedOperationException("This is a file!");
}
List<UsbFile> list = new ArrayList<>();
Iterator<? extends FSEntry> iterator = dir.iterator();
while(iterator.hasNext()) {
FSEntry entry = iterator.next();
list.add(new UsbFileWrapper(entry));
}
UsbFile[] array = new UsbFile[list.size()];
array = list.toArray(array);
return array;
}
@Override
public long getLength() {
if(dir != null) {
throw new UnsupportedOperationException("This is a directory!");
}
return file.getLength();
}
@Override
public void setLength(long newLength) throws IOException {
if(dir != null) {
throw new UnsupportedOperationException("This is a directory!");
}
file.setLength(newLength);
}
@Override
public void read(long offset, ByteBuffer destination) throws IOException {
if(dir != null) {
throw new UnsupportedOperationException("This is a directory!");
}
file.read(offset, destination);
}
@Override
public void write(long offset, ByteBuffer source) throws IOException {
if(dir != null) {
throw new UnsupportedOperationException("This is a directory!");
}
file.write(offset, source);
}
@Override
public void flush() throws IOException {
if(dir != null) {
throw new UnsupportedOperationException("This is a directory!");
}
file.flush();
}
@Override
public void close() throws IOException {
flush();
}
@Override
public UsbFile createDirectory(String name) throws IOException {
if(dir == null) {
throw new UnsupportedOperationException("This is a file!");
}
return new UsbFileWrapper(dir.addDirectory(name));
}
@Override
public UsbFile createFile(String name) throws IOException {
if(dir == null) {
throw new UnsupportedOperationException("This is a file!");
}
return new UsbFileWrapper(dir.addFile(name));
}
@Override
public void moveTo(UsbFile destination) throws IOException {
// TODO implement me
throw new UnsupportedOperationException("not implemented");