info.guardianproject.iocipher.FileInputStream Java Examples

The following examples show how to use info.guardianproject.iocipher.FileInputStream. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MjpegPlayerActivity.java    From CameraV with GNU General Public License v3.0 6 votes vote down vote up
public void initAudio(String vfsPath) throws Exception {

    	isAudio = new BufferedInputStream(new FileInputStream(vfsPath));

    	if (useAAC)
    	{
    		aac = new AACHelper();
    		aac.setDecoder(MediaConstants.sAudioSampleRate, MediaConstants.sAudioChannels, MediaConstants.sAudioBitRate);
    	}
    	else
    	{
	
	        int minBufferSize = AudioTrack.getMinBufferSize(MediaConstants.sAudioSampleRate,
	        		MediaConstants.sChannelConfigOut, AudioFormat.ENCODING_PCM_16BIT)*8;
	
	        at = new AudioTrack(AudioManager.STREAM_MUSIC, MediaConstants.sAudioSampleRate,
	        		MediaConstants.sChannelConfigOut, AudioFormat.ENCODING_PCM_16BIT,
	            minBufferSize, AudioTrack.MODE_STREAM);
	        
    	}
         
    }
 
Example #2
Source File: GalleryActivity.java    From CameraV with GNU General Public License v3.0 6 votes vote down vote up
public void run ()
{
	BitmapFactory.Options bounds = new BitmapFactory.Options();	    
	bounds.inSampleSize = 8;	 	    
	Bitmap b;
	try {
		FileInputStream fis = new FileInputStream(fileImage);
		b = BitmapFactory.decodeStream(fis, null, bounds);
		fis.close();
		mBitCache.put(fileImage.getAbsolutePath(), b);
		mBitLoaders.remove(fileImage.getAbsolutePath());

		h.post(new Runnable()
		{
			public void run ()
			{
				((IconicList)gridview.getAdapter()).notifyDataSetChanged();
			}
		});
		
		//VirtualFileSystem.get().detachThread();
    
	} catch (Exception e) {
		Log.e(TAG,"error decoding bitmap preview",e);
	}
}
 
Example #3
Source File: DropboxSyncManager.java    From CameraV with GNU General Public License v3.0 6 votes vote down vote up
private boolean loadCredentials ()
{
	try
	{
		Properties props = new Properties();
		info.guardianproject.iocipher.File fileProps = new info.guardianproject.iocipher.File("/dropbox.properties");
		
		if (fileProps.exists())
		{
	        info.guardianproject.iocipher.FileInputStream fis = new info.guardianproject.iocipher.FileInputStream(fileProps);        
	        props.loadFromXML(fis);
	        
	        mStoredAccessToken = props.getProperty("dbtoken");
	        
	        return true;
		}
        
        
	}
	catch (IOException ioe)
	{
		Log.e("DbAuthLog", "Error I/O", ioe);
	}
	
	return false;
}
 
Example #4
Source File: ProofMode.java    From zom-android-matrix with Apache License 2.0 6 votes vote down vote up
private static String getSHA256FromFileContent(String filename)
{

    try
    {
        MessageDigest digest = MessageDigest.getInstance("SHA-256");
        byte[] buffer = new byte[65536]; //created at start.
        InputStream fis = new FileInputStream(filename);
        int n = 0;
        while (n != -1)
        {
            n = fis.read(buffer);
            if (n > 0)
            {
                digest.update(buffer, 0, n);
            }
        }
        byte[] digestResult = digest.digest();
        return asHex(digestResult);
    }
    catch (Exception e)
    {
        return null;
    }
}
 
Example #5
Source File: ProofMode.java    From Zom-Android-XMPP with GNU General Public License v3.0 6 votes vote down vote up
private static String getSHA256FromFileContent(String filename)
{

    try
    {
        MessageDigest digest = MessageDigest.getInstance("SHA-256");
        byte[] buffer = new byte[65536]; //created at start.
        InputStream fis = new FileInputStream(filename);
        int n = 0;
        while (n != -1)
        {
            n = fis.read(buffer);
            if (n > 0)
            {
                digest.update(buffer, 0, n);
            }
        }
        byte[] digestResult = digest.digest();
        return asHex(digestResult);
    }
    catch (Exception e)
    {
        return null;
    }
}
 
