[Q] Problem shifting Statusbar to bottom - Xposed General

Hi all,
I tried (partially succesful) to shift the status bar to the bottom of the screen. Unfortunatelly a black rectangle at the former statusbar position stays and keeps the apps away to use the full space (see picture below).
Here is my code so far:
Code:
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
if (!lpparam.packageName.equals("com.android.systemui"))
return;
else {
XposedHelpers.findAndHookMethod("com.android.systemui.statusbar.phone.PhoneStatusBar", lpparam.classLoader, "getStatusBarGravity", new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam param) {
return Gravity.BOTTOM | Gravity.FILL_HORIZONTAL;
}
});
XposedHelpers.findAndHookMethod("com.android.systemui.statusbar.phone.PhoneStatusBar", lpparam.classLoader, "getStatusBarHeight", new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam param) {
return 65;
}
});
}
I tried already to override the resource "status_bar_height" with "0", but without success (Not found):
Code:
@Override
public void initZygote(StartupParam startupParam) throws Throwable {
String MODULE_PATH = startupParam.modulePath;
XModuleResources modRes = XModuleResources.createInstance(MODULE_PATH, null);
XResources.setSystemWideReplacement("android", "dimension", "status_bar_height", modRes.fwd(R.dimen.my_height));
}
The XPosed-Modul Dimension Editor also doesn't work by the way.
Maybe I could somehow make some magic in the PhoneWindowManager.java to let the apps fill till the screen top, but I don't know how:
https://github.com/DirtyUnicorns-Ki.../internal/policy/impl/PhoneWindowManager.java
Further information: Dirty Unicorn ROM for Galaxy Note N7000 KitKat.
Thank you very much!

Related

[Q] Use System context

Is there a way to use System context from non system app?
I try to create xposed module that enable double-tap to sleep in my specific app (the app is for G3 smart case only, so I try to mimic LG's stock Quick Circle apps).
I tried to override PowerManager.gotoSleep that will do
[CODEjava] mService.gotoSleep(time, GO_TO_SLEEP_REASON_DEVICE_ADMIN)[/CODE]
but it seem that the GO_TO_SLEEP_REASON_USER isn't the problem.
can I save the context of a system app for later use? using this code, context somewhy is null...
Java:
public class XposedModule implements IXposedHookLoadPackage {
static Context context;
[user=439709]@override[/user]
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
if (lpparam.packageName.equals("com.yoavst.quickapps")) {
findAndHookMethod("com.yoavst.quickapps.DoubleTapper", lpparam.classLoader, "onDoubleTap", Context.class, MotionEvent.class, new XC_MethodHook() {
[user=439709]@override[/user]
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("onDoubleTap After; context: " + (context == null ? "null" : "notNull"));
if (context != null) {
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
powerManager.goToSleep(((MotionEvent) param.args[1]).getEventTime());
}
}
});
} else if (lpparam.packageName.equals("com.android.systemui")) {
findAndHookMethod("com.android.systemui.SystemUIService", lpparam.classLoader, "onCreate", new XC_MethodHook() {
[user=439709]@override[/user]
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
// this will be called before the clock was updated by the original method
}
[user=439709]@override[/user]
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("hooking onCreate: " + (param.thisObject == null ? "null" :"not Null"));
context = (Service) param.thisObject;
XposedBridge.log("context: " + (context == null ? "null" :"not Null"));
}
});
}
}
}
You could call AndroidAppHelper.currentApplication() if you need any context — it doesn't look you need the system's context anyway..
GermainZ said:
You could call AndroidAppHelper.currentApplication() if you need any context — it doesn't look you need the system's context anyway..
Click to expand...
Click to collapse
I need the context of an app with DEVICE_POWER permission (level 2 permission).
Oh, wait — your code won't work at all the way you expect it to work. Keep in mind the hooked code is running in the hooked app's process, so even though you set "context" in com.android.systemui, the "context" variable is still null in the "com.yoavst.quickapps" process (and will *always* be null).
You probably want to send a broadcast from your app instead, and register a BroadcastReceiver somewhere in SystemUI to handle it.
@yoavst you need to use a Device Policy Manager that will allow you to turn off the display. Doesn't even require root or xposed.

