Skip to content

Commit

Permalink
优化debuggable控制开关
Browse files Browse the repository at this point in the history
  • Loading branch information
king committed Apr 11, 2022
1 parent 7569ac5 commit 7c71f01
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ ROM从PixelExperience调整为aosp10,后续如果有更新,不再维护Pixel
> * 注入so
> * 注入dex(实现对应的接口触发调用。目前未完成)
### 更新说明
> * 优化可以控制是否打开debuggable,该功能对应lineageOS版本MikRom,这个选项修改后,需要重新安装app生效。
### 附录

该项目仅为个人练手作品,非商业项目。开源仅供学习,请勿用于非法用途。
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/mik/mikmanager/Common/PackageItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class PackageItem implements Parcelable {
//是否设置生效
public boolean enabled;
public boolean isBlock;
public boolean isDebug;
public PackageItem(){
packageName="";
appName="";
Expand All @@ -77,6 +78,7 @@ public PackageItem(){
rediectDir="";
forbids="";
isBlock=false;
isDebug=false;
}
protected PackageItem(Parcel in) {
packageName = in.readString();
Expand Down Expand Up @@ -104,6 +106,7 @@ protected PackageItem(Parcel in) {
forbids=in.readString();
enabled=in.readBoolean();
isBlock=in.readBoolean();
isDebug=in.readBoolean();
}

@Override
Expand Down Expand Up @@ -133,6 +136,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeString(forbids);
dest.writeByte((byte) (enabled ? 1 : 0));
dest.writeByte((byte) (isBlock ? 1 : 0));
dest.writeByte((byte) (isDebug ? 1 : 0));
}

@Override
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/mik/mikmanager/EditPackageActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ public void onClick(View v) {
}
item.packageName=workAppFragment.txtPackageName.getText().toString();
item.appName=workAppFragment.txtAppName.getText().toString();
item.isDebug=workAppFragment.swDebug.isChecked();
if(initDump){
item.breakClass=dumpFragment.txtBreakClass.getText().toString();
item.isTuoke=dumpFragment.swTuoke.isChecked();
Expand Down Expand Up @@ -381,6 +382,7 @@ public void onClick(View view) {
if(packageData!=null){
workAppFragment.txtPackageName.setText(packageData.packageName);
workAppFragment.txtAppName.setText(packageData.appName);
workAppFragment.swDebug.setChecked(packageData.isDebug);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Switch;
import android.widget.Toast;

import androidx.fragment.app.Fragment;
Expand All @@ -33,6 +34,8 @@ public class WorkAppFragment extends Fragment {

public Button btnRemove;

public Switch swDebug;

private FragmentListen listener;

public WorkAppFragment() {
Expand Down Expand Up @@ -72,6 +75,7 @@ public void onStart() {
txtPackageName = (EditText)getActivity().findViewById(R.id.txtPackageName);
txtAppName = (EditText)getActivity().findViewById(R.id.txtAppName);
btnSave = (Button)getActivity().findViewById(R.id.btnSave);
swDebug = (Switch)getActivity().findViewById(R.id.swDebug);
btnRemove = (Button)getActivity().findViewById(R.id.btnRemove);
btnSelectPackage = (Button)getActivity().findViewById(R.id.btnSelectPackage);
listener.onWorkAppAttach();
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/layout/fragment_work_app.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
android:hint="应用包名"
android:minHeight="45dp"
android:textSize="18sp" />
<Switch
android:id="@+id/swDebug"
style="@style/FormMargin"
android:text="开启Debuggable"/>
<Button
android:id="@+id/btnSave"
android:layout_width="fill_parent"
Expand Down

0 comments on commit 7c71f01

Please sign in to comment.