Example #6
Source File: FullScreenMJPEGPlayerFragment.java    From CameraV with GNU General Public License v3.0 5 votes vote down vote up
private void initVideo() throws IllegalArgumentException, SecurityException, IllegalStateException, IOException {

		try {

			videoView.setSource(new MjpegInputStream(new FileInputStream(media_.dcimEntry.fileAsset.path),getActivity().getCacheDir()));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
			
	}
 
Example #7
Source File: MjpegViewerActivity.java    From CameraV with GNU General Public License v3.0 5 votes vote down vote up
public void initAudio(String vfsPath) throws Exception {

    	isAudio = new BufferedInputStream(new FileInputStream(vfsPath));

    	if (useAAC)
    	{
    		aac = new AACHelper();
    		aac.setDecoder(MediaConstants.sAudioSampleRate, MediaConstants.sAudioChannels, MediaConstants.sAudioBitRate);
    	}
    	else
    	{
	
	        int minBufferSize = AudioTrack.getMinBufferSize(MediaConstants.sAudioSampleRate,
	        		MediaConstants.sChannelConfigOut, AudioFormat.ENCODING_PCM_16BIT)*8;
	
	        at = new AudioTrack(AudioManager.STREAM_MUSIC, MediaConstants.sAudioSampleRate,
	        		MediaConstants.sChannelConfigOut, AudioFormat.ENCODING_PCM_16BIT,
	            minBufferSize, AudioTrack.MODE_STREAM);
	        
    	}
         
    }
 
Example #8
Source File: GalleryActivity.java    From CameraV with GNU General Public License v3.0 5 votes vote down vote up
@Override
    protected java.io.File doInBackground(File... params) {

        try {
String fileName = "/sdcard/" + new Date().getTime() + ".pgp.asc";
            java.io.File fileTimeCap = new java.io.File(fileName);
            java.io.FileOutputStream osTimeCap = new java.io.FileOutputStream(fileTimeCap);

            boolean asciiArmor = true;
            boolean integrityCheck = true;

            PgpHelper pgpHelper = PgpHelper.getInstance();

            PGPPublicKey encKey = pgpHelper.readPublicKey(new java.io.FileInputStream(new java.io.File("/sdcard/jack.asc")));

            pgpHelper.encryptStream(osTimeCap, new FileInputStream(params[0]), params[0].getName(), params[0].length(), new Date(), encKey, asciiArmor, integrityCheck);

            params[0].delete();

return fileTimeCap;
        }
        catch (Exception ioe)
        {
            Log.e("PGPExport","unable to export",ioe);
            Toast.makeText(activity,"Unable to export to PGP: " + ioe.getMessage(),Toast.LENGTH_LONG).show();
        }

        return null;
    }
 
Example #9
Source File: FullScreenMJPEGViewFragment.java    From CameraV with GNU General Public License v3.0 5 votes vote down vote up
private void initVideo() throws IllegalArgumentException, SecurityException, IllegalStateException, IOException {

		try {
			videoView.setSource(new MjpegInputStream(new info.guardianproject.iocipher.FileInputStream(media_.dcimEntry.fileAsset.path)));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
			
	}
 
Example #10
Source File: SecureMediaStore.java    From Zom-Android-XMPP with GNU General Public License v3.0 5 votes vote down vote up
public static void copyToExternal(String sourcePath, java.io.File targetPath) throws IOException {
    // copy
    FileInputStream fis = new FileInputStream(new File(sourcePath));
    java.io.FileOutputStream fos = new java.io.FileOutputStream(targetPath, false);

    IOUtils.copyLarge(fis, fos);

    fos.close();
    fis.close();
}
 
Example #11
Source File: SecureMediaStore.java    From Zom-Android-XMPP with GNU General Public License v3.0 5 votes vote down vote up
public static void copyToVfs(java.io.File sourceFile, String targetPath) throws IOException {
    // create the target directories tree
    mkdirs( targetPath );
    // copy
    java.io.InputStream fis = null;
    fis  = new java.io.FileInputStream(sourceFile);

    FileOutputStream fos = new FileOutputStream(new File(targetPath), false);

    IOUtils.copyLarge(fis, fos);

    fos.close();
    fis.close();
}
 
Example #12
Source File: SecureMediaStore.java    From Zom-Android-XMPP with GNU General Public License v3.0 5 votes vote down vote up
public static InputStream openInputStream (Context context, Uri uri) throws FileNotFoundException {
    InputStream is;

    if (uri.getScheme() != null && uri.getScheme().equals("vfs"))
        is = new info.guardianproject.iocipher.FileInputStream(uri.getPath());
    else
        is = context.getContentResolver().openInputStream(uri);


    return is;
}
 
Example #13
Source File: ProofMode.java    From Zom-Android-XMPP with GNU General Public License v3.0 5 votes vote down vote up
private static void writeProof (Context context, String mediaPath, String hash, boolean showDeviceIds, boolean showLocation, boolean showMobileNetwork, String safetyCheckResult, boolean isBasicIntegrity, boolean isCtsMatch, long notarizeTimestamp, String notes)
{

    File fileMedia = new File(mediaPath);

    File fileMediaSig = new File(mediaPath + OPENPGP_FILE_TAG);
    File fileMediaProof = new File(mediaPath + PROOF_FILE_TAG);
    File fileMediaProofSig = new File(mediaPath + PROOF_FILE_TAG + OPENPGP_FILE_TAG);

    try {

        //sign the media file
        if (!fileMediaSig.exists())
            PgpUtils.getInstance(context).createDetachedSignature(new FileInputStream(fileMedia), new FileOutputStream(fileMediaSig), PgpUtils.DEFAULT_PASSWORD);

        //add data to proof csv and sign again
        boolean writeHeaders = !fileMediaProof.exists();
        writeTextToFile(context, fileMediaProof, buildProof(context, mediaPath, writeHeaders, showDeviceIds, showLocation, showMobileNetwork, safetyCheckResult, isBasicIntegrity, isCtsMatch, notarizeTimestamp, notes));

        if (fileMediaProof.exists()) {
            //sign the proof file again
            PgpUtils.getInstance(context).createDetachedSignature(new FileInputStream(fileMediaProof), new FileOutputStream(fileMediaProofSig), PgpUtils.DEFAULT_PASSWORD);
        }

    } catch (Exception e) {
        Log.e("MediaWatcher", "Error signing media or proof", e);
    }

}
 
Example #14
Source File: ProofMode.java    From zom-android-matrix with Apache License 2.0 5 votes vote down vote up
private static void writeProof (Context context, String mediaPath, String hash, boolean showDeviceIds, boolean showLocation, boolean showMobileNetwork, String safetyCheckResult, boolean isBasicIntegrity, boolean isCtsMatch, long notarizeTimestamp, String notes)
{

    File fileMedia = new File(mediaPath);

    File fileMediaSig = new File(mediaPath + OPENPGP_FILE_TAG);
    File fileMediaProof = new File(mediaPath + PROOF_FILE_TAG);
    File fileMediaProofSig = new File(mediaPath + PROOF_FILE_TAG + OPENPGP_FILE_TAG);

    try {

        //sign the media file
        if (!fileMediaSig.exists())
            PgpUtils.getInstance(context).createDetachedSignature(new FileInputStream(fileMedia), new FileOutputStream(fileMediaSig), PgpUtils.DEFAULT_PASSWORD);

        //add data to proof csv and sign again
        boolean writeHeaders = !fileMediaProof.exists();
        writeTextToFile(context, fileMediaProof, buildProof(context, mediaPath, writeHeaders, showDeviceIds, showLocation, showMobileNetwork, safetyCheckResult, isBasicIntegrity, isCtsMatch, notarizeTimestamp, notes));

        if (fileMediaProof.exists()) {
            //sign the proof file again
            PgpUtils.getInstance(context).createDetachedSignature(new FileInputStream(fileMediaProof), new FileOutputStream(fileMediaProofSig), PgpUtils.DEFAULT_PASSWORD);
        }

    } catch (Exception e) {
        Log.e("MediaWatcher", "Error signing media or proof", e);
    }

}
 
Example #15
Source File: GlideUtils.java    From zom-android-matrix with Apache License 2.0 5 votes vote down vote up
public static void loadImageFromUri(Context context, Uri uri, ImageView imageView) {
    if(SecureMediaStore.isVfsUri(uri))
    {
        try {
            info.guardianproject.iocipher.File fileImage = new info.guardianproject.iocipher.File(uri.getPath());
            if (fileImage.exists())
            {
                FileInputStream fis = new info.guardianproject.iocipher.FileInputStream(fileImage);
                Glide.with(context)
                        .load(fis)
                        .apply(noDiskCacheOptions)
                        .into(imageView);
            }
        }
        catch (Exception e)
        {
            Log.w(LOG_TAG,"unable to load image: " + uri.toString());
        }
    }
    else if (uri.getScheme() != null && uri.getScheme().equals("asset"))
    {
        String assetPath = "file:///android_asset/" + uri.getPath().substring(1);
        Glide.with(context)
                .load(assetPath)
                .apply(noDiskCacheOptions)
                .into(imageView);
    }
    else
    {
        Glide.with(context)
                .load(uri)
                .into(imageView);
    }
}
 
Example #16
Source File: GlideUtils.java    From zom-android-matrix with Apache License 2.0 5 votes vote down vote up
public static boolean loadVideoFromUri(Context context, Uri uri, ImageView imageView) {
    if(SecureMediaStore.isVfsUri(uri))
    {
        try {
            info.guardianproject.iocipher.File fileVideo = new info.guardianproject.iocipher.File(uri.getPath());
            if (fileVideo.exists())
            {
                Glide.with(context)
                        .load(new info.guardianproject.iocipher.FileInputStream(fileVideo))
                        .apply(noDiskCacheOptions)
                        .into(imageView);
                return true;
            }
            return false;
        }
        catch (Exception e)
        {
            Log.w(LOG_TAG,"unable to load image: " + uri.toString());
        }
    }
    else if (uri.getScheme() != null && uri.getScheme().equals("asset"))
    {
        String assetPath = "file:///android_asset/" + uri.getPath().substring(1);
        Glide.with(context)
                .load(assetPath)
                .apply(noDiskCacheOptions)
                .into(imageView);
        return true;
    }
    else
    {
        Glide.with(context)
                .load(uri)
                .into(imageView);
        return true;
    }

    return false;
}
 
Example #17
Source File: GlideVFSLoader.java    From zom-android-matrix with Apache License 2.0 4 votes vote down vote up
@Override
public boolean handles(info.guardianproject.iocipher.FileInputStream model) {
    return true;
}
 
Example #18
Source File: GlideVFSLoader.java    From Zom-Android-XMPP with GNU General Public License v3.0 4 votes vote down vote up
public GlideVFSCacheKey(FileInputStream fis) {
    this.fis = fis;
}
 
Example #19
Source File: GlideVFSLoader.java    From zom-android-matrix with Apache License 2.0 4 votes vote down vote up
@Override
public ModelLoader<FileInputStream, InputStream> build(MultiModelLoaderFactory multiFactory) {
    return new GlideVFSLoader();
}
 
Example #20
Source File: ImageViewerActivity.java    From CameraV with GNU General Public License v3.0 4 votes vote down vote up
/** Called when the activity is first created. */

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		requestWindowFeature(Window.FEATURE_NO_TITLE);
	    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
	    WindowManager.LayoutParams.FLAG_FULLSCREEN);

		//prevent screenshots
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
				WindowManager.LayoutParams.FLAG_SECURE);
		
		// This example uses decor view, but you can use any visible view.
		View decorView = getWindow().getDecorView();
		int uiOptions = View.SYSTEM_UI_FLAG_LOW_PROFILE;
		decorView.setSystemUiVisibility(uiOptions);
		
	        
		setContentView(R.layout.pzsimageview);
		
		Intent intent = getIntent();
		String action = intent.getAction();
		String type = intent.getType();
		
		ImageView iv = (ImageView)findViewById(R.id.imageview);
		
		if (intent.hasExtra("vfs"))
		{
			try
			{
				File file = new File(intent.getExtras().getString("vfs"));
				Bitmap bmp = null;
				
				BitmapFactory.Options options = new BitmapFactory.Options();
				options.inJustDecodeBounds = true;
				 BitmapFactory.decodeStream(new FileInputStream(file),null,options);
				int imageHeight = options.outHeight;
				int imageWidth = options.outWidth;
				String imageType = options.outMimeType;
				
				options.inJustDecodeBounds = false;
				options.inSampleSize = 2;
				bmp =  BitmapFactory.decodeStream(new FileInputStream(file),null,options);
				
				iv.setImageBitmap(bmp);
			}
			catch (Exception e)
			{
				Log.d("Image","error showing vfs image",e);
			}
		}
		else
		{
			iv.setImageURI(intent.getData());
		}
		
	}
 