[Q] Hook to BroadcastReceiver.

How to hook a onReceive method which is inside BroadcastReceiver?
Code:
public class RecentsActivity extends Activity
{
mIntentReceiver = new BroadcastReceiver()
{
public void onReceive(Context context, Intent intent)
{
...
}
};
}
I want to get my hook called when onReceive is invoked.
Anyone know?
mIntentReceiver is registered within onCreate method, so...
PHP:
XposedHelpers.findAndHookMethod(RecentsActivity.class, "onCreate", Bundle.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
// get the field
final BroadcastReceiver mIntentReceiver = (BroadcastReceiver) XposedHelpers.getObjectField(param.thisObject, "mIntentReceiver");
// hook its class
XposedHelpers.findAndHookMethod(mIntentReceiver.getClass(), "onReceive", Context.class, Intent.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
// check it !!!
BroadcastReceiver thiz = (BroadcastReceiver) param.thisObject;
if (thiz == mIntentReceiver) {
// get parameters
Context context = (Context) param.args[0];
Intent intent = (Intent) param.args[1];
// do your job...
}
}
});
}
});
Hope that helps you!!

[Q] How to hook the step counter sensor?

I have searched relative keyword such as `sensor` in the repo, but could not find the answer.
I want to hook the step counter's sensor to do some auto-testing jobs on a health-kit app. Basically, we could get the steps by listening the SensorManager, the demo code would be
Code:
public class StepsActivity extends Activity implements SensorEventListener {
private SensorManager sensorManager;
private TextView count;
boolean activityRunning;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_steps);
count = (TextView) findViewById(R.id.count);
sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
}
@Override
protected void onResume() {
super.onResume();
activityRunning = true;
Sensor countSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER);
if (countSensor != null) {
sensorManager.registerListener(this, countSensor, SensorManager.SENSOR_DELAY_UI);
} else {
Toast.makeText(this, "Count sensor not available!", Toast.LENGTH_LONG).show();
}
}
@Override
protected void onPause() {
super.onPause();
activityRunning = false;
}
@Override
public void onSensorChanged(SensorEvent event) {
if (activityRunning) {
count.setText(String.valueOf(event.values[0]));
}
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
}
I've read the tutorial, I know we could hook a specific function in a specific class, such as
Code:
findAndHookMethod("com.android.systemui.statusbar.policy.Clock", lpparam.classLoader, "updateClock", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
TextView tv = (TextView) param.thisObject;
String text = tv.getText().toString();
tv.setText("time is:"+text);
tv.setTextColor(Color.RED);
}
});
But I'm wondering how to hook the data on system sensor?
I got the answer from github user townbull right now
I'm still a new user here and I was not permitted to publish external link here.
/XposedExp/blob/master/src/com/samsung/xposedexp/SensorHooks.java
coom said:
I got the answer from github user townbull right now
I'm still a new user here and I was not permitted to publish external link here.
/XposedExp/blob/master/src/com/samsung/xposedexp/SensorHooks.java
Click to expand...
Click to collapse
hi,i found that code is about samsung,what about nexus5 or other phone?

Drawer navigation with navigation toggle

