Android uses init.rc trigger script to hide built-in apps

Source: Internet
Author: User

"Implementing Logic"by setting the flag bit in the PROPERTY_SERVICE.C, implement the interface change flag bit in the setting,use the services declared in Init.rc to listen for changes in flag bits, explicitly start the declared service, execute the corresponding script, rename the app suffix from the apk to Bak, and hide it (showing the opposite logic).
"Implementation Steps" to hide the Google Play Store (system/priv-app/phonesky.apk) as an example:1. First declare and initialize the flag bit in system/core/init/property_service.c, 0 is hidden, 1 is display, default is hidden
     {"App.launcher.start", Aid_system, 0},+   {"App.phonesky.show", Aid_system, 0},//add by ZJ     {"CDMA.",        aid_ RADIO,    0},    //add by Gfzhu VIA


2. Implement the corresponding interface in the Setup developer options:file path: Packages/apps/settings/src/com/android/settings/developmentsettings.java① Declaration and initialization:
private static final String Show_phonesky = "Show_phonesky";p rivate checkboxpreference Mshowphonesky;mshowphonesky = Findandinitcheckboxpref (Show_phonesky);

the logic of ②checkbox:
       (Batterymanager.battery_plugged_ac | BATTERYMANAGER.BATTERY_PLUGGED_USB): 0); +      } else if (preference = = Mshowphonesky) {//ZJ add+           if (Mshowphonesky. IsChecked ()) +           {+              systemproperties.set ("App.phonesky.show", "1"); +           }else{+              systemproperties.set ( "App.phonesky.show", "0"); +           }         } else if (preference = = Mbthcisnooplog) {



③ Add a preference:Packages/apps/settings/res/xml/development_prefs.xml
     android:targetclass= "Com.android.settings.SetFullBackupPassword"/>     </preferencescreen>+       < Checkboxpreference +        android:key= "Show_phonesky" +        android:title= "@string/show_phonesky" +        />     


④ Add string characters for the corresponding language:
<string name= "Show_phonesky" >show Google Play store</string>


A new listener is added in the ⑤ setting to initialize the checkbox logic:Packages/apps/settings/src/com/android/settings/bootreceiver.javaThe contents are as follows:
Package Com.android.settings;import Android.content.broadcastreceiver;import Android.content.context;import Android.content.intent;import Android.content.sharedpreferences;import Android.os.systemclock;import     Android.util.log;import Android.os.systemproperties;public class Bootreceiver extends broadcastreceiver{@Override public void OnReceive (Context arg0, Intent arg1) {//TODO auto-generated method stub String          Action = Arg1.getaction (); if (Action.equals (intent.action_boot_completed)) {Sharedpreferences shared = Arg0.getsharedpreferenc             ES ("Com.android.settings_preferences", context.mode_private);             Boolean Show_phonesky = Shared.getboolean ("Show_phonesky", false);                    if (Show_phonesky) {systemproperties.set ("App.phonesky.show", "1");                    }else{systemproperties.set ("App.phonesky.show", "0"); }          }     }}


⑥ Add Broadcastreceiver permissions and declarations to the Androidmanifest file in Settings:
<uses-permission android:name= "Android.permission.RECEIVE_BOOT_COMPLETED"/><receiver android:name= ". Bootreceiver ">            <intent-filter>                <action android:name=" Android.intent.action.BOOT_COMPLETED "/ >               <category android:name= "Android.intent.category.DEFAULT"/>                    </intent-filter>      </ Receiver>


3. Add the corresponding service and trigger conditions in the init.rc:Path: mediatek/config/esky27_tb_ccn_mlc_kk/init.rc
+# ZJ Add start+ #Hide or Show Google Play dynamicly+ #disabled: The service does not run automatically and must be started explicitly through the server. + #oneshot: Does not restart automatically when this service exits. +service hidephonesky/system/bin/hidephonesky+       disabled+       oneshot    +service showphonesky/system/bin/ showphonesky+       disabled+       oneshot    + #on property:sys.boot_completed=1+#   start Renamephonesky+on property:app.phonesky.show=1+   start Showphonesky+on property:app.phonesky.show=0+   start hidephonesky+# ZJ ADD END


4. Hide and show the app's script:Hide Apps: Vendor/thirdparty/app/dte/hidephoneskycontent:
#!/system/bin/sh#!/system/bin/busyboxmount-o remount,rw/system;mv/system/priv-app/phonesky.apk/system/priv-app/ Phonesky.bak

Display application: Vendor/thirdparty/app/dte/showphonesky
Content:
#!/system/bin/sh#!/system/bin/busyboxmount-o remount,rw/system;mv/system/priv-app/phonesky.bak/system/priv-app/ phonesky.apk


5. Copy the script to the System/bin directory:refer to the following format to add to the corresponding MK file:
+ #添加重命名GooglePlay脚本 +product_copy_files + = +       Vendor/thirdparty/app/dte/hidephonesky:system/bin/hidephonesky +       Vendor/thirdparty/app/dte/showphonesky:system/bin/showphonesky +       vendor/thirdparty/app/dte/ Phonesky.bak:system/priv-app/phonesky.bak





Android uses init.rc trigger script to hide built-in apps

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.