Example #21
Source File: GlideVFSLoader.java    From zom-android-matrix with Apache License 2.0 4 votes vote down vote up
public GlideVFSCacheKey(FileInputStream fis) {
    this.fis = fis;
}
 
Example #22
Source File: GlideVFSLoader.java    From zom-android-matrix with Apache License 2.0 4 votes vote down vote up
public VFSDataFetcher(info.guardianproject.iocipher.FileInputStream vfsFileStream) {
    // explode model fields so that they can't be modified (finals in OBBFile are optional)
    this.vfsFileStream = vfsFileStream;
}
 
Example #23
Source File: GlideVFSLoader.java    From zom-android-matrix with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public LoadData<InputStream> buildLoadData(info.guardianproject.iocipher.FileInputStream model, int width, int height, Options options) {
    return new LoadData<>(new GlideVFSCacheKey(model), new VFSDataFetcher(model));
}
 
Example #24
Source File: GlideVFSLoader.java    From Zom-Android-XMPP with GNU General Public License v3.0 4 votes vote down vote up
@Nullable
@Override
public LoadData<InputStream> buildLoadData(info.guardianproject.iocipher.FileInputStream model, int width, int height, Options options) {
    return new LoadData<>(new GlideVFSCacheKey(model), new VFSDataFetcher(model));
}
 