Hi. Can you link to some simple tutorial or other help for Drawer navigation with navigation toggle. I plan to use lot of fragments.
I have implemented Navigation drawer. But when I open fragment and add back arrow when fragment is open instead "navigation hamburger icon", it doesn't go back to starting page but instead open drawer again. Here is the code I mostly got from tutorial,but want to move on:
MainActivity:
Code:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView=(ListView)findViewById(R.id.listView);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
toolbar=(Toolbar) findViewById(R.id.app_bar);
setSupportActionBar(toolbar);
//getSupportActionBar().setDisplayShowHomeEnabled(true);
final NavigationDrawerFragment drawerFragment=(NavigationDrawerFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_navigation_drawer);
drawerFragment.setUp(R.id.fragment_navigation_drawer,(DrawerLayout)findViewById(R.id.drawer_layout),toolbar);
adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,sports);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
selectItem(position);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mDrawerLayout.closeDrawers();
}
});
}
protected void setFragment(Fragment fragment) {
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction =
fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.drawer_layout, fragment);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
}
private void selectItem(int position)
{
switch (position) {
case 0:
setFragment(new SoccerFragment());
break;
}
}
and for navigation fragment:
Code:
public NavigationDrawerFragment() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mUserLearnedDrawer=Boolean.valueOf(readFromPreferences(getActivity(), KEY_USER_LEARNED_DRAWER, "false"));
if (savedInstanceState!=null)
{
mFromSavedInstanceState=true;
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_navigation_drawer, container, false);
}
public void setUp(int fragmentId,DrawerLayout drawerLayout,Toolbar toolbar) {
//containerView=getActivity().findViewById(fragmentId);
mDrawerLayout=drawerLayout;
mDrawerToggle=new ActionBarDrawerToggle(getActivity(),drawerLayout,toolbar,R.string.drawer_open,R.string.drawer_close)
{
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
if (!mUserLearnedDrawer)
{
mUserLearnedDrawer=true;
saveToPreferences(getActivity(), KEY_USER_LEARNED_DRAWER,mUserLearnedDrawer+"");
}
getActivity().invalidateOptionsMenu();
}
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
getActivity().invalidateOptionsMenu();
}
};
//if (mUserLearnedDrawer && mFromSavedInstanceState)
//{
// mDrawerLayout.openDrawer(containerView);
//}
mDrawerLayout.setDrawerListener(mDrawerToggle);
mDrawerLayout.post(new Runnable() {
@Override
public void run() {
mDrawerToggle.syncState();
}
});
}
public static void saveToPreferences(Context context,String preferenceName,String preferenceValue)
{
SharedPreferences sharedPreferences=context.getSharedPreferences(PREF_FILE_NAME,Context.MODE_PRIVATE);
SharedPreferences.Editor editor=sharedPreferences.edit();
editor.putString(preferenceName, preferenceValue);
editor.apply(); //or commit()
}
public static String readFromPreferences(Context context,String preferenceName,String defaultValue)
{
SharedPreferences sharedPreferences=context.getSharedPreferences(PREF_FILE_NAME, Context.MODE_PRIVATE);
return sharedPreferences.getString(preferenceName,defaultValue);
}
}

Cannot hook DexFile Class

Hi,
I am trying to analyze an application(obfuscated with dexguard) which uses DexFile to load classes during runtime.
To list out what all classes the application call, I use the following Xposed code - (that's because the code is obfuscated and we cannot search for DexFile on the decompiled code).
Code:
findAndHookMethod("java.lang.ClassLoader", lpparam.classLoader, "loadClass", String.class, new XC_MethodHook() {
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
String classname = (String) param.args[0];
XposedBridge.log("Class Called - " + classname + " " + i++);
}
This lists all the classes and I see that the application calls "dalvik.system.DexFile". I used the following code to hook into DexFile constructor -
Code:
Constructor<?> constructDexFile = findConstructorExact(dalvik.system.DexFile.class, String.class);
XposedBridge.hookMethod(constructDexFile, new XC_MethodHook(XCallback.PRIORITY_HIGHEST) {
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("DexFile Class 1 called");
}
});
Constructor<?> constructDexFile1 = findConstructorExact(dalvik.system.DexFile.class, File.class);
XposedBridge.hookMethod(constructDexFile1, new XC_MethodHook(XCallback.PRIORITY_HIGHEST) {
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("DexFile Class 2 called");
}
});
Analyzing the log output, I see no trace of DexFile constructor being called.
Can someone help me out on how to analyze such application?

Categories

Resources