Android uses the init. rc trigger script to hide built-in applications. androidinit. rc

Source: Internet
Author: User

Android uses the init. rc trigger script to hide built-in applications. androidinit. rc
[Implementation logic] sets a flag in property_service.c. In the settings, the interface changes the flag and uses init. the declared service in rc listens for changes in the flag space, explicitly starts the declared service, executes the corresponding script, and renames the application Suffix from apk to bak, to hide (the display logic is the opposite ).
[Implementation steps] use the example of hiding Google Play Store (system/priv-app/Phonesky.apk): 1. first, declare and initialize the flag in system/core/init/property_service.c. 0 is hidden, 1 is displayed, and 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 Set developer options: file path: packages/apps/Settings/src/com/android/settings/DevelopmentSettings. java ① declaration and initialization:
private static final String SHOW_PHONESKY = "show_phonesky";private CheckBoxPreference mShowPhonesky;mShowPhonesky = findAndInitCheckboxPref(SHOW_PHONESKY);

② CheckBox logic:
       (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" +        />     <CheckBoxPreference 


④ Add the string character of the corresponding language:
<string name="show_phonesky">Show Google Play Store</string>


⑤ Add a new listener in the Settings to initialize the Checkbox logic: packages/apps/settings/src/com/android/Settings/BootReceiver. java content is 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.getSharedPreferences("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 the BroadcastReceiver permission and statement to the AndroidManifest file of 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 condition to init. rc: Path: mediatek/config/esky27_tb_ccn_mlc_kk/init. rc
+ # ZJ Add START + # Hide or Show Google Play Dynamicly + # disabled: the service will not run automatically and must be started explicitly through the server. + # Oneshot: the service will not be restarted automatically when it 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 display the App Script: Hide the App: vendor/ThirdParty/App/dte/hidePhonesky content:
#!/system/bin/sh#!/system/bin/busyboxmount -o remount,rw /system;mv /system/priv-app/Phonesky.apk /system/priv-app/Phonesky.bak

Show applications: 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. Add the script to the corresponding mk file in the following format:
+ # Add and rename GooglePlay script + 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





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.