Android Open Source - ShellAndroid Normal Releaser






From Project

Back to project page ShellAndroid.

License

The source code is released under:

Apache License

If you think the Android project ShellAndroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package z.hol.shellandroid;
/*  w  ww. j a  va  2 s .co  m*/
import android.content.Context;

import java.io.File;
import java.io.IOException;

import z.hol.shellandroid.utils.AssetUtils;

/**
 * Normal releaser for most android os
 * Created by holmes on 11/21/14.
 */
public class NormalReleaser extends AbsReleaser {


    /**
     * use #getContext method to get context
     *
     * @param context
     */
    public NormalReleaser(Context context) {
        super(context);
    }

    @Override
    public File release() throws IOException {
        Context context = getContext();
        int cpuType = Cpu.getCpuType();
        final String cflagName;
        if (cpuType == Cpu.CPU_INTEL){
            cflagName = ShellAndroid.CFLAG_TOOL_X86_FILE_NAME;
        }else{
            cflagName = ShellAndroid.CFLAG_TOOL_FILE_NAME;
        }

        try {
            AssetUtils.extractAsset(context, cflagName, true);
        } catch (IOException e) {
            // e.printStackTrace();
            // extra cflag error, so don't block the sh
            throw e;
        }
        File cFlag = context.getFileStreamPath(cflagName);
        return cFlag;
    }

    @Override
    public String getCFlagName() {
        int cpuType = Cpu.getCpuType();
        final String cflagName;
        if (cpuType == Cpu.CPU_INTEL){
            cflagName = ShellAndroid.CFLAG_TOOL_X86_FILE_NAME;
        }else{
            cflagName = ShellAndroid.CFLAG_TOOL_FILE_NAME;
        }
        return cflagName;
    }
}




Java Source Code List

z.hol.shellandroid.AbsReleaser.java
z.hol.shellandroid.CFlagRelease.java
z.hol.shellandroid.Chmod.java
z.hol.shellandroid.Cpu.java
z.hol.shellandroid.DefaultChmod.java
z.hol.shellandroid.LollipopReleaser.java
z.hol.shellandroid.NormalReleaser.java
z.hol.shellandroid.ShellAndroid.java
z.hol.shellandroid.ShellChmod.java
z.hol.shellandroid.Shell.java
z.hol.shellandroid.example.MainActivity.java
z.hol.shellandroid.exception.ShellExecuteException.java
z.hol.shellandroid.utils.AssetUtils.java
z.hol.shellandroid.utils.ShellUtils.java