/*********************************************************************
* I.MX6 Android 移除 Settings wifi功能
* 说明:
* 本文主要记录如何修改Android Settings中的主选项,初衷是有些
* 设置并不是我们需要,隐藏掉还是比较好的。
*
* 2016-3-5 深圳 南山平山村 曾剑锋
********************************************************************/ 参考文档:
. Android Settings开发之修改
http://blog.csdn.net/wangjinyu501/article/details/22077803
. Android Settings和SettingsProvider源码分析与修改
http://www.cncoders.net/article/11633/
. 何时使用 Preference Headers
http://blog.csdn.net/ixiaobu/article/details/8609935 一、cat packages/apps/Settings/AndroidManifest.xml
......
<!-- Settings --> <activity android:name="Settings" ------+
android:label="@string/settings_label_launcher" |
android:taskAffinity="com.android.settings" |
android:launchMode="singleTask"> |
<intent-filter> |
<action android:name="android.intent.action.MAIN" /> |
<action android:name="android.settings.SETTINGS" /> |
<category android:name="android.intent.category.DEFAULT" /> |
<category android:name="android.intent.category.LAUNCHER" /> |
</intent-filter> |
</activity> |
...... |
|
二、cat packages/apps/Settings/src/com/android/settings/Settings.java <---+
......
/**
* Populate the activity with the top-level headers.
*/
@Override
public void onBuildHeaders(List<Header> headers) {
loadHeadersFromResource(R.xml.settings_headers, headers);
|
updateHeaderList(headers); |
} |
...... |
V
三、cat packages/apps/Settings/res/xml/settings_headers.xml
......
<!-- Wifi -->
<!--
<header
android:id="@+id/wifi_settings"
android:fragment="com.android.settings.wifi.WifiSettings"
android:title="@string/wifi_settings_title"
android:icon="@drawable/ic_settings_wireless" />
-->
...... 四、error:
. error :
. 现象:
......
make: Entering directory `/home/myzr/myandroid'
target R.java/Manifest.java: Settings (out/target/common/obj/APPS/Settings_intermediates/src/R.stamp)
/home/myzr/myandroid/packages/apps/Settings/AndroidManifest.xml:: error: Error: No resource found that matches the given name (at 'resource' with value '@id/wifi_settings').
/home/myzr/myandroid/packages/apps/Settings/AndroidManifest.xml:: error: Error: No resource found that matches the given name (at 'resource' with value '@id/wifi_settings').
/home/myzr/myandroid/packages/apps/Settings/AndroidManifest.xml:: error: Error: No resource found that matches the given name (at 'resource' with value '@id/wifi_settings').
make: *** [out/target/common/obj/APPS/Settings_intermediates/src/R.stamp] Error
make: Leaving directory `/home/myzr/myandroid' . 解决办法:
cat packages/apps/Settings/AndroidManifest.xml
......
<!-- Top-level settings --> <!--
<activity android:name="Settings$WifiSettingsActivity"
android:taskAffinity=""
android:label="@string/wifi_settings"
android:configChanges="orientation|keyboardHidden|screenSize"
android:excludeFromRecents="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.WIFI_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.VOICE_LAUNCH" />
<category android:name="com.android.settings.SHORTCUT" />
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.wifi.WifiSettings" />
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
android:resource="@id/wifi_settings" />
</activity>
--> <!-- Keep compatibility with old shortcuts. -->
<!--
<activity-alias android:name=".wifi.WifiSettings"
android:taskAffinity="com.android.settings"
android:label="@string/wifi_settings"
android:targetActivity="Settings$WifiSettingsActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:exported="true">
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.wifi.WifiSettings" />
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
android:resource="@id/wifi_settings" />
</activity-alias> <activity android:name=".wifi.WifiPickerActivity"
android:taskAffinity="com.android.settings"
android:parentActivityName="Settings">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.net.wifi.PICK_WIFI_NETWORK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity> <activity android:name=".wifi.WifiSetupActivity"
android:theme="@style/setup_wizard_theme"
android:label="@string/wifi_setup_wizard_title"
android:icon="@drawable/empty_icon"
android:clearTaskOnLaunch="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="com.android.net.wifi.SETUP_WIFI_NETWORK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity> <activity android:name=".wifi.WifiSettingsForSetupWizardXL"
android:theme="@android:style/Theme.Holo.NoActionBar"
android:screenOrientation="behind"
android:clearTaskOnLaunch="true"
android:windowSoftInputMode="adjustResize"
android:exported="true" /> <activity android:name="Settings$AdvancedWifiSettingsActivity"
android:taskAffinity="com.android.settings"
android:label="@string/wifi_advanced_settings_label"
android:configChanges="orientation|keyboardHidden|screenSize"
android:parentActivityName="Settings$WifiSettingsActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.WIFI_IP_SETTINGS" />
<category android:name="android.intent.category.VOICE_LAUNCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.wifi.AdvancedWifiSettings" />
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
android:resource="@id/wifi_settings" />
<meta-data android:name="com.android.settings.PARENT_FRAGMENT_TITLE"
android:resource="@string/wifi_settings" />
<meta-data android:name="com.android.settings.PARENT_FRAGMENT_CLASS"
android:value="com.android.settings.Settings$WifiSettingsActivity" />
</activity>
-->
...... . error :
. 现象:
......
No private recovery resources for TARGET_DEVICE sabresd_6dq
make: Entering directory `/home/myzr/myandroid'
target R.java/Manifest.java: Settings (out/target/common/obj/APPS/Settings_intermediates/src/R.stamp)
(skipping file '.settings_headers.xml.swp' due to ANDROID_AAPT_IGNORE pattern '.*')
target Java: Settings (out/target/common/obj/APPS/Settings_intermediates/classes)
/home/myzr/myandroid/packages/apps/Settings/src/com/android/settings/Settings.java:: cannot find symbol
symbol : variable wifi_settings
location: class com.android.settings.R.id
} else if (id == R.id.wifi_settings) {
^
/home/myzr/myandroid/packages/apps/Settings/src/com/android/settings/Settings.java:: cannot find symbol
symbol : variable wifi_settings
location: class com.android.settings.R.id
} else if (header.id == R.id.wifi_settings || header.id == R.id.bluetooth_settings) {
^
/home/myzr/myandroid/packages/apps/Settings/src/com/android/settings/Settings.java:: cannot find symbol
symbol : variable wifi_settings
location: class com.android.settings.R.id
if (header.id == R.id.wifi_settings) {
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
errors
make: *** [out/target/common/obj/APPS/Settings_intermediates/classes-full-debug.jar] Error
make: Leaving directory `/home/myzr/myandroid' . 解决办法:
cat packages/apps/Settings/src/com/android/settings/Settings.java
......
// Show only these settings for restricted users
private int[] SETTINGS_FOR_RESTRICTED = {
R.id.wireless_section,
//R.id.wifi_settings,
R.id.bluetooth_settings,
R.id.data_usage_settings,
R.id.wireless_settings,
R.id.device_section,
R.id.sound_settings,
R.id.display_settings,
R.id.storage_settings,
R.id.application_settings,
R.id.battery_settings,
R.id.personal_section,
R.id.location_settings,
R.id.security_settings,
R.id.language_settings,
R.id.user_settings,
R.id.account_settings,
R.id.account_add,
R.id.system_section,
R.id.date_time_settings,
R.id.about_settings,
R.id.accessibility_settings
}
......
private void updateHeaderList(List<Header> target) {
while (i < target.size()) {
Header header = target.get(i);
// Ids are integers, so downcasting
int id = (int) header.id;
if (id == R.id.operator_settings || id == R.id.manufacturer_settings) {
Utils.updateHeaderToSpecificActivityFromMetaDataOrRemove(this, target, header);
}
/** annotation this part
else if (id == R.id.wifi_settings) {
// Remove WiFi Settings if WiFi service is not available.
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI)) {
target.remove(i);
}
}
*/
else if (id == R.id.bluetooth_settings) {
// Remove Bluetooth Settings if Bluetooth service is not available.
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
target.remove(i);
}
} else if (id == R.id.data_usage_settings) {
......
......
}
......
private static class HeaderAdapter extends ArrayAdapter<Header> {
......
static int getHeaderType(Header header) {
if (header.fragment == null && header.intent == null) {
return HEADER_TYPE_CATEGORY;
} else if (
/** annotation this part
header.id == R.id.wifi_settings ||
*/
header.id == R.id.bluetooth_settings) {
return HEADER_TYPE_SWITCH;
} else {
return HEADER_TYPE_NORMAL;
}
}
......
}
......
@Override
public View getView(int position, View convertView, ViewGroup parent) {
......
// All view fields must be updated every time, because the view may be recycled
switch (headerType) {
case HEADER_TYPE_CATEGORY:
holder.title.setText(header.getTitle(getContext().getResources()));
break; case HEADER_TYPE_SWITCH:
// Would need a different treatment if the main menu had more switches
/** annotation this part
if (header.id == R.id.wifi_settings) {
mWifiEnabler.setSwitch(holder.switch_);
} else {
*/
mBluetoothEnabler.setSwitch(holder.switch_);
/*
}
*/
// No break, fall through on purpose to update common fields //$FALL-THROUGH$
case HEADER_TYPE_NORMAL:
if (header.extras != null
&& header.extras.containsKey(ManageAccountsSettings.KEY_ACCOUNT_TYPE)) {
String accType = header.extras.getString(
ManageAccountsSettings.KEY_ACCOUNT_TYPE);
ViewGroup.LayoutParams lp = holder.icon.getLayoutParams();
lp.width = getContext().getResources().getDimensionPixelSize(
R.dimen.header_icon_width);
lp.height = lp.width;
holder.icon.setLayoutParams(lp);
Drawable icon = mAuthHelper.getDrawableForType(getContext(), accType);
holder.icon.setImageDrawable(icon);
} else {
holder.icon.setImageResource(header.iconRes);
}
holder.title.setText(header.getTitle(getContext().getResources()));
CharSequence summary = header.getSummary(getContext().getResources());
if (!TextUtils.isEmpty(summary)) {
holder.summary.setVisibility(View.VISIBLE);
holder.summary.setText(summary);
} else {
holder.summary.setVisibility(View.GONE);
}
break;
}
......
}
......

I.MX6 Android 移除 Settings wifi功能的更多相关文章

  1. I.MX6 android 移除shutdown功能

    /************************************************************************ * I.MX6 android 移除shutdown ...

  2. 解决Android 6.0获取wifi Mac地址为02:00:00:00:00:00问题【转】

    本文转载自:http://www.jb51.net/article/128398.htm 这篇文章主要介绍了Android 6.0获取wifi Mac地址为02:00:00:00:00:00的解决方法 ...

  3. I.MX6 Android 5.1 快速合成系统

    /**************************************************************************** * I.MX6 Android 5.1 快速 ...

  4. I.MX6 Android netperf

    /***************************************************************************** * I.MX6 Android netpe ...

  5. I.MX6 Android U-blox miniPCI 4G porting

    /************************************************************************** * I.MX6 Android U-blox m ...

  6. I.MX6 android 设置 默认 动态桌面

    /************************************************************************ * I.MX6 android 设置 默认 动态桌面 ...

  7. I.MX6 android 禁止低电量自动关机

    /************************************************************************ * I.MX6 android 禁止低电量自动关机 ...

  8. Android KitKat 4.4 Wifi移植AP模式和网络共享的调试日志

    Tethering技术在移动平台上已经运用的越来越广泛了.它能够把移动设备当做一个接入点,其它的设备能够通过Wi-Fi.USB或是Bluetooth等方式连接到此移动设备.在Android中能够将Wi ...

  9. 用ESP8266+android,制作自己的WIFI小车(Android 软件)

    先说一下这篇文章里面的内容:TCP 客户端, 自定义对话框, 自定义按钮, ProgressBar竖直显示, 重力感应传感器,手机返回键新开启界面的问题(返回上次的界面),数据保存 软件的通信是配合 ...

随机推荐

  1. 关于Segmentation fault (core dumped)几个简单问题的整理

    有的程序可以通过编译,但在运行时会出现Segment fault(段错误).这通常都是指针错误引起的.但这不像编译错误一样会提示到文件一行,而是没有任何信息.一种办法是用gdb的step, 一步一步寻 ...

  2. Android:使用命令行工具adb、mksdcard等

    有一些Android的工具需要在命令行的环境中运行,只是可以选择Windows的开始->运行,键入cmd并确定,进入命令行的界面中运行.主要的命令行工具包括adb和mksdcard等.命令行的工 ...

  3. 1065. A+B and C (64bit)

    #include<stdio.h> #include <math.h> int main() { long long a,b,c,sum; int n,i; while(sca ...

  4. MySQL 5.6.21 最新版的安装

    上一篇 写了对于入门者来说困难的事情,博主最近装了mysql软件,下面来看看mysql的安装. 下载mysql软件安装程序,我的是在百度软件中心上下载的,选择百度是因为里面没有什么捆绑软件: 下载完了 ...

  5. ORACLE中常见的几种锁

    ORACLE中常见的几种锁: 0:none 1:null 空 2:Row-S 行共享(RS):共享表锁,sub share 3:Row-X 行独占(RX):用于行的修改,sub exclusive 4 ...

  6. 【css】web标准

    网页主要由三部分组成:结构(Structure).表现(Presentation)和行为(Behavior) 结构重点理解: XHTML 1.应用形式 ccs+div  2000 2.基于xml 和x ...

  7. http://blog.csdn.net/itplus/article/details/10088625

    http://blog.csdn.net/itplus/article/details/10088625 DBSCAN

  8. Maven 解决JAR包冲突

    在JAR 冲突的情况下, 利用Eclipse方式解决JAR包冲突时比较方便简洁的,步骤如下 1. 在Eclipse 中打开pom.xml , 选择  “Dependency  Hierarchy” 2 ...

  9. Binary search for the first element greater than target

    We all know how to search through an array for an element whose value equals the target value, but h ...

  10. <base target="_blank"/>

    <base target=_blank> 是将基本链接的目标框架都改为新页打开