how to change/replace class constants - Xposed General

i have a class like this
PHP:
package com.insight.sdk;
public class ISBuildConfig {
public static int ASSETS_JAR_VERSION_CODE = 100043;
public static String ASSETS_JAR_VERSION_NAME = "v100.1.2.0_release";
public static boolean DEBUG = false;
public static int LOADER_VERSION_CODE = 100043;
public static String LOADER_VERSION_NAME = "v2.1.3_release";
public static final int NOUGAT = 24;
}
i want to change DEBUG to true
how to use xposed to change this value?

hotwap said:
...
how to use xposed to change this value?
Click to expand...
Click to collapse
Try kooking it as early as possible (Application's onCreate() is a good place to do that):
PHP:
XposedHelpers.findAndHookMethod(>>> APPLICATION.class <<<, "onCreate", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedHelpers.setStaticBooleanField(ISBuildConfig.class, "DEBUG", true);
}
}

Related

[Q] Retrieve HTTP POST/GET & Response

I am trying to log HTTP requests and answers from single apps.
Code:
import java.net.URL;
import android.util.Log;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
public class Module implements IXposedHookLoadPackage {
@Override
public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
if (lpparam.packageName.equals(Common.CLASSNAME)) {
final Class<?> httpUrlConnection = XposedHelpers.findClass(
"java.net.HttpURLConnection", lpparam.classLoader);
XposedBridge.hookAllConstructors(httpUrlConnection, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
URL url = (URL)param.args[0];
Log.d("httpLogger", "call:"+url.toString());
}
});
}
}
}
So far i can retrieve the URLs but i do not know how to advance any further from here. Can you tell a smart way to approache the problem.
now that its been a while and i did not get any closer.. *bump*
Well, just follow API.
HttpResponse response = httpclient.execute(httppost);
Click to expand...
Click to collapse
So hook "execute" method from HttpClient class.
I have two problems with that.
The first one is:
HttpClient seems to be deprecated (http://developer.android.com/reference/org/apache/http/client/HttpClient.html). I am guessing a decent application would already use java.net.URL.openConnection().
But if we keep that point asside and assume the request we are trying to hook would be done with HttpClient execute i tryed to just see any of them done:
Code:
public class Module implements IXposedHookLoadPackage {
protected static final String HTTP_TAG = "myHttpLogger";
@Override
public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
final Class<?> httpUrlConnection = findClass("org.apache.http.client.HttpClient", lpparam.classLoader);
findAndHookMethod(httpUrlConnection, "execute", HttpResponse.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
Log.d(HTTP_TAG, "execute");
}
});
}
}
This trows an exception
Code:
java.lang.NoSuchMethodError: org.apache.http.client.HttpClient#execute(org.apache.http.HttpResponse)#exact
Can you tell me where i went wrong or show me a different approach?
You used HttpResponse.class as method's params. But it is not right.
HttpUriRequest.class is right parameter.
To covel all "execute" methods (I see many here http://developer.android.com/reference/org/apache/http/client/HttpClient.html), use XposedBridge.hookAllmethods API

[Q] [Answered by Self]How to get NinePatchDrawable from file without stretching it?

Hello,
I am trying to get a *.9.png from sd card in my xposed module.
The Image loads and is set where I need it to be but it gets stretched.
I tried this:
Code:
resparam.res.setReplacement("com.whatsapp", "drawable", "input", new XResources.DrawableLoader() {
@Override
public Drawable newDrawable(XResources mRes, int id) throws Throwable {
XSharedPreferences prefs = new XSharedPreferences("in.proficientapps.uwte.trial", "saveImage");
String imagePath = prefs.getString("mImage", null);
Bitmap bitmap = BitmapFactory.decodeFile(imagePath);
byte[] chunk = bitmap.getNinePatchChunk();
//boolean result = NinePatch.isNinePatchChunk(chunk);
if (chunk == null) {
XposedBridge.log("Chunk is empty");
return Drawable.createFromPath(imagePath);
} else
return new NinePatchDrawable(bitmap, chunk, new Rect(), null);
}
});
and this:
Code:
resparam.res.setReplacement("com.whatsapp", "drawable", "input", new XResources.DrawableLoader() {
@Override
public Drawable newDrawable(XResources mRes, int id) throws Throwable {
XSharedPreferences prefs = new XSharedPreferences("in.proficientapps.uwte.trial", "saveImage");
String imagePath = prefs.getString("mImage", null);
return new NinePatchDrawable.createFromPath(imagePath);
}
});
Both results in same thing.
I have added a screenshot of how it looks on using the above codes.
Fixed the issue by compiling the *.9.png image by following the guide here : http://modmymobile.com/forums/404-motorola-cliq-themes/555408-guide-editing-compiling-draw9-9-png-images.html
I hope this will help other users too in future.

afterHookedMethod Variable assignment method

Code:
public class SuperHook implements IXposedHookLoadPackage, IXposedHookZygoteInit {
Config mConfig;
Gson mGson;
@Override
public void initZygote(StartupParam startupParam) throws Throwable {
mConfig = new Config();
mGson = new Gson();
}
@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable {
Log.d("SuperHook", "handleLoadPackage imei:" + mConfig.getmImei());
if (loadPackageParam.packageName.equals("cn.superscript.supertools")) {
Class<?> classSuperService = XposedHelpers.findClass(SuperService.class.getName(), loadPackageParam.classLoader);
XposedHelpers.findAndHookMethod(classSuperService, "onStartCommand", Intent.class, int.class, int.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
super.afterHookedMethod(param);
Intent intent = (Intent) param.args[0];
String json = intent.getStringExtra("json");
mConfig = mGson.fromJson(json, new TypeToken<Config>() {
}.getType());
Log.d("SuperHook", "onStartCommand: imei = " + mConfig.getmImei());
}
});
}
}
}
Log:
01-21 18:49:56.220 664-664/? D/SuperHook: handleLoadPackage imei:null
01-21 18:49:56.240 664-664/? D/SuperHook: onStartCommand: imei = 3333333
01-21 18:50:00.930 757-757/com.android.settings D/SuperHook: handleLoadPackage imei:null
why handleLoadPackage imei = null , onStartCommand: imei = 3333333 successful.
Please help me, thank you

