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

Source: Internet
Author: User

The implementation logic implements the interface change flag bit in the setup by setting the flag bit in the property_service.c. 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 in System/core/init/property_ Flag bits are declared and initialized in service.c, 0 is hidden, 1 is displayed, default is hidden

?
123      { 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:

?
123 privatestatic final String SHOW_PHONESKY = show_phonesky;privateCheckBoxPreference mShowPhonesky;mShowPhonesky = findAndInitCheckboxPref(SHOW_PHONESKY);


The logic of ②checkbox:

?
123456789        (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

?
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 666768697071727374757677787980818283848586878889909192      android:targetClass=com.android.settings.SetFullBackupPassword />     +       <checkboxpreference android:key="show_phonesky" android:title="@string/show_phonesky">     <checkboxpreference pre="">④添加对应语言的string字符:<pre class="brush:java;"><string name="show_phonesky">Show Google Play Store</string></pre><br><br>⑤设置中新增一个监听,初始化Checkbox的逻辑: packages/apps/Settings/src/com/android/settings/BootReceiver.java 内容如下:<pre class="brush:java;">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);                    }          }     }}</pre><br><br>⑥在Settings的AndroidManifest文件中添加BroadcastReceiver的权限和声明:<pre class="brush:java;"><uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED/"></uses-permission></pre><br>3.在init.rc中添加对应的服务和触发条件: 路径:mediatek/config/esky27_tb_ccn_mlc_kk/init.rc<pre class="brush:java;">+# ZJ Add START+#Hide or Show Google Play Dynamicly+#disabled:服务不会自动运行,必须显式地通过服务器来启动。+#oneshot:当此服务退出时不会自动重启。+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</pre><br><br>4.隐藏和显示应用的脚本: 隐藏应用:vendor/ThirdParty/App/dte/hidePhonesky 内容:<br><pre class="brush:java;">#!/system/bin/sh#!/system/bin/busyboxmount -o remount,rw /system;mv /system/priv-app/Phonesky.apk /system/priv-app/Phonesky.bak</pre><br>显示应用:vendor/ThirdParty/App/dte/showPhonesky<br>内容:<br><pre class="brush:java;">#!/system/bin/sh#!/system/bin/busyboxmount -o remount,rw /system;mv /system/priv-app/Phonesky.bak /system/priv-app/Phonesky.apk</pre><br><br>5.拷贝脚本到system/bin目录下: 参考以下格式添加到对应的mk文件:<pre class="brush:java;">+#添加重命名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</pre></checkboxpreference></checkboxpreference><br><br><br><br><br>

A companion tour, a free dating site: www.jieberu.com

Push family, free tickets, scenic spots: www.tuituizu.com

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.