(String data, boolean decrypt)
| 138 | } |
| 139 | |
| 140 | private LibStoken importToken(String data, boolean decrypt) { |
| 141 | Uri uri = Uri.parse(data); |
| 142 | String path = uri.getPath(); |
| 143 | boolean isFile = false; |
| 144 | |
| 145 | if (path != null && |
| 146 | ("file".equals(uri.getScheme()) || "content".equals(uri.getScheme()))) { |
| 147 | /* |
| 148 | * Arguably we shouldn't take file:// URIs from QR codes, |
| 149 | * and maybe we should be more careful about what we accept |
| 150 | * from other apps too |
| 151 | */ |
| 152 | isFile = true; |
| 153 | data = Misc.readStringFromUri(this, uri); |
| 154 | if (data == null) { |
| 155 | showError(ImportInstructionsFragment.INST_FILE_ERROR, path); |
| 156 | return null; |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | LibStoken lib = new LibStoken(); |
| 161 | if (lib.importString(data) != LibStoken.SUCCESS || |
| 162 | (decrypt && lib.decryptSeed(null, null) != LibStoken.SUCCESS)) { |
| 163 | showError(ImportInstructionsFragment.INST_BAD_TOKEN, isFile ? "" : data); |
| 164 | lib.destroy(); |
| 165 | return null; |
| 166 | } |
| 167 | |
| 168 | return lib; |
| 169 | } |
| 170 | |
| 171 | private boolean guessDevID(LibStoken lib, String id) { |
| 172 | // This checks the devid hash, but on v2 tokens it is only 15 bits and is |
no test coverage detected