Need help deleting childview from groupview in expandablelistview w/custom adapter

Hey guys, I am having problem with deleting the childview from my expandablelistview. It deletes (I think), however, when I add a new childview, it is the exact same as the one I just deleted.
youtu.be/eJjR9FEpaaY
codes below
My activity
Code:
public class PlanSetterAct extends AppCompatActivity {
private Button nextBtn;
private EditText planName, weekNum;
private ExpandableListView weekdayList;
List<String> listDataHeader;
HashMap<String, List<String>> listDataChild;
private PlanSetterListAdapter adapter;
private int childCount = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.plan_setter);
weekdayList = (ExpandableListView) findViewById(R.id.plan_setter_exercise_list);
nextBtn = (Button) findViewById(R.id.plan_next_btn);
planName = (EditText) findViewById(R.id.plan_name_edit);
weekNum = (EditText) findViewById(R.id.plan_num_edit);
prepareNextButton();
prepareExerciseList();
adapter = new PlanSetterListAdapter(this.getApplicationContext(),listDataHeader,listDataChild);
weekdayList.setAdapter(adapter);
exerciseListChildListener();
}
private void prepareNextButton(){
nextBtn.animate().setDuration(1000);
nextBtn.animate().translationXBy(-500);
nextBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(Checker.hasText(planName) && Checker.isNum(weekNum)){
Utilities.setButtonClickColor(nextBtn, Color.GREEN);
startActivity(new Intent(PlanSetterAct.this, UserMainAct.class));
finish();
Utilities.debugLog("Moving to UserMainAct");
}else{
Utilities.setButtonClickColor(nextBtn, Color.RED);
}
}
});
}
private void prepareExerciseList() {
listDataHeader = new ArrayList<String>();
listDataChild = new HashMap<String, List<String>>();
// Adding child data
listDataHeader.add("Monday");
listDataHeader.add("Tuesday");
listDataHeader.add("Wednesday");
listDataHeader.add("Thursday");
listDataHeader.add("Friday");
listDataHeader.add("Saturday");
listDataHeader.add("Sunday");
for(int i = 0; i < listDataHeader.size(); i++) {
listDataChild.put(listDataHeader.get(i), new ArrayList<String>());
}
}
private void exerciseListChildListener(){
weekdayList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
ExpandableListView expandableListView = (ExpandableListView) parent;
long pos = expandableListView.getExpandableListPosition(position);
int itemType = ExpandableListView.getPackedPositionType(pos);
int groupPosition = ExpandableListView.getPackedPositionGroup(pos);
int childPosition = ExpandableListView.getPackedPositionChild(pos);
List<String> parentGroup = listDataChild.get(listDataHeader.get(groupPosition));
if(itemType == ExpandableListView.PACKED_POSITION_TYPE_GROUP){
parentGroup.add(childPosition+"");
adapter.notifyDataSetChanged();
return true;
}else if(itemType == ExpandableListView.PACKED_POSITION_TYPE_CHILD){
debugLog("Parent position: " + groupPosition +" | child position: " + childPosition);
parentGroup.remove(childPosition);
adapter.notifyDataSetChanged();
return true;
}
return false;
}
});
}
}
My Adapter
Code:
public class PlanSetterListAdapter extends BaseExpandableListAdapter {
private Context context;
private List<String> listDataHeader;
private HashMap<String, List<String>> listDataChild;
public PlanSetterListAdapter(Context context, List<String> listDataHeader,
HashMap<String, List<String>> listChildData) {
this.context = context;
this.listDataHeader = listDataHeader;
this.listDataChild = listChildData;
}
@Override
public Object getChild(int groupPosition, int childPosititon) {
return this.listDataChild.get(this.listDataHeader.get(groupPosition))
.get(childPosititon);
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public View getChildView(int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
final LayoutInflater inflater;
if (convertView == null) {
inflater= (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.add_exercise_layout, null);
}
final LinearLayout txtListChild = (LinearLayout) convertView.findViewById(R.id.plan_setter_add_exercise);
final LinearLayout addExerciseLayout = (LinearLayout) txtListChild.getChildAt(0);
Button okBtn = (Button) addExerciseLayout.getChildAt(1);
//init and gone from xml
okBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
TextView errorView = (TextView) txtListChild.getChildAt(1);
TextView finalView = (TextView) txtListChild.getChildAt(2);
LinearLayout exerciseAddLayout = (LinearLayout) addExerciseLayout.getChildAt(0);
EditText exerciseNameEdit = ((EditText)exerciseAddLayout.getChildAt(0));
EditText exerciseLbsEdit = (EditText)exerciseAddLayout.getChildAt(2);
EditText exerciseRepsEdit = (EditText) exerciseAddLayout.getChildAt(4);
if(hasText(exerciseNameEdit) && isNum(exerciseLbsEdit) && isNum(exerciseRepsEdit)){
String exerciseNameStr = exerciseNameEdit.getText().toString();
String exerciseWeightStr = exerciseLbsEdit.getText().toString()+"lbs";
String exerciseRepsStr = exerciseLbsEdit.getText().toString()+"x";
finalView.setText(exerciseNameStr + " at " + exerciseWeightStr + " for " +exerciseRepsStr);
finalView.setTextSize(20);
//display
setVisibleAndAnimate(context,finalView);
addExerciseLayout.setVisibility(View.GONE);
errorView.setVisibility(View.GONE);
}else{
setVisibleAndAnimate(context,errorView);
}
}
});
return convertView;
}
@Override
public int getChildrenCount(int groupPosition) {
return this.listDataChild.get(this.listDataHeader.get(groupPosition))
.size();
}
@Override
public Object getGroup(int groupPosition) {
return this.listDataHeader.get(groupPosition);
}
@Override
public int getGroupCount() {
return this.listDataHeader.size();
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
String headerTitle = (String) getGroup(groupPosition);
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this.context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.expandable_list_parent, null);
}
TextView lblListHeader = (TextView) convertView
.findViewById(R.id.lblListHeader);
lblListHeader.setTypeface(null, Typeface.BOLD);
lblListHeader.setText(headerTitle);
return convertView;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
}

