android4.4 Framework add third-party call interface

Source: Internet
Author: User

Recently, the third-party executable files are encapsulated into the interface and transplanted into the system. Now will be a tortuous road to success to do a summary, and share with you.

Software platform: Android

Hardware platform: Marvell

Third-party executable files: AA, BB;

Job requirements: Two files must be executed sequentially in order to complete the function, at the framework layer to provide the appropriate API interface for the application to invoke.

Because this interface is related to WiFi, the framework layer adds the interface to the Wifiapmanager.java,

---a/wifi/java/android/net/wifi/wifiapmanager.java
+ + + B/wifi /java/android/net/wifi/wifiapmanager.java
@@ -1213,6 +1213,20 @@ -1213,6 class Wifiapmanager {
             return false;
         }
     }

public Boolean startxx () {
try {
Mservice.startxx ();
return true;
} catch (RemoteException e) {
return false;
}
}

public Boolean stopxx () {
try {
Mservice.stopxx ();
return true;
} catch (RemoteException e) {
return false;
}
}

Note Modify the appropriate aidl file, otherwise the interface cannot be called.

---a/wifi/java/android/net/wifi/iwifiapmanager.aidl
+ + B/wifi/java/android/net/wifi/iwifiapmanager.aidl
@@ -103,6 +103,10 @@ -103,6 Iwifiapmanager
void Startwifi ();

void Stopwifi ();
+
+ void Startxx ();
+
+ void Stopxx ();

Then there is the change of the protagonist part:

---a/services/java/com/android/server/wifi/wifiapservice.java
+ + B/services/java/com/android/server/wifi/wifiapservice.java
@@ -1010,6 +1010,21 @@ -1010,6 final class Wifiapservice extends Iwifiapmanager.stub {
return info;
     }
 
+ public void Startxx () {
+ systemproperties Properties = new Systemproperties ();
+
+ properties.set ("Ctl.stop", "Xx_killer");
+ properties.set ("Ctl.start", "Xx_start");
+
+       }
+
+ public void Stopxx () {
+ systemproperties Properties = new Systemproperties ();
+
+ properties.set ("Ctl.stop", "Xx_start");
+ properties.set ("Ctl.start", "Xx_killer");
+       }
we see that the corresponding method will open or kill the corresponding service, and two service (Xx_start, xx_stop) is declared in init.rc.

---a/copyfiles/root/init.pxa1l88.rc
+ + b/copyfiles/root/init.pxa1l88.rc
@@ -313,6 +313,20 @@ -313,6 hostapd2/system/bin/hostapd-dd-e/data/misc/wifi/entropy.bin/data/mis
Disabled
OneShot

+# XX Killer
+service xx_killer/system/bin/wifiapp_helper.sh-k
+ User Root
+ Group Log System
+ Class Main
+ Disabled
+
+# XX Start
+service xx_start/system/bin/wifiapp_helper.sh-s
+ User Root
+ Group Log System
+ Class Main
+ Disabled
+

The execution of the service is done through the wifiapp_helper.sh script, with the following script:

#!/system/bin/sh

Wifidir=/data/weixin
Src=/system/etc/weixin
dnsfile= $WIFIDIR/blackwhitedns.conf

app_log0= $WIFIDIR/wifiapp.log
app_log1= $WIFIDIR/wifiapp1.log

list_log0= $WIFIDIR/list.log
list_log1= $WIFIDIR/list1.log

Mkdir=mkdir
chmod= "CHMOD 777"
Cp=cp
Cd=cd
Mv=mv
Rm=rm

function Direxsit () {
if [!-D "$WIFIDIR"]; Then
$MKDIR "$WIFIDIR"
$CP $SRC/blackwhitelist $WIFIDIR
$CP $SRC/blackwhitelist_weixin.conf $WIFIDIR
$CP $SRC/wifiapp $WIFIDIR
$CP $SRC/wifiapp.conf $WIFIDIR


$CHMOD $WIFIDIR/*
Fi
}


function Execwifiapp () {
$CD $WIFIDIR
Echo $PWD

If [-f $APP _log0]; Then
$MV $APP _log0 $APP _log1
./aa-c wifiapp.conf &> $APP _log0
Else
./aa-c wifiapp.conf &> $APP _log0
Fi
}

function Execblack () {
$CD $WIFIDIR
Echo $PWD

If [-f $LIST _log0]; Then
$MV $LIST _log0 $LIST _log1
./bb > $LIST _log0
Else
./bb > $LIST _log0
Fi
}

Case $ in
"-S")
Direxsit
Execwifiapp
Execblack
Exit 0;;

"-K")
Pid= ' PS | BusyBox grep blackwhite | awk ' {print $} '
Kill-9 $PID
Pid= ' PS | BusyBox grep Wifiapp | awk ' {print $} '
Kill-9 $PID
$RM $DNSFILE
Exit 0;;
Esac

At this point, the porting is complete. There is a need to switch to the executable file placement directory to execute correctly, or error, so the script must first switch directories, and then execute ~~~~~

android4.4 Framework add third-party call interface

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.