android的預設引數的修改
轉自::http://blog.csdn.net/cbk861110/article/details/25216765
重點的幾項是:
5.設定--》開發者選項--修改後臺程序限制
frameworks/base/services/java/com/android/server$vi ./am/ActivityManagerService.java
大概839行 把int mProcessLimitOverride = -1;改成4(不得超過4個程序)
標準限制對應 -1
不允許後臺程序對應 0
不得超過1個程序 對應 1
不得超過2個程序 對應 2
不得超過3個程序 對應 3
6. 預設不要鎖屏,設定-安全--螢幕鎖定 (無)
overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
<bool name="def_lockscreen_disabled">true</bool>
7. 位置服務--- 預設Google的位置服務為勾選
overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
<stringname="def_location_providers_allowed"translatable="false">gps</string>
改成
<stringname="def_location_providers_allowed"translatable="false">gps,network</string>
常用修改
一. 修改預設(Settting.apk 中選項預設值一般存在於frameworks\base\packages\SettingsProvider\res\values\defaults.xml)
1. 預設勾選未知來源
<boolname="def_install_non_market_apps">false</bool>
2. 預設鈴聲, 通知, 鬧鐘音樂
可以在system.prop 分別配置
ro.config.ringtone=Playa.ogg(預設鈴聲設定,檔案在/system/media/audio/ringtones 把喜歡的鈴聲放這裡,比如123.MP3放入ringtones資料夾中,這裡程式碼改為ro.config.ringtone=123.mp3)
ro.config.notification_sound=regulus.ogg(預設提示音,檔案在/system/media/audio/notifications 修改方法同上)
ro.config.alarm_alert=Alarm_Beep_03.ogg(預設鬧鈴,檔案在/system/media/audio/alarms 修改方法同上)
3. 桌布不跟隨滑動
packages/apps/Launcher2/./src/com/android/launcher2/Workspace.java 大概 875行
private float wallpaperOffsetForCurrentScroll()
修改 wallpaperOffsetForCurrentScroll 的返回值。改成 return 0.5f;
Launcher 總結:
1、launcher的佈局太居中,要想兩邊拉伸
<\packages\apps\Launcher2\res\values\dimens.xml>
<dimen name=" apps_customize_pageLayoutPaddingLeft">40dp</dimen>
<dimen name=" apps_customize_pageLayoutPaddingRight">40dp</dimen>
apps tab欄的寬度( Launcher2icon 數目、大小)
\packages\apps\Launcher2\res\layout-sw720dp\workspace.xml>
launcher:cellCountX="10"
launcher:cellCountY="6"
2、或者不想改數目:
<\packages\apps\Launcher2\src\com\android\launcher2\AppsCustomizeTabHost.java>
protected void onMeasure(intwidthMeasureSpec, int heightMeasureSpec) {
mTabs.getLayoutParams().width= contentWidth + 108;
3、workspace、AppsCustomize的cell大小:
<\packages\apps\Launcher2\res\values-sw600dp\dimens.xml>
<dimenname="workspace_cell_width">110dip</dimen>
<dimen name="workspace_cell_height">110dip</dimen>
<dimenname="apps_customize_cell_width">110dp</dimen>
<dimen name="apps_customize_cell_height">110dp</dimen>
4、裡面icon的大小:
<\packages\apps\Launcher2\res\values-sw600dp\dimens.xml>
<dimenname="app_icon_size">80dp</dimen>
5、workspace沒有拖動,第二頁第一個icon出現在第一頁的最右邊:
加大workspace的寬度,或間距:
workspace的paddingLeft、paddingRight:
<\packages\apps\Launcher2\res\values-sw600dp-land\dimens.xml>
<dimenname="workspace_left_padding">50dip</dimen>
<dimen name="workspace_right_padding">50dip</dimen>
workspace兩屏間距:
<dimen name="workspace_page_spacing">100dp</dimen>
修改workspace的字型大小:
如果沒有就新增:
<\packages\apps\Launcher2\res\values-sw480dp\styles.xml>
<style name="WorkspaceIcon.Landscape">
<item name="android:textSize">13sp</item>
</style>
6、加wallpaper:
1.<\packages\apps\Launcher2\res\values-sw600dp\wallpapers.xml>
加wallpaper的名字
2.<\packages\apps\Launcher2\res\drawable-nodpi>
加如wallpaper
7、gallery的widget預設新增到workspace上:
<\packages\apps\Launcher2\res\xml\default_workspace.xml>
<!-- Middle screen [2] -->
<appwidget
launcher:packageName="com.android.gallery3d"
launcher:className="com.android.gallery3d.gadget.PhotoAppWidgetProvider"
launcher:screen="2"
launcher:x="1"
launcher:y="0"
launcher:spanX="3"
launcher:spanY="3" />
<\packages\apps\Gallery2\src\com\android\gallery3d\gadget\PhotoAppWidgetProvider.java>
@Override
public void onUpdate(Contextcontext,
for (int id : appWidgetIds) {
if(id == 2){
helper.setWidget(id,WidgetDatabaseHelper.TYPE_SHUFFLE,null);
}
}
8、在桌面上新增網頁的快捷方式:
<\packages\apps\Launcher2\res\xml\default_workspace.xml>
<shortcut
launcher:title="@string/application_name"
launcher:icon="@drawable/ic_no_applications"
launcher:uri="http://www.aaa.com"
launcher:screen="0"
launcher:x="0"
launcher:y="3" />
9、在桌面上預設放資料夾:
<\packages\apps\Launcher2\res\xml\default_workspace.xml>
<folder
launcher:screen="2"
launcher:x="2"
launcher:y="2"
launcher:title ="@string/application_name" >
<favorite
launcher:className="com.android.deskclock.DeskClock"
launcher:packageName="com.android.deskclock"
launcher:container="1"
launcher:x="0"
launcher:y="0"/>
<favorite
launcher:className="com.android.calculator2.Calculator"
launcher:packageName="com.android.calculator2"
launcher:container="1"
launcher:x="0"
launcher:y="0"/>
</folder>
10、桌面上新增快捷方式,點選播放視訊:
<\packages\apps\Launcher2\res\xml-sw720dp\default_workspace.xml>
<shortcutlauncher:title="@string/application_name"
launcher:icon="@drawable/ic_launcher_application"
launcher:uri="file:///mnt/sdcard/external_sdcard/1...playermenu;end"
launcher:screen="2"
launcher:x="1"
launcher:y="1"/>
11、安裝apk,顯示隱藏的google play:
1.寫google顯示的apk:
GooglePlayShow的activity:
ComponentName componentname = newComponentName("com.android.vending","com.android.vending.AssetBrowserActivity");
packagemanager.setComponentEnabledSetting(componentname, 1, 1);
componentname = new ComponentName("com.example.googleplayshow","com.example.googleplayshow.MainActivity");
packagemanager.setComponentEnabledSetting(componentname, 2, 1);
2.<\packages\apps\Launcher2\src\com\android\launcher2\LauncherModel.java>
} else if(Intent.ACTION_PACKAGE_ADDED.equals(action)) {
if (!replacing) {
if(packageName.equals("com.example.googleplayshow")){
context.startActivity(new Intent().setComponent(new ComponentName("com.example.googleplayshow","com.example.googleplayshow.MainActivity")).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
op = PackageUpdatedTask.OP_ADD;
} else {
op = PackageUpdatedTask.OP_UPDATE;
}
}
隱藏google search:
<\packages\apps\Launcher2\src\com\android\launcher2\Launcher.java>
private void setupViews() {
mSearchDropTargetBar = (SearchDropTargetBar)mDragLayer.findViewById(R.id.qsb_bar);
mSearchDropTargetBar.hideSearchBar(false);
void showWorkspace(boolean animated, Runnable onCompleteRunnable) {
//mSearchDropTargetBar.showSearchBar(wasInSpringLoadedMode);
12、widget中隱藏google play:
<\packages\apps\Launcher2\src\com\android\launcher2\AppsCustomizePagedView.java>
updatePackages裡面新增:
if(!widget.provider.getPackageName().equals("com.android.vending")&&!widget.provider.getPackageName().equals("com.android.vending.MarketWidgetProvider")){
mWidgets.add(widget);
}
13、clock的widget下部分顯示不全,向上調
<\packages\amlogic\Launcher2\res\values\dimens.xml>
<dimen name="app_widget_preview_padding_top">10dp</dimen>
修改widget的text的size:
<\packages\amlogic\Launcher2\res\layout\apps_customize_widget.xml>
android:id="@+id/widget_name"
android:textSize="20sp" />
14、launcher中隱藏一個app:
需要該app的packageName,例如要隱藏settings:
<\packages\apps\Launcher2\src\com\android\launcher2\LauncherModel.java>
private void loadAllAppsByBatch() {
apps =packageManager.queryIntentActivities(mainIntent, 0);
ResolveInfo removeApp =null;
for(ResolveInfoinfo:apps){
if(info.activityInfo.packageName.equals("com.android.settings")){
removeApp = info;
}
}
if(removeApp != null){
apps.remove(removeApp);
}
15、launcher中隱藏多個app:紅色為改動部分
<\packages\apps\Launcher2\src\com\android\launcher2\LauncherModel.java>
private void loadAllAppsByBatch() {
final PackageManager packageManager = mContext.getPackageManager();
List<ResolveInfo> apps = newArrayList<ResolveInfo>();
List<ResolveInfo> allApps = null;
int N = Integer.MAX_VALUE;
int startIndex;
int i=0;
int batchSize = -1;
while (i < N && !mStopped) {
if (i == 0) {
mAllAppsList.clear();
final long qiaTime =DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;
allApps =packageManager.queryIntentActivities(mainIntent, 0);
for(ResolveInfo info :allApps){
if(info.activityInfo != null
&& !info.activityInfo.packageName.equalsIgnoreCase("com.android.email")
&&!info.activityInfo.packageName.equalsIgnoreCase("com.android.providers.downloads.ui")
&& !info.activityInfo.packageName.equalsIgnoreCase("com.adobe.flashplayer")){
apps.add(info);
}
}
settings 問題總結:
1.入口,設定分屏顯示
frameworks\base\core\res\res\values\bools.xml下的 preferences_prefer_dual_pane 為true.
<bool name="preferences_prefer_dual_pane">true</bool>
2.top level headers--這裡可以去掉左邊的headers
<settings.java>
private voidupdateHeaderList(List<Header> target) {
if(!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
target.remove(header);
}
3.預設字型:
public voidreadFontSizePreference(ListPreference pref) {
ActivityManagerNative.getDefault().getConfiguration()
系統的Configuration是從ActivityManagerService設定的:
<\frameworks\base\services\java\com\android\server\am\ActivityManagerService.java>
mConfiguration.setToDefaults();
fontScale =Float.parseFloat(SystemProperties.get("ro.fontScale","1"));
4.settings的theme:
<\packages\apps\Settings\AndroidManifest.xml>
<application android:label="@string/settings_label"
android:icon="@mipmap/ic_launcher_settings"
android:taskAffinity=""
android:theme="@android :style/Theme.Holo"
android:uiOptions="splitActionBarWhenNarrow"
android:hardwareAccelerated="true">
<\frameworks\base\core\res\res\values\themes.xml>
<stylename="Theme.Holo">
字型顏色
<itemname="textColorPrimary">@android :color/primary_text_holo_dark</item>
加亮框的顏色:
<itemname="activatedBackgroundIndicator">@android:drawable/activated_background_holo_dark</item>
觸控框的顏色:
<itemname="listChoiceBackgroundIndicator">@android :drawable/list_selector_holo_dark</item>
左邊背景:
<itemname="windowBackground">@android :drawable/screen_background_selector_dark</item>
右邊的背景:
<itemname="detailsElementBackground">@android :drawable/panel_bg_holo_dark</item>
title的背景:
<itemname="actionBarStyle">@android :style/Widget.Holo.ActionBar</item>
5.設定--》開發者選項--修改後臺程序限制
frameworks/base/services/java/com/android/server$vi ./am/ActivityManagerService.java
大概839行 把int mProcessLimitOverride = -1;改成4(不得超過4個程序)
標準限制對應 -1
不允許後臺程序對應 0
不得超過1個程序 對應 1
不得超過2個程序 對應 2
不得超過3個程序 對應 3
6. 預設不要鎖屏,設定-安全--螢幕鎖定 (無)
overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
<bool name="def_lockscreen_disabled">true</bool>
7. 位置服務--- 預設Google的位置服務為勾選
overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
<stringname="def_location_providers_allowed"translatable="false">gps</string>
改成
<stringname="def_location_providers_allowed"translatable="false">gps,network</string>
常用修改
一. 修改預設(Settting.apk 中選項預設值一般存在於frameworks\base\packages\SettingsProvider\res\values\defaults.xml)
1. 預設勾選未知來源
<boolname="def_install_non_market_apps">false</bool>
2. 預設鈴聲, 通知, 鬧鐘音樂
可以在system.prop 分別配置
ro.config.ringtone=Playa.ogg(預設鈴聲設定,檔案在/system/media/audio/ringtones 把喜歡的鈴聲放這裡,比如123.MP3放入ringtones資料夾中,這裡程式碼改為ro.config.ringtone=123.mp3)
ro.config.notification_sound=regulus.ogg(預設提示音,檔案在/system/media/audio/notifications 修改方法同上)
ro.config.alarm_alert=Alarm_Beep_03.ogg(預設鬧鈴,檔案在/system/media/audio/alarms 修改方法同上)
3. 桌布不跟隨滑動
packages/apps/Launcher2/./src/com/android/launcher2/Workspace.java 大概 875行
private float wallpaperOffsetForCurrentScroll()
修改 wallpaperOffsetForCurrentScroll 的返回值。改成 return 0.5f;
二.隱藏或刪除某項
1.去掉設定中Wifi選項
device/amlogic/xxxref/xxxref.mk 檔案中
# Device specific system feature description
PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/tablet_core_hardware.xml:system/etc/permissions/tablet_core_hardware.xml\
frameworks/native/data/etc/android.hardware.wifi.xml:system/etc/permissions/android.hardware.wifi.xml\ (刪除)
2.去掉設定中藍芽選項
參考 wifi。
在 tablet_core_hardware.xml 刪除 <feature name="android.hardware.bluetooth"/> 這一行
3. HDMI 部分
1)去掉HDMI選項 在system.prop中加入 ro.hdmi.autoswitch=false
2)去掉480p 選項在prop中設定 ro.hdmi480p.enable=false
4. 去掉 powerwidget 中某一項
以去掉 gps 為例
在 packages\apps\Settings\res\layout\widget.xml 下,移除
<ImageView
android:layout_width="1dip"
android:layout_height="match_parent"
android:background="@drawable/appwidget_settings_divider_holo"
android:contentDescription="@null"
/>
<LinearLayout
android:id="@+id/btn_bluetooth"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="match_parent"
android:paddingTop="12dp"
android:background="@drawable/appwidget_button_center"
android:clickable="true"
android:focusable="true"
android:orientation="vertical">
<ImageView
android:id="@+id/img_bluetooth"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:scaleType="center"
android:contentDescription="@null"
/>
<ImageView
android:id="@+id/ind_bluetooth"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:contentDescription="@null"
/>
</LinearLayout>
然後 com.android.settings.widget.SettingsAppWidgetProvider.java
註釋 views.setOnClickPendingIntent(R.id.btn_gps, getLaunchPendingIntent(context,BUTTON_GPS)); 這一行。
5. 去掉 Setting widget 中某一項
以去掉 "網路共享與行動式熱點" 為例
根據"網路共享與行動式熱點" 這個關鍵詞在 values-zh_rCN 中搜索到的 key值,然後在AndroidManifest.xml 搜尋這個 key值。找到對於的Activity 配置
移除 <category android:name="com.android.settings.SHORTCUT"/> 這一行。
6. 修改瀏覽器預設瀏覽器模式
packages\apps\Browser\res\xml-sw600dp\advanced_preferences.xml
<ListPreference
android:key="user_agent"
android:title="@string/pref_development_uastring"
android:entries="@array/pref_development_ua_choices"
android:entryValues="@array/pref_development_ua_values"
android:defaultValue="3"/>
修改 android:defaultValue="3" 具體的值參考一下選項
<string-arrayname="pref_development_ua_choices" translatable="false">
<item>Android</item>
<item>Desktop</item>
<item>iPhone</item>
<item>iPad</item>
<item>Froyo-N1</item>
<item>Honeycomb-Xoom</item>
</string-array>
<!-- Do not tranlsate. Development option -->
<string-array name="pref_development_ua_values"translatable="false">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
7. workspace 預置資料夾
範例
folder 放到最前面。launcher:container 的值是folder的資料庫中的id。一般從1開始。
<folder
launcher:screen="2"
launcher:x="1"
launcher:y="1"
launcher:title="@string/application_name" >
<favorite
launcher:className="com.android.settings"
launcher:packageName="com.android.settings.Settings"
launcher:container="2"
launcher:x="0"
launcher:y="0" />
<favorite
launcher:className="com.fb.FileBrower"
launcher:packageName="com.fb.FileBrower.FileBrower"
launcher:container="2"
launcher:x="0"
launcher:y="0" />
</folder>
widget 範例
<appwidget
launcher:packageName="com.android.calendar"
launcher:className="com.android.calendar.widget.CalendarAppWidgetProvider"
launcher:screen="1"
launcher:x="0"
launcher:y="0"
launcher:spanX="2"
launcher:spanY="3" />
快捷方式範例
<favorite
launcher:packageName="com.android.settings"
launcher:className="com.android.settings.Settings"
launcher:screen="2"
launcher:x="1"
launcher:y="3" />
網頁快捷方式
<shortcut
launcher:title="@string/custom_google"
launcher:icon="@drawable/favicon_google"
launcher:screen="3"
launcher:x="4"
launcher:y="1"/>
8. 系統自帶LatinIME 高階設定--按鍵音量設定 修改預設值
java/res/values/keypress-volumes.xml
<string-arrayname="keypress_volumes" translatable="false">
<!-- Build.HARDWARE,volume -->
<item>amlogic,0.3</item> //加入這行。把0.3改成自己的預設值。0.3代表30%
<item>herring,0.5</item>
<item>tuna,0.5</item>
<item>stingray,0.4</item>
9.lockscreen座標數字時鐘被遮住
請調整紅色的數字:
<\frameworks\base\core\res\res\layout-sw600dp\keyguard_screen_tab_unlock_land.xml>
<!-- left side: status and music -->
<RelativeLayout
android:layout_height="match_parent"
android:layout_weight="0.5"
<!-- righ