├── .gitignore ├── .navigation └── app │ └── raw │ └── main.nvg.xml ├── LICENSE ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── org │ │ └── efidroid │ │ └── efidroidmanager │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ └── armeabi-v7a │ │ │ └── busybox │ ├── java │ │ └── org │ │ │ └── efidroid │ │ │ └── efidroidmanager │ │ │ ├── AppConstants.java │ │ │ ├── DataHelper.java │ │ │ ├── RootToolsEx.java │ │ │ ├── Util.java │ │ │ ├── activities │ │ │ ├── AboutActivity.java │ │ │ ├── GenericProgressActivity.java │ │ │ ├── MainActivity.java │ │ │ ├── NotificationReceiverActivity.java │ │ │ └── OperatingSystemEditActivity.java │ │ │ ├── fragments │ │ │ ├── EmptyFragment.java │ │ │ ├── InstallFragment.java │ │ │ ├── InstallStatusRecyclerViewAdapter.java │ │ │ ├── OperatingSystemFragment.java │ │ │ ├── OperatingSystemRecyclerViewAdapter.java │ │ │ └── operatingsystemedit │ │ │ │ ├── GeneralFragment.java │ │ │ │ ├── PartitionItemFragment.java │ │ │ │ ├── PartitionItemRecyclerViewAdapter.java │ │ │ │ ├── ReplacementItemFragment.java │ │ │ │ └── ReplacementItemRecyclerViewAdapter.java │ │ │ ├── models │ │ │ ├── DeviceInfo.java │ │ │ ├── FSTab.java │ │ │ ├── MountInfo.java │ │ │ └── OperatingSystem.java │ │ │ ├── services │ │ │ ├── GenericProgressIntentService.java │ │ │ └── IntentServiceEx.java │ │ │ ├── tasks │ │ │ ├── EFIDroidInstallServiceTask.java │ │ │ ├── EFIDroidUninstallServiceTask.java │ │ │ ├── OSRemovalProgressServiceTask.java │ │ │ └── OSUpdateProgressServiceTask.java │ │ │ ├── types │ │ │ ├── ArgbEvaluator.java │ │ │ ├── CommandEx.java │ │ │ ├── FABListener.java │ │ │ ├── FSTabEntry.java │ │ │ ├── InstallationEntry.java │ │ │ ├── InstallationStatus.java │ │ │ ├── MountEntry.java │ │ │ ├── OSEditFragmentInteractionListener.java │ │ │ ├── Pointer.java │ │ │ ├── ProgressReceiver.java │ │ │ ├── ProgressServiceTask.java │ │ │ ├── ReturnCodeException.java │ │ │ ├── RootFileChooserDialog.java │ │ │ └── SystemPropertiesProxy.java │ │ │ └── view │ │ │ ├── CustomViewPager.java │ │ │ └── ProgressCircle.java │ └── res │ │ ├── anim │ │ ├── abc_slide_in_bottom_full.xml │ │ ├── abc_slide_in_left_full.xml │ │ ├── abc_slide_in_right_full.xml │ │ ├── abc_slide_out_bottom_full.xml │ │ ├── abc_slide_out_left_full.xml │ │ ├── abc_slide_out_right_full.xml │ │ └── hold.xml │ │ ├── drawable-v21 │ │ ├── ic_menu_camera.xml │ │ ├── ic_menu_gallery.xml │ │ ├── ic_menu_manage.xml │ │ ├── ic_menu_send.xml │ │ ├── ic_menu_share.xml │ │ ├── ic_menu_slideshow.xml │ │ └── ripple.xml │ │ ├── drawable │ │ ├── activatable_item_background.xml │ │ ├── efidroid.xml │ │ ├── ic_action_cancel.xml │ │ ├── ic_action_delete.xml │ │ ├── ic_action_done.xml │ │ ├── ic_action_refresh.xml │ │ ├── ic_dialog_add.xml │ │ ├── ic_menu_archive.xml │ │ ├── ic_menu_bug_report.xml │ │ ├── ic_menu_color_lens.xml │ │ ├── ic_menu_extension.xml │ │ ├── ic_menu_hospital.xml │ │ ├── ic_menu_info.xml │ │ ├── ic_menu_info_outline.xml │ │ ├── ic_menu_memory.xml │ │ ├── ic_menu_settings.xml │ │ ├── md_circle.xml │ │ ├── side_nav_bar.xml │ │ └── tablayout_background_transition.xml │ │ ├── layout │ │ ├── activity_about.xml │ │ ├── activity_main.xml │ │ ├── activity_operating_system_edit.xml │ │ ├── activity_osupdate_progress.xml │ │ ├── app_bar_main.xml │ │ ├── content_about.xml │ │ ├── content_main.xml │ │ ├── dialog_edit_partition.xml │ │ ├── dialog_new_cmdline.xml │ │ ├── divider.xml │ │ ├── efidroid_simple_spinner_dropdown_item.xml │ │ ├── fragment_general.xml │ │ ├── fragment_install.xml │ │ ├── fragment_operating_system_edit.xml │ │ ├── fragment_operatingsystem_item.xml │ │ ├── fragment_operatingsystem_list.xml │ │ ├── fragment_partitionitem.xml │ │ ├── fragment_partitionitem_list.xml │ │ ├── fragment_replacemenitem.xml │ │ ├── fragment_replacemenitem_header.xml │ │ ├── fragment_replacemenitem_list.xml │ │ ├── nav_header_main.xml │ │ └── toolbar_layout_install.xml │ │ ├── menu │ │ ├── actionmode_operatingsystemedit.xml │ │ ├── activity_main_drawer.xml │ │ ├── activity_operatingsystemedit.xml │ │ └── fragment_install.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-v21 │ │ └── styles.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── arrays.xml │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── drawables.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── org │ └── efidroid │ └── efidroidmanager │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── sub_projects ├── RootShell ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── example │ │ └── rootshell │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── stericson │ │ │ └── rootshell │ │ │ ├── NativeJavaClass.java │ │ │ ├── RootShell.java │ │ │ ├── SanityCheckRootShell.java │ │ │ ├── containers │ │ │ └── RootClass.java │ │ │ ├── exceptions │ │ │ └── RootDeniedException.java │ │ │ └── execution │ │ │ ├── Command.java │ │ │ ├── JavaCommand.java │ │ │ └── Shell.java │ └── res │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── example │ └── rootshell │ └── ExampleUnitTest.java └── RootTools ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src ├── androidTest └── java │ └── com │ └── example │ └── roottools │ └── ApplicationTest.java ├── main ├── AndroidManifest.xml ├── java │ └── com │ │ └── stericson │ │ └── roottools │ │ ├── Constants.java │ │ ├── RootTools.java │ │ ├── SanityCheckRootTools.java │ │ ├── containers │ │ ├── Mount.java │ │ ├── Permissions.java │ │ └── Symlink.java │ │ └── internal │ │ ├── Installer.java │ │ ├── InternalVariables.java │ │ ├── Remounter.java │ │ ├── RootToolsInternalMethods.java │ │ └── Runner.java └── res │ └── values │ └── strings.xml └── test └── java └── com └── example └── roottools └── ExampleUnitTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea 5 | .DS_Store 6 | /build 7 | /captures 8 | .externalNativeBuild 9 | -------------------------------------------------------------------------------- /.navigation/app/raw/main.nvg.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 10 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | static def gitRevision() { 4 | def cmd = "git rev-parse --short HEAD" 5 | return cmd.execute().text.trim() 6 | } 7 | 8 | static def gitDirty() { 9 | def cmd = "git diff-index --name-only HEAD" 10 | if(cmd.execute().text.trim().length()>0) 11 | return "-dirty"; 12 | return ""; 13 | } 14 | 15 | android { 16 | compileSdkVersion 25 17 | buildToolsVersion "25.0.2" 18 | defaultConfig { 19 | applicationId "org.efidroid.efidroidmanager" 20 | minSdkVersion 15 21 | targetSdkVersion 25 22 | versionCode 5 23 | versionName "1.0-g${gitRevision()}${gitDirty()}" 24 | 25 | buildConfigField "long", "TIMESTAMP", System.currentTimeMillis() + "L" 26 | buildConfigField "String", "USERNAME", "\""+System.getProperty("user.name")+"\"" 27 | buildConfigField "String", "HOSTNAME", "\""+InetAddress.getLocalHost().getHostName()+"\"" 28 | } 29 | buildTypes { 30 | release { 31 | minifyEnabled false 32 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 33 | } 34 | debug { 35 | applicationIdSuffix ".debug" 36 | versionNameSuffix "-debug" 37 | } 38 | } 39 | } 40 | 41 | dependencies { 42 | compile fileTree(dir: 'libs', include: ['*.jar']) 43 | testCompile 'junit:junit:4.12' 44 | compile('com.github.afollestad.material-dialogs:core:0.8.5.6@aar') { 45 | transitive = true 46 | } 47 | compile('com.github.afollestad.material-dialogs:commons:0.8.5.6@aar') { 48 | transitive = true 49 | } 50 | compile 'com.android.support:appcompat-v7:25.3.1' 51 | compile 'com.android.support:design:25.3.1' 52 | compile 'com.android.support:support-v4:25.3.1' 53 | compile 'com.android.support:recyclerview-v7:25.3.1' 54 | compile 'com.mcxiaoke.volley:library:1.0.19' 55 | compile 'org.ini4j:ini4j:0.5.4' 56 | compile 'commons-io:commons-io:2.5' 57 | compile 'com.melnykov:floatingactionbutton:1.3.0' 58 | compile project(':sub_projects:RootTools') 59 | } 60 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/m1cha/Android/Sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/org/efidroid/efidroidmanager/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 14 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 29 | 32 | 35 | 36 | 37 | 40 | 44 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /app/src/main/assets/armeabi-v7a/busybox: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/efidroid/android_app_efidroidmanager/9d797ac9d072ac6316e04c341c800f736cfdbbac/app/src/main/assets/armeabi-v7a/busybox -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/AppConstants.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager; 2 | 3 | import android.content.Context; 4 | import android.os.Build; 5 | import android.text.TextUtils; 6 | 7 | import org.efidroid.efidroidmanager.models.DeviceInfo; 8 | import org.efidroid.efidroidmanager.types.SystemPropertiesProxy; 9 | 10 | public final class AppConstants { 11 | private static final String URL_EFIDROID_SERVER = "https://raw.githubusercontent.com/efidroid"; 12 | 13 | public static final String DEVICE_NAME = Build.MANUFACTURER.toLowerCase() + "/" + Build.DEVICE.toLowerCase(); 14 | public static final String SHAREDPREFS_GLOBAL = "org.efidroid.efidroidmanager"; 15 | public static final String SHAREDPREFS_GLOBAL_LAST_DEVICEINFO_UPDATE = "last_deviceinfo_update"; 16 | public static final String SHAREDPREFS_GLOBAL_LAST_APP_VERSION = "last_app_version"; 17 | 18 | public static final String PATH_INTERNAL_DEVICES = "devices.json"; 19 | public static final String PATH_INTERNAL_FSTAB = "fstab.multiboot"; 20 | 21 | private static String getUrlServer(Context context) { 22 | String url = SystemPropertiesProxy.get(context, "efidroid.server_url", ""); 23 | if (TextUtils.isEmpty(url)) 24 | url = URL_EFIDROID_SERVER; 25 | 26 | return url; 27 | } 28 | 29 | public static String getUrlOta(Context context) { 30 | return getUrlServer(context) + "/ota/master"; 31 | } 32 | 33 | public static String getUrlDeviceList(Context context) { 34 | return getUrlOta(context) + "/devices.json"; 35 | } 36 | 37 | public static String getUrlDeviceRepo(Context context, DeviceInfo deviceInfo) { 38 | return getUrlServer(context) + "/device/" + deviceInfo.getDeviceName(); 39 | } 40 | 41 | public static String getUrlDeviceFsTab(Context context, DeviceInfo deviceInfo) { 42 | return getUrlDeviceRepo(context, deviceInfo) + "/fstab.multiboot"; 43 | } 44 | 45 | public static String getUrlUpdates(Context context, DeviceInfo deviceInfo) { 46 | return getUrlOta(context) + "/" + deviceInfo.getDeviceName() + "/info.json"; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/activities/AboutActivity.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager.activities; 2 | 3 | import android.os.Bundle; 4 | import android.support.design.widget.FloatingActionButton; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.support.v7.widget.Toolbar; 7 | import android.view.MenuItem; 8 | import android.view.View; 9 | import android.widget.TextView; 10 | 11 | import org.efidroid.efidroidmanager.BuildConfig; 12 | import org.efidroid.efidroidmanager.R; 13 | 14 | import java.text.DateFormat; 15 | 16 | public class AboutActivity extends AppCompatActivity { 17 | 18 | @Override 19 | protected void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | setContentView(R.layout.activity_about); 22 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 23 | setSupportActionBar(toolbar); 24 | 25 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); 26 | fab.setVisibility(View.GONE); 27 | if (getSupportActionBar() != null) 28 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 29 | 30 | TextView textVersion = (TextView) findViewById(R.id.textVersion); 31 | textVersion.setText(getString(R.string.app_version, BuildConfig.VERSION_NAME)); 32 | 33 | DateFormat format = DateFormat.getDateTimeInstance(); 34 | TextView textBuildinfo = (TextView) findViewById(R.id.textBuildInfo); 35 | textBuildinfo.setText(getString(R.string.compiled_by, BuildConfig.USERNAME, BuildConfig.HOSTNAME, format.format(BuildConfig.TIMESTAMP))); 36 | } 37 | 38 | @Override 39 | public boolean onOptionsItemSelected(MenuItem item) { 40 | switch (item.getItemId()) { 41 | case android.R.id.home: 42 | finish(); 43 | return true; 44 | default: 45 | return super.onOptionsItemSelected(item); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/activities/NotificationReceiverActivity.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager.activities; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | 6 | import org.efidroid.efidroidmanager.services.GenericProgressIntentService; 7 | 8 | public class NotificationReceiverActivity extends AppCompatActivity { 9 | 10 | public static final String ARG_NOTIFICATION_ID = "notification_id"; 11 | public static final String ARG_SERVICE_CLASS = "service_class"; 12 | public static final int NOTIFICATION_ID_OP_UPDATE_SERVICE = 1; 13 | 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | 18 | switch (getIntent().getIntExtra(ARG_NOTIFICATION_ID, -1)) { 19 | case NOTIFICATION_ID_OP_UPDATE_SERVICE: 20 | GenericProgressIntentService.handleNotificationIntent(this, (Class) getIntent().getSerializableExtra(ARG_SERVICE_CLASS)); 21 | } 22 | 23 | finish(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/fragments/EmptyFragment.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager.fragments; 2 | 3 | import android.support.v4.app.Fragment; 4 | 5 | public class EmptyFragment extends Fragment { 6 | public EmptyFragment() { 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/fragments/InstallStatusRecyclerViewAdapter.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager.fragments; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.graphics.drawable.Drawable; 6 | import android.os.AsyncTask; 7 | import android.support.v4.content.res.ResourcesCompat; 8 | import android.support.v7.widget.RecyclerView; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.widget.ImageView; 13 | import android.widget.TextView; 14 | 15 | import org.efidroid.efidroidmanager.R; 16 | import org.efidroid.efidroidmanager.models.OperatingSystem; 17 | 18 | import java.util.List; 19 | 20 | /** 21 | * {@link RecyclerView.Adapter} that can display a {@link OperatingSystem} and makes a call to the 22 | * specified {@link OperatingSystemFragment.OnOperatingSystemFragmentInteractionListener}. 23 | */ 24 | public class InstallStatusRecyclerViewAdapter extends RecyclerView.Adapter { 25 | 26 | private final List mValues; 27 | 28 | public static class Item { 29 | public String title; 30 | public String subtitle; 31 | 32 | public Item(String title, String subtitle) { 33 | this.title = title; 34 | this.subtitle = subtitle; 35 | } 36 | } 37 | 38 | public InstallStatusRecyclerViewAdapter(List items) { 39 | mValues = items; 40 | } 41 | 42 | @Override 43 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 44 | View view = LayoutInflater.from(parent.getContext()) 45 | .inflate(R.layout.fragment_replacemenitem, parent, false); 46 | 47 | return new ViewHolder(view); 48 | } 49 | 50 | @Override 51 | public void onBindViewHolder(final ViewHolder holder, int position) { 52 | Item item = mValues.get(position); 53 | 54 | holder.mItem = item; 55 | holder.mTitleView.setText(item.title); 56 | 57 | if (item.subtitle != null && item.subtitle.length() > 0) { 58 | holder.mSubtitleView.setText(item.subtitle); 59 | holder.mSubtitleView.setVisibility(View.VISIBLE); 60 | } else { 61 | holder.mSubtitleView.setVisibility(View.GONE); 62 | } 63 | } 64 | 65 | @Override 66 | public int getItemCount() { 67 | return mValues.size(); 68 | } 69 | 70 | public class ViewHolder extends RecyclerView.ViewHolder { 71 | public final View mView; 72 | public final TextView mTitleView; 73 | public final TextView mSubtitleView; 74 | public Item mItem; 75 | 76 | public ViewHolder(View view) { 77 | super(view); 78 | mView = view; 79 | mTitleView = (TextView) view.findViewById(R.id.text); 80 | mSubtitleView = (TextView) view.findViewById(R.id.text2); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/fragments/OperatingSystemFragment.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager.fragments; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.support.annotation.NonNull; 7 | import android.support.design.widget.AppBarLayout; 8 | import android.support.design.widget.CoordinatorLayout; 9 | import android.support.v4.app.Fragment; 10 | import android.support.v4.content.res.ResourcesCompat; 11 | import android.support.v7.widget.LinearLayoutManager; 12 | import android.support.v7.widget.RecyclerView; 13 | import android.view.Gravity; 14 | import android.view.LayoutInflater; 15 | import android.view.View; 16 | import android.view.ViewGroup; 17 | 18 | import com.afollestad.materialdialogs.DialogAction; 19 | import com.afollestad.materialdialogs.MaterialDialog; 20 | import com.melnykov.fab.FloatingActionButton; 21 | 22 | import org.efidroid.efidroidmanager.R; 23 | 24 | import org.efidroid.efidroidmanager.Util; 25 | import org.efidroid.efidroidmanager.activities.GenericProgressActivity; 26 | import org.efidroid.efidroidmanager.activities.OperatingSystemEditActivity; 27 | import org.efidroid.efidroidmanager.models.DeviceInfo; 28 | import org.efidroid.efidroidmanager.models.OperatingSystem; 29 | import org.efidroid.efidroidmanager.tasks.OSRemovalProgressServiceTask; 30 | 31 | import java.util.List; 32 | 33 | /** 34 | * A fragment representing a list of Items. 35 | *

36 | * Activities containing this fragment MUST implement the {@link OnOperatingSystemFragmentInteractionListener} 37 | * interface. 38 | */ 39 | public class OperatingSystemFragment extends Fragment implements OperatingSystemRecyclerViewAdapter.OnInteractionListener { 40 | private OnOperatingSystemFragmentInteractionListener mListener; 41 | 42 | // request codes 43 | private static final int REQUEST_EDIT_OS = 0; 44 | private static final int REQUEST_CREATE_OS = 1; 45 | private static final int REQUEST_DELETE_OS = 2; 46 | 47 | /** 48 | * Mandatory empty constructor for the fragment manager to instantiate the 49 | * fragment (e.g. upon screen orientation changes). 50 | */ 51 | public OperatingSystemFragment() { 52 | } 53 | 54 | @Override 55 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 56 | Bundle savedInstanceState) { 57 | View view = inflater.inflate(R.layout.fragment_operatingsystem_list, container, false); 58 | 59 | // Set the adapter 60 | if (view instanceof RecyclerView) { 61 | Context context = view.getContext(); 62 | RecyclerView recyclerView = (RecyclerView) view; 63 | recyclerView.setLayoutManager(new LinearLayoutManager(context)); 64 | recyclerView.setAdapter(new OperatingSystemRecyclerViewAdapter(mListener.getOperatingSystems(), this)); 65 | recyclerView.setNestedScrollingEnabled(false); 66 | mListener.getFAB().attachToRecyclerView(recyclerView); 67 | } 68 | 69 | // configure toolbar 70 | AppBarLayout appBarLayout = mListener.getAppBarLayout(); 71 | Util.setToolBarHeight(appBarLayout, 0, false); 72 | 73 | // show FAB 74 | FloatingActionButton fab = mListener.getFAB(); 75 | fab.setImageDrawable(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_dialog_add, getActivity().getTheme())); 76 | fab.setVisibility(View.VISIBLE); 77 | fab.setOnClickListener(new View.OnClickListener() { 78 | @Override 79 | public void onClick(View view) { 80 | Intent intent = new Intent(getContext(), OperatingSystemEditActivity.class); 81 | intent.putExtra(OperatingSystemEditActivity.ARG_OPERATING_SYSTEM, new OperatingSystem()); 82 | intent.putExtra(OperatingSystemEditActivity.ARG_DEVICE_INFO, mListener.getDeviceInfo()); 83 | startActivityForResult(intent, REQUEST_CREATE_OS); 84 | } 85 | }); 86 | 87 | CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); 88 | layoutParams.gravity = Gravity.END | Gravity.BOTTOM; 89 | layoutParams.setMargins(layoutParams.leftMargin, 0, layoutParams.rightMargin, layoutParams.bottomMargin); 90 | fab.setLayoutParams(layoutParams); 91 | 92 | return view; 93 | } 94 | 95 | @Override 96 | public void onAttach(Context context) { 97 | super.onAttach(context); 98 | if (context instanceof OnOperatingSystemFragmentInteractionListener) { 99 | mListener = (OnOperatingSystemFragmentInteractionListener) context; 100 | } else { 101 | throw new RuntimeException(context.toString() 102 | + " must implement OnOperatingSystemFragmentInteractionListener"); 103 | } 104 | } 105 | 106 | @Override 107 | public void onDetach() { 108 | super.onDetach(); 109 | mListener = null; 110 | } 111 | 112 | @Override 113 | public void onOperatingSystemClicked(OperatingSystem item) { 114 | Intent intent = new Intent(getContext(), OperatingSystemEditActivity.class); 115 | intent.putExtra(OperatingSystemEditActivity.ARG_OPERATING_SYSTEM, item); 116 | intent.putExtra(OperatingSystemEditActivity.ARG_DEVICE_INFO, mListener.getDeviceInfo()); 117 | startActivityForResult(intent, REQUEST_EDIT_OS); 118 | } 119 | 120 | @Override 121 | public void onOperatingSystemLongClicked(final OperatingSystem item) { 122 | new MaterialDialog.Builder(getContext()) 123 | .title(R.string.action_delete) 124 | .content(getString(R.string.os_delete_confirmation, item.getName())) 125 | .positiveText(R.string.action_delete) 126 | .negativeText(R.string.md_cancel_label) 127 | .onPositive(new MaterialDialog.SingleButtonCallback() { 128 | @Override 129 | public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { 130 | Bundle extras = new Bundle(); 131 | Intent intent = GenericProgressActivity.makeIntent( 132 | getContext(), 133 | OSRemovalProgressServiceTask.class, 134 | extras, 135 | getString(R.string.deleting_system, item.getName()), 136 | R.anim.hold, R.anim.abc_slide_out_right_full, 137 | R.anim.hold, R.anim.abc_slide_out_right_full 138 | ); 139 | 140 | extras.putParcelable(OSRemovalProgressServiceTask.ARG_OPERATING_SYSTEM, item); 141 | startActivityForResult(intent, REQUEST_DELETE_OS); 142 | getActivity().overridePendingTransition(R.anim.abc_slide_in_right_full, R.anim.hold); 143 | } 144 | }).show(); 145 | } 146 | 147 | @Override 148 | public void onActivityResult(int requestCode, int resultCode, Intent data) { 149 | switch (requestCode) { 150 | case REQUEST_EDIT_OS: 151 | case REQUEST_CREATE_OS: 152 | if (resultCode == OperatingSystemEditActivity.RESULT_UPDATED) 153 | mListener.reloadOperatingSystems(); 154 | break; 155 | 156 | case REQUEST_DELETE_OS: 157 | mListener.reloadOperatingSystems(); 158 | break; 159 | 160 | default: 161 | super.onActivityResult(requestCode, resultCode, data); 162 | } 163 | } 164 | 165 | public interface OnOperatingSystemFragmentInteractionListener { 166 | DeviceInfo getDeviceInfo(); 167 | 168 | FloatingActionButton getFAB(); 169 | 170 | AppBarLayout getAppBarLayout(); 171 | 172 | List getOperatingSystems(); 173 | 174 | void reloadOperatingSystems(); 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/fragments/OperatingSystemRecyclerViewAdapter.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager.fragments; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.graphics.drawable.Drawable; 6 | import android.os.AsyncTask; 7 | import android.support.v4.content.res.ResourcesCompat; 8 | import android.support.v7.widget.RecyclerView; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.widget.ImageView; 13 | import android.widget.TextView; 14 | 15 | import org.efidroid.efidroidmanager.R; 16 | import org.efidroid.efidroidmanager.models.OperatingSystem; 17 | 18 | import java.util.List; 19 | 20 | /** 21 | * {@link RecyclerView.Adapter} that can display a {@link OperatingSystem} and makes a call to the 22 | * specified {@link OperatingSystemFragment.OnOperatingSystemFragmentInteractionListener}. 23 | */ 24 | public class OperatingSystemRecyclerViewAdapter extends RecyclerView.Adapter { 25 | 26 | private final List mValues; 27 | private final OnInteractionListener mListener; 28 | 29 | private void loadIconsAsync(final Context context) { 30 | new AsyncTask() { 31 | @Override 32 | protected Void doInBackground(Void... params) { 33 | for (int i = 0; i < mValues.size(); i++) { 34 | OperatingSystem os = mValues.get(i); 35 | 36 | try { 37 | if (!os.hasLoadedIcon()) { 38 | os.getIconBitmap(context); 39 | publishProgress(i); 40 | } 41 | } catch (Exception e) { 42 | e.printStackTrace(); 43 | } 44 | } 45 | 46 | return null; 47 | } 48 | 49 | @Override 50 | protected void onProgressUpdate(Integer... values) { 51 | for (int pos : values) { 52 | notifyItemChanged(pos); 53 | } 54 | } 55 | }.execute(); 56 | } 57 | 58 | public OperatingSystemRecyclerViewAdapter(List items, OnInteractionListener listener) { 59 | mValues = items; 60 | mListener = listener; 61 | } 62 | 63 | @Override 64 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 65 | View view = LayoutInflater.from(parent.getContext()) 66 | .inflate(R.layout.fragment_operatingsystem_item, parent, false); 67 | 68 | loadIconsAsync(view.getContext()); 69 | 70 | return new ViewHolder(view); 71 | } 72 | 73 | @Override 74 | public void onBindViewHolder(final ViewHolder holder, int position) { 75 | OperatingSystem os = mValues.get(position); 76 | 77 | holder.mItem = os; 78 | holder.mTitleView.setText(os.getName()); 79 | 80 | Bitmap iconBitmap = null; 81 | if (os.hasLoadedIcon()) { 82 | try { 83 | iconBitmap = os.getIconBitmap(holder.mView.getContext()); 84 | if (iconBitmap != null) 85 | holder.mImageView.setImageBitmap(iconBitmap); 86 | } catch (Exception e) { 87 | e.printStackTrace(); 88 | } 89 | } 90 | 91 | if (iconBitmap == null) { 92 | Drawable icon = ResourcesCompat.getDrawable( 93 | holder.mView.getResources(), 94 | android.R.mipmap.sym_def_app_icon, 95 | holder.mView.getContext().getTheme() 96 | ); 97 | holder.mImageView.setImageDrawable(icon); 98 | } 99 | 100 | String desc = os.getDescription(); 101 | if (desc != null && desc.length() > 0) { 102 | holder.mSubtitleView.setText(desc); 103 | holder.mSubtitleView.setVisibility(View.VISIBLE); 104 | } else { 105 | holder.mSubtitleView.setVisibility(View.GONE); 106 | } 107 | 108 | holder.mView.setOnClickListener(new View.OnClickListener() { 109 | @Override 110 | public void onClick(View v) { 111 | if (null != mListener) { 112 | // Notify the active callbacks interface (the activity, if the 113 | // fragment is attached to one) that an item has been selected. 114 | mListener.onOperatingSystemClicked(holder.mItem); 115 | } 116 | } 117 | }); 118 | 119 | holder.mView.setOnLongClickListener(new View.OnLongClickListener() { 120 | @Override 121 | public boolean onLongClick(View v) { 122 | if (null != mListener) { 123 | // Notify the active callbacks interface (the activity, if the 124 | // fragment is attached to one) that an item has been selected. 125 | mListener.onOperatingSystemLongClicked(holder.mItem); 126 | return true; 127 | } 128 | return false; 129 | } 130 | }); 131 | } 132 | 133 | @Override 134 | public int getItemCount() { 135 | return mValues.size(); 136 | } 137 | 138 | public class ViewHolder extends RecyclerView.ViewHolder { 139 | public final View mView; 140 | public final TextView mTitleView; 141 | public final TextView mSubtitleView; 142 | public final ImageView mImageView; 143 | public OperatingSystem mItem; 144 | 145 | public ViewHolder(View view) { 146 | super(view); 147 | mView = view; 148 | mTitleView = (TextView) view.findViewById(R.id.text); 149 | mSubtitleView = (TextView) view.findViewById(R.id.text2); 150 | mImageView = (ImageView) view.findViewById(R.id.image); 151 | } 152 | } 153 | 154 | public interface OnInteractionListener { 155 | void onOperatingSystemClicked(OperatingSystem item); 156 | 157 | void onOperatingSystemLongClicked(OperatingSystem item); 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/fragments/operatingsystemedit/PartitionItemRecyclerViewAdapter.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager.fragments.operatingsystemedit; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.ImageView; 8 | import android.widget.TextView; 9 | 10 | import org.apache.commons.io.FileUtils; 11 | import org.efidroid.efidroidmanager.R; 12 | import org.efidroid.efidroidmanager.models.OperatingSystem; 13 | import org.efidroid.efidroidmanager.types.OSEditFragmentInteractionListener; 14 | 15 | import java.util.List; 16 | 17 | public class PartitionItemRecyclerViewAdapter extends RecyclerView.Adapter implements OperatingSystem.OperatingSystemChangeListener { 18 | private List mValues; 19 | private final OSEditFragmentInteractionListener mListener; 20 | private final OperatingSystem mOperatingSystem; 21 | 22 | public PartitionItemRecyclerViewAdapter(OperatingSystem os, OSEditFragmentInteractionListener listener) { 23 | mOperatingSystem = os; 24 | mListener = listener; 25 | rebuild(); 26 | } 27 | 28 | @Override 29 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 30 | View view = LayoutInflater.from(parent.getContext()) 31 | .inflate(R.layout.fragment_partitionitem, parent, false); 32 | return new ViewHolder(view); 33 | } 34 | 35 | @Override 36 | public void onBindViewHolder(final ViewHolder holder, int position) { 37 | OperatingSystem.Partition partition = mValues.get(position); 38 | 39 | // data 40 | holder.mItem = partition; 41 | 42 | // text 43 | holder.mIdView.setText(partition.getPartitionName()); 44 | 45 | // description 46 | String description = partition.toIniPath(); 47 | if (partition.getType() != OperatingSystem.Partition.TYPE_BIND) { 48 | description += " (" + FileUtils.byteCountToDisplaySize(partition.getSize()) + ")"; 49 | } 50 | holder.mContentView.setText(description); 51 | 52 | // icon letter 53 | String letter = ""; 54 | switch (partition.getType()) { 55 | case OperatingSystem.Partition.TYPE_BIND: 56 | letter = "B"; 57 | break; 58 | case OperatingSystem.Partition.TYPE_LOOP: 59 | letter = "L"; 60 | break; 61 | } 62 | holder.mIconLetter.setText(letter); 63 | 64 | // onclick 65 | if(mOperatingSystem.isCreationMode()) { 66 | holder.mView.setOnClickListener(new View.OnClickListener() { 67 | @Override 68 | public void onClick(View v) { 69 | if (null != mListener) { 70 | mListener.onPartitionItemClicked(holder.mItem); 71 | } 72 | } 73 | }); 74 | } 75 | } 76 | 77 | @Override 78 | public int getItemCount() { 79 | return mValues.size(); 80 | } 81 | 82 | private void rebuild() { 83 | mValues = mOperatingSystem.getPartitions(); 84 | } 85 | 86 | @Override 87 | public void onOperatingSystemChanged() { 88 | rebuild(); 89 | notifyDataSetChanged(); 90 | } 91 | 92 | @Override 93 | public void onAttachedToRecyclerView(RecyclerView recyclerView) { 94 | super.onAttachedToRecyclerView(recyclerView); 95 | mOperatingSystem.addChangeListener(this); 96 | } 97 | 98 | @Override 99 | public void onDetachedFromRecyclerView(RecyclerView recyclerView) { 100 | super.onDetachedFromRecyclerView(recyclerView); 101 | mOperatingSystem.removeChangeListener(this); 102 | } 103 | 104 | public class ViewHolder extends RecyclerView.ViewHolder { 105 | public final View mView; 106 | public final TextView mIdView; 107 | public final TextView mContentView; 108 | public final ImageView mImageView; 109 | public final TextView mIconLetter; 110 | public OperatingSystem.Partition mItem; 111 | 112 | public ViewHolder(View view) { 113 | super(view); 114 | mView = view; 115 | mIdView = (TextView) view.findViewById(android.support.design.R.id.text); 116 | mContentView = (TextView) view.findViewById(android.support.design.R.id.text2); 117 | mImageView = (ImageView) view.findViewById(android.support.design.R.id.image); 118 | mIconLetter = (TextView) view.findViewById(R.id.icon_letter); 119 | } 120 | 121 | @Override 122 | public String toString() { 123 | return super.toString() + " '" + mContentView.getText() + "'"; 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/models/DeviceInfo.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager.models; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | import org.efidroid.efidroidmanager.AppConstants; 7 | import org.efidroid.efidroidmanager.RootToolsEx; 8 | import org.efidroid.efidroidmanager.types.FSTabEntry; 9 | import org.efidroid.efidroidmanager.types.MountEntry; 10 | import org.json.JSONException; 11 | import org.json.JSONObject; 12 | 13 | import java.io.IOException; 14 | 15 | public class DeviceInfo implements Parcelable { 16 | 17 | // data 18 | private String mDeviceName = null; 19 | private FSTab mFSTab = null; 20 | 21 | // state 22 | public LoadingState mLoadingState = LoadingState.STATE_LOAD_DEVICEINFO; 23 | 24 | public enum LoadingState { 25 | STATE_LOAD_DEVICEINFO, 26 | STATE_LOAD_FSTAB, 27 | } 28 | 29 | public DeviceInfo() { 30 | } 31 | 32 | protected DeviceInfo(Parcel in) { 33 | mDeviceName = in.readString(); 34 | mFSTab = in.readParcelable(FSTab.class.getClassLoader()); 35 | } 36 | 37 | public static final Creator CREATOR = new Creator() { 38 | @Override 39 | public DeviceInfo createFromParcel(Parcel in) { 40 | return new DeviceInfo(in); 41 | } 42 | 43 | @Override 44 | public DeviceInfo[] newArray(int size) { 45 | return new DeviceInfo[size]; 46 | } 47 | }; 48 | 49 | @Override 50 | public int describeContents() { 51 | return 0; 52 | } 53 | 54 | @Override 55 | public void writeToParcel(Parcel dest, int flags) { 56 | dest.writeString(mDeviceName); 57 | dest.writeParcelable(mFSTab, flags); 58 | } 59 | 60 | public void parseDeviceList(String json) throws JSONException { 61 | JSONObject jsonObject = new JSONObject(json); 62 | mDeviceName = jsonObject.getString(AppConstants.DEVICE_NAME); 63 | } 64 | 65 | public void parseFSTab(String data) throws IOException { 66 | mFSTab = new FSTab(data); 67 | } 68 | 69 | public String getDeviceName() { 70 | return mDeviceName; 71 | } 72 | 73 | public FSTab getFSTab() { 74 | return mFSTab; 75 | } 76 | 77 | public String getESPDir(boolean requireUEFIESPDir) { 78 | for (FSTabEntry entry : mFSTab.getFSTabEntries()) { 79 | String espFlag = entry.getESP(); 80 | if (espFlag == null) 81 | continue; 82 | 83 | try { 84 | // load mount info 85 | MountInfo mountInfo = RootToolsEx.getMountInfo(); 86 | 87 | int[] majmin = RootToolsEx.getDeviceNode(entry.getBlkDevice()); 88 | MountEntry mountEntry = mountInfo.getByMajorMinor(majmin[0], majmin[1]); 89 | if (mountEntry == null) 90 | return null; 91 | String mountPoint = mountEntry.getMountPoint(); 92 | 93 | // absolute path 94 | if (espFlag.startsWith("/")) 95 | return mountPoint + espFlag; 96 | 97 | if (espFlag.equals("datamedia")) { 98 | String path; 99 | 100 | if (requireUEFIESPDir) 101 | path = mountPoint + "/media/0/UEFIESP"; 102 | else 103 | path = mountPoint + "/media/0"; 104 | if (RootToolsEx.isDirectory(path)) 105 | return path; 106 | 107 | if (requireUEFIESPDir) 108 | path = mountPoint + "/media/UEFIESP"; 109 | else 110 | path = mountPoint + "/media"; 111 | if (RootToolsEx.isDirectory(path)) 112 | return path; 113 | } 114 | } catch (Exception e) { 115 | return null; 116 | } 117 | } 118 | 119 | return null; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/models/FSTab.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager.models; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | import org.apache.commons.io.IOUtils; 7 | import org.efidroid.efidroidmanager.types.FSTabEntry; 8 | 9 | import java.io.IOException; 10 | import java.io.StringReader; 11 | import java.util.ArrayList; 12 | import java.util.Arrays; 13 | import java.util.Collections; 14 | import java.util.List; 15 | 16 | public class FSTab implements Parcelable { 17 | // data 18 | private ArrayList mFSTabEntries = new ArrayList<>(); 19 | 20 | public FSTab(String data) throws IOException { 21 | List lines = IOUtils.readLines(new StringReader(data)); 22 | 23 | for(String line : lines) { 24 | String[] parts = line.split(" "); 25 | ArrayList al = new ArrayList<>(Arrays.asList(parts)); 26 | al.removeAll(Collections.singleton("")); 27 | mFSTabEntries.add(new FSTabEntry(al.get(0), al.get(1), al.get(2), al.get(3), al.get(4))); 28 | } 29 | } 30 | 31 | protected FSTab(Parcel in) { 32 | in.readList(mFSTabEntries, FSTabEntry.class.getClassLoader()); 33 | } 34 | 35 | public static final Creator CREATOR = new Creator() { 36 | @Override 37 | public FSTab createFromParcel(Parcel in) { 38 | return new FSTab(in); 39 | } 40 | 41 | @Override 42 | public FSTab[] newArray(int size) { 43 | return new FSTab[size]; 44 | } 45 | }; 46 | 47 | public List getFSTabEntries() { 48 | return mFSTabEntries; 49 | } 50 | 51 | public FSTabEntry getEntryByName(String name) { 52 | for (FSTabEntry entry : getFSTabEntries()) { 53 | if(entry.getName().equals(name)) 54 | return entry; 55 | } 56 | return null; 57 | } 58 | 59 | @Override 60 | public int describeContents() { 61 | return 0; 62 | } 63 | 64 | @Override 65 | public void writeToParcel(Parcel dest, int flags) { 66 | dest.writeList(mFSTabEntries); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/models/MountInfo.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager.models; 2 | 3 | import org.efidroid.efidroidmanager.types.MountEntry; 4 | 5 | import java.util.List; 6 | 7 | public class MountInfo { 8 | private final List mMountEntries; 9 | 10 | public MountInfo(List mountEntries) { 11 | mMountEntries = mountEntries; 12 | } 13 | 14 | public MountEntry getByMajorMinor(int major, int minor) { 15 | for (MountEntry mountEntry : mMountEntries) { 16 | if (mountEntry.getMajor() == major && mountEntry.getMinor() == minor && mountEntry.getRoot().equals("/")) { 17 | return mountEntry; 18 | } 19 | } 20 | 21 | return null; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/tasks/EFIDroidUninstallServiceTask.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager.tasks; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Keep; 5 | 6 | import com.stericson.roottools.RootTools; 7 | 8 | import org.efidroid.efidroidmanager.AppConstants; 9 | import org.efidroid.efidroidmanager.R; 10 | import org.efidroid.efidroidmanager.RootToolsEx; 11 | import org.efidroid.efidroidmanager.models.DeviceInfo; 12 | import org.efidroid.efidroidmanager.services.GenericProgressIntentService; 13 | import org.efidroid.efidroidmanager.types.FSTabEntry; 14 | import org.efidroid.efidroidmanager.types.InstallationEntry; 15 | import org.efidroid.efidroidmanager.types.InstallationStatus; 16 | import org.efidroid.efidroidmanager.types.ProgressServiceTask; 17 | import org.json.JSONArray; 18 | import org.json.JSONObject; 19 | 20 | import java.io.BufferedInputStream; 21 | import java.io.FileOutputStream; 22 | import java.io.InputStream; 23 | import java.io.OutputStream; 24 | import java.net.URL; 25 | import java.net.URLConnection; 26 | 27 | public class EFIDroidUninstallServiceTask extends ProgressServiceTask { 28 | // args 29 | public static final String ARG_DEVICE_INFO = "device_info"; 30 | public static final String ARG_INSTALL_STATUS = "installation_status"; 31 | 32 | // data 33 | private DeviceInfo mDeviceInfo = null; 34 | private InstallationStatus mInstallationStatus = null; 35 | 36 | // status 37 | private boolean mSuccess = false; 38 | private int mProgress = 0; 39 | 40 | 41 | @Keep 42 | @SuppressWarnings("unused") 43 | public EFIDroidUninstallServiceTask(GenericProgressIntentService service) { 44 | super(service); 45 | } 46 | 47 | private void doUninstall() throws Exception { 48 | // get esp parent directory 49 | String espParent = mDeviceInfo.getESPDir(false); 50 | if (espParent == null) 51 | throw new Exception(getService().getString(R.string.cant_find_esp_partition)); 52 | 53 | // create UEFIESP dir 54 | String espDir = espParent + "/UEFIESP"; 55 | RootToolsEx.mkdir(espDir, true); 56 | 57 | // restore backups 58 | for (FSTabEntry entry : mDeviceInfo.getFSTab().getFSTabEntries()) { 59 | if (!entry.isUEFI()) 60 | continue; 61 | 62 | RootToolsEx.dd(espDir + "/partition_" + entry.getName() + ".img", entry.getBlkDevice()); 63 | } 64 | 65 | // remove backups 66 | for (FSTabEntry entry : mDeviceInfo.getFSTab().getFSTabEntries()) { 67 | if (!entry.isUEFI()) 68 | continue; 69 | 70 | RootTools.deleteFileOrDirectory(espDir + "/partition_" + entry.getName() + ".img", false); 71 | } 72 | } 73 | 74 | public void onProcess(Bundle extras) { 75 | mDeviceInfo = extras.getParcelable(ARG_DEVICE_INFO); 76 | mInstallationStatus = extras.getParcelable(ARG_INSTALL_STATUS); 77 | 78 | mProgress = 0; 79 | mSuccess = false; 80 | try { 81 | mProgress = publishProgress(50, getService().getString(R.string.uninstalling)); 82 | doUninstall(); 83 | 84 | mSuccess = true; 85 | } catch (Exception e) { 86 | e.printStackTrace(); 87 | mSuccess = false; 88 | publishProgress(mProgress, e.getLocalizedMessage()); 89 | } 90 | 91 | // publish status 92 | if (mSuccess) 93 | publishProgress(100, "Done"); 94 | publishFinish(mSuccess); 95 | } 96 | 97 | @Override 98 | public String getNotificationProgressTitle() { 99 | return getService().getString(R.string.uninstalling_efidroid); 100 | } 101 | 102 | @Override 103 | public String getNotificationResultTitle() { 104 | if (mSuccess) { 105 | return getService().getString(R.string.uninstalling_efidroid_successful); 106 | } else { 107 | return getService().getString(R.string.error_uninstalliing_efidroid); 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/tasks/OSRemovalProgressServiceTask.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager.tasks; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Keep; 5 | 6 | import com.stericson.roottools.RootTools; 7 | 8 | import org.efidroid.efidroidmanager.R; 9 | import org.efidroid.efidroidmanager.RootToolsEx; 10 | import org.efidroid.efidroidmanager.models.OperatingSystem; 11 | import org.efidroid.efidroidmanager.services.GenericProgressIntentService; 12 | import org.efidroid.efidroidmanager.types.ProgressServiceTask; 13 | 14 | public class OSRemovalProgressServiceTask extends ProgressServiceTask { 15 | // args 16 | public static final String ARG_OPERATING_SYSTEM = "operatingsystem"; 17 | 18 | private OperatingSystem mOperatingSystem = null; 19 | private boolean mSuccess = false; 20 | 21 | @Keep 22 | @SuppressWarnings("unused") 23 | public OSRemovalProgressServiceTask(GenericProgressIntentService service) { 24 | super(service); 25 | } 26 | 27 | public void onProcess(Bundle extras) { 28 | OperatingSystem os = extras.getParcelable(ARG_OPERATING_SYSTEM); 29 | if(os==null) { 30 | mSuccess = false; 31 | publishProgress(0, "NULL Operating System"); 32 | publishFinish(mSuccess); 33 | return; 34 | } 35 | 36 | mOperatingSystem = os; 37 | mSuccess = false; 38 | 39 | int progress = 0; 40 | try { 41 | String romDir = os.getDirectory(); 42 | if(!RootToolsEx.isDirectory(romDir)) { 43 | throw new Exception(getService().getString(R.string.os_does_not_exist)); 44 | } 45 | 46 | publishProgress(1, getService().getString(R.string.removing_system, os.getName())); 47 | if(!RootTools.deleteFileOrDirectory(romDir, false)) { 48 | throw new Exception(getService().getString(R.string.cant_delete_os)); 49 | } 50 | 51 | mSuccess = true; 52 | } 53 | catch (Exception e) { 54 | mSuccess = false; 55 | publishProgress(progress, e.getLocalizedMessage()); 56 | } 57 | 58 | // publish status 59 | if(mSuccess) 60 | publishProgress(100, getService().getString(R.string.md_done_label)); 61 | publishFinish(mSuccess); 62 | } 63 | 64 | @Override 65 | public String getNotificationProgressTitle() { 66 | return getService().getString(R.string.removing_system, mOperatingSystem.getName()); 67 | } 68 | 69 | @Override 70 | public String getNotificationResultTitle() { 71 | if (mSuccess) { 72 | return getService().getString(R.string.removed_system, mOperatingSystem.getName()); 73 | } else { 74 | return getService().getString(R.string.error_removing_system, mOperatingSystem.getName()); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/types/ArgbEvaluator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.efidroid.efidroidmanager.types; 18 | 19 | import android.animation.TypeEvaluator; 20 | import android.animation.ValueAnimator; 21 | 22 | /** 23 | * This evaluator can be used to perform type interpolation between integer 24 | * values that represent ARGB colors. 25 | */ 26 | public class ArgbEvaluator implements TypeEvaluator { 27 | private static final ArgbEvaluator sInstance = new ArgbEvaluator(); 28 | 29 | /** 30 | * Returns an instance of ArgbEvaluator that may be used in 31 | * {@link ValueAnimator#setEvaluator(TypeEvaluator)}. The same instance may 32 | * be used in multiple Animators because it holds no state. 33 | * 34 | * @return An instance of ArgbEvalutor. 35 | * @hide 36 | */ 37 | public static ArgbEvaluator getInstance() { 38 | return sInstance; 39 | } 40 | 41 | /** 42 | * This function returns the calculated in-between value for a color 43 | * given integers that represent the start and end values in the four 44 | * bytes of the 32-bit int. Each channel is separately linearly interpolated 45 | * and the resulting calculated values are recombined into the return value. 46 | * 47 | * @param fraction The fraction from the starting to the ending values 48 | * @param startValue A 32-bit int value representing colors in the 49 | * separate bytes of the parameter 50 | * @param endValue A 32-bit int value representing colors in the 51 | * separate bytes of the parameter 52 | * @return A value that is calculated to be the linearly interpolated 53 | * result, derived by separating the start and end values into separate 54 | * color channels and interpolating each one separately, recombining the 55 | * resulting values in the same way. 56 | */ 57 | public Object evaluate(float fraction, Object startValue, Object endValue) { 58 | int startInt = (Integer) startValue; 59 | int startA = (startInt >> 24) & 0xff; 60 | int startR = (startInt >> 16) & 0xff; 61 | int startG = (startInt >> 8) & 0xff; 62 | int startB = startInt & 0xff; 63 | 64 | int endInt = (Integer) endValue; 65 | int endA = (endInt >> 24) & 0xff; 66 | int endR = (endInt >> 16) & 0xff; 67 | int endG = (endInt >> 8) & 0xff; 68 | int endB = endInt & 0xff; 69 | 70 | return (int) ((startA + (int) (fraction * (endA - startA))) << 24) | 71 | (int) ((startR + (int) (fraction * (endR - startR))) << 16) | 72 | (int) ((startG + (int) (fraction * (endG - startG))) << 8) | 73 | (int) ((startB + (int) (fraction * (endB - startB)))); 74 | } 75 | } -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/types/CommandEx.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager.types; 2 | 3 | import com.stericson.rootshell.execution.Command; 4 | 5 | public class CommandEx extends Command { 6 | private StringBuffer mErrorBuffer = new StringBuffer(); 7 | 8 | public CommandEx(int id, String... command) { 9 | super(id, command); 10 | } 11 | 12 | public CommandEx(int id, boolean handlerEnabled, String... command) { 13 | super(id, handlerEnabled, command); 14 | } 15 | 16 | public CommandEx(int id, int timeout, String... command) { 17 | super(id, timeout, command); 18 | } 19 | 20 | public CommandEx(int id, boolean handlerEnabled, int timeout, String... command) { 21 | super(id, handlerEnabled, timeout, command); 22 | } 23 | 24 | @Override 25 | public void commandOutput(int id, String line) { 26 | super.commandOutput(id, line); 27 | mErrorBuffer.append(line); 28 | } 29 | 30 | public String getErrorBuffer() { 31 | return mErrorBuffer.toString(); 32 | } 33 | 34 | public void checkReturnCode() throws Exception { 35 | if (getExitCode() != 0) { 36 | String s = getErrorBuffer(); 37 | if (s.trim().length() == 0) 38 | throw new ReturnCodeException(getExitCode()); 39 | else 40 | throw new Exception(s); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/types/FABListener.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager.types; 2 | 3 | public interface FABListener { 4 | void onFABClicked(); 5 | } 6 | -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/types/FSTabEntry.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager.types; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | import org.efidroid.efidroidmanager.RootToolsEx; 7 | 8 | public class FSTabEntry implements Parcelable { 9 | final String mBlkDevice; 10 | final String mMountPoint; 11 | final String mFsType; 12 | final String mMountFlags; 13 | final String mFfMgrFlags; 14 | 15 | public FSTabEntry(String blkDevice, String mountPoint, String fsType, String mountFlags, String fsMgrFlags) { 16 | mMountPoint = mountPoint; 17 | mFsType = fsType; 18 | mMountFlags = mountFlags; 19 | mFfMgrFlags = fsMgrFlags; 20 | 21 | // use backup node if it exists 22 | String new_blkDevice = blkDevice; 23 | try { 24 | String backup = "/multiboot/dev/replacement_backup_" + getName(); 25 | if (RootToolsEx.nodeExists(backup)) { 26 | new_blkDevice = backup; 27 | } 28 | } catch (Exception e) { 29 | e.printStackTrace(); 30 | } 31 | mBlkDevice = new_blkDevice; 32 | } 33 | 34 | protected FSTabEntry(Parcel in) { 35 | mBlkDevice = in.readString(); 36 | mMountPoint = in.readString(); 37 | mFsType = in.readString(); 38 | mMountFlags = in.readString(); 39 | mFfMgrFlags = in.readString(); 40 | } 41 | 42 | public static final Creator CREATOR = new Creator() { 43 | @Override 44 | public FSTabEntry createFromParcel(Parcel in) { 45 | return new FSTabEntry(in); 46 | } 47 | 48 | @Override 49 | public FSTabEntry[] newArray(int size) { 50 | return new FSTabEntry[size]; 51 | } 52 | }; 53 | 54 | @Override 55 | public int describeContents() { 56 | return 0; 57 | } 58 | 59 | @Override 60 | public void writeToParcel(Parcel dest, int flags) { 61 | dest.writeString(mBlkDevice); 62 | dest.writeString(mMountPoint); 63 | dest.writeString(mFsType); 64 | dest.writeString(mMountFlags); 65 | dest.writeString(mFfMgrFlags); 66 | } 67 | 68 | public String getBlkDevice() { 69 | try { 70 | if (RootToolsEx.isDirectory("/multiboot")) 71 | return "/multiboot" + RootToolsEx.realpath(mBlkDevice); 72 | } catch (Exception e) { 73 | } 74 | 75 | return mBlkDevice; 76 | } 77 | 78 | public String getMountPoint() { 79 | return mMountPoint; 80 | } 81 | 82 | public String getName() { 83 | return getMountPoint().substring(1); 84 | } 85 | 86 | public String getFsType() { 87 | return mFsType; 88 | } 89 | 90 | public String getMountFlags() { 91 | return mMountFlags; 92 | } 93 | 94 | public String getFfMgrFlags() { 95 | return mFfMgrFlags; 96 | } 97 | 98 | public boolean isMultiboot() { 99 | String[] parts = mFfMgrFlags.split(","); 100 | for (String part : parts) { 101 | if (part.equals("multiboot")) 102 | return true; 103 | } 104 | 105 | return false; 106 | } 107 | 108 | public boolean isUEFI() { 109 | String[] parts = mFfMgrFlags.split(","); 110 | for (String part : parts) { 111 | if (part.equals("uefi")) 112 | return true; 113 | } 114 | 115 | return false; 116 | } 117 | 118 | public String getESP() { 119 | String[] parts = mFfMgrFlags.split(","); 120 | for (String part : parts) { 121 | if (!part.startsWith("esp")) 122 | continue; 123 | 124 | return part.substring(4); 125 | } 126 | 127 | return null; 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/types/InstallationStatus.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager.types; 2 | 3 | import android.content.Context; 4 | import android.os.Parcel; 5 | import android.os.Parcelable; 6 | 7 | import org.efidroid.efidroidmanager.AppConstants; 8 | import org.efidroid.efidroidmanager.models.DeviceInfo; 9 | import org.efidroid.efidroidmanager.models.FSTab; 10 | import org.json.JSONArray; 11 | import org.json.JSONException; 12 | import org.json.JSONObject; 13 | 14 | import java.io.BufferedInputStream; 15 | import java.io.InputStream; 16 | import java.net.URL; 17 | import java.net.URLConnection; 18 | import java.util.ArrayList; 19 | import java.util.Date; 20 | 21 | public class InstallationStatus implements Parcelable { 22 | private ArrayList mInstallationEntries = new ArrayList<>(); 23 | private JSONObject mUpdate = null; 24 | 25 | public InstallationStatus() { 26 | } 27 | 28 | private JSONArray getUpdateList(Context context, DeviceInfo deviceInfo) throws Exception { 29 | StringBuilder sb = new StringBuilder(); 30 | 31 | // connect 32 | URL url = new URL(AppConstants.getUrlUpdates(context, deviceInfo)); 33 | URLConnection connection = url.openConnection(); 34 | connection.connect(); 35 | 36 | // open stream 37 | InputStream input = new BufferedInputStream(connection.getInputStream()); 38 | 39 | // copy data 40 | byte data[] = new byte[1024]; 41 | int count; 42 | while ((count = input.read(data)) != -1) { 43 | sb.append(new String(data, 0, count)); 44 | } 45 | input.close(); 46 | 47 | return new JSONArray(sb.toString()); 48 | } 49 | 50 | public void doLoad(Context context, DeviceInfo deviceInfo) { 51 | 52 | // load installation info 53 | FSTab fsTab = deviceInfo.getFSTab(); 54 | for (FSTabEntry entry : fsTab.getFSTabEntries()) { 55 | if (!entry.isUEFI()) 56 | continue; 57 | 58 | // build entry 59 | InstallationEntry installationEntry = new InstallationEntry(entry, deviceInfo); 60 | mInstallationEntries.add(installationEntry); 61 | } 62 | 63 | // get update list 64 | try { 65 | if (isInstalled() && !isBroken()) { 66 | JSONArray updateList = getUpdateList(context, deviceInfo); 67 | JSONObject latestUpdate = null; 68 | for (int i = 0; i < updateList.length(); i++) { 69 | JSONObject o = updateList.getJSONObject(i); 70 | 71 | if (latestUpdate == null || o.getLong("timestamp") > latestUpdate.getLong("timestamp")) 72 | latestUpdate = o; 73 | } 74 | 75 | if (latestUpdate != null && latestUpdate.getLong("timestamp") > getWorkingEntry().getTimeStamp()) 76 | mUpdate = latestUpdate; 77 | } 78 | } catch (Exception e) { 79 | e.printStackTrace(); 80 | } 81 | } 82 | 83 | public ArrayList getInstallationEntries() { 84 | return mInstallationEntries; 85 | } 86 | 87 | public InstallationEntry getWorkingEntry() { 88 | for (InstallationEntry entry : mInstallationEntries) { 89 | int status = entry.getStatus(); 90 | if (status == InstallationEntry.STATUS_OK) 91 | return entry; 92 | } 93 | 94 | return null; 95 | } 96 | 97 | public InstallationEntry getEntryByName(String name) { 98 | for (InstallationEntry entry : mInstallationEntries) { 99 | if (entry.getFsTabEntry().getName().equals(name)) 100 | return entry; 101 | } 102 | 103 | return null; 104 | } 105 | 106 | private int getInstalledCount() { 107 | int installedCount = 0; 108 | for (InstallationEntry entry : mInstallationEntries) { 109 | if (entry.getStatus() == InstallationEntry.STATUS_OK) 110 | installedCount++; 111 | } 112 | return installedCount; 113 | } 114 | 115 | private int getEspOnlyCount() { 116 | int count = 0; 117 | for (InstallationEntry entry : mInstallationEntries) { 118 | int status = entry.getStatus(); 119 | if (status == InstallationEntry.STATUS_ESP_ONLY) 120 | count++; 121 | } 122 | return count; 123 | } 124 | 125 | public boolean isInstalled() { 126 | return getInstalledCount() > 0 || getEspOnlyCount() > 0; 127 | } 128 | 129 | public boolean isBroken() { 130 | return getInstalledCount() != mInstallationEntries.size(); 131 | } 132 | 133 | public boolean isUpdateAvailable() { 134 | return mUpdate != null; 135 | } 136 | 137 | public Date getUpdateDate() { 138 | try { 139 | return new Date(mUpdate.getLong("timestamp") * 1000l); 140 | } catch (JSONException e) { 141 | e.printStackTrace(); 142 | } 143 | return new Date(); 144 | } 145 | 146 | protected InstallationStatus(Parcel in) { 147 | in.readList(mInstallationEntries, InstallationEntry.class.getClassLoader()); 148 | try { 149 | String jsonString = (String) in.readValue(String.class.getClassLoader()); 150 | if (jsonString != null) 151 | mUpdate = new JSONObject(jsonString); 152 | } catch (JSONException e) { 153 | e.printStackTrace(); 154 | } 155 | } 156 | 157 | public static final Creator CREATOR = new Creator() { 158 | @Override 159 | public InstallationStatus createFromParcel(Parcel in) { 160 | return new InstallationStatus(in); 161 | } 162 | 163 | @Override 164 | public InstallationStatus[] newArray(int size) { 165 | return new InstallationStatus[size]; 166 | } 167 | }; 168 | 169 | @Override 170 | public int describeContents() { 171 | return 0; 172 | } 173 | 174 | @Override 175 | public void writeToParcel(Parcel dest, int flags) { 176 | dest.writeList(mInstallationEntries); 177 | dest.writeValue(mUpdate == null ? null : mUpdate.toString()); 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/types/MountEntry.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager.types; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | import java.util.ArrayList; 7 | import java.util.Arrays; 8 | import java.util.List; 9 | 10 | public class MountEntry implements Parcelable { 11 | private final int mMountID; 12 | private final int mParentID; 13 | private final int mMajor; 14 | private final int mMinor; 15 | private final String mRoot; 16 | private final String mMountPoint; 17 | private final String mMountOptions; 18 | private final String mOptionalFields; 19 | private final String mFsType; 20 | private final String mMountSource; 21 | private final String mSuperOptions; 22 | 23 | public MountEntry(int mountID, int parentID, int major, int minor, String root, String mountPoint, String mountOptions, String optionalFields, String fsType, String mountSource, String superOptions) { 24 | mMountID = mountID; 25 | mParentID = parentID; 26 | mMajor = major; 27 | mMinor = minor; 28 | mRoot = root; 29 | mMountPoint = mountPoint; 30 | mMountOptions = mountOptions; 31 | mOptionalFields = optionalFields; 32 | mFsType = fsType; 33 | mMountSource = mountSource; 34 | mSuperOptions = superOptions; 35 | } 36 | 37 | protected MountEntry(Parcel in) { 38 | mMountID = in.readInt(); 39 | mParentID = in.readInt(); 40 | mMajor = in.readInt(); 41 | mMinor = in.readInt(); 42 | mRoot = in.readString(); 43 | mMountPoint = in.readString(); 44 | mMountOptions = in.readString(); 45 | mOptionalFields = in.readString(); 46 | mFsType = in.readString(); 47 | mMountSource = in.readString(); 48 | mSuperOptions = in.readString(); 49 | } 50 | 51 | public static final Creator CREATOR = new Creator() { 52 | @Override 53 | public MountEntry createFromParcel(Parcel in) { 54 | return new MountEntry(in); 55 | } 56 | 57 | @Override 58 | public MountEntry[] newArray(int size) { 59 | return new MountEntry[size]; 60 | } 61 | }; 62 | 63 | @Override 64 | public int describeContents() { 65 | return 0; 66 | } 67 | 68 | @Override 69 | public void writeToParcel(Parcel dest, int flags) { 70 | dest.writeInt(mMountID); 71 | dest.writeInt(mParentID); 72 | dest.writeInt(mMajor); 73 | dest.writeInt(mMinor); 74 | dest.writeString(mRoot); 75 | dest.writeString(mMountPoint); 76 | dest.writeString(mMountOptions); 77 | dest.writeString(mOptionalFields); 78 | dest.writeString(mFsType); 79 | dest.writeString(mMountSource); 80 | dest.writeString(mSuperOptions); 81 | } 82 | 83 | public int getMountID() { 84 | return mMountID; 85 | } 86 | 87 | public int getParentID() { 88 | return mParentID; 89 | } 90 | 91 | public int getMajor() { 92 | return mMajor; 93 | } 94 | 95 | public int getMinor() { 96 | return mMinor; 97 | } 98 | 99 | public String getRoot() { 100 | return mRoot; 101 | } 102 | 103 | public String getMountPoint() { 104 | return mMountPoint; 105 | } 106 | 107 | public String getMountOptions() { 108 | return mMountOptions; 109 | } 110 | 111 | public String getOptionalFields() { 112 | return mOptionalFields; 113 | } 114 | 115 | public String getFsType() { 116 | return mFsType; 117 | } 118 | 119 | public String getMountSource() { 120 | return mMountSource; 121 | } 122 | 123 | public String getSuperOptions() { 124 | return mSuperOptions; 125 | } 126 | 127 | public List getMountOptionsList() { 128 | return new ArrayList<>(Arrays.asList(getMountOptions().split(","))); 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/types/OSEditFragmentInteractionListener.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager.types; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | import android.support.design.widget.TabLayout; 6 | 7 | import org.efidroid.efidroidmanager.models.DeviceInfo; 8 | import org.efidroid.efidroidmanager.models.OperatingSystem; 9 | import org.efidroid.efidroidmanager.view.CustomViewPager; 10 | 11 | import java.util.ArrayList; 12 | 13 | public interface OSEditFragmentInteractionListener { 14 | class MultibootPartitionInfo implements Parcelable { 15 | public final String name; 16 | public final long size; 17 | 18 | public MultibootPartitionInfo(String name, long size) { 19 | this.name = name; 20 | this.size = size; 21 | } 22 | 23 | protected MultibootPartitionInfo(Parcel in) { 24 | this.name = in.readString(); 25 | this.size = in.readLong(); 26 | } 27 | 28 | public static final Creator CREATOR = new Creator() { 29 | @Override 30 | public MultibootPartitionInfo createFromParcel(Parcel in) { 31 | return new MultibootPartitionInfo(in); 32 | } 33 | 34 | @Override 35 | public MultibootPartitionInfo[] newArray(int size) { 36 | return new MultibootPartitionInfo[size]; 37 | } 38 | }; 39 | 40 | @Override 41 | public int describeContents() { 42 | return 0; 43 | } 44 | 45 | @Override 46 | public void writeToParcel(Parcel dest, int flags) { 47 | dest.writeString(name); 48 | dest.writeLong(size); 49 | } 50 | } 51 | 52 | class MultibootDir implements Parcelable { 53 | public static final Creator CREATOR = new Creator() { 54 | @Override 55 | public MultibootDir createFromParcel(Parcel in) { 56 | return new MultibootDir(in); 57 | } 58 | 59 | @Override 60 | public MultibootDir[] newArray(int size) { 61 | return new MultibootDir[size]; 62 | } 63 | }; 64 | public final String path; 65 | public final MountEntry mountEntry; 66 | 67 | public MultibootDir(String path, MountEntry mountEntry) { 68 | this.path = path; 69 | this.mountEntry = mountEntry; 70 | } 71 | 72 | protected MultibootDir(Parcel in) { 73 | this.path = in.readString(); 74 | this.mountEntry = in.readParcelable(MountEntry.class.getClassLoader()); 75 | } 76 | 77 | @Override 78 | public int describeContents() { 79 | return 0; 80 | } 81 | 82 | @Override 83 | public void writeToParcel(Parcel dest, int flags) { 84 | dest.writeString(path); 85 | dest.writeParcelable(mountEntry, flags); 86 | } 87 | 88 | @Override 89 | public String toString() { 90 | return path + " (" + mountEntry.getFsType() + ")"; 91 | } 92 | } 93 | 94 | interface CommitListener { 95 | boolean onCommit(); 96 | } 97 | 98 | // data methods 99 | DeviceInfo getDeviceInfo(); 100 | 101 | OperatingSystem getOperatingSystem(); 102 | 103 | ArrayList getMultibootDirectories(); 104 | 105 | ArrayList getMultibootPartitionInfo(); 106 | 107 | // callbacks 108 | void onPartitionItemClicked(OperatingSystem.Partition item); 109 | 110 | // listeners 111 | void addOnCommitListener(CommitListener listener); 112 | 113 | void removeOnCommitListener(CommitListener listener); 114 | 115 | // UI 116 | CustomViewPager getViewPager(); 117 | 118 | TabLayout getTabLayout(); 119 | 120 | void setFabVisible(final boolean visible); 121 | } 122 | -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/types/Pointer.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager.types; 2 | 3 | public class Pointer { 4 | public T value; 5 | 6 | public Pointer(T value) { 7 | this.value = value; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/types/ProgressReceiver.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager.types; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.IntentFilter; 7 | import android.os.Bundle; 8 | 9 | import org.efidroid.efidroidmanager.services.GenericProgressIntentService; 10 | 11 | public class ProgressReceiver { 12 | // argument values 13 | private Class mServiceClass = null; 14 | private Bundle mServiceBundle = null; 15 | private Class mServiceHandler = null; 16 | 17 | // broadcast actions 18 | public static final String ACTION_OPUPDATE_PROGRESS = "progressreceiver_action_opupdate_progress"; 19 | public static final String ARG_OPUPDATE_PROGRESS = "progressreceiver_arg_opupdate_progress"; 20 | public static final String ARG_OPUPDATE_TEXT = "progressreceiver_arg_opupdate_text"; 21 | public static final String ACTION_OPUPDATE_FINISH = "progressreceiver_action_opupdate_finish"; 22 | public static final String ARG_OPUPDATE_SUCCESS = "progressreceiver_arg_opupdate_success"; 23 | 24 | // private argument names 25 | private static final String ARG_PROGRESS = "progressreceiver_progress"; 26 | private static final String ARG_PROGRESS_TEXT = "progressreceiver_progress_text"; 27 | private static final String ARG_SUCCESS = "progressreceiver_success"; 28 | private static final String ARG_FINISHED = "progressreceiver_finished"; 29 | private static final String ARG_RUNNING = "progressreceiver_running"; 30 | private static final String ARG_SERVICE_CLASS = "progressreceiver_service_class"; 31 | private static final String ARG_SERVICE_HANDLER = "progressreceiver_service_handler"; 32 | 33 | // status 34 | private int mProgress = 0; 35 | private String mProgressText = ""; 36 | private boolean mSuccess = false; 37 | private boolean mFinished = false; 38 | private boolean mIsRunning = false; 39 | 40 | // context, listener 41 | private Context mContext; 42 | private OnStatusChangeListener mListener; 43 | 44 | public void reset() { 45 | if (mIsRunning) 46 | throw new RuntimeException("service is still running"); 47 | 48 | mProgress = 0; 49 | mProgressText = ""; 50 | mSuccess = false; 51 | mFinished = false; 52 | } 53 | 54 | public interface OnStatusChangeListener { 55 | void onStatusUpdate(int progress, String text); 56 | 57 | void onCompleted(boolean success); 58 | } 59 | 60 | private BroadcastReceiver receiver = new BroadcastReceiver() { 61 | @Override 62 | public void onReceive(Context context, Intent intent) { 63 | switch (intent.getAction()) { 64 | case ACTION_OPUPDATE_PROGRESS: 65 | if (!mFinished) { 66 | mProgress = intent.getIntExtra(ARG_OPUPDATE_PROGRESS, -1); 67 | mProgressText = intent.getStringExtra(ARG_OPUPDATE_TEXT); 68 | 69 | mListener.onStatusUpdate(mProgress, mProgressText); 70 | } 71 | break; 72 | 73 | case ACTION_OPUPDATE_FINISH: 74 | mSuccess = intent.getBooleanExtra(ARG_OPUPDATE_SUCCESS, false); 75 | mFinished = true; 76 | mIsRunning = false; 77 | 78 | mListener.onCompleted(mSuccess); 79 | break; 80 | } 81 | } 82 | }; 83 | 84 | public ProgressReceiver(Context context, OnStatusChangeListener listener, Class serviceClass, Class serviceHandler, Bundle serviceBundle) { 85 | // initialize variables 86 | mFinished = false; 87 | mSuccess = false; 88 | mIsRunning = false; 89 | mContext = context; 90 | mListener = listener; 91 | 92 | // get data 93 | mServiceClass = serviceClass; 94 | mServiceBundle = serviceBundle; 95 | mServiceHandler = serviceHandler; 96 | 97 | if (mServiceClass == null) 98 | mServiceClass = GenericProgressIntentService.class; 99 | if (mServiceBundle == null) 100 | mServiceBundle = new Bundle(); 101 | 102 | // register broadcast receiver 103 | IntentFilter filter = new IntentFilter(); 104 | filter.addAction(ACTION_OPUPDATE_PROGRESS); 105 | filter.addAction(ACTION_OPUPDATE_FINISH); 106 | mContext.registerReceiver(receiver, filter); 107 | } 108 | 109 | public void notifyDestroy() { 110 | mContext.unregisterReceiver(receiver); 111 | } 112 | 113 | public void notifyPause() { 114 | // show notification 115 | if (!mFinished) 116 | GenericProgressIntentService.showNotification(mContext, mServiceClass, true); 117 | } 118 | 119 | public void notifyResume() { 120 | // hide notification 121 | if (!mFinished) 122 | GenericProgressIntentService.showNotification(mContext, mServiceClass, false); 123 | } 124 | 125 | public void setServiceClass(Class serviceClass) { 126 | if (mIsRunning) 127 | throw new RuntimeException("service is still running"); 128 | 129 | mServiceClass = serviceClass; 130 | } 131 | 132 | public void setServiceHandler(Class serviceHandler) { 133 | if (mIsRunning) 134 | throw new RuntimeException("service is still running"); 135 | 136 | mServiceHandler = serviceHandler; 137 | } 138 | 139 | public void setServiceBundle(Bundle bundle) { 140 | if (mIsRunning) 141 | throw new RuntimeException("service is still running"); 142 | 143 | mServiceBundle = bundle; 144 | } 145 | 146 | public void onSaveInstanceState(Bundle outState) { 147 | // store private data 148 | outState.putInt(ARG_PROGRESS, mProgress); 149 | outState.putString(ARG_PROGRESS_TEXT, mProgressText); 150 | outState.putBoolean(ARG_SUCCESS, mSuccess); 151 | outState.putBoolean(ARG_FINISHED, mFinished); 152 | outState.putBoolean(ARG_RUNNING, mIsRunning); 153 | 154 | outState.putSerializable(ARG_SERVICE_CLASS, mServiceClass); 155 | outState.putSerializable(ARG_SERVICE_HANDLER, mServiceHandler); 156 | } 157 | 158 | public void onRestoreInstanceState(Bundle savedInstanceState) { 159 | // restore private data 160 | mProgress = savedInstanceState.getInt(ARG_PROGRESS); 161 | mProgressText = savedInstanceState.getString(ARG_PROGRESS_TEXT); 162 | mSuccess = savedInstanceState.getBoolean(ARG_SUCCESS); 163 | mFinished = savedInstanceState.getBoolean(ARG_FINISHED); 164 | mIsRunning = savedInstanceState.getBoolean(ARG_RUNNING); 165 | 166 | mServiceClass = (Class) savedInstanceState.getSerializable(ARG_SERVICE_CLASS); 167 | mServiceHandler = (Class) savedInstanceState.getSerializable(ARG_SERVICE_HANDLER); 168 | 169 | mListener.onStatusUpdate(mProgress, mProgressText); 170 | if (mFinished) 171 | mListener.onCompleted(mSuccess); 172 | } 173 | 174 | public void startService() { 175 | if (mIsRunning) 176 | throw new RuntimeException("service is still running"); 177 | 178 | // start service 179 | Intent serviceIntent = new Intent(mContext, mServiceClass); 180 | serviceIntent.putExtra(GenericProgressIntentService.ARG_BUNDLE, mServiceBundle); 181 | serviceIntent.putExtra(GenericProgressIntentService.ARG_HANDLER, mServiceHandler); 182 | mIsRunning = true; 183 | mContext.startService(serviceIntent); 184 | } 185 | 186 | public boolean wasSuccessful() { 187 | return mSuccess; 188 | } 189 | 190 | public boolean isFinished() { 191 | return mFinished; 192 | } 193 | 194 | public int getProgress() { 195 | return mProgress; 196 | } 197 | 198 | public String getProgressText() { 199 | return mProgressText; 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/types/ProgressServiceTask.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager.types; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | 6 | import org.efidroid.efidroidmanager.activities.GenericProgressActivity; 7 | import org.efidroid.efidroidmanager.services.GenericProgressIntentService; 8 | 9 | public abstract class ProgressServiceTask { 10 | private GenericProgressIntentService mService; 11 | 12 | public ProgressServiceTask(GenericProgressIntentService service) { 13 | mService = service; 14 | } 15 | 16 | protected GenericProgressIntentService getService() { 17 | return mService; 18 | } 19 | 20 | public int publishProgress(int percent, String text) { 21 | return mService.publishProgress(percent, text); 22 | } 23 | 24 | public void publishFinish(boolean success) { 25 | mService.publishFinish(success); 26 | } 27 | 28 | public boolean shouldStop() { 29 | return mService.shouldStop(); 30 | } 31 | 32 | abstract public void onProcess(Bundle extras); 33 | 34 | abstract public String getNotificationProgressTitle(); 35 | 36 | abstract public String getNotificationResultTitle(); 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/types/ReturnCodeException.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager.types; 2 | 3 | public class ReturnCodeException extends Exception { 4 | public ReturnCodeException(int code) { 5 | super("return code was non zero: " + code); 6 | } 7 | 8 | public static void check(int code) throws ReturnCodeException { 9 | if (code != 0) 10 | throw new ReturnCodeException(code); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/org/efidroid/efidroidmanager/view/CustomViewPager.java: -------------------------------------------------------------------------------- 1 | package org.efidroid.efidroidmanager.view; 2 | 3 | import android.content.Context; 4 | import android.support.v4.view.ViewPager; 5 | import android.util.AttributeSet; 6 | import android.view.MotionEvent; 7 | 8 | public class CustomViewPager extends ViewPager { 9 | 10 | private boolean enabled; 11 | 12 | public CustomViewPager(Context context, AttributeSet attrs) { 13 | super(context, attrs); 14 | this.enabled = true; 15 | } 16 | 17 | @Override 18 | public boolean onTouchEvent(MotionEvent event) { 19 | return this.enabled && super.onTouchEvent(event); 20 | 21 | } 22 | 23 | @Override 24 | public boolean onInterceptTouchEvent(MotionEvent event) { 25 | return this.enabled && super.onInterceptTouchEvent(event); 26 | 27 | } 28 | 29 | public void setPagingEnabled(boolean enabled) { 30 | this.enabled = enabled; 31 | } 32 | } -------------------------------------------------------------------------------- /app/src/main/res/anim/abc_slide_in_bottom_full.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/anim/abc_slide_in_left_full.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/anim/abc_slide_in_right_full.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/anim/abc_slide_out_bottom_full.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/anim/abc_slide_out_left_full.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/anim/abc_slide_out_right_full.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/anim/hold.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_camera.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_gallery.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_manage.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_send.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_share.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_slideshow.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ripple.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/activatable_item_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/efidroid.xml: -------------------------------------------------------------------------------- 1 | 3 | 5 | 7 | 9 | 11 | 13 | 15 | 17 | 19 | 21 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_action_cancel.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_action_delete.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_action_done.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_action_refresh.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_dialog_add.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_archive.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_bug_report.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_color_lens.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_extension.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_hospital.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_info.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_info_outline.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_memory.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_settings.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/md_circle.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/side_nav_bar.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/tablayout_background_transition.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_about.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 19 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_operating_system_edit.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 21 | 22 | 28 | 29 | 30 | 31 | 36 | 37 | 38 | 39 | 44 | 45 | 46 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_osupdate_progress.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 22 | 23 | 29 | 30 | 42 | 43 | 50 | 51 | 52 | 53 | 59 | 60 | 65 | 66 | 70 | 71 |