Skip to content

Commit

Permalink
Fix restoring Backups and installing apk/zip Overlays on non vendor p…
Browse files Browse the repository at this point in the history
…artition devices

Improve detection of compatible files for apk/zip Overlay installing
  • Loading branch information
nschnettler committed Apr 6, 2016
1 parent 24b1bcd commit d61f163
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "com.lovejoy777.rroandlayersmanager"
minSdkVersion 21
targetSdkVersion 23
versionCode 36
versionName "4.4.2"
versionCode 39
versionName "4.4.4"
archivesBaseName = "LayersManager"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public interface Singleton {
String getOverlayFolder();

String getMountFolder();

String getParentOfOverlayFolder();
}

private static class VendorDevice implements Singleton {
Expand All @@ -59,6 +61,9 @@ public String getOverlayFolder() {
public String getMountFolder() {
return "/vendor";
}

@Override
public String getParentOfOverlayFolder(){return "/vendor";}
}


Expand All @@ -73,5 +78,8 @@ public String getOverlayFolder() {
public String getMountFolder() {
return "/system";
}

@Override
public String getParentOfOverlayFolder(){return "/system/vendor";}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ protected Void doInBackground(String... files) {

Utils.remount("rw");
System.out.println("MOVE!");
Utils.moveFile(tempDir , DeviceSingleton.getInstance().getMountFolder() + "/");
Utils.moveFile(tempDir , DeviceSingleton.getInstance().getParentOfOverlayFolder() + "/");
Utils.applyPermissionsRecursive(DeviceSingleton.getInstance().getOverlayFolder(), "644");
Utils.applyPermissions(DeviceSingleton.getInstance().getOverlayFolder(), "755");
Utils.remount("ro");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class BackupRestoreFragment extends Fragment {
private CoordinatorLayout cordLayout = null;

private static void zipFolder(String inputFolderPath, String outZipPath) {
System.out.println("ZZZZZZIIIIIIPP");

try {
FileOutputStream fos = new FileOutputStream(outZipPath);
ZipOutputStream zos = new ZipOutputStream(fos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.support.v7.widget.helper.ItemTouchHelper;
import android.util.Log;
import android.util.TypedValue;
import android.view.*;
import android.widget.RelativeLayout;
Expand All @@ -40,6 +41,7 @@
import com.lovejoy777.rroandlayersmanager.helper.RecyclerItemClickListener;
import com.lovejoy777.rroandlayersmanager.menu;

import java.io.File;
import java.util.*;

public class PluginFragment extends Fragment implements AsyncResponse {
Expand Down Expand Up @@ -195,21 +197,32 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
//IF multiple files selected
if (data.getClipData() != null){
ClipData clipdata = data.getClipData();
for (int i=0; i<clipdata.getItemCount();i++)
{
paths.add(Utils.getPath(getActivity(), clipdata.getItemAt(i).getUri()));
new Commands.InstallZipBetterWay(getActivity(), this).execute(paths.toArray(new String[paths.size()]));
for (int i=0; i<clipdata.getItemCount();i++) {
String path = Utils.getPath(getActivity(), clipdata.getItemAt(i).getUri());
if (path.endsWith(".apk") || (path.endsWith(".zip"))) {
paths.add(path);
}
else {
Toast.makeText(getActivity(),"File "+ path +" is not supported",Toast.LENGTH_SHORT).show();
}
}

if (paths.size() != 0) {
new Commands.InstallZipBetterWay(getActivity(), this).execute(paths.toArray(new String[paths.size()]));
}
} else {


}
else {
Uri uri = data.getData();
String path = Utils.getPath(getActivity(), uri);
System.out.println(Utils.getMimeType(path));
if (Utils.getMimeType(path)=="application/vnd.android.package-archive" || Utils.getMimeType(path)=="application/zip"){
if (path.endsWith(".apk") || (path.endsWith(".zip"))){
paths.add(Utils.getPath(getActivity(), uri));
new Commands.InstallZipBetterWay(getActivity(), this).execute(paths.toArray(new String[paths.size()]));
}else {
Toast.makeText(getActivity(),"File type not supported",Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(),"File type not supported: "+Utils.getMimeType(path),Toast.LENGTH_SHORT).show();

}

}
Expand Down

1 comment on commit d61f163

@smeroni68
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ISSUE: Restore function do not work.
ROM: AOSP 6.0.1 r24
LOGCAT: https://dl.dropboxusercontent.com/u/82930263/Lmanager/logcat_lmanager.txt

DESCRIPTION: Please check in the logcat attached. The restore is creating /system/vendor/overlay folder (verified). But the copying of the apk overlays fail and the folder stay empty. Manually copying the apk overlays in the folder and reboot works perfectly. Hope the log will help detecting finally the solution.

If you like to involve me on testing any fix, let me know here.

Thanks for your time.

EDIT: looking the logcat, move command fail.

Please sign in to comment.