[REQUEST] BLOCK/DISABLE Pull-down Quick Toggle on Secure Lockscreen

Maybe any devs can adapt this for Magisk module?
https://github.com/char101/xposed-q...main/java/com/github/char101/qslock/Main.java
Code:
package com.github.char101.qslock;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;
import android.util.Log;
public class Main implements IXposedHookLoadPackage {
private static final String TAG = "qslock";
private static final int DISABLE_EXPAND = 0x00010000;
private static final int DISABLE_NOTIFICATION_ICONS = 0x00020000;
private static final int DISABLE_NOTIFICATION_ALERTS = 0x00040000;
private static final int DISABLE_NOTIFICATION_TICKER = 0x00080000;
private static final int DISABLE_SYSTEM_INFO = 0x00100000;
private static final int DISABLE_HOME = 0x00200000;
private static final int DISABLE_RECENT = 0x01000000;
private static final int DISABLE_BACK = 0x00400000;
private static final int DISABLE_CLOCK = 0x00800000;
private static final int DISABLE_SEARCH = 0x02000000;
private static final int DISABLE_NONE = 0x00000000;
private static final int DISABLE2_QUICK_SETTINGS = 1;
private static final int DISABLE2_SYSTEM_ICONS = 1 << 1;
private static final int DISABLE2_NOTIFICATION_SHADE = 1 << 2;
private static final int DISABLE2_GLOBAL_ACTIONS = 1 << 3;
private static final int DISABLE2_ROTATE_SUGGESTIONS = 1 << 4;
private static final int DISABLE2_NONE = 0x00000000;
public int getProp(Class<?> SystemProperties, String name, int defaultValue) {
String val = (String) XposedHelpers.callStaticMethod(SystemProperties, "get", new Class<?>[]{String.class}, name);
try {
return val.equals("") ? defaultValue : Integer.parseInt(val);
} catch (NumberFormatException ex) {
Log.e(TAG, "invalid value for " + name + ": " + val);
return defaultValue;
}
}
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
if (!lpparam.packageName.equals("com.android.systemui")) {
return;
}
XposedBridge.log(TAG + ": started");
final Class<?> SystemProperties = XposedHelpers.findClass("android.os.SystemProperties", null);
XposedHelpers.findAndHookMethod("com.android.systemui.keyguard.KeyguardViewMediator", lpparam.classLoader, "adjustStatusBarLocked", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Object mStatusBarManager = XposedHelpers.getObjectField(param.thisObject, "mStatusBarManager");
if (mStatusBarManager != null) {
boolean mShowing = (boolean) XposedHelpers.getBooleanField(param.thisObject, "mShowing");
final int mode2 = getProp(SystemProperties,"persist.qslock.mode2", DISABLE2_QUICK_SETTINGS);
if (mShowing) {
final int mode = getProp(SystemProperties,"persist.qslock.mode", 0);
if (mode > 0) {
Log.i(TAG, "disable: " + mode);
XposedHelpers.callMethod(mStatusBarManager, "disable", new Class<?>[]{int.class}, mode);
}
if (mode2 > 0) {
Log.i(TAG, "disable2: " + mode2);
XposedHelpers.callMethod(mStatusBarManager, "disable2", new Class<?>[]{int.class}, mode2);
}
} else {
if (mode2 > 0) {
XposedHelpers.callMethod(mStatusBarManager, "disable2", new Class<?>[]{int.class}, DISABLE2_NONE);
}
}
} else {
Log.e(TAG, "mStatusBarManager is null");
}
}
});
}
}
Crescendo Xenomorph said:
Maybe any devs can adapt this for Magisk module?
https://github.com/char101/xposed-q...main/java/com/github/char101/qslock/Main.java
Click to expand...
Click to collapse
Not possible,Xposed alters code while magisk alters files,you can't convert an Xposed module into a magisk module
Sent from my Moto G 2015 using XDA Labs
DanGLES3 said:
Not possible,Xposed alters code while magisk alters files,you can't convert an Xposed module into a magisk module
Sent from my Moto G 2015 using XDA Labs
Click to expand...
Click to collapse
or maybe a cue of what code in what smali that it replaces?
Sent from my MI 5s Plus using Tapatalk

Categories

Resources