Hi, I'm developing a module that change an image in an app, plus change a color.
The module is working fine on CM12, but on my Xperia LP Stock ROM, it's not, even though I'm hooking the same app with no changes, here the log :
variables :
XResources res = Xposed.INIT_PACKAGE_RESOURCES_PARAM.res;
Xposed :
public static InitPackageResourcesParam INIT_PACKAGE_RESOURCES_PARAM;
Image replacement
Code
HTML:
if (resId2 != 0) {
Log.d("InTheHook", "Blue Selected");
res.setReplacement(resId, new XResources.DrawableLoader() {
[user=439709]@override[/user]
public Drawable newDrawable(XResources res, int id) throws Throwable {
return Xposed.X_MODULE_RESOURCES.getDrawable(R.drawable.blue);
}
});
}
Log
HTML:
01-06 06:41:40.308 1395-2252/? D/InTheHook: Blue Selected
01-06 06:41:40.313 1395-2252/? E/Xposed: at de.robv.android.xposed.IXposedHookInitPackageResources$Wrapper.handleInitPackageResources(IXposedHookInitPackageResources.java:20)
01-06 06:41:40.313 1395-2252/? E/Xposed: at de.robv.android.xposed.XposedBridge$7.afterHookedMethod(XposedBridge.java:351)
01-06 06:41:40.313 1395-2252/? E/Xposed: at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:689)
Color replacement
HTML:
int material_accent = res.getIdentifier("material_accent", "color", Xposed.Music_PACKAGE_NAME);
if (material_accent != 0) {
Log.d("MusicHook", "material_accent");
res.setReplacement(material_accent, Color.BLACK);
}
Log :
HTML:
01-06 06:41:40.308 1395-2252/? D/MusicHook: material_accent
01-06 06:41:40.313 1395-2252/? E/Module: at com.abohani.moduletest.hooks.music(java:20)
that line is the "setReplacement" line, it's not replacing .
A New log :
01-10 01:20:19.219 17798-17798/? E/Xposed: at com.abohani.moduletest.hooks.hook(NotificationHeaderBg.java:77)
01-10 01:20:19.219 17798-17798/? E/Xposed: at com.abohani.moduletest.Xposed.handleInitPackageResources(Xposed.java:75)
01-10 01:20:19.219 17798-17798/? W/System.err: at com.abohani.moduletest.hooks.hook(NotificationHeaderBg.java:77)
01-10 01:20:19.219 17798-17798/? W/System.err: at com.abohani.moduletest.Xposed.handleInitPackageResources(Xposed.java:75)
01-10 01:20:19.852 17798-17798/? W/PackageManager: Failure retrieving resources for com.abohani.moduletest: Resource ID #0x0
I have used multi sizes for the picture, as some of the devs said it's a problem from the size/resolution, didn't work also .
Related
Hi,
i'm constantly getting this error in my logcat. I've no idea what i can do to fix it. I'm using v.0.35 of Elk759's http://forum.xda-developers.com/showthread.php?t=1827934 CM10 Rom for htc desire. This error occurs since version 0.33.
Can you tell me to which app this notification service belongs? pid 456 belongs to "system_server", pid 539 belongs to "com.android.systemui" so i just can't delete the corresponding data.
Code:
D/SizeAdaptiveLayout( 539): [email protected] view [email protected] measured out of bounds at 95px clamped to 96px
E/NotificationService( 456): An error occurred profiling the notification.
E/NotificationService( 456): java.lang.NullPointerException
E/NotificationService( 456): at com.android.server.NotificationManagerService.enqueueNotificationInternal(NotificationManagerService.java:1147)
E/NotificationService( 456): at com.android.server.NotificationManagerService.enqueueNotificationWithTag(NotificationManagerService.java:983)
E/NotificationService( 456): at android.app.INotificationManager$Stub.onTransact(INotificationManager.java:129)
E/NotificationService( 456): at android.os.Binder.execTransact(Binder.java:367)
E/NotificationService( 456): at dalvik.system.NativeStart.run(Native Method)
D/SizeAdaptiveLayout( 539): [email protected] view [email protected] measured out of bounds at 95px clamped to 96px
E/NotificationService( 456): An error occurred profiling the notification.
E/NotificationService( 456): java.lang.NullPointerException
E/NotificationService( 456): at com.android.server.NotificationManagerService.enqueueNotificationInternal(NotificationManagerService.java:1147)
E/NotificationService( 456): at com.android.server.NotificationManagerService.enqueueNotificationWithTag(NotificationManagerService.java:983)
E/NotificationService( 456): at android.app.INotificationManager$Stub.onTransact(INotificationManager.java:129)
E/NotificationService( 456): at android.os.Binder.execTransact(Binder.java:367)
E/NotificationService( 456): at dalvik.system.NativeStart.run(Native Method)
D/SizeAdaptiveLayout( 539): [email protected] view [email protected] measured out of bounds at 95px clamped to 96px
I found the matching code in http://code.metager.de/source/xref/CyanogenMod/AndroidFrameworksBase/services/java/com/android/server/NotificationManagerService.java. It says:
Code:
synchronized (mNotificationList) {
final boolean inQuietHours = inQuietHours();
NotificationRecord r = new NotificationRecord(pkg, tag, id,
callingUid, callingPid,
priority,
notification);
NotificationRecord old = null;
int index = indexOfNotificationLocked(pkg, tag, id);
if (index < 0) {
mNotificationList.add(r);
} else {
old = mNotificationList.remove(index);
mNotificationList.add(index, r);
// Make sure we don't lose the foreground service state.
if (old != null) {
notification.flags |=
old.notification.flags&Notification.FLAG_FOREGROUND_SERVICE;
}
}
// Ensure if this is a foreground service that the proper additional
// flags are set.
if ((notification.flags&Notification.FLAG_FOREGROUND_SERVICE) != 0) {
notification.flags |= Notification.FLAG_ONGOING_EVENT
| Notification.FLAG_NO_CLEAR;
}
if (notification.icon != 0) {
StatusBarNotification n = new StatusBarNotification(pkg, id, tag,
r.uid, r.initialPid, notification);
n.priority = r.priority;
if (old != null && old.statusBarKey != null) {
r.statusBarKey = old.statusBarKey;
long identity = Binder.clearCallingIdentity();
try {
mStatusBar.updateNotification(r.statusBarKey, n);
}
finally {
Binder.restoreCallingIdentity(identity);
}
} else {
long identity = Binder.clearCallingIdentity();
try {
r.statusBarKey = mStatusBar.addNotification(n);
if ((n.notification.flags & Notification.FLAG_SHOW_LIGHTS) != 0) {
mAttentionLight.pulse();
}
}
finally {
Binder.restoreCallingIdentity(identity);
}
}
sendAccessibilityEvent(notification, pkg);
} else {
Slog.e(TAG, "Ignoring notification with icon==0: " + notification);
if (old != null && old.statusBarKey != null) {
long identity = Binder.clearCallingIdentity();
try {
mStatusBar.removeNotification(old.statusBarKey);
}
finally {
Binder.restoreCallingIdentity(identity);
}
}
}
try {
final ProfileManager profileManager =
(ProfileManager) mContext.getSystemService(Context.PROFILE_SERVICE);
ProfileGroup group = profileManager.getActiveProfileGroup(pkg);
notification = group.processNotification(notification);
} catch(Throwable th) {
Log.e(TAG, "An error occurred profiling the notification.", th);
}
// If we're not supposed to beep, vibrate, etc. then don't.
if (((mDisabledNotifications & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) == 0)
&& (!(old != null
&& (notification.flags & Notification.FLAG_ONLY_ALERT_ONCE) != 0 ))
&& mSystemReady) {
final AudioManager audioManager = (AudioManager) mContext
.getSystemService(Context.AUDIO_SERVICE);
// sound
final boolean useDefaultSound =
(notification.defaults & Notification.DEFAULT_SOUND) != 0;
if (!(inQuietHours && mQuietHoursMute)
&& (useDefaultSound || notification.sound != null)) {
Uri uri;
if (useDefaultSound) {
uri = Settings.System.DEFAULT_NOTIFICATION_URI;
} else {
uri = notification.sound;
}
boolean looping = (notification.flags & Notification.FLAG_INSISTENT) != 0;
int audioStreamType;
if (notification.audioStreamType >= 0) {
audioStreamType = notification.audioStreamType;
} else {
audioStreamType = DEFAULT_STREAM_TYPE;
}
mSoundNotification = r;
// do not play notifications if stream volume is 0
// (typically because ringer mode is silent).
if (audioManager.getStreamVolume(audioStreamType) != 0) {
long identity = Binder.clearCallingIdentity();
try {
mSound.play(mContext, uri, looping, audioStreamType);
}
finally {
Binder.restoreCallingIdentity(identity);
}
}
}
// vibrate
final boolean useDefaultVibrate =
(notification.defaults & Notification.DEFAULT_VIBRATE) != 0;
if (!(inQuietHours && mQuietHoursStill)
&& (useDefaultVibrate || notification.vibrate != null)
&& audioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_NOTIFICATION)) {
mVibrateNotification = r;
mVibrator.vibrate(useDefaultVibrate ? DEFAULT_VIBRATE_PATTERN
: notification.vibrate,
((notification.flags & Notification.FLAG_INSISTENT) != 0) ? 0: -1);
}
}
I installed a new firmware and my backup didn't work. So i thinks this counts as a "full wipe". Anyways, i think the wrong data belongs to "systemui". You can delete all stored data with Titanium backup.
I've had the same error again after a full restore via Titanium backup. This time i deleted all data from "google play services" and it helped.
EDIT: Sorry, it came back again. I'm doing now a full wipe and only restore the data i really need.
Code:
public class MainActivity extends Activity implements SensorEventListener{
final String tag = "myLogs";
SensorManager sm = null;
Sensor lightSensor;
float lightQuantity;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sm = (SensorManager) getSystemService(SENSOR_SERVICE);
lightSensor = sm.getDefaultSensor(Sensor.TYPE_LIGHT);
if(lightSensor == null)
Log.d(tag, "no sensor:(");
else
Log.d(tag, "GOT IT!");
}
@Override
protected void onResume() {
super.onResume();
sm.registerListener((SensorEventListener)this, lightSensor, SensorManager.SENSOR_DELAY_NORMAL);
}
@Override
protected void onStop() {
sm.unregisterListener((SensorEventListener)this);
super.onStop();
}
public void onAccuracyChanged(Sensor sensor, int accuracy) {
Log.d(tag,"onAccuracyChanged: " + sensor.getType() + ", accuracy: " + accuracy);
}
public void onSensorChanged(SensorEvent event) {
lightQuantity = event.values[0];
Log.d(tag,"onSensorChanged: " + event.sensor.getType() + ", result: " + lightQuantity);
}
}
cant reach the light sensor stats with this code
"no sensor" message always. What am i doung wrong?
You're not doing anything wrong. The problem is that Xperia doesn't have the sensor implemented in a standard Android way through drivers.
There's only a proprietary implementation which can be used through reading the kernel variables as detailed below.
The path to your sensor is "/sys/class/leds/lcd-backlight/als/value"
You can read it with the following code:
Code:
InputStream is = new FileInputStream(sensorPath);
InputStreamReader ir = new InputStreamReader(is);
char[] buf = new char[20];
int siz = ir.read(buf, 0, 20);
if (siz > 0)
{
float sensor = Float.parseFloat(String.copyValueOf(buf, 0, siz).replaceAll(",", "."));
}
is.close();
thank u once more)
Hi,
when I try to make a jquery ajax "Typeost" request, I get an 404 not found (from cache) error. I've tried several workarounds to fix this problem but it doesn't worked. Here some code snippets to ilustrate my attempts:
This is my Ajax POST request:
Code:
$.ajaxSetup({
headers: {
"X-Requested-With" : "XMLHttpRequest",
"Content-Type" : "application/atom+xml",
"cache-control" : "no-cache",
"DataServiceVersion" : "2.0",
"X-CSRF-Token" : header_xcsrf_token,
},
cache: false,
});
$.ajax({
type: 'POST',
url: url + new Date().getTime(),
data : data,
beforeSend : function(xhr) {
// crypto call before authentication
var bytes = Crypto.charenc.Binary.stringToBytes(user + ":" + password);
var base64 = Crypto.util.bytesToBase64(bytes);
//build request header
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
success: function(data, status, xhr) {
alert("data sent");
},
error: function(jqXHR, textStatus, errorThrown){
alert(textStatus + " " + errorThrown + " " + jqXHR.status + " " + jqXHR.responseText);
}
});
I've also tried to avoid the AppCache with following code in JAVA onCreate Method:
HTML:
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.init();
super.appView.getSettings().setAppCacheEnabled(false);
super.loadUrl(Config.getStartUrl());
CookieManager.getInstance().setAcceptCookie(true);
// Set by <content src="index.html" /> in config.xml
//super.loadUrl("file:///android_asset/www/index.html");
}
every time the Ajax Post request is made, it is directed to cache, and I don't know how to prevent it.
Cris Vilares said:
Hi,
when I try to make a jquery ajax "Typeost" request, I get an 404 not found (from cache) error. I've tried several workarounds to fix this problem but it doesn't worked.
Click to expand...
Click to collapse
You're probably getting a 404 because you're appending the timestamp onto the url without any seperator. Try this...
Code:
$.ajax({
type: 'POST',
url: url + (url.search("?") == -1 ? "?" : "&") + new Date().getTime(),
data : data,
beforeSend : function(xhr) {
// crypto call before authentication
var bytes = Crypto.charenc.Binary.stringToBytes(user + ":" + password);
var base64 = Crypto.util.bytesToBase64(bytes);
//build request header
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
success: function(data, status, xhr) {
alert("data sent");
},
error: function(jqXHR, textStatus, errorThrown){
alert(textStatus + " " + errorThrown + " " + jqXHR.status + " " + jqXHR.responseText);
}
});
That will append either ?nnnnnnnn or &nnnnnnnn to the url, depending on whether it already has a ? in it.
So I've created module to hijack an app's onPictureTaken callback method to manipulate the image-data that is returned from the Camera (android.hardware.Camera.PictureCallback).
I have succeeded to manipulate the image to return a Grayscale of it which was my first goal.
Now I want to replace the entire image with an image loaded from the filesystem which I'm unsuccessful in doing. I've tried different methods, paths etc. but haven't managed to do it. I've never been able to find the file which I want to load.
The full path of the image file I want to load is according to Solid Explorer
Code:
/storage/emulated/0/input.png
What code should I use to load the filesystem image into a Bitmap?
Do I need to take any extra Camera parameters into account that says stuff about the image?
Do I need take file permissions into account?
I'm running an OPO on Lollipop 5.0.2 / Cyanogen OS 12.0 / Xposed 67
This is the code I've used to create the Grayscale example:
Code:
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint;
import android.os.Environment;
import java.io.ByteArrayOutputStream;
import java.io.File;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
public class CamHook implements IXposedHookLoadPackage {
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
XposedBridge.log("Loaded app: " + lpparam.packageName);
if (!lpparam.packageName.equals("somepackage.somewhere.app"))
return;
XposedBridge.log("CamHook: We're here!");
findAndHookMethod("somepackage.somewhere.app.NewPhotoFragment$3$1", lpparam.classLoader, "onPictureTaken", "byte[]", "android.hardware.Camera", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("CamHook: before picture taken");
XposedBridge.log("CamHook: byteLength " + ((byte[]) (param.args)[0]).length);
byte[] bitmapdata = ((byte[]) (param.args)[0]);
Bitmap bitmap = BitmapFactory.decodeByteArray(bitmapdata, 0, bitmapdata.length);
XposedBridge.log("CamHook: StorageState: " + Environment.getExternalStorageState());
XposedBridge.log("CamHook: StoragePath: " + Environment.getExternalStorageDirectory().getAbsolutePath());
XposedBridge.log("CamHook: StoragePathEnv: " + System.getenv("EXTERNAL_STORAGE"));
//Bitmap bitmap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getAbsolutePath() + "/input.jpg");
XposedBridge.log("CamHook: Bitmap is null: " + (bitmap == null));
bitmap = toGrayscale(bitmap);
ByteArrayOutputStream blob = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 0, blob);
param.args[0] = blob.toByteArray();
}
/*@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
// this will be called after the clock was updated by the original method
}*/
});
}
public Bitmap toGrayscale(Bitmap bmpOriginal)
{
int width, height;
height = bmpOriginal.getHeight();
width = bmpOriginal.getWidth();
Bitmap bmpGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bmpGrayscale);
Paint paint = new Paint();
ColorMatrix cm = new ColorMatrix();
cm.setSaturation(0);
ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
paint.setColorFilter(f);
c.drawBitmap(bmpOriginal, 0, 0, paint);
return bmpGrayscale;
}
}
Does this mean it's working? App settings and YouTube adaway seem to work. But I know app settings can work without xposed
Did you get this to work?
Hi,
I found your thread. Did you ever get this to work?
Kind regards!
Hello did it work out for you? I am also looking into similar thing.
سلام
Hi, I'm new to the subject of modules for Xposed, I hope you can help.
1) I have managed to make a change in the status bar of android, with a few lines.
Code:
String methodeStatusBar = "com.android.systemui.statusbar.phone.PhoneStatusBar";
XposedHelpers.findAndHookMethod(methodeStatusBar, lpparam.classLoader, "makeStatusBarView", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
super.afterHookedMethod(param);
XposedBridge.log("Hola Mundo-> Xposed: " + param);
Context mContext = (Context)XposedHelpers.getObjectField(param.thisObject, "mContext");
LinearLayout mStatusBarContents = (LinearLayout)XposedHelpers.getObjectField(param.thisObject, "mStatusBarContents");
mStatusBarContents.setBackgroundColor(Color.rgb(100, 100, 255));
XposedBridge.log("findAndHookMethod-> Xposed: " + mContext);
XposedBridge.log("findAndHookMethod-> Xposed: " + mStatusBarContents);
}
});
2) I manage to identify activity that has focus.
Code:
XposedHelpers.findAndHookMethod(Activity.class, "onWindowFocusChanged", boolean.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
super.afterHookedMethod(param);
Activity activity = (Activity) param.thisObject;
}
});
3) but I can not connect "StatusBar" with "Activity", to extract the color of the "activity" and then set the "setBackgroundColor" the statusbar.
my question is: How can I connect "StatusBar" with "Activity"?
you can help me !!!!
translation "translate.google.com.do/".