Example #25
Source File: GlideVFSLoader.java    From Zom-Android-XMPP with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean handles(info.guardianproject.iocipher.FileInputStream model) {
    return true;
}
 
Example #26
Source File: GlideVFSLoader.java    From Zom-Android-XMPP with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ModelLoader<FileInputStream, InputStream> build(MultiModelLoaderFactory multiFactory) {
    return new GlideVFSLoader();
}
 
Example #27
Source File: OtrDataHandler.java    From Zom-Android-XMPP with GNU General Public License v3.0 4 votes vote down vote up
private String checkSum(String filename) throws IOException {
    FileInputStream fis = new FileInputStream(new File(filename));
    String sum = sha1sum(fis);
    fis.close();
    return sum;
}
 
Example #28
Source File: GlideVFSLoader.java    From Zom-Android-XMPP with GNU General Public License v3.0 4 votes vote down vote up
public VFSDataFetcher(info.guardianproject.iocipher.FileInputStream vfsFileStream) {
    // explode model fields so that they can't be modified (finals in OBBFile are optional)
    this.vfsFileStream = vfsFileStream;
}
 
Example #29
Source File: FullScreenMJPEGViewFragment.java    From CameraV with GNU General Public License v3.0 3 votes vote down vote up
public void initAudio(String vfsPath) throws Exception {

    	isAudio = new BufferedInputStream(new FileInputStream(vfsPath));

	
        int minBufferSize = AudioTrack.getMinBufferSize(MediaConstants.sAudioSampleRate,
        		MediaConstants.sChannelConfigOut, AudioFormat.ENCODING_PCM_16BIT)*8;

        at = new AudioTrack(AudioManager.STREAM_MUSIC, MediaConstants.sAudioSampleRate,
        		MediaConstants.sChannelConfigOut, AudioFormat.ENCODING_PCM_16BIT,
            minBufferSize, AudioTrack.MODE_STREAM);
        
	     
    }
 
Example #30
Source File: FullScreenMJPEGPlayerFragment.java    From CameraV with GNU General Public License v3.0 3 votes vote down vote up
public void initAudio(String vfsPath) throws Exception {

    	isAudio = new BufferedInputStream(new FileInputStream(vfsPath));

	
        int minBufferSize = AudioTrack.getMinBufferSize(MediaConstants.sAudioSampleRate,
        		MediaConstants.sChannelConfigOut, AudioFormat.ENCODING_PCM_16BIT)*8;

        at = new AudioTrack(AudioManager.STREAM_MUSIC, MediaConstants.sAudioSampleRate,
        		MediaConstants.sChannelConfigOut, AudioFormat.ENCODING_PCM_16BIT,
            minBufferSize, AudioTrack.MODE_STREAM);
        
	     
    }