Commit 441e603b authored by topjohnwu's avatar topjohnwu

Update FlashZip to use Uri

parent 7511df61
......@@ -24,7 +24,7 @@
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
<service
android:name=".services.MonitorService"
android:label="@string/accessibility_service_name"
android:label="@string/app_name"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
......
......@@ -4,6 +4,7 @@ import android.app.Fragment;
import android.content.Intent;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
......@@ -138,8 +139,8 @@ public class MagiskFragment extends Fragment {
getActivity(),
new DownloadReceiver(getString(R.string.magisk)) {
@Override
public void task(File file) {
new Async.FlashZIP(mContext, mName, file.getPath()).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
public void task(Uri uri) {
new Async.FlashZIP(mContext, uri).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
}
},
Utils.magiskLink, "latest_magisk.zip"))
......@@ -164,10 +165,10 @@ public class MagiskFragment extends Fragment {
.setPositiveButton(R.string.download_install, (dialogInterface, i) -> Utils.downloadAndReceive(getActivity(),
new DownloadReceiver() {
@Override
public void task(File file) {
public void task(Uri uri) {
Intent install = new Intent(Intent.ACTION_INSTALL_PACKAGE);
install.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
install.setData(FileProvider.getUriForFile(mContext, "com.topjohnwu.magisk.provider", file));
install.setData(uri);
mContext.startActivity(install);
}
},
......
......@@ -6,6 +6,7 @@ import android.animation.ValueAnimator;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.net.Uri;
import android.os.AsyncTask;
import android.preference.PreferenceManager;
import android.support.v7.widget.RecyclerView;
......@@ -147,9 +148,8 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
DownloadReceiver receiver = new DownloadReceiver() {
@Override
public void task(File file) {
Log.d("Magisk", "Task firing");
new Async.FlashZIP(context, repo.getId(), file.toString()).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
public void task(Uri uri) {
new Async.FlashZIP(context, uri, repo.getName() + "-v" + repo.getVersion());
}
};
String filename = repo.getId().replace(" ", "") + ".zip";
......
package com.topjohnwu.magisk.module;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;
import com.topjohnwu.magisk.R;
import com.topjohnwu.magisk.utils.Logger;
import com.topjohnwu.magisk.utils.Utils;
......@@ -13,13 +7,10 @@ public class Module extends BaseModule {
private String mRemoveFile;
private String mDisableFile;
private String mZipUrl, mLogUrl;
private boolean mEnable, mRemove, mUpdateAvailable = false;
public Module(Context context, String path) {
public Module(String path) {
super();
parseProps(Utils.readFile(path + "/module.prop"));
mRemoveFile = path + "/remove";
......@@ -33,13 +24,7 @@ public class Module extends BaseModule {
if (mName == null)
mName = mId;
if (mDescription == null)
mDescription = context.getString(R.string.no_info_provided);
if (mVersion == null)
mVersion = context.getString(R.string.no_info_provided);
Logger.dh("Module id: " + mId);
Logger.dh("Creating Module, id: " + mId);
mEnable = !Utils.itemExist(mDisableFile);
mRemove = Utils.itemExist(mRemoveFile);
......@@ -52,12 +37,11 @@ public class Module extends BaseModule {
repo.setInstalled();
if (repo.getVersionCode() > mVersionCode) {
repo.setUpdate();
mUpdateAvailable = true;
}
}
}
public String getmLogUrl() {return mLogUrl; }
public void createDisableFile() {
mEnable = !Utils.createFile(mDisableFile);
}
......@@ -82,8 +66,6 @@ public class Module extends BaseModule {
return mRemove;
}
public String getmZipUrl() { return mZipUrl; }
public boolean isUpdateAvailable() { return mUpdateAvailable; }
}
\ No newline at end of file
......@@ -38,8 +38,8 @@ public abstract class DownloadReceiver extends BroadcastReceiver {
int status = c.getInt(columnIndex);
switch (status) {
case DownloadManager.STATUS_SUCCESSFUL:
File file = new File(Uri.parse(c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI))).getPath());
task(file);
Uri uri = Uri.parse(c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI)));
task(uri);
break;
default:
Toast.makeText(context, R.string.download_file_error, Toast.LENGTH_LONG).show();
......@@ -54,5 +54,5 @@ public abstract class DownloadReceiver extends BroadcastReceiver {
downloadID = id;
}
public abstract void task(File file);
public void task(Uri uri) {}
}
......@@ -41,18 +41,51 @@
android:layout_alignParentStart="true"
android:layout_below="@id/title"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/no_info_provided"
android:textColor="@android:color/tertiary_text_dark"
android:textIsSelectable="false"
android:textStyle="bold|italic"/>
<TextView
android:id="@+id/author"
android:layout_width="@dimen/card_textview_width"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@id/version_name"
android:text="@string/no_info_provided"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/tertiary_text_dark"
android:textIsSelectable="false"
android:textStyle="bold|italic"/>
<TextView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/author"
android:layout_gravity="center_vertical"
android:text="@string/no_info_provided"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textIsSelectable="false"/>
<TextView
android:id="@+id/warning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/description"
android:layout_gravity="center_vertical"
android:text="@string/remove_file_created"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/red500"
android:visibility="gone"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/expand_layout"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:orientation="horizontal"
android:paddingTop="15dp">
android:paddingTop="20dp">
<CheckBox
......@@ -90,95 +123,6 @@
<!--android:layout_alignBaseline="@id/title"-->
<!--android:layout_alignParentEnd="true"-->
<!--/>-->
<TextView
android:id="@+id/description"
android:layout_width="@dimen/card_textview_width"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@id/version_name"
android:layout_gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textIsSelectable="false"/>
<TextView
android:id="@+id/warning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/description"
android:layout_gravity="center_vertical"
android:text="@string/remove_file_created"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/red500"
android:visibility="gone"/>
<LinearLayout
android:id="@+id/expand_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@id/description"
android:minHeight="70dp"
android:orientation="vertical"
>
<TextView
android:id="@+id/author"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/tertiary_text_dark"
android:textIsSelectable="false"
android:textStyle="bold|italic"/>
<TextView
android:id="@+id/updateStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="20dip"
android:gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textIsSelectable="false"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="40dip"
android:layout_gravity="center"
android:layout_marginBottom="0dip"
android:orientation="horizontal">
<ImageView
android:id="@+id/changeLog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/card_imageview_margin"
android:layout_marginStart="@dimen/card_imageview_margin"
android:background="@drawable/ic_changelog"
android:backgroundTint="@color/icon_grey"/>
<ImageView
android:id="@+id/authorLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/card_imageview_margin"
android:layout_marginStart="@dimen/card_imageview_margin"
android:background="@drawable/ic_author"
android:backgroundTint="@color/icon_grey"/>
<ImageView
android:id="@+id/supportLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/card_imageview_margin"
android:layout_marginStart="@dimen/card_imageview_margin"
android:background="@drawable/ic_support"
android:backgroundTint="@color/icon_grey"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
......
......@@ -54,7 +54,7 @@
<string name="remove_file_deleted">Module will not be removed at next reboot</string>
<string name="disable_file_created">Module will be disabled at next reboot</string>
<string name="disable_file_removed">Module will be enabled at next reboot</string>
<string name="author">Created by </string>
<string name="author">Created by %1$s</string>
<!--Log Fragment-->
<string name="menuSaveToSd">Save to SD</string>
......@@ -83,12 +83,12 @@
<string name="no_root_access">No root access, functionality limited</string>
<string name="no_thanks">No thanks</string>
<string name="accessibility_service_description">Accessibility service required for Magisk auto-unroot feature</string>
<string name="accessibility_service_name">Magisk Manager</string>
<string name="update_title">%1$s Update!</string>
<string name="update_msg">New version v%2$s of %1$s is available!\nChangelog:\n%3$s</string>
<string name="download_install">Download and install</string>
<string name="download_file_error">Error downloading file</string>
<string name="manual_install">File downloaded in %1$s\nFlash it in recovery manually</string>
<string name="install_error">Installation error!</string>
<string name="manual_install">Error in flashing file, zip file placed in %1$s\nFlash it in recovery manually</string>
<string name="reboot_title">Installation succeeded!</string>
<string name="reboot_msg">Do you want to reboot now?</string>
<string name="reboot">Reboot</string>
......@@ -101,6 +101,7 @@
<string name="supersu">SuperSU</string>
<string name="root_system_msg">It seems that you have incompatible root installed\nDo you want to install Magisk compatible root now?</string>
<!--Web Related-->
<string name="pass">MagiskRox666</string>
<string name="some_string">GTYybRBTYf5his9kQ16ZNO7qgkBJ/5MyVe4CGceAOIoXgSnnk8FTd4F1dE9p5Eus</string>
<string name="downloads">Downloads</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment