Im just getting into developing modules for Xposed Framework.
I get a basic module working, just a module that does nothing but saying that its loaded and prints to log.
Next step was to try hooking the Clock in SystemUI, following rovo89's instructions on GitHub (dont know if I can link?)
The code is as follows:
package com.example.xxx.xposedtest;
import android.graphics.Color;
import android.widget.TextView;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
import de.robv.android.xposed.XposedHelpers;
public class xposedTest implements IXposedHookLoadPackage {
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
if(!lpparam.packageName.equals("com.android.systemui")) {
XposedBridge.log("Did not find package")
return;
}
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(text + " :)");
XposedBridge.log("Package loaded: Function ran");
}
});
}
}
The log says "Did not find package". And the hook method ofcourse did not run.
My guess is that Samsung s7 edge has some kind of other implementation, other class/method name.
How do I find out what method to actually hook since Samsung decided to not go AOSP? All information on the subject is appriciated.
The answer was other xposed modules were interfering.
Answering if anyone encounters the same problem
Related
I'm writing code for a splash screen as part of a project but when I am trying to use RxJava all the other functions are working fine until I get to 'subscribe' which isn't registering so I'm wondering am I missing a library I didn't import or something?
The error message I get when trying to run is: 'Cannot resolve method 'subscribe'. I've tried asking the tutorial creator, as well as looking at the top relevant questions about the 'subscribe' function on StackOverflow and even looking at the full list of methods in the Completable library but I can't find a solution so I'm really desperate, please help
These are my dependencies:
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.20'
My Code:
package codebymech.fyprideshareapp;
import androidx.appcompat.app.AppCompatActivity;
import android.app.Notification;
import android.os.Bundle;
import android.widget.Toast;
import java.util.concurrent.TimeUnit;
import io.reactivex.Completable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Action;
public class Activity_SplashScreen extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
delay_Splash();
}
private void delay_Splash() {
Completable.timer(delay: 5, TimeUnit.SECONDS,
AndroidSchedulers.mainThread())
.subscribe(new Action() {
#Override
public void run() throws Exception {
Toast.makeText(Activity_SplashScreen.this, "!! Splash Screen Finished", Toast.LENGTH_SHORT).show();
}
});
}
}
Part of tutorial where the code is from:
https://youtu.be/144TuYxEu2M?t=489
You have to remove delay: . This is not possible in Java. If you look at the video, you see a delay: in given method, but it is added by the IDE (IntelliJ) in order to give you a hint, which parameter you are currently editing.
Import
import io.reactivex.Completable;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
Java8
Completable.timer(5, TimeUnit.SECONDS,
Schedulers.trampoline())
.subscribe(() -> {
System.out.println("x");
});
Java7
Completable.timer(5, TimeUnit.SECONDS,
Schedulers.trampoline())
.subscribe(new Action() {
#Override
public void run() throws Exception {
System.out.println("x");
}
});
Downloaded latest android Studio (android-studio-bundle-162.3871768-windows).
We were using com.android.sdklib.SdkManager class in our software but in latest Android Studio I'm not able to find the above mentioned class in any jar present inside the tools\lib folder.
Can anyone suggest what is the better alternative for this?
if you want to get a list of all the targets installed for knowledge, then you can just simply run the SDK manager. But since you want to call the getTargets() method, it means you need it for other purposes. check up the documentation on the android studio web page to find out if it the class you are searching for exists and the location of its jar file.
We can find the soure code of all the android classes in the below link.
https://javalibs.com/artifact/com.android.tools/sdklib?className=com.android.sdklib.tool.SdkManagerCli&source
SdkManagerCli class have equivalent method listPackages()which will list the packages.
We need to import sdklib-25.3.2.jar, repository-25.3.2.jar and common-25.3.2.jar to project.
Below is the working code for listing packages:-
import java.io.File;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.TreeSet;
import com.android.repository.Revision;
import com.android.repository.api.ConsoleProgressIndicator;
import com.android.repository.api.LocalPackage;
import com.android.repository.api.ProgressIndicator;
import com.android.repository.api.RepoManager;
import com.android.repository.impl.meta.RepositoryPackages;
import com.android.sdklib.repository.AndroidSdkHandler;
public class AndroidTesting {
public static void main(String[] args) {
listPackages();
}
private static void listPackages() {
AndroidSdkHandler mHandler = AndroidSdkHandler.getInstance(new
File("filePath")); //for eg:-sdk/platforms for API
ProgressIndicator progress = new ConsoleProgressIndicator();
RepoManager mRepoManager = mHandler.getSdkManager(progress);
mRepoManager.loadSynchronously(cacheExpirationMs, progress,
downloader, settings)(0, progress, null, null);
RepositoryPackages packages = mRepoManager.getPackages();
Collection<LocalPackage> locals = new TreeSet<LocalPackage>();
Collection<LocalPackage> localObsoletes = new
TreeSet<LocalPackage>();
for (LocalPackage local : packages.getLocalPackages().values()) {
if (local.obsolete()) {
localObsoletes.add(local);
} else {
locals.add(local);
}
Revision version = local.getVersion();
System.out.println(local.getDisplayName() + " "
+ local.getVersion() );
}
}
}
I am quite new to android development, I know the basics activities, maps, sqlite, etc.
I would like to be able to implement some 3D objects to be able to interact with within my apps. After a bit of searching I found that rajawali seems to be the best method. As you do I started with the first tutorial and reading the source code from the example docs.
Where I have become lost is I have followed the tutorial word for word and and I cant run the application due to errors in the script. If anybody has used Rajawali before I would appreiate some pointers as to where I have gone wrong. (the tutorial was last updated 2 month ago so its quite recent). Tutorial
Here is my source code
MainActivity:
package rajawali.tutorials;
import rajawali.RajawaliActivity;
import android.os.Bundle;
import android.view.Menu;
public class MainActivity extends RajawaliActivity {
private Renderer mRenderer;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mRenderer = new Renderer(this);
mRenderer.setSurfaceView(mSurfaceView);
super.setRenderer(mRenderer);
}
}
Renderer:
package rajawali.tutorials;
import javax.microedition.khronos.opengles.GL10;
import android.content.Context;
import rajawali.lights.DirectionalLight;
import rajawali.materials.textures.ATexture.TextureException;
import rajawali.materials.textures.Texture;
import rajawali.primitives.Sphere;
import rajawali.renderer.RajawaliRenderer;
public class Renderer extends RajawaliRenderer {
private DirectionalLight mLight;
Sphere mSphere;
public Renderer(Context context) {
super(context);
setFrameRate(60);
}
public void initScene() {
mLight = new DirectionalLight(1f, 0.2f, -1.0f);
mLight.setColor(1.0f, 1.0f, 1.0f);
mLight.setPower(2);
try {
*DiffuseMaterial* material = new *DiffuseMaterial*(); //there is an error here (DiffuseMaterial cannot be rsolved as a type)
material.addTexture(new *Texture(R.drawable.earthtruecolor_nasa_big)*); //here (constructor Texture(int) cannot be defined)
mSphere = new Sphere(1, 24, 24);
mSphere.setMaterial(material);
mSphere.*addLight(mLight)*; //and here (The method addLight(DirectionalLight) is undefined for the type Sphere)
addChild(mSphere);
} catch (TextureException e) {
e.printStackTrace();
}
getCurrentCamera().setZ(4.2f);
}
#Override
public void onDrawFrame(GL10 glUnused) {
super.onDrawFrame(glUnused);
mSphere.setRotY(mSphere.getRotY() + 1);
}
}
I don't realy want to be spoon feed code if I can help it but it appears that the error is in the 'DiffuseMaterial'. Why is this or is there a better way of manipulating 3D objects other than using min3D or Rajawali?
I also have been trying to run this rajawali tutorial using next code.
Class RajawaliTutorialActivity
package rajawali.tutorials;
import rajawali.RajawaliActivity;
import android.os.Bundle;
public class RajawaliTutorialActivity extends RajawaliActivity {
public RajawaliTutorialRenderer mRenderer;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mRenderer = new RajawaliTutorialRenderer(this);
mRenderer.setSurfaceView(mSurfaceView);
super.setRenderer(mRenderer);
}
}
Class RajawaliTutorialRenderer
package rajawali.tutorials;
import javax.microedition.khronos.opengles.GL10;
import android.content.Context;
import rajawali.Camera;
import rajawali.Object3D;
import rajawali.lights.DirectionalLight;
import rajawali.materials.Material;
import rajawali.materials.textures.ATexture.TextureException;
import rajawali.materials.textures.Texture;
import rajawali.primitives.Sphere;
import rajawali.renderer.RajawaliRenderer;
public class RajawaliTutorialRenderer extends RajawaliRenderer {
public DirectionalLight light;
public Object3D sphere;
public Context context;
public Camera camera;
public RajawaliTutorialRenderer(Context context) {
super(context);
this.context = context;
setFrameRate(60);
}
public void initScene() {
light = new DirectionalLight(1f, 0.2f, -1.0f); // set the direction
light.setColor(1.0f, 1.0f, 1.0f);
light.setPower(2);
try{
Material material = new Material();
material.addTexture(new Texture("earthColors", R.drawable.earthtruecolor_nasa_big));
material.setColorInfluence(0);
sphere = new Sphere(1, 24, 24);
sphere.setMaterial(material);
getCurrentScene().addLight(light);
super.addChild(sphere);
} catch (TextureException e){
e.printStackTrace();
}
getCurrentCamera().setZ(4.2f);
}
#Override
public void onDrawFrame(GL10 glUnused) {
super.onDrawFrame(glUnused);
sphere.setRotY(sphere.getRotY() + 1);
}
}
See that changes are:
declare sphere object as Object3D instead Sphere.
change DiffuseMaterial by Material for material declaration.
change parameters to get Texture. First parameter is an custom identifier and second parameter is the resource id.
add the line material.setColorInfluence(0); after load texture, if this line isn't added, the "heart" becomes red (I'm not sure why).
replace sphere object by scene object (accessing with getCurrentScene method) to call addLight method.
Add try/catch for line material.addTexture() as this method now throws a TextureException
add getCurrentCamera().setZ(4.2f); to the end of initScene
It looks like this has to do with the version of Rajawali.
On this page it says not to use the master branch:
Whether you choose to clone or download, you probably will want to use one of the release tags. The master branch of both the library and examples is used for development and should be considered unstable for production code. When we release a stable version, it will be tagged. If you are cloning, you can simply checkout a tag.
If you cloned Rajawali using git, you'll want to checkout from a tag. To list the tags:
$ git tag
v0.9
At the time of writing, v0.9 is your only choice.
$ git checkout v0.9
Now you'll have DiffuseMaterial available. However, some of the other classes are still missing.
EDIT:
It looks like this tutorial neither applies to v0.9 nor the latest master branch. I made a working version of tutorial 1, which you can find linked here.
You can also use the RajawaliExamples application I wrote, which is composed of contributed examples, as a demonstration of using the master branch.
https://github.com/MasDennis/RajawaliExamples
Also to clarify on Deans quote, the statement made there is dissuade people from freaking out when the API changed underneath them which was mostly relevant when jwoolston was making large changes to support scene graphs. The bulk of that work is done and if ever finished, the api is likely to change significantly from its current state as the other major items are already complete. Such items are pieces like animation, more parsing options, flexible rendering, etc.
I am learning OSGI, CQ5 these days. I am trying to build a bundle that have service (My first code).
I successfully build a bundle and upload that bundle on CQ5, and install that also.
But component shows registered only, not active. Why ?
I also want to activate this service. How can I do this ? Someone on net said to make jsp. I also do that, but didn't get any response. Help me from this problem. I spent lot of time on this, lot of searching, but I didn't get any solution.
How can I use my service in CQ5, CRXDE(Adobe).
JSP code are :-
<% var service = sling.getService(Packages.mh.osgitest.SayHello); %>
<%= service.sayHelloTest() %>
Above code is not working.
The snapshots of these are
Bundle
component
service
My codes are as :-
SayHello
package service.expose;
import org.apache.felix.scr.annotations.Service;
public interface SayHello {
public void sayHelloTest();
}
SayHelloTestServlet // Servlet have no sense here.
package service.expose;
import java.io.IOException;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Service;
#Component
#Service(value = SayHello.class)
public class SayHelloTestServlet implements SayHello {
public void sayHelloTest() {
System.out.println("Testing Say Hello");
}
#Activate
protected void activate() {
System.out.println("service started");
}
#Deactivate
protected void deactivate() {
System.out.println("service stopped");
}
}
Use #Component(immediate=true) to instantiate your service as soon as the bundle is activated as opposed to on-demand.
I'm experimenting with twitter4j on android (new to both) coded up a simple process in java just to test it out. It downloads a users timeline and prints to screen.
I modify the code for android, but I get a TwitterException when i try to download the user timeline. I checked out the debugger and the exception is null; no information given. I've also added the Internet permission to the android manifest on previous advice. Heres the code:
package com.test;
import java.util.List;
import twitter4j.Status;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import android.app.Activity;
import android.os.Bundle;
public class Test2 extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
List<Status> statuses = null;
Twitter api = new TwitterFactory().getInstance("USERNAME","PASSWORD");
try{
statuses = api.getUserTimeline();
}
catch(TwitterException e){
System.out.println("ERROR");
System.exit(-1);
}
for(Status s: statuses){
System.out.println(s.getText());
}
}
}
I realise this only prints to the console, just to keep it simple.
Thanks for any and all help.
Make sure you have the INTERNET permission in your AndroidManifest.xml file.
Also System.out.println() is not recommended on Android. Please use the android.util.Log class and send your debugging output to LogCat (available via adb logcat, DDMS, or the DDMS perspective in Eclipse).
Please check your timestamp. Each HttpRequest contain current timestamp, if the timestamp is wrong then it throw exception.