Skip to content

Commit

Permalink
manager: change dex file naming rules
Browse files Browse the repository at this point in the history
  • Loading branch information
RikkaW committed Nov 7, 2017
1 parent a6816d9 commit 74c0ae9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ task upload(type: GradleBuild) {

def gitCommitId = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
def gitCommitCount = Integer.parseInt('git rev-list --count HEAD'.execute([], project.rootDir).text.trim())
def baseVersionName = '2.0.0'
def baseVersionName = '2.1.0-beta'

ext {
supportLibraryVersion = '26.1.0'
Expand Down
7 changes: 4 additions & 3 deletions manager/src/main/java/moe/shizuku/manager/ServerLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@ public static void init(Context context) {

private static void copyDex(Context context) {
int apiVersion = Math.min(ShizukuConstants.MAX_SDK, Build.VERSION.SDK_INT);
String dex = String.format(Locale.ENGLISH, "server-%d.dex", apiVersion);
File file = new File(context.getExternalFilesDir(null), dex);
String source = String.format(Locale.ENGLISH, "server-%d.dex", apiVersion);
String target = String.format(Locale.ENGLISH, "server-%d-v%d.dex", apiVersion, ShizukuConstants.SERVER_VERSION);
File file = new File(context.getExternalFilesDir(null), target);

DEX_PATH = file.getAbsolutePath();
COMMAND_ROOT_OLD = "app_process -Djava.class.path=" + DEX_PATH + " /system/bin --nice-name=shizuku_server moe.shizuku.server.ShizukuServer &";

try {
InputStream is = context.getAssets().open(dex);
InputStream is = context.getAssets().open(source);
OutputStream os = new FileOutputStream(file);

IOUtils.copy(is, os);
Expand Down
20 changes: 15 additions & 5 deletions manager/src/main/java/moe/shizuku/manager/adapter/MainAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import moe.shizuku.manager.viewholder.StartAdbViewHolder;
import moe.shizuku.manager.viewholder.StartRootViewHolder;
import moe.shizuku.support.recyclerview.BaseRecyclerViewAdapter;
import moe.shizuku.support.recyclerview.BaseViewHolder;
import moe.shizuku.support.recyclerview.CreatorPool;

/**
Expand All @@ -22,15 +23,25 @@

public class MainAdapter extends BaseRecyclerViewAdapter {

private static final Object ITEM_ADB = new Object();

private static class MainCreatorPool extends CreatorPool {

@Override
public int getCreatorIndex(BaseRecyclerViewAdapter adapter, int position) {
if (adapter.getItemAt(position) == null) {
if (adapter.getItemAt(position) == ITEM_ADB) {
return 3;
}
return super.getCreatorIndex(adapter, position);
}

@Override
public BaseViewHolder.Creator getCreator(int index) {
if (index == 3) {
return StartAdbViewHolder.CREATOR;
}
return super.getCreator(index);
}
}

public MainAdapter(Context context) {
Expand All @@ -39,8 +50,7 @@ public MainAdapter(Context context) {
getCreatorPool()
.putRule(ShizukuState.class, ServerStatusViewHolder.CREATOR)
.putRule(Integer.class, ManageAppsViewHolder.CREATOR)
.putRule(Boolean.class, StartRootViewHolder.CREATOR)
.putRule(Object.class, StartAdbViewHolder.CREATOR);
.putRule(Boolean.class, StartRootViewHolder.CREATOR);

updateData(context, ShizukuState.createUnknown());

Expand All @@ -66,11 +76,11 @@ public void updateData(Context context, ShizukuState state) {
boolean rootRestart = state.isRoot();

if (adb) {
getItems().add(null);
getItems().add(ITEM_ADB);
getItems().add(rootRestart);
} else {
getItems().add(rootRestart);
getItems().add(null);
getItems().add(ITEM_ADB);
}
}

Expand Down

0 comments on commit 74c0ae9

Please sign in to comment.