Including a package in android source code - android

I am modifying CyanogenMod (CM 7) Source code,
i want to include "Cyanogen/packages/apps/phone/src/com/android/phone/CallNotifier.java" in the "Cyanogen/frameworks/base/policy/src/com/android/internal/policy/impl/LockPatternGuardview.java" file. I added "import com.android.phone.CallNotifier;" in the LockPatternGuardview.java file and upon compiling i get this error.
LockPatternKeyguardView.java:20: package com.android.phone does not exist
import com.android.phone.CallNotifier;
^
But CallNotifier.java is included in the "com.android.phone" package, so if someone can please tell that how to include com.android.phone package ?

You can't include com.android.phone, it's hidden.
You might be able to access it via reflection but in most cases, the telephony stack is setup so that it's running in a different process and you won't be able to access anything meaningfull.

In development case, android api is consisted of collection of abstract class. And the implemented class kept on android os. So that when you use android api, during execution it actually call that implemented classes from android os. Therefore, you actually implement that class, but it unable to find that class from os.
It'll happen if you install this app as third party, try to push your app in /system/app/ path, and reboot your device. It'll be installed.
System folder always stays in readonly mode.
Search on google about push to system tutorial.
Good luck...

Related

Compiling system-api calls for 3th party apps with root process

in android system api there are several methods which are not compileable for a 3th party app (means: not a system app/system signature signed app).
special example: goToSleep() in PowerManager. (which turns off screen)
goToSleep is also marked as removed if you look at docs at developer.android.com history. but in fact it is defined in sdk source code when you look in e.g. powermanager.java.
if you try to use it, you get standard compiler error, unknown reference.
but in e.g. well known 3th party launcher Lawnchair they use it in a root service (provided by john wu's libsu) to turn of screen after double tap screen. so the root service has of course the permissions at runtime to use that method.
at runtime.. but what settings in android studio project enable to get that compiled??
the source of lawnchair is at github. that special source file is:
https://github.com/LawnchairLauncher/lawnchair/blob/12.1-dev/lawnchair/src/app/lawnchair/root/RootHelperBackend.java
thanks in advance for some tips

How to create batch command for : compile + sign + install + run

Background
As it turns out, it's quite an annoyance to test out in-app-billing (i've written about it here) . Each time you find a bug and need to test your app, you must have the following steps:
compile the app , preferably with the debuggable="true" flag on the manifest
sign the app with your real key you've created for the play store.
install the app on your device
run the app on your device, preferably debugging it via eclipse.
If you'd use a batch operation instead of doing all of those by yourself, it should make things easier to test such apps, and might also be useful for other apps as well.
The question
Is there any way to make the whole process fully automatic, so that with a single click of a button, it will do all of the above?
I know how to achieve 3+4 (using "adb.exe install -r *.apk" and "adb.exe shell am start -n FULL_ACTIVITY_PATH" ), but I don't know how to achieve the others.
If there is a solution that doesn't involve a third party app or plugin (like maven or Ant), it could be very nice. Of course, if that's what is available, I would like to know if it's possible to achieve via a batch file that will use them somehow.
Is there maybe a way to mimic how Eclipse does things in this regard, without being so specific on the project (maybe just the path of the project and that's it)?
Maybe you can package app by ant . You can do every thing you what int the ant code of packaging ,causing the core code is to make property configs in your app and referenced lib, such as build.xml,local.properties...,and replace channel in AndroidMainfest.xml ,so you can also replace any code in your android app,just as you want ,to change the flag of debug , because all the operation just handle local file before packaging your app,you can copy or modify any file in your app. After above process ,you get a app,then you can run other code to install the app. Recently ,I have been using the batch package method to get a lot of app for different channel .so hope it helps.

A lot of errors after Android 2.3 Launcher Source Code is imported into my workspace

I have task to modify android gingerbread launcher (2.3). I want to download launcher's sources and add some functionality. I have found sources here:
android Gingerbread launcher sources
I download this and import into workspace as is. As a result I get numerous compile errors (some classes are missing, instance variables are missing, etc). Why? I mean why wouldn't it compile? What should I do to make it compile?
P.S. By the way, when project is imported, used platform as per project settings is not 2.3, so I have to manually set it to 2.3. However, numerous errors still remain.
To convert an AOSP application into a standalone SDK application, you will need to find all the "classes and variable not present in the SDK" and remove/replace the references to them. The simplest is to remove the references to them, if the app will still run with reduced functionality. For references to internal resources, you can simply copy those to your project and modify the R values to point to your local copy. You are welcome to examine the "classes and variable not present in the SDK" and determine that you can copy those as well (refactoring them into a new package), in which case you would update your project to refer to the copied and refactored classes.
The easier solution would be to use someone's source where they already did that..Here found one at
Launcher2 full compilable Ginngerbread lancher code
Have a look at here.
It is the Launcher2 from ICS, not GB, but they are very similar.
From Wiki: Note that it is not completely bug free, and adding widgets will crash the app (as it uses a system level permission. Maybe if you installed via root it'll work).
Here's a list of what all I had to do, that I can recall doing:
There are lots of methods like setFastXXX (for example, setFastAlpha()) that aren't available to us. Changing these to setXXX (for example, 'setAlpha()`) worked for me.
Some thing which are available to us via getSystemService() are initialized directly in the code, like the usage of the Vibrator class. These need to be changed to use getSystemService().

Launch .apk file on Android device

Might seem a pleonasm the 'Title' but I wrote it to emphasize the issue.
I have an application running on an Android device, using the 2.2 Froyo library. The application has to (1) install - if not already installed - then (2) launch an .apk file already present in the data/data/myapp/files/ folder.
Knowing Java I would have used a shell execution of the above operations. But Android is also a separate namespace, therefore I would like to know how to do the sequence install + launch of the .apk file.
To note that, while I'm using Eclipse/Ubuntu now, the implementation should take into account ONLY the Android OS APIs, not my dev environment available tools.
Thanks
You do not launch an apk file. An apk file can be thought of as a container holding some number of activities, services, receivers, among other constructs. It's likely you mean you want to launch an activity (which is performed using the startActivity() method from the Context class, or one of its many subclasses) but by no means is that a certainty.
It would seem from your question that you need to learn quite a bit about Android before continuing on the path suggested by your question, because the question you've posted is really too vague to be answered in a reasonable manner for stackoverflow.

Replace a system application with your own modified application on android

I downloaded the source code of OI Notepad and did some modifications to it. And then made an .apk file out of it. But when I try to install the .apk it shows
This is a system application.
Do you still want to replace it?
When i say yes it moves forward but does not install it..
I have this post My application tries replace another my application and the answer given there the package name of both the apps cannot be same.
But is there any way in which I can manage to install modified OI Notepad without any hassles of replacing the older one. It happens in Emulator..
Thanks
If you are using eclipse you can right click the package tree and use the refactor option to quickly change the package. This, in most cases, correctly updates the Application Manifest for you. This 'should' resolve the error you are having keeping in mind that you will now have two versions of the application so it may be in your best interest to change the application name of your custom version so you can easily distinguish between the two.

Categories

Resources