Misc cleanup on AndroidManifest.xml
- Add a few activities to widget list. These are more commonly used settings, so adding them to widget list for easier access. - Storage - System - About phone - Remove useless intent-filters from AndroidManifest. - If the intent-filter is just action MAIN and category DEFAULT, it doesn't do anything. Bug: 74806595 Test: visual Change-Id: I5d80bc6c88f7bf60adabac872e92b72b341b97e6
This commit is contained in:
@@ -261,10 +261,6 @@
|
|||||||
<action android:name="android.net.wifi.PICK_WIFI_NETWORK" />
|
<action android:name="android.net.wifi.PICK_WIFI_NETWORK" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||||
android:value="true" />
|
android:value="true" />
|
||||||
</activity>
|
</activity>
|
||||||
@@ -302,10 +298,6 @@
|
|||||||
<action android:name="android.settings.WIFI_SAVED_NETWORK_SETTINGS" />
|
<action android:name="android.settings.WIFI_SAVED_NETWORK_SETTINGS" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
android:value="com.android.settings.wifi.SavedAccessPointsWifiSettings" />
|
android:value="com.android.settings.wifi.SavedAccessPointsWifiSettings" />
|
||||||
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||||
@@ -475,6 +467,11 @@
|
|||||||
<action android:name="com.android.settings.WIFI_TETHER_SETTINGS" />
|
<action android:name="com.android.settings.WIFI_TETHER_SETTINGS" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="com.android.settings.SHORTCUT" />
|
||||||
|
</intent-filter>
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
android:value="com.android.settings.wifi.tether.WifiTetherSettings" />
|
android:value="com.android.settings.wifi.tether.WifiTetherSettings" />
|
||||||
</activity>
|
</activity>
|
||||||
@@ -616,21 +613,14 @@
|
|||||||
<action android:name="android.settings.VOICE_INPUT_SETTINGS" />
|
<action android:name="android.settings.VOICE_INPUT_SETTINGS" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
android:value="com.android.settings.applications.assist.ManageAssist" />
|
android:value="com.android.settings.applications.assist.ManageAssist" />
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name="Settings$KeyboardLayoutPickerActivity"
|
<activity android:name="Settings$KeyboardLayoutPickerActivity"
|
||||||
android:label="@string/keyboard_layout_picker_title"
|
android:label="@string/keyboard_layout_picker_title"
|
||||||
android:clearTaskOnLaunch="true">
|
android:clearTaskOnLaunch="true"
|
||||||
<intent-filter>
|
android:exported="true">
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
android:value="com.android.settings.inputmethod.KeyboardLayoutPickerFragment" />
|
android:value="com.android.settings.inputmethod.KeyboardLayoutPickerFragment" />
|
||||||
</activity>
|
</activity>
|
||||||
@@ -642,10 +632,6 @@
|
|||||||
<action android:name="android.settings.HARD_KEYBOARD_SETTINGS" />
|
<action android:name="android.settings.HARD_KEYBOARD_SETTINGS" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
android:value="com.android.settings.inputmethod.PhysicalKeyboardFragment" />
|
android:value="com.android.settings.inputmethod.PhysicalKeyboardFragment" />
|
||||||
</activity>
|
</activity>
|
||||||
@@ -879,10 +865,6 @@
|
|||||||
<action android:name="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS" />
|
<action android:name="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
android:value="com.android.settings.notification.ZenModeEventRuleSettings" />
|
android:value="com.android.settings.notification.ZenModeEventRuleSettings" />
|
||||||
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||||
@@ -984,6 +966,7 @@
|
|||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<category android:name="android.intent.category.VOICE_LAUNCH" />
|
<category android:name="android.intent.category.VOICE_LAUNCH" />
|
||||||
|
<category android:name="com.android.settings.SHORTCUT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter android:priority="270">
|
<intent-filter android:priority="270">
|
||||||
<action android:name="com.android.settings.action.SETTINGS" />
|
<action android:name="com.android.settings.action.SETTINGS" />
|
||||||
@@ -1230,17 +1213,6 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name="Settings$BackgroundCheckSummaryActivity"
|
|
||||||
android:label="@string/background_check_title"
|
|
||||||
android:enabled="false">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
|
||||||
android:value="com.android.settings.applications.appops.BackgroundCheckSummary" />
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="Settings$LocationSettingsActivity"
|
android:name="Settings$LocationSettingsActivity"
|
||||||
android:label="@string/location_settings_title"
|
android:label="@string/location_settings_title"
|
||||||
@@ -1317,10 +1289,6 @@
|
|||||||
<action android:name="com.android.settings.MONITORING_CERT_INFO" />
|
<action android:name="com.android.settings.MONITORING_CERT_INFO" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
@@ -1423,10 +1391,6 @@
|
|||||||
<action android:name="android.settings.USAGE_ACCESS_SETTINGS" />
|
<action android:name="android.settings.USAGE_ACCESS_SETTINGS" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
android:value="com.android.settings.applications.manageapplications.ManageApplications" />
|
android:value="com.android.settings.applications.manageapplications.ManageApplications" />
|
||||||
</activity>
|
</activity>
|
||||||
@@ -1524,10 +1488,6 @@
|
|||||||
<action android:name="android.settings.CAPTIONING_SETTINGS" />
|
<action android:name="android.settings.CAPTIONING_SETTINGS" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
android:value="com.android.settings.accessibility.CaptionPropertiesFragment" />
|
android:value="com.android.settings.accessibility.CaptionPropertiesFragment" />
|
||||||
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||||
@@ -1792,6 +1752,7 @@
|
|||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="com.android.settings.SHORTCUT" />
|
||||||
<category android:name="android.intent.category.VOICE_LAUNCH" />
|
<category android:name="android.intent.category.VOICE_LAUNCH" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter android:priority="5">
|
<intent-filter android:priority="5">
|
||||||
@@ -2093,10 +2054,6 @@
|
|||||||
<action android:name="android.settings.NFCSHARING_SETTINGS" />
|
<action android:name="android.settings.NFCSHARING_SETTINGS" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
android:value="com.android.settings.nfc.AndroidBeam" />
|
android:value="com.android.settings.nfc.AndroidBeam" />
|
||||||
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||||
@@ -2113,10 +2070,6 @@
|
|||||||
<action android:name="android.settings.CAST_SETTINGS" />
|
<action android:name="android.settings.CAST_SETTINGS" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<intent-filter android:priority="6">
|
<intent-filter android:priority="6">
|
||||||
<action android:name="com.android.settings.action.SETTINGS"/>
|
<action android:name="com.android.settings.action.SETTINGS"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
@@ -2148,10 +2101,6 @@
|
|||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name="Settings$TestingSettingsActivity" android:label="@string/testing">
|
<activity android:name="Settings$TestingSettingsActivity" android:label="@string/testing">
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
android:value="com.android.settings.TestingSettings" />
|
android:value="com.android.settings.TestingSettings" />
|
||||||
</activity>
|
</activity>
|
||||||
@@ -2254,10 +2203,6 @@
|
|||||||
<action android:name="android.settings.ACCOUNT_SYNC_SETTINGS" />
|
<action android:name="android.settings.ACCOUNT_SYNC_SETTINGS" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
android:value="com.android.settings.accounts.AccountSyncSettings" />
|
android:value="com.android.settings.accounts.AccountSyncSettings" />
|
||||||
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||||
@@ -2288,10 +2233,6 @@
|
|||||||
<action android:name="android.settings.ADD_ACCOUNT_SETTINGS" />
|
<action android:name="android.settings.ADD_ACCOUNT_SETTINGS" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||||
android:value="true" />
|
android:value="true" />
|
||||||
</activity>
|
</activity>
|
||||||
@@ -2352,10 +2293,6 @@
|
|||||||
<action android:name="android.app.action.START_ENCRYPTION" />
|
<action android:name="android.app.action.START_ENCRYPTION" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
android:value="com.android.settings.security.CryptKeeperSettings" />
|
android:value="com.android.settings.security.CryptKeeperSettings" />
|
||||||
</activity>
|
</activity>
|
||||||
@@ -2422,10 +2359,6 @@
|
|||||||
<action android:name="android.settings.USER_SETTINGS" />
|
<action android:name="android.settings.USER_SETTINGS" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<intent-filter android:priority="45">
|
<intent-filter android:priority="45">
|
||||||
<action android:name="com.android.settings.action.SETTINGS" />
|
<action android:name="com.android.settings.action.SETTINGS" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
@@ -2494,10 +2427,6 @@
|
|||||||
<action android:name="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS" />
|
<action android:name="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
android:value="com.android.settings.notification.NotificationAccessSettings" />
|
android:value="com.android.settings.notification.NotificationAccessSettings" />
|
||||||
</activity>
|
</activity>
|
||||||
@@ -2511,10 +2440,6 @@
|
|||||||
<action android:name="android.settings.VR_LISTENER_SETTINGS" />
|
<action android:name="android.settings.VR_LISTENER_SETTINGS" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
android:value="com.android.settings.applications.VrListenerSettings" />
|
android:value="com.android.settings.applications.VrListenerSettings" />
|
||||||
</activity>
|
</activity>
|
||||||
@@ -2559,10 +2484,6 @@
|
|||||||
<action android:name="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS" />
|
<action android:name="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
android:value="com.android.settings.notification.ZenAccessSettings" />
|
android:value="com.android.settings.notification.ZenAccessSettings" />
|
||||||
</activity>
|
</activity>
|
||||||
@@ -2651,10 +2572,6 @@
|
|||||||
<action android:name="android.settings.APP_NOTIFICATION_SETTINGS" />
|
<action android:name="android.settings.APP_NOTIFICATION_SETTINGS" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
android:value="com.android.settings.notification.AppNotificationSettings" />
|
android:value="com.android.settings.notification.AppNotificationSettings" />
|
||||||
</activity>
|
</activity>
|
||||||
@@ -2662,10 +2579,6 @@
|
|||||||
<!-- Show channel group-level notification settings (group passed in as extras) -->
|
<!-- Show channel group-level notification settings (group passed in as extras) -->
|
||||||
<activity android:name="Settings$ChannelGroupNotificationSettingsActivity"
|
<activity android:name="Settings$ChannelGroupNotificationSettingsActivity"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
android:value="com.android.settings.notification.ChannelGroupNotificationSettings" />
|
android:value="com.android.settings.notification.ChannelGroupNotificationSettings" />
|
||||||
</activity>
|
</activity>
|
||||||
@@ -2678,10 +2591,6 @@
|
|||||||
<action android:name="android.settings.CHANNEL_NOTIFICATION_SETTINGS" />
|
<action android:name="android.settings.CHANNEL_NOTIFICATION_SETTINGS" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
android:value="com.android.settings.notification.ChannelNotificationSettings" />
|
android:value="com.android.settings.notification.ChannelNotificationSettings" />
|
||||||
</activity>
|
</activity>
|
||||||
@@ -2776,10 +2685,6 @@
|
|||||||
<action android:name="com.android.settings.sim.SIM_SUB_INFO_SETTINGS" />
|
<action android:name="com.android.settings.sim.SIM_SUB_INFO_SETTINGS" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<intent-filter android:priority="2">
|
<intent-filter android:priority="2">
|
||||||
<action android:name="com.android.settings.action.SETTINGS" />
|
<action android:name="com.android.settings.action.SETTINGS" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
@@ -3078,6 +2983,10 @@
|
|||||||
<action android:name="android.settings.SYNC_SETTINGS" />
|
<action android:name="android.settings.SYNC_SETTINGS" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="com.android.settings.SHORTCUT" />
|
||||||
|
</intent-filter>
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
android:value="com.android.settings.accounts.AccountDashboardFragment"/>
|
android:value="com.android.settings.accounts.AccountDashboardFragment"/>
|
||||||
<meta-data android:name="com.android.settings.category"
|
<meta-data android:name="com.android.settings.category"
|
||||||
@@ -3095,6 +3004,10 @@
|
|||||||
<intent-filter android:priority="-1">
|
<intent-filter android:priority="-1">
|
||||||
<action android:name="com.android.settings.action.SETTINGS"/>
|
<action android:name="com.android.settings.action.SETTINGS"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="com.android.settings.SHORTCUT" />
|
||||||
|
</intent-filter>
|
||||||
<meta-data android:name="com.android.settings.category"
|
<meta-data android:name="com.android.settings.category"
|
||||||
android:value="com.android.settings.category.ia.homepage"/>
|
android:value="com.android.settings.category.ia.homepage"/>
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
|
@@ -19,11 +19,5 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||||
android:title="@string/manage_device_admin"
|
android:title="@string/manage_device_admin"
|
||||||
android:key="device_admin_settings">
|
android:key="device_admin_settings"
|
||||||
|
settings:controller="com.android.settings.applications.specialaccess.deviceadmin.DeviceAdminListPreferenceController" />
|
||||||
<PreferenceCategory
|
|
||||||
android:key="device_admin_list"
|
|
||||||
android:title="@string/summary_placeholder"
|
|
||||||
settings:controller="com.android.settings.applications.specialaccess.deviceadmin.DeviceAdminListPreferenceController" />
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
|
@@ -173,8 +173,12 @@ public class DeviceAdminListPreferenceController extends BasePreferenceControlle
|
|||||||
final Context prefContext = mPreferenceGroup.getContext();
|
final Context prefContext = mPreferenceGroup.getContext();
|
||||||
final int childrenCount = mPreferenceGroup.getPreferenceCount();
|
final int childrenCount = mPreferenceGroup.getPreferenceCount();
|
||||||
for (int i = 0; i < childrenCount; i++) {
|
for (int i = 0; i < childrenCount; i++) {
|
||||||
SwitchPreference pref = (SwitchPreference) mPreferenceGroup.getPreference(i);
|
final Preference pref = mPreferenceGroup.getPreference(i);
|
||||||
preferenceCache.put(pref.getKey(), pref);
|
if (!(pref instanceof SwitchPreference)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final SwitchPreference appSwitch = (SwitchPreference) pref;
|
||||||
|
preferenceCache.put(appSwitch.getKey(), appSwitch);
|
||||||
}
|
}
|
||||||
for (DeviceAdminListItem item : mAdmins) {
|
for (DeviceAdminListItem item : mAdmins) {
|
||||||
final String key = item.getKey();
|
final String key = item.getKey();
|
||||||
|
@@ -32,7 +32,7 @@ import android.widget.CompoundButton;
|
|||||||
import com.android.internal.app.LocalePicker;
|
import com.android.internal.app.LocalePicker;
|
||||||
import com.android.internal.app.LocaleStore;
|
import com.android.internal.app.LocaleStore;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.shortcut.CreateShortcut;
|
import com.android.settings.shortcut.ShortcutsUpdateTask;
|
||||||
|
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -294,7 +294,7 @@ class LocaleDragAndDropAdapter
|
|||||||
|
|
||||||
LocalePicker.updateLocales(mLocalesToSetNext);
|
LocalePicker.updateLocales(mLocalesToSetNext);
|
||||||
mLocalesSetLast = mLocalesToSetNext;
|
mLocalesSetLast = mLocalesToSetNext;
|
||||||
new CreateShortcut.ShortcutsUpdateTask(mContext).execute();
|
new ShortcutsUpdateTask(mContext).execute();
|
||||||
|
|
||||||
mLocalesToSetNext = null;
|
mLocalesToSetNext = null;
|
||||||
|
|
||||||
|
@@ -191,37 +191,4 @@ public class CreateShortcut extends LauncherActivity {
|
|||||||
return new Intent(Intent.ACTION_MAIN).addCategory("com.android.settings.SHORTCUT");
|
return new Intent(Intent.ACTION_MAIN).addCategory("com.android.settings.SHORTCUT");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ShortcutsUpdateTask extends AsyncTask<Void, Void, Void> {
|
|
||||||
|
|
||||||
private final Context mContext;
|
|
||||||
|
|
||||||
public ShortcutsUpdateTask(Context context) {
|
|
||||||
mContext = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Void doInBackground(Void... params) {
|
|
||||||
ShortcutManager sm = mContext.getSystemService(ShortcutManager.class);
|
|
||||||
PackageManager pm = mContext.getPackageManager();
|
|
||||||
|
|
||||||
List<ShortcutInfo> updates = new ArrayList<>();
|
|
||||||
for (ShortcutInfo info : sm.getPinnedShortcuts()) {
|
|
||||||
if (!info.getId().startsWith(SHORTCUT_ID_PREFIX)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ComponentName cn = ComponentName.unflattenFromString(
|
|
||||||
info.getId().substring(SHORTCUT_ID_PREFIX.length()));
|
|
||||||
ResolveInfo ri = pm.resolveActivity(getBaseIntent().setComponent(cn), 0);
|
|
||||||
if (ri == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
updates.add(new ShortcutInfo.Builder(mContext, info.getId())
|
|
||||||
.setShortLabel(ri.loadLabel(pm)).build());
|
|
||||||
}
|
|
||||||
if (!updates.isEmpty()) {
|
|
||||||
sm.updateShortcuts(updates);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
62
src/com/android/settings/shortcut/ShortcutsUpdateTask.java
Normal file
62
src/com/android/settings/shortcut/ShortcutsUpdateTask.java
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.shortcut;
|
||||||
|
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.content.pm.ShortcutInfo;
|
||||||
|
import android.content.pm.ShortcutManager;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ShortcutsUpdateTask extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
|
private final Context mContext;
|
||||||
|
|
||||||
|
public ShortcutsUpdateTask(Context context) {
|
||||||
|
mContext = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void doInBackground(Void... params) {
|
||||||
|
ShortcutManager sm = mContext.getSystemService(ShortcutManager.class);
|
||||||
|
PackageManager pm = mContext.getPackageManager();
|
||||||
|
|
||||||
|
List<ShortcutInfo> updates = new ArrayList<>();
|
||||||
|
for (ShortcutInfo info : sm.getPinnedShortcuts()) {
|
||||||
|
if (!info.getId().startsWith(CreateShortcut.SHORTCUT_ID_PREFIX)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ComponentName cn = ComponentName.unflattenFromString(
|
||||||
|
info.getId().substring(CreateShortcut.SHORTCUT_ID_PREFIX.length()));
|
||||||
|
ResolveInfo ri = pm.resolveActivity(CreateShortcut.getBaseIntent().setComponent(cn), 0);
|
||||||
|
if (ri == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
updates.add(new ShortcutInfo.Builder(mContext, info.getId())
|
||||||
|
.setShortLabel(ri.loadLabel(pm)).build());
|
||||||
|
}
|
||||||
|
if (!updates.isEmpty()) {
|
||||||
|
sm.updateShortcuts(updates);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@@ -16,22 +16,20 @@
|
|||||||
|
|
||||||
package com.android.settings.shortcut;
|
package com.android.settings.shortcut;
|
||||||
|
|
||||||
|
import static com.android.settings.shortcut.CreateShortcut.SHORTCUT_ID_PREFIX;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static org.mockito.Mockito.any;
|
import static org.mockito.Mockito.any;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.eq;
|
import static org.mockito.Mockito.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.content.pm.ShortcutInfo;
|
import android.content.pm.ShortcutInfo;
|
||||||
import android.content.pm.ShortcutManager;
|
import android.content.pm.ShortcutManager;
|
||||||
@@ -44,7 +42,6 @@ import org.junit.Before;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Captor;
|
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.robolectric.Robolectric;
|
import org.robolectric.Robolectric;
|
||||||
@@ -63,16 +60,12 @@ import java.util.List;
|
|||||||
@Config(shadows = ShadowConnectivityManager.class)
|
@Config(shadows = ShadowConnectivityManager.class)
|
||||||
public class CreateShortcutTest {
|
public class CreateShortcutTest {
|
||||||
|
|
||||||
private static final String SHORTCUT_ID_PREFIX = CreateShortcut.SHORTCUT_ID_PREFIX;
|
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private ShadowConnectivityManager mShadowConnectivityManager;
|
private ShadowConnectivityManager mShadowConnectivityManager;
|
||||||
private ShadowPackageManager mPackageManager;
|
private ShadowPackageManager mPackageManager;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private ShortcutManager mShortcutManager;
|
private ShortcutManager mShortcutManager;
|
||||||
@Captor
|
|
||||||
private ArgumentCaptor<List<ShortcutInfo>> mListCaptor;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
@@ -107,40 +100,6 @@ public class CreateShortcutTest {
|
|||||||
.isEqualTo(SHORTCUT_ID_PREFIX + intent.getComponent().flattenToShortString());
|
.isEqualTo(SHORTCUT_ID_PREFIX + intent.getComponent().flattenToShortString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shortcutsUpdateTask() {
|
|
||||||
mContext = spy(RuntimeEnvironment.application);
|
|
||||||
doReturn(mShortcutManager).when(mContext).getSystemService(eq(Context.SHORTCUT_SERVICE));
|
|
||||||
final Intent shortcut1 = CreateShortcut.getBaseIntent().setComponent(
|
|
||||||
new ComponentName(mContext, Settings.ManageApplicationsActivity.class));
|
|
||||||
final ResolveInfo ri1 = mock(ResolveInfo.class);
|
|
||||||
final Intent shortcut2 = CreateShortcut.getBaseIntent().setComponent(
|
|
||||||
new ComponentName(mContext, Settings.SoundSettingsActivity.class));
|
|
||||||
final ResolveInfo ri2 = mock(ResolveInfo.class);
|
|
||||||
when(ri1.loadLabel(any(PackageManager.class))).thenReturn("label1");
|
|
||||||
when(ri2.loadLabel(any(PackageManager.class))).thenReturn("label2");
|
|
||||||
mPackageManager.addResolveInfoForIntent(shortcut1, ri1);
|
|
||||||
mPackageManager.addResolveInfoForIntent(shortcut2, ri2);
|
|
||||||
|
|
||||||
final List<ShortcutInfo> pinnedShortcuts = Arrays.asList(
|
|
||||||
makeShortcut("d1"),
|
|
||||||
makeShortcut("d2"),
|
|
||||||
makeShortcut(Settings.ManageApplicationsActivity.class),
|
|
||||||
makeShortcut("d3"),
|
|
||||||
makeShortcut(Settings.SoundSettingsActivity.class));
|
|
||||||
when(mShortcutManager.getPinnedShortcuts()).thenReturn(pinnedShortcuts);
|
|
||||||
|
|
||||||
new CreateShortcut.ShortcutsUpdateTask(mContext).doInBackground();
|
|
||||||
|
|
||||||
verify(mShortcutManager, times(1)).updateShortcuts(mListCaptor.capture());
|
|
||||||
|
|
||||||
final List<ShortcutInfo> updates = mListCaptor.getValue();
|
|
||||||
|
|
||||||
assertThat(updates).hasSize(2);
|
|
||||||
assertThat(pinnedShortcuts.get(2).getId()).isEqualTo(updates.get(0).getId());
|
|
||||||
assertThat(pinnedShortcuts.get(4).getId()).isEqualTo(updates.get(1).getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void queryActivities_shouldOnlyIncludeSystemApp() {
|
public void queryActivities_shouldOnlyIncludeSystemApp() {
|
||||||
final ResolveInfo ri1 = new ResolveInfo();
|
final ResolveInfo ri1 = new ResolveInfo();
|
||||||
@@ -165,14 +124,6 @@ public class CreateShortcutTest {
|
|||||||
assertThat(info.get(0)).isEqualTo(ri2);
|
assertThat(info.get(0)).isEqualTo(ri2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ShortcutInfo makeShortcut(Class<?> className) {
|
|
||||||
ComponentName cn = new ComponentName(mContext, className);
|
|
||||||
return makeShortcut(SHORTCUT_ID_PREFIX + cn.flattenToShortString());
|
|
||||||
}
|
|
||||||
|
|
||||||
private ShortcutInfo makeShortcut(String id) {
|
|
||||||
return new ShortcutInfo.Builder(mContext, id).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class TestClass extends CreateShortcut {
|
private static class TestClass extends CreateShortcut {
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,117 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.shortcut;
|
||||||
|
|
||||||
|
import static com.android.settings.shortcut.CreateShortcut.SHORTCUT_ID_PREFIX;
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
|
import static org.mockito.Mockito.doReturn;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
|
import static org.mockito.Mockito.times;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.content.pm.ShortcutInfo;
|
||||||
|
import android.content.pm.ShortcutManager;
|
||||||
|
|
||||||
|
import com.android.settings.Settings;
|
||||||
|
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
|
import org.mockito.Captor;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.shadow.api.Shadow;
|
||||||
|
import org.robolectric.shadows.ShadowPackageManager;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
|
public class ShortcutsUpdateTaskTest {
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
private ShadowPackageManager mPackageManager;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private ShortcutManager mShortcutManager;
|
||||||
|
@Captor
|
||||||
|
private ArgumentCaptor<List<ShortcutInfo>> mListCaptor;
|
||||||
|
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
mContext = RuntimeEnvironment.application;
|
||||||
|
mPackageManager = Shadow.extract(mContext.getPackageManager());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shortcutsUpdateTask() {
|
||||||
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
|
doReturn(mShortcutManager).when(mContext).getSystemService(eq(Context.SHORTCUT_SERVICE));
|
||||||
|
final Intent shortcut1 = CreateShortcut.getBaseIntent().setComponent(
|
||||||
|
new ComponentName(mContext, Settings.ManageApplicationsActivity.class));
|
||||||
|
final ResolveInfo ri1 = mock(ResolveInfo.class);
|
||||||
|
final Intent shortcut2 = CreateShortcut.getBaseIntent().setComponent(
|
||||||
|
new ComponentName(mContext, Settings.SoundSettingsActivity.class));
|
||||||
|
final ResolveInfo ri2 = mock(ResolveInfo.class);
|
||||||
|
when(ri1.loadLabel(any(PackageManager.class))).thenReturn("label1");
|
||||||
|
when(ri2.loadLabel(any(PackageManager.class))).thenReturn("label2");
|
||||||
|
mPackageManager.addResolveInfoForIntent(shortcut1, ri1);
|
||||||
|
mPackageManager.addResolveInfoForIntent(shortcut2, ri2);
|
||||||
|
|
||||||
|
final List<ShortcutInfo> pinnedShortcuts = Arrays.asList(
|
||||||
|
makeShortcut("d1"),
|
||||||
|
makeShortcut("d2"),
|
||||||
|
makeShortcut(Settings.ManageApplicationsActivity.class),
|
||||||
|
makeShortcut("d3"),
|
||||||
|
makeShortcut(Settings.SoundSettingsActivity.class));
|
||||||
|
when(mShortcutManager.getPinnedShortcuts()).thenReturn(pinnedShortcuts);
|
||||||
|
|
||||||
|
new ShortcutsUpdateTask(mContext).doInBackground();
|
||||||
|
|
||||||
|
verify(mShortcutManager, times(1)).updateShortcuts(mListCaptor.capture());
|
||||||
|
|
||||||
|
final List<ShortcutInfo> updates = mListCaptor.getValue();
|
||||||
|
|
||||||
|
assertThat(updates).hasSize(2);
|
||||||
|
assertThat(pinnedShortcuts.get(2).getId()).isEqualTo(updates.get(0).getId());
|
||||||
|
assertThat(pinnedShortcuts.get(4).getId()).isEqualTo(updates.get(1).getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
private ShortcutInfo makeShortcut(Class<?> className) {
|
||||||
|
ComponentName cn = new ComponentName(mContext, className);
|
||||||
|
return makeShortcut(SHORTCUT_ID_PREFIX + cn.flattenToShortString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ShortcutInfo makeShortcut(String id) {
|
||||||
|
return new ShortcutInfo.Builder(mContext, id).build();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user