Loading packages/SettingsLib/src/com/android/settingslib/drawer/CategoryKey.java +13 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,9 @@ */ package com.android.settingslib.drawer; import java.util.HashMap; import java.util.Map; public final class CategoryKey { // Activities in this category shows up in Settings homepage. Loading @@ -33,4 +36,14 @@ public final class CategoryKey { public static final String CATEGORY_SECURITY = "com.android.settings.category.ia.security"; public static final String CATEGORY_ACCOUNT = "com.android.settings.category.ia.accounts"; public static final String CATEGORY_SYSTEM = "com.android.settings.category.ia.system"; public static final Map<String, String> KEY_COMPAT_MAP; static { KEY_COMPAT_MAP = new HashMap<>(); KEY_COMPAT_MAP.put("com.android.settings.category.wireless", CATEGORY_NETWORK); KEY_COMPAT_MAP.put("com.android.settings.category.device", CATEGORY_SYSTEM); KEY_COMPAT_MAP.put("com.android.settings.category.personal", CATEGORY_SYSTEM); KEY_COMPAT_MAP.put("com.android.settings.category.system", CATEGORY_SYSTEM); } } packages/SettingsLib/src/com/android/settingslib/drawer/CategoryManager.java +54 −0 Original line number Diff line number Diff line Loading @@ -17,14 +17,18 @@ package com.android.settingslib.drawer; import android.content.ComponentName; import android.content.Context; import android.support.annotation.VisibleForTesting; import android.util.ArrayMap; import android.util.Log; import android.util.Pair; import com.android.settingslib.applications.InterestingConfigChanges; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; public class CategoryManager { Loading Loading @@ -106,7 +110,57 @@ public class CategoryManager { for (DashboardCategory category : mCategories) { mCategoryByKeyMap.put(category.key, category); } backwardCompatCleanupForCategory(mTileByComponentCache, mCategoryByKeyMap); } } @VisibleForTesting synchronized void backwardCompatCleanupForCategory( Map<Pair<String, String>, Tile> tileByComponentCache, Map<String, DashboardCategory> categoryByKeyMap) { // A package can use a) CategoryKey, b) old category keys, c) both. // Check if a package uses old category key only. // If yes, map them to new category key. // Build a package name -> tile map first. final Map<String, List<Tile>> packageToTileMap = new HashMap<>(); for (Entry<Pair<String, String>, Tile> tileEntry : tileByComponentCache.entrySet()) { final String packageName = tileEntry.getKey().first; List<Tile> tiles = packageToTileMap.get(packageName); if (tiles == null) { tiles = new ArrayList<>(); packageToTileMap.put(packageName, tiles); } tiles.add(tileEntry.getValue()); } for (Entry<String, List<Tile>> entry : packageToTileMap.entrySet()) { final List<Tile> tiles = entry.getValue(); // Loop map, find if all tiles from same package uses old key only. boolean useNewKey = false; boolean useOldKey = false; for (Tile tile : tiles) { if (CategoryKey.KEY_COMPAT_MAP.containsKey(tile.category)) { useOldKey = true; } else { useNewKey = true; break; } } // Uses only old key, map them to new keys one by one. if (useOldKey && !useNewKey) { for (Tile tile : tiles) { final String newCategoryKey = CategoryKey.KEY_COMPAT_MAP.get(tile.category); tile.category = newCategoryKey; // move tile to new category. DashboardCategory newCategory = categoryByKeyMap.get(newCategoryKey); if (newCategory == null) { newCategory = new DashboardCategory(); categoryByKeyMap.put(newCategoryKey, newCategory); } newCategory.tiles.add(tile); } } } } } packages/SettingsLib/tests/Android.mk +3 −18 Original line number Diff line number Diff line # Copyright (C) 2015 The Android Open Source Project # Copyright (C) 2016 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. Loading @@ -15,20 +15,5 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := tests LOCAL_CERTIFICATE := platform LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_JAVA_LIBRARIES := android.test.runner telephony-common LOCAL_PACKAGE_NAME := SettingsLibTests LOCAL_STATIC_JAVA_LIBRARIES := \ android-support-test \ espresso-core \ mockito-target-minus-junit4 include frameworks/base/packages/SettingsLib/common.mk include $(BUILD_PACKAGE) # Include all makefiles in subdirectories include $(call all-makefiles-under,$(LOCAL_PATH)) packages/SettingsLib/tests/integ/Android.mk 0 → 100644 +34 −0 Original line number Diff line number Diff line # Copyright (C) 2015 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := tests LOCAL_CERTIFICATE := platform LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_JAVA_LIBRARIES := android.test.runner telephony-common LOCAL_PACKAGE_NAME := SettingsLibTests LOCAL_STATIC_JAVA_LIBRARIES := \ android-support-test \ espresso-core \ mockito-target-minus-junit4 include frameworks/base/packages/SettingsLib/common.mk include $(BUILD_PACKAGE) packages/SettingsLib/tests/AndroidManifest.xml→packages/SettingsLib/tests/integ/AndroidManifest.xml +0 −0 File moved. View file Loading
packages/SettingsLib/src/com/android/settingslib/drawer/CategoryKey.java +13 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,9 @@ */ package com.android.settingslib.drawer; import java.util.HashMap; import java.util.Map; public final class CategoryKey { // Activities in this category shows up in Settings homepage. Loading @@ -33,4 +36,14 @@ public final class CategoryKey { public static final String CATEGORY_SECURITY = "com.android.settings.category.ia.security"; public static final String CATEGORY_ACCOUNT = "com.android.settings.category.ia.accounts"; public static final String CATEGORY_SYSTEM = "com.android.settings.category.ia.system"; public static final Map<String, String> KEY_COMPAT_MAP; static { KEY_COMPAT_MAP = new HashMap<>(); KEY_COMPAT_MAP.put("com.android.settings.category.wireless", CATEGORY_NETWORK); KEY_COMPAT_MAP.put("com.android.settings.category.device", CATEGORY_SYSTEM); KEY_COMPAT_MAP.put("com.android.settings.category.personal", CATEGORY_SYSTEM); KEY_COMPAT_MAP.put("com.android.settings.category.system", CATEGORY_SYSTEM); } }
packages/SettingsLib/src/com/android/settingslib/drawer/CategoryManager.java +54 −0 Original line number Diff line number Diff line Loading @@ -17,14 +17,18 @@ package com.android.settingslib.drawer; import android.content.ComponentName; import android.content.Context; import android.support.annotation.VisibleForTesting; import android.util.ArrayMap; import android.util.Log; import android.util.Pair; import com.android.settingslib.applications.InterestingConfigChanges; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; public class CategoryManager { Loading Loading @@ -106,7 +110,57 @@ public class CategoryManager { for (DashboardCategory category : mCategories) { mCategoryByKeyMap.put(category.key, category); } backwardCompatCleanupForCategory(mTileByComponentCache, mCategoryByKeyMap); } } @VisibleForTesting synchronized void backwardCompatCleanupForCategory( Map<Pair<String, String>, Tile> tileByComponentCache, Map<String, DashboardCategory> categoryByKeyMap) { // A package can use a) CategoryKey, b) old category keys, c) both. // Check if a package uses old category key only. // If yes, map them to new category key. // Build a package name -> tile map first. final Map<String, List<Tile>> packageToTileMap = new HashMap<>(); for (Entry<Pair<String, String>, Tile> tileEntry : tileByComponentCache.entrySet()) { final String packageName = tileEntry.getKey().first; List<Tile> tiles = packageToTileMap.get(packageName); if (tiles == null) { tiles = new ArrayList<>(); packageToTileMap.put(packageName, tiles); } tiles.add(tileEntry.getValue()); } for (Entry<String, List<Tile>> entry : packageToTileMap.entrySet()) { final List<Tile> tiles = entry.getValue(); // Loop map, find if all tiles from same package uses old key only. boolean useNewKey = false; boolean useOldKey = false; for (Tile tile : tiles) { if (CategoryKey.KEY_COMPAT_MAP.containsKey(tile.category)) { useOldKey = true; } else { useNewKey = true; break; } } // Uses only old key, map them to new keys one by one. if (useOldKey && !useNewKey) { for (Tile tile : tiles) { final String newCategoryKey = CategoryKey.KEY_COMPAT_MAP.get(tile.category); tile.category = newCategoryKey; // move tile to new category. DashboardCategory newCategory = categoryByKeyMap.get(newCategoryKey); if (newCategory == null) { newCategory = new DashboardCategory(); categoryByKeyMap.put(newCategoryKey, newCategory); } newCategory.tiles.add(tile); } } } } }
packages/SettingsLib/tests/Android.mk +3 −18 Original line number Diff line number Diff line # Copyright (C) 2015 The Android Open Source Project # Copyright (C) 2016 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. Loading @@ -15,20 +15,5 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := tests LOCAL_CERTIFICATE := platform LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_JAVA_LIBRARIES := android.test.runner telephony-common LOCAL_PACKAGE_NAME := SettingsLibTests LOCAL_STATIC_JAVA_LIBRARIES := \ android-support-test \ espresso-core \ mockito-target-minus-junit4 include frameworks/base/packages/SettingsLib/common.mk include $(BUILD_PACKAGE) # Include all makefiles in subdirectories include $(call all-makefiles-under,$(LOCAL_PATH))
packages/SettingsLib/tests/integ/Android.mk 0 → 100644 +34 −0 Original line number Diff line number Diff line # Copyright (C) 2015 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := tests LOCAL_CERTIFICATE := platform LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_JAVA_LIBRARIES := android.test.runner telephony-common LOCAL_PACKAGE_NAME := SettingsLibTests LOCAL_STATIC_JAVA_LIBRARIES := \ android-support-test \ espresso-core \ mockito-target-minus-junit4 include frameworks/base/packages/SettingsLib/common.mk include $(BUILD_PACKAGE)
packages/SettingsLib/tests/AndroidManifest.xml→packages/SettingsLib/tests/integ/AndroidManifest.xml +0 −0 File moved. View file