一些常用的開關
Config.xml
路徑指向位置為framework/base/core/res/res/valuse/configs.xml
最近因為要移除通話相關的子產品。除了改改字元串這些的,有些東西用一些value配置了
。是以如果需要移除通話,短信這塊的UI顯示還有功能相關的。找了找幾個簡單的做了一個彙總
<string-array translatable="false" name="networkAttributes">
<item>"wifi,1,1,1,-1,true"</item> <!--wifi是否支援 -->
<!-- <item>"mobile,0,0,0,-1,true"</item>--> <!--資料連接配接是否支援 比如設定裡面的第一項的summary和手機資料連接配接相關的都是通過這個東西控制的-->
<item>"wifi_p2p,13,1,0,-1,true"</item>
<item>"bluetooth,7,7,1,60000,true"</item>
<item>"ethernet,9,9,2,-1,true"</item>
</string-array>
<!-- 語音通話是否支援 -->
<bool name="config_voice_capable">false</bool>
<!-- 短信是否支援 -->
<bool name="config_sms_capable">false</bool>
PackageManager.hasSystemFeature(XXXX)
這些是偏向一些硬體(sensor)功能的 當然還有一些系統服務,比如GPS位置資訊/多點觸摸/螢幕旋轉/閃光燈這塊的// 具體的呢是看 system|vendor|odm|oem 下的etc/sysconfig中的一些xml清單
這個xml的讀取是在SystemConfig.java中的,godir 去找位置看看是怎麼個read法的就行了
這裡面還有很多一些關于權限的配置。補充一個xml吧
<permissions>
<!-- This is Android and fully CTS compatible. Basically this is for CTS tests to use. -->
<feature name="android.software.cts" />
<!-- basic hardware feature for tablet -->
<feature name="android.hardware.audio.output" />
<feature name="android.hardware.location" />
<feature name="android.hardware.location.network" />
<feature name="android.hardware.sensor.accelerometer" />
<feature name="android.hardware.touchscreen" />
<feature name="android.hardware.touchscreen.multitouch" />
<feature name="android.hardware.touchscreen.multitouch.distinct" />
<feature name="android.hardware.faketouch" />
<feature name="android.hardware.microphone" />
<feature name="android.hardware.screen.landscape" />
<feature name="android.hardware.screen.portrait" />
<!-- basic system services -->
<feature name="android.software.app_widgets" />
<feature name="android.software.connectionservice" />
<feature name="android.software.voice_recognizers" />
<feature name="android.software.backup" />
<feature name="android.software.home_screen" />
<feature name="android.software.input_methods" />
<!-- Feature to specify if the device supports adding device admins. -->
<feature name="android.software.device_admin" />
</permissions>
設定中的預設開關
SettingsProvider裡面 就不詳細贅述了
SystemProperties
emmm 這個也是一些開關 有些可以set 有些不可以,ro開頭的一般是寫死固定的 persit開頭的是可以修改的。重新開機也會儲存的,昨天遇到一個問題,是問了一下朋友才解決的
在Gallery2中 我import android.os.SystemProperties;的時候始終找不到這個類。編譯報錯,想了想可能是makefile的原因,但是一時半會想不出,然後請教了一下朋友。是因為LOCAL_SDK_VERSION := current 引起的,這個是不編譯隐藏api 很遺憾 我們的SystemProperties 就是隐藏的API,還要加個LOCAL_PRIVATE_PLATFORM_APIS := true 使用SDK的隐藏API進行編譯。就可以了
SystemUI QSTile的一些預設展示項
frameworks/base/packages/SystemUi/src/com/android/systemui/qs/QSTileHost.java
protected List<String> loadTileSpecs(Context context, String tileList) {
final Resources res = context.getResources();
final String defaultTileList = res.getString(R.string.quick_settings_tiles_default);//這裡是預設配置項
if (tileList == null) {
tileList = res.getString(R.string.quick_settings_tiles);
if (DEBUG) Log.d(TAG, "Loaded tile specs from config: " + tileList);
} else {
if (DEBUG) Log.d(TAG, "Loaded tile specs from setting: " + tileList);//注意此LOG資訊
}
final ArrayList<String> tiles = new ArrayList<String>();
boolean addedDefault = false;
for (String tile : tileList.split(",")) {
tile = tile.trim();
if (tile.isEmpty()) continue;
if (tile.equals("default")) {
if (!addedDefault) {
tiles.addAll(Arrays.asList(defaultTileList.split(",")));
addedDefault = true;
}
} else {
tiles.add(tile);
}
}
return tiles;
}
Android O 新增了一個TileService 可以通過Tileservice去新增部分自定義的QStiles。按照以前的修改方式就是修改configs.xml中的
<string name="quick_settings_tiles_default" translatable="false">
wifi,bt,dnd,flashlight,battery,cell,airplane,cast
</string>
但是我們不知道這些wifi bt dnd 是有在QSFactoryImpl.java中的createTile函數中對應的
public QSTile createTile(String tileSpec) {
if (tileSpec.equals("wifi")) return new WifiTile(mHost);
else if (tileSpec.equals("bt")) return new BluetoothTile(mHost);
else if (tileSpec.equals("cell")) return new CellularTile(mHost);
else if (tileSpec.equals("dnd")) return new DndTile(mHost);
else if (tileSpec.equals("inversion")) return new ColorInversionTile(mHost);
else if (tileSpec.equals("airplane")) return new AirplaneModeTile(mHost);
else if (tileSpec.equals("work")) return new WorkModeTile(mHost);
else if (tileSpec.equals("rotation")) return new RotationLockTile(mHost);
else if (tileSpec.equals("flashlight")) return new FlashlightTile(mHost);
else if (tileSpec.equals("location")) return new LocationTile(mHost);
else if (tileSpec.equals("cast")) return new CastTile(mHost);
else if (tileSpec.equals("hotspot")) return new HotspotTile(mHost);
else if (tileSpec.equals("user")) return new UserTile(mHost);
else if (tileSpec.equals("battery")) return new BatterySaverTile(mHost);
else if (tileSpec.equals("saver")) return new DataSaverTile(mHost);
else if (tileSpec.equals("night")) return new NightDisplayTile(mHost);
else if (tileSpec.equals("nfc")) return new NfcTile(mHost);
// Intent tiles.
else if (tileSpec.startsWith(IntentTile.PREFIX)) return IntentTile.create(mHost, tileSpec);
else if (tileSpec.startsWith(CustomTile.PREFIX)) return CustomTile.create(mHost, tileSpec);
else {
Log.w(TAG, "Bad tile spec: " + tileSpec);
return null;
}
}
是以想新增一些第三方tileview的話,建議還是在QSTileHost中打開開關DEBUG,重新編譯push
然後自己手動添加想要的tileview 然後這裡 會列印出來的 要注意的LOG資訊是
if (DEBUG) Log.d(TAG, "Loaded tile specs from setting: " + tileList); 輸出這句LOG
Example:
Loaded tile specs from setting: wifi,bt,dnd,battery,airplane,cast,custom(com.android.systemui/com.softwinner.screenshot.ScreenshotTileService),custom(com.android.systemui/com.softwinner.screenrecord.ScreenrecordTileService)