以实现在设置中添加USB选项,切换HOST模式与OTG模式为例:
1,settings 应用一般在 目录:\packages\apps\Settings\src\com\android\settings\SettingsActivity.java 设置java文件
主要看如下方法:
private void updateTilesList(Listtarget) {
final boolean showDev = mDevelopmentPreferences.getBoolean(
DevelopmentSettings.PREF_SHOW,
android.os.Build.TYPE.equals("eng"));
final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
final int size = target.size();
for (int i = 0; i < size; i++) {
DashboardCategory category = target.get(i);
// Ids are integers, so downcasting is ok
int id = (int) category.id;
int n = category.getTilesCount() - 1;
while (n >= 0) {
DashboardTile tile = category.getTile(n);
boolean removeTile = false;
id = (int) tile.id;
if (id == R.id.operator_settings || id == R.id.manufacturer_settings) {
if (!Utils.updateTileToSpecificActivityFromMetaDataOrRemove(this, tile)) {
removeTile = true;
}
} else if (id == R.id.wifi_settings) {
// Remove WiFi Settings if WiFi service is not available.
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI)) {
removeTile = true;
}
} else if (id == R.id.bluetooth_settings) {
// Remove Bluetooth Settings if Bluetoo