Information Technology Reference
In-Depth Information
In general, the aspects as such are written in the well-known AspectJ syntax
and are not Android-specific except for the methods intercepted in the pointcuts
and the ones called in the pieces of advice. All mapping to the Android platform
is done by the abc compiler during the weaving process.
Since we only want a notification when an SMS message has actually been
sent, the order of the pieces of advice inside the aspect is important: We place the
around advice last to give it precedence over the after advice which shall only
be executed when the around advice proceeds, i.e., the target phone number is
not a premium-rate number. Otherwise, the SMS message is blocked and thus
shall not be logged.
abc supports two different frontends for parsing Java source code: Polyglot
and JastAdd. The Polyglot frontend is a bit dated and should not be used for
instrumenting Android applications from source. JastAdd can be enabled as an
extension using the -ext abc.ja command-line option. Also note that abc has
its own class path which is independent of the JDK's class path and which must
be set using the -cp option. It should include both the JRE's rt.jar file and
abc's own abc-runtime.jar file. Since our target application references classes
from the Android framework, we also need to include the android.jar file.
If applications written for modern versions of the Android API are also sup-
ported on older platforms (i.e., have a lower minimum SDK version that one
they were developed for), the Android eclipse plugin automatically integrates
so-called support classes which add some newer APIs to older platforms. The
respective jar file can then found in the libs directory of the application project
and needs to be included in abc's class path as well.
The complete command-line for instrumenting the example is shown in List-
ing 1.6. The Android support is enabled with the -android option, the APK file
name is given with the -injars switch.
1 java -cp abc-ja-exts-complete.jar abc.main.Main \
2
-cp /path/to/rt.jar: \
3
/path/to/android-support-v4.jar: \
4
/path/to/android.jar: \
5
/path/to/abc-runtime.jar \
6
-ext abc.ja \
7
-android -injars /path/to/RV2013.apk \
8
/path/to/SendSMS_PremiumAspect.aj
Listing 1.6. abc compiler command-line
Unsigned applications will not run on the Android OS, which is why the instru-
mented apk file still needs to be signed before it can be run on a real phone or
the emulator (c.f. Section 2.6).
4 Instrumentation with Tracematches
While AspectJ is rather convenient for describing Android instrumentations (see
Section 3), it requires additional manual effort when sequences of actions shall be
tracked. Tracematches [22] provide a simple regular-expression based approach
to declaratively abstract from such tracking. Let us assume we want to raise an
 
Search WWH ::




Custom Search