I.MX6 Android 移除 Settings wifi功能
/*********************************************************************
* 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功能的更多相关文章
- I.MX6 android 移除shutdown功能
/************************************************************************ * I.MX6 android 移除shutdown ...
- 解决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的解决方法 ...
- I.MX6 Android 5.1 快速合成系统
/**************************************************************************** * I.MX6 Android 5.1 快速 ...
- I.MX6 Android netperf
/***************************************************************************** * I.MX6 Android netpe ...
- I.MX6 Android U-blox miniPCI 4G porting
/************************************************************************** * I.MX6 Android U-blox m ...
- I.MX6 android 设置 默认 动态桌面
/************************************************************************ * I.MX6 android 设置 默认 动态桌面 ...
- I.MX6 android 禁止低电量自动关机
/************************************************************************ * I.MX6 android 禁止低电量自动关机 ...
- Android KitKat 4.4 Wifi移植AP模式和网络共享的调试日志
Tethering技术在移动平台上已经运用的越来越广泛了.它能够把移动设备当做一个接入点,其它的设备能够通过Wi-Fi.USB或是Bluetooth等方式连接到此移动设备.在Android中能够将Wi ...
- 用ESP8266+android,制作自己的WIFI小车(Android 软件)
先说一下这篇文章里面的内容:TCP 客户端, 自定义对话框, 自定义按钮, ProgressBar竖直显示, 重力感应传感器,手机返回键新开启界面的问题(返回上次的界面),数据保存 软件的通信是配合 ...
随机推荐
- IE10用video标签播放本地mp4文件失败的解决办法
1. 首先用“格式工厂”将要播放的视频文件按照“AVC高质量与大小”转换为要求格式的mp4文件: 2. 设置IIS7.5,添加mp4的MIME类型,步骤如下: 1.打开IIS管理器(运行inetmgr ...
- 微软职位内部推荐-Senior Network Engineer
微软近期Open的职位: Global Foundation Services is the team behind the cloud. GFS is responsible for deliver ...
- Castle ActiveRecord简单介绍
Castle ActiveRecord框架是一个基于.NET的ORM框架,它实现了ActiveRecord设计模式.它本身就是基于NHibernate,只是封 装了NHibernate的大部分烦杂细节 ...
- Xcode 向6.0以后版本添加iOS开发空白模板
打开finder,找到应用程序,找到xcode 右键显示包内容.按照如下目录进行查找:Contents ▸ Developer ▸ Platforms ▸ iPhoneOS.platform ▸ De ...
- mybatis include标签
使用mybatis 的include标签达到SQL片段达到代码复用的目的 示例: xml文件 <sql id="paysql"> payid,p.oid,p.bdate ...
- BZOJ 3288 Mato矩阵 解题报告
这个题好神呀..Orz taorunz 有一个结论,这个结论感觉很优美: $$ans = \prod_{i=1}^{n}\varphi(i)$$ 至于为什么呢,大概是这样子的: 对于每个数字 $x$, ...
- [转载]Unity3D 游戏引擎之使用C#语言建立本地数据库(SQLITE)
以前在开发中一直使用IOS源生的数据库,通过传递消息的形式在与Unity3D中进行交互.本文我在详细说说如何使用C#语言来在MAC 操作系统下创建Unity本地数据库,我是C#控哇咔咔--- 首先你需 ...
- [转载]Unity3D的断点调试功能
断点调试功能可谓是程序员必备的功能了.Unity3D支持编写js和c#脚本,但很多人可能不知道,其实Unity3D也能对程序进行断点调试的.不过这个断点调试功能只限于使用Unity3D自带的MonoD ...
- 团体程序设计天梯赛-练习集L1-002. 打印沙漏
L1-002. 打印沙漏 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 本题要求你写个程序把给定的符号打印成沙漏的形状.例如给 ...
- Window Event 2008
https://support.microsoft.com/en-us/kb/947226