Merge changes I24a9d34d,I443e9d2b into nyc-dev
am: 346c1f4f24
* commit '346c1f4f2461fc7c38e4c2ad87f26864ad4fa347':
Add default app prefs to app info
Rearrange configure/default apps
This commit is contained in:
@@ -2768,7 +2768,7 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name="Settings$ManageDefaultAppsActivity"
|
<activity android:name="Settings$AdvancedAppsActivity"
|
||||||
android:taskAffinity=""
|
android:taskAffinity=""
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<intent-filter android:priority="1">
|
<intent-filter android:priority="1">
|
||||||
@@ -2780,7 +2780,7 @@
|
|||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</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.ManageDefaultApps" />
|
android:value="com.android.settings.applications.AdvancedAppSettings" />
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<service
|
<service
|
||||||
|
@@ -126,4 +126,8 @@
|
|||||||
<!-- Confirm device credentials screen -->
|
<!-- Confirm device credentials screen -->
|
||||||
<attr name="confirmDeviceCredentialsSideMargin" format="dimension" />
|
<attr name="confirmDeviceCredentialsSideMargin" format="dimension" />
|
||||||
<attr name="confirmDeviceCredentialsTopMargin" format="dimension" />
|
<attr name="confirmDeviceCredentialsTopMargin" format="dimension" />
|
||||||
|
|
||||||
|
<declare-styleable name="WorkPreference">
|
||||||
|
<attr name="forWork" format="boolean" />
|
||||||
|
</declare-styleable>
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -6511,7 +6511,10 @@
|
|||||||
<string name="fingerprint_not_recognized">Not recognized</string>
|
<string name="fingerprint_not_recognized">Not recognized</string>
|
||||||
|
|
||||||
<!-- Title for Default Apps settings [CHAR LIMIT=30] -->
|
<!-- Title for Default Apps settings [CHAR LIMIT=30] -->
|
||||||
<string name="default_apps_title">Default Apps</string>
|
<string name="default_apps_title">Default</string>
|
||||||
|
|
||||||
|
<!-- Title for Default Apps settings for work [CHAR LIMIT=30] -->
|
||||||
|
<string name="default_for_work">Default for work</string>
|
||||||
|
|
||||||
<!-- Title for Assist and voice input settings [CHAR LIMIT=30] -->
|
<!-- Title for Assist and voice input settings [CHAR LIMIT=30] -->
|
||||||
<string name="assist_and_voice_input_title">Assist & voice input</string>
|
<string name="assist_and_voice_input_title">Assist & voice input</string>
|
||||||
@@ -7246,4 +7249,8 @@
|
|||||||
<string name="notification_log_details_default">default</string>
|
<string name="notification_log_details_default">default</string>
|
||||||
<!-- Notification log debug tool: the word 'none' -->
|
<!-- Notification log debug tool: the word 'none' -->
|
||||||
<string name="notification_log_details_none">none</string>
|
<string name="notification_log_details_none">none</string>
|
||||||
|
|
||||||
|
<!-- [CHAR_LIMIT=60] Label for special access screen -->
|
||||||
|
<string name="special_access">Special access</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -24,52 +24,80 @@
|
|||||||
android:title="@string/app_permissions"
|
android:title="@string/app_permissions"
|
||||||
settings:keywords="@string/keywords_app_permissions" />
|
settings:keywords="@string/keywords_app_permissions" />
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceCategory
|
||||||
|
android:title="@string/default_apps_title">
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
android:key="domain_urls"
|
android:key="domain_urls"
|
||||||
android:title="@string/domain_urls_title"
|
android:title="@string/domain_urls_title"
|
||||||
android:fragment="com.android.settings.applications.ManageApplications">
|
android:fragment="com.android.settings.applications.ManageApplications">
|
||||||
<extra
|
<extra
|
||||||
android:name="classname"
|
android:name="classname"
|
||||||
android:value="com.android.settings.Settings$DomainsURLsAppListActivity" />
|
android:value="com.android.settings.Settings$DomainsURLsAppListActivity" />
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="assist_and_voice_input"
|
||||||
|
android:fragment="com.android.settings.applications.ManageAssist"
|
||||||
|
android:title="@string/assist_and_voice_input_title" />
|
||||||
|
|
||||||
|
<com.android.settings.applications.DefaultHomePreference
|
||||||
|
android:key="default_home"
|
||||||
|
android:title="@string/home_app"
|
||||||
|
android:summary="@string/no_default_home" />
|
||||||
|
|
||||||
|
<com.android.settings.applications.DefaultBrowserPreference
|
||||||
|
android:key="default_browser"
|
||||||
|
android:title="@string/default_browser_title"
|
||||||
|
android:summary="@string/default_browser_title_none" />
|
||||||
|
|
||||||
|
<com.android.settings.applications.DefaultPhonePreference
|
||||||
|
android:key="default_phone_app"
|
||||||
|
android:title="@string/default_phone_title"
|
||||||
|
settings:keywords="@string/keywords_default_phone_app" />
|
||||||
|
|
||||||
|
<com.android.settings.applications.DefaultEmergencyPreference
|
||||||
|
android:key="default_emergency_app"
|
||||||
|
android:title="@string/default_emergency_app"
|
||||||
|
settings:keywords="@string/keywords_emergency_app" />
|
||||||
|
|
||||||
|
<com.android.settings.applications.DefaultSmsPreference
|
||||||
|
android:key="default_sms_app"
|
||||||
|
android:title="@string/sms_application_title"
|
||||||
|
settings:keywords="@string/keywords_more_default_sms_app" />
|
||||||
|
|
||||||
|
<com.android.settings.applications.DefaultNotificationAssistantPreference
|
||||||
|
android:key="default_notification_asst_app"
|
||||||
|
android:title="@string/default_notification_assistant" />
|
||||||
|
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<com.android.settings.WorkOnlyCategory
|
||||||
|
android:key="work_defaults"
|
||||||
|
android:title="@string/default_for_work">
|
||||||
|
|
||||||
|
<com.android.settings.applications.DefaultBrowserPreference
|
||||||
|
android:key="work_default_browser"
|
||||||
|
android:title="@string/default_browser_title"
|
||||||
|
android:summary="@string/default_browser_title_none"
|
||||||
|
settings:forWork="true" />
|
||||||
|
|
||||||
|
<com.android.settings.applications.DefaultPhonePreference
|
||||||
|
android:key="work_default_phone_app"
|
||||||
|
android:title="@string/default_phone_title"
|
||||||
|
settings:keywords="@string/keywords_default_phone_app"
|
||||||
|
settings:forWork="true" />
|
||||||
|
|
||||||
|
</com.android.settings.WorkOnlyCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="@string/advanced_apps" />
|
android:title="@string/advanced_apps">
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:key="default_apps"
|
android:key="special_access"
|
||||||
android:fragment="com.android.settings.applications.ManageDefaultApps"
|
android:fragment="com.android.settings.applications.SpecialAccessSettings"
|
||||||
android:title="@string/default_apps_title"
|
android:title="@string/special_access" />
|
||||||
settings:keywords="@string/keywords_default_apps" />
|
|
||||||
|
|
||||||
<PreferenceScreen
|
|
||||||
android:key="system_alert_window"
|
|
||||||
android:title="@string/system_alert_window_settings"
|
|
||||||
android:fragment="com.android.settings.applications.ManageApplications"
|
|
||||||
settings:keywords="@string/keywords_system_alert_window">
|
|
||||||
<extra
|
|
||||||
android:name="classname"
|
|
||||||
android:value="com.android.settings.Settings$OverlaySettingsActivity" />
|
|
||||||
</PreferenceScreen>
|
|
||||||
|
|
||||||
<PreferenceScreen
|
|
||||||
android:key="write_settings_apps"
|
|
||||||
android:title="@string/write_settings"
|
|
||||||
android:fragment="com.android.settings.applications.ManageApplications"
|
|
||||||
settings:keywords="@string/keywords_write_settings">
|
|
||||||
<extra
|
|
||||||
android:name="classname"
|
|
||||||
android:value="com.android.settings.Settings$WriteSettingsActivity" />
|
|
||||||
</PreferenceScreen>
|
|
||||||
|
|
||||||
<PreferenceScreen
|
|
||||||
android:key="high_power_apps"
|
|
||||||
android:title="@string/high_power_apps"
|
|
||||||
android:fragment="com.android.settings.applications.ManageApplications"
|
|
||||||
settings:keywords="@string/keywords_ignore_optimizations">
|
|
||||||
<extra
|
|
||||||
android:name="classname"
|
|
||||||
android:value="com.android.settings.Settings$HighPowerApplicationsActivity" />
|
|
||||||
</PreferenceScreen>
|
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -1,62 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- 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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<PreferenceScreen
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
|
||||||
android:key="default_apps">
|
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:key="assist_and_voice_input"
|
|
||||||
android:fragment="com.android.settings.applications.ManageAssist"
|
|
||||||
android:title="@string/assist_and_voice_input_title"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<com.android.settings.applications.DefaultHomePreference
|
|
||||||
android:key="default_home"
|
|
||||||
android:title="@string/home_app"
|
|
||||||
android:summary="@string/no_default_home"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<com.android.settings.applications.DefaultBrowserPreference
|
|
||||||
android:key="default_browser"
|
|
||||||
android:title="@string/default_browser_title"
|
|
||||||
android:summary="@string/default_browser_title_none"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<com.android.settings.applications.DefaultPhonePreference
|
|
||||||
android:key="default_phone_app"
|
|
||||||
android:title="@string/default_phone_title"
|
|
||||||
settings:keywords="@string/keywords_default_phone_app"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<com.android.settings.applications.DefaultEmergencyPreference
|
|
||||||
android:key="default_emergency_app"
|
|
||||||
android:title="@string/default_emergency_app"
|
|
||||||
settings:keywords="@string/keywords_emergency_app"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<com.android.settings.applications.DefaultSmsPreference
|
|
||||||
android:key="default_sms_app"
|
|
||||||
android:title="@string/sms_application_title"
|
|
||||||
settings:keywords="@string/keywords_more_default_sms_app"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<com.android.settings.applications.DefaultNotificationAssistantPreference
|
|
||||||
android:key="default_notification_asst_app"
|
|
||||||
android:title="@string/default_notification_assistant" />
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
|
80
res/xml/special_access.xml
Normal file
80
res/xml/special_access.xml
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- 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.
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:key="high_power_apps"
|
||||||
|
android:title="@string/high_power_apps"
|
||||||
|
android:fragment="com.android.settings.applications.ManageApplications"
|
||||||
|
settings:keywords="@string/keywords_ignore_optimizations">
|
||||||
|
<extra
|
||||||
|
android:name="classname"
|
||||||
|
android:value="com.android.settings.Settings$HighPowerApplicationsActivity" />
|
||||||
|
</PreferenceScreen>
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:key="device_administrators"
|
||||||
|
android:title="@string/manage_device_admin"
|
||||||
|
android:fragment="com.android.settings.DeviceAdminSettings" />
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:key="zen_access"
|
||||||
|
android:title="@string/manage_zen_access_title"
|
||||||
|
android:fragment="com.android.settings.notification.ZenAccessSettings" />
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:key="system_alert_window"
|
||||||
|
android:title="@string/system_alert_window_settings"
|
||||||
|
android:fragment="com.android.settings.applications.ManageApplications"
|
||||||
|
settings:keywords="@string/keywords_system_alert_window">
|
||||||
|
<extra
|
||||||
|
android:name="classname"
|
||||||
|
android:value="com.android.settings.Settings$OverlaySettingsActivity" />
|
||||||
|
</PreferenceScreen>
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:key="write_settings_apps"
|
||||||
|
android:title="@string/write_settings"
|
||||||
|
android:fragment="com.android.settings.applications.ManageApplications"
|
||||||
|
settings:keywords="@string/keywords_write_settings">
|
||||||
|
<extra
|
||||||
|
android:name="classname"
|
||||||
|
android:value="com.android.settings.Settings$WriteSettingsActivity" />
|
||||||
|
</PreferenceScreen>
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:key="notification_access"
|
||||||
|
android:title="@string/manage_notification_access_title"
|
||||||
|
android:fragment="com.android.settings.notification.NotificationAccessSettings" />
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:key="data_saver"
|
||||||
|
android:title="@string/unrestricted_data_saver"
|
||||||
|
android:fragment="com.android.settings.datausage.UnrestrictedDataAccess" />
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:key="usage_access"
|
||||||
|
android:title="@string/usage_access"
|
||||||
|
android:fragment="com.android.settings.applications.ManageApplications"
|
||||||
|
settings:keywords="@string/keywords_write_settings">
|
||||||
|
<extra
|
||||||
|
android:name="classname"
|
||||||
|
android:value="com.android.settings.Settings$UsageAccessSettingsActivity" />
|
||||||
|
</PreferenceScreen>
|
||||||
|
</PreferenceScreen>
|
@@ -23,9 +23,12 @@ import android.content.DialogInterface;
|
|||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
import android.os.UserHandle;
|
||||||
|
import android.os.UserManager;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -47,6 +50,9 @@ public class AppListPreference extends CustomListPreference {
|
|||||||
|
|
||||||
public static final String ITEM_NONE_VALUE = "";
|
public static final String ITEM_NONE_VALUE = "";
|
||||||
|
|
||||||
|
protected final boolean mForWork;
|
||||||
|
protected final int mUserId;
|
||||||
|
|
||||||
private Drawable[] mEntryDrawables;
|
private Drawable[] mEntryDrawables;
|
||||||
private boolean mShowItemNone = false;
|
private boolean mShowItemNone = false;
|
||||||
private CharSequence[] mSummaries;
|
private CharSequence[] mSummaries;
|
||||||
@@ -91,13 +97,24 @@ public class AppListPreference extends CustomListPreference {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AppListPreference(Context context, AttributeSet attrs,
|
public AppListPreference(Context context, AttributeSet attrs, int defStyle, int defAttrs) {
|
||||||
int defStyleAttr, int defStyleRes) {
|
super(context, attrs, defStyle, defAttrs);
|
||||||
super(context, attrs, defStyleAttr, defStyleRes);
|
|
||||||
|
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.WorkPreference, 0, 0);
|
||||||
|
mForWork = a.getBoolean(R.styleable.WorkPreference_forWork, false);
|
||||||
|
final UserHandle managedProfile = Utils.getManagedProfile(UserManager.get(context));
|
||||||
|
mUserId = mForWork && managedProfile != null ? managedProfile.getIdentifier()
|
||||||
|
: UserHandle.myUserId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AppListPreference(Context context, AttributeSet attrs) {
|
public AppListPreference(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
|
||||||
|
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.WorkPreference, 0, 0);
|
||||||
|
mForWork = a.getBoolean(R.styleable.WorkPreference_forWork, false);
|
||||||
|
final UserHandle managedProfile = Utils.getManagedProfile(UserManager.get(context));
|
||||||
|
mUserId = mForWork && managedProfile != null ? managedProfile.getIdentifier()
|
||||||
|
: UserHandle.myUserId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShowItemNone(boolean showItemNone) {
|
public void setShowItemNone(boolean showItemNone) {
|
||||||
@@ -114,7 +131,8 @@ public class AppListPreference extends CustomListPreference {
|
|||||||
int selectedIndex = -1;
|
int selectedIndex = -1;
|
||||||
for (int i = 0; i < packageNames.length; i++) {
|
for (int i = 0; i < packageNames.length; i++) {
|
||||||
try {
|
try {
|
||||||
ApplicationInfo appInfo = pm.getApplicationInfo(packageNames[i].toString(), 0);
|
ApplicationInfo appInfo = pm.getApplicationInfoAsUser(packageNames[i].toString(), 0,
|
||||||
|
mUserId);
|
||||||
applicationNames.add(appInfo.loadLabel(pm));
|
applicationNames.add(appInfo.loadLabel(pm));
|
||||||
validatedPackageNames.add(appInfo.packageName);
|
validatedPackageNames.add(appInfo.packageName);
|
||||||
entryDrawables.add(appInfo.loadIcon(pm));
|
entryDrawables.add(appInfo.loadIcon(pm));
|
||||||
@@ -162,8 +180,8 @@ public class AppListPreference extends CustomListPreference {
|
|||||||
int selectedIndex = -1;
|
int selectedIndex = -1;
|
||||||
for (int i = 0; i < componentNames.length; i++) {
|
for (int i = 0; i < componentNames.length; i++) {
|
||||||
try {
|
try {
|
||||||
ApplicationInfo appInfo = pm.getApplicationInfo(
|
ApplicationInfo appInfo = pm.getApplicationInfoAsUser(
|
||||||
componentNames[i].getPackageName().toString(), 0);
|
componentNames[i].getPackageName().toString(), 0, mUserId);
|
||||||
applicationNames.add(appInfo.loadLabel(pm));
|
applicationNames.add(appInfo.loadLabel(pm));
|
||||||
validatedComponentNames.add(componentNames[i].flattenToString());
|
validatedComponentNames.add(componentNames[i].flattenToString());
|
||||||
entryDrawables.add(appInfo.loadIcon(pm));
|
entryDrawables.add(appInfo.loadIcon(pm));
|
||||||
|
@@ -47,6 +47,7 @@ public abstract class InstrumentedFragment extends PreferenceFragment {
|
|||||||
// Used for generic logging of Settings Preference Persistence, should not be used
|
// Used for generic logging of Settings Preference Persistence, should not be used
|
||||||
// outside SharedPreferencesLogger.
|
// outside SharedPreferencesLogger.
|
||||||
public static final int ACTION_GENERIC_PACKAGE = UNDECLARED + 16;
|
public static final int ACTION_GENERIC_PACKAGE = UNDECLARED + 16;
|
||||||
|
public static final int SPECIAL_ACCESS = UNDECLARED + 17;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Declare the view of this category.
|
* Declare the view of this category.
|
||||||
|
@@ -21,7 +21,7 @@ import android.content.Context;
|
|||||||
/**
|
/**
|
||||||
* Interface for classes whose instances can provide the availability of the preference.
|
* Interface for classes whose instances can provide the availability of the preference.
|
||||||
*/
|
*/
|
||||||
public interface PreferenceAvailabilityProvider {
|
public interface SelfAvailablePreference {
|
||||||
/**
|
/**
|
||||||
* @return the availability of the preference. Please make sure the availability in managed
|
* @return the availability of the preference. Please make sure the availability in managed
|
||||||
* profile is taken into account.
|
* profile is taken into account.
|
@@ -124,7 +124,7 @@ public class Settings extends SettingsActivity {
|
|||||||
public static class WriteSettingsActivity extends SettingsActivity { /* empty */ }
|
public static class WriteSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class AppDrawOverlaySettingsActivity extends SettingsActivity { /* empty */ }
|
public static class AppDrawOverlaySettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class AppWriteSettingsActivity extends SettingsActivity { /* empty */ }
|
public static class AppWriteSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class ManageDefaultAppsActivity extends SettingsActivity { /* empty */ }
|
public static class AdvancedAppsActivity extends SettingsActivity { /* empty */ }
|
||||||
|
|
||||||
public static class WifiCallingSuggestionActivity extends SettingsActivity { /* empty */ }
|
public static class WifiCallingSuggestionActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class ZenModeAutomationSuggestionActivity extends SettingsActivity { /* empty */ }
|
public static class ZenModeAutomationSuggestionActivity extends SettingsActivity { /* empty */ }
|
||||||
|
@@ -56,11 +56,11 @@ import com.android.settings.accessibility.AccessibilitySettingsForSetupWizard;
|
|||||||
import com.android.settings.accessibility.CaptionPropertiesFragment;
|
import com.android.settings.accessibility.CaptionPropertiesFragment;
|
||||||
import com.android.settings.accounts.AccountSettings;
|
import com.android.settings.accounts.AccountSettings;
|
||||||
import com.android.settings.accounts.AccountSyncSettings;
|
import com.android.settings.accounts.AccountSyncSettings;
|
||||||
|
import com.android.settings.applications.AdvancedAppSettings;
|
||||||
import com.android.settings.applications.DrawOverlayDetails;
|
import com.android.settings.applications.DrawOverlayDetails;
|
||||||
import com.android.settings.applications.InstalledAppDetails;
|
import com.android.settings.applications.InstalledAppDetails;
|
||||||
import com.android.settings.applications.ManageApplications;
|
import com.android.settings.applications.ManageApplications;
|
||||||
import com.android.settings.applications.ManageAssist;
|
import com.android.settings.applications.ManageAssist;
|
||||||
import com.android.settings.applications.ManageDefaultApps;
|
|
||||||
import com.android.settings.applications.ProcessStatsSummary;
|
import com.android.settings.applications.ProcessStatsSummary;
|
||||||
import com.android.settings.applications.ProcessStatsUi;
|
import com.android.settings.applications.ProcessStatsUi;
|
||||||
import com.android.settings.applications.UsageAccessDetails;
|
import com.android.settings.applications.UsageAccessDetails;
|
||||||
@@ -315,7 +315,7 @@ public class SettingsActivity extends SettingsDrawerActivity
|
|||||||
ProcessStatsSummary.class.getName(),
|
ProcessStatsSummary.class.getName(),
|
||||||
DrawOverlayDetails.class.getName(),
|
DrawOverlayDetails.class.getName(),
|
||||||
WriteSettingsDetails.class.getName(),
|
WriteSettingsDetails.class.getName(),
|
||||||
ManageDefaultApps.class.getName(),
|
AdvancedAppSettings.class.getName(),
|
||||||
WallpaperTypeSettings.class.getName(),
|
WallpaperTypeSettings.class.getName(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -25,6 +25,7 @@ import android.content.Context;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.XmlRes;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.PreferenceGroup;
|
import android.support.v7.preference.PreferenceGroup;
|
||||||
import android.support.v7.preference.PreferenceGroupAdapter;
|
import android.support.v7.preference.PreferenceGroupAdapter;
|
||||||
@@ -132,6 +133,25 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
|
|||||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addPreferencesFromResource(@XmlRes int preferencesResId) {
|
||||||
|
super.addPreferencesFromResource(preferencesResId);
|
||||||
|
checkAvailablePrefs(getPreferenceScreen());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkAvailablePrefs(PreferenceGroup preferenceGroup) {
|
||||||
|
if (preferenceGroup == null) return;
|
||||||
|
for (int i = 0; i < preferenceGroup.getPreferenceCount(); i++) {
|
||||||
|
Preference pref = preferenceGroup.getPreference(i);
|
||||||
|
if (pref instanceof SelfAvailablePreference
|
||||||
|
&& !((SelfAvailablePreference) pref).isAvailable(getContext())) {
|
||||||
|
preferenceGroup.removePreference(pref);
|
||||||
|
} else if (pref instanceof PreferenceGroup) {
|
||||||
|
checkAvailablePrefs((PreferenceGroup) pref);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public FloatingActionButton getFloatingActionButton() {
|
public FloatingActionButton getFloatingActionButton() {
|
||||||
return mFloatingActionButton;
|
return mFloatingActionButton;
|
||||||
}
|
}
|
||||||
|
@@ -64,6 +64,8 @@ import android.provider.ContactsContract.RawContacts;
|
|||||||
import android.service.persistentdata.PersistentDataBlockManager;
|
import android.service.persistentdata.PersistentDataBlockManager;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.PreferenceGroup;
|
import android.support.v7.preference.PreferenceGroup;
|
||||||
|
import android.support.v7.preference.PreferenceManager;
|
||||||
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
@@ -83,7 +85,6 @@ import android.view.animation.AnimationUtils;
|
|||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TabWidget;
|
import android.widget.TabWidget;
|
||||||
import com.android.internal.util.UserIcons;
|
import com.android.internal.util.UserIcons;
|
||||||
import com.android.settings.datausage.DataUsageList;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -1025,5 +1026,41 @@ public final class Utils extends com.android.settingslib.Utils {
|
|||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<String> getNonIndexable(int xml, Context context) {
|
||||||
|
List<String> ret = new ArrayList<>();
|
||||||
|
PreferenceManager manager = new PreferenceManager(context);
|
||||||
|
PreferenceScreen screen = manager.inflateFromResource(context, xml, null);
|
||||||
|
checkPrefs(screen, ret);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void checkPrefs(PreferenceGroup group, List<String> ret) {
|
||||||
|
if (group == null) return;
|
||||||
|
for (int i = 0; i < group.getPreferenceCount(); i++) {
|
||||||
|
Preference pref = group.getPreference(i);
|
||||||
|
if (pref instanceof SelfAvailablePreference
|
||||||
|
&& !((SelfAvailablePreference) pref).isAvailable(group.getContext())) {
|
||||||
|
ret.add(pref.getKey());
|
||||||
|
if (pref instanceof PreferenceGroup) {
|
||||||
|
addAll((PreferenceGroup) pref, ret);
|
||||||
|
}
|
||||||
|
} else if (pref instanceof PreferenceGroup) {
|
||||||
|
checkPrefs((PreferenceGroup) pref, ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addAll(PreferenceGroup group, List<String> ret) {
|
||||||
|
if (group == null) return;
|
||||||
|
for (int i = 0; i < group.getPreferenceCount(); i++) {
|
||||||
|
Preference pref = group.getPreference(i);
|
||||||
|
ret.add(pref.getKey());
|
||||||
|
if (pref instanceof PreferenceGroup) {
|
||||||
|
addAll((PreferenceGroup) pref, ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
35
src/com/android/settings/WorkOnlyCategory.java
Normal file
35
src/com/android/settings/WorkOnlyCategory.java
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* 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. 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;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.UserManager;
|
||||||
|
import android.support.v7.preference.PreferenceCategory;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A PreferenceCategory that is only visible when the device has a work profile.
|
||||||
|
*/
|
||||||
|
public class WorkOnlyCategory extends PreferenceCategory implements SelfAvailablePreference {
|
||||||
|
|
||||||
|
public WorkOnlyCategory(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAvailable(Context context) {
|
||||||
|
return Utils.getManagedProfile(UserManager.get(context)) != null;
|
||||||
|
}
|
||||||
|
}
|
@@ -16,23 +16,29 @@
|
|||||||
package com.android.settings.applications;
|
package com.android.settings.applications;
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.provider.SearchIndexableResource;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
|
|
||||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.applications.PermissionsSummaryHelper.PermissionsResultCallback;
|
import com.android.settings.applications.PermissionsSummaryHelper.PermissionsResultCallback;
|
||||||
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
|
import com.android.settings.search.Indexable;
|
||||||
import com.android.settingslib.applications.ApplicationsState;
|
import com.android.settingslib.applications.ApplicationsState;
|
||||||
import com.android.settingslib.applications.ApplicationsState.AppEntry;
|
import com.android.settingslib.applications.ApplicationsState.AppEntry;
|
||||||
import com.android.settingslib.applications.ApplicationsState.Session;
|
import com.android.settingslib.applications.ApplicationsState.Session;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class AdvancedAppSettings extends SettingsPreferenceFragment implements
|
public class AdvancedAppSettings extends SettingsPreferenceFragment implements
|
||||||
ApplicationsState.Callbacks {
|
ApplicationsState.Callbacks, Indexable {
|
||||||
|
|
||||||
static final String TAG = "AdvancedAppSettings";
|
static final String TAG = "AdvancedAppSettings";
|
||||||
|
|
||||||
@@ -176,4 +182,20 @@ public class AdvancedAppSettings extends SettingsPreferenceFragment implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||||
|
new BaseSearchIndexProvider() {
|
||||||
|
@Override
|
||||||
|
public List<SearchIndexableResource> getXmlResourcesToIndex(
|
||||||
|
Context context, boolean enabled) {
|
||||||
|
SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||||
|
sir.xmlResId = R.xml.advanced_apps;
|
||||||
|
return Arrays.asList(sir);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getNonIndexableKeys(Context context) {
|
||||||
|
return Utils.getNonIndexable(R.xml.advanced_apps, context);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@@ -136,7 +136,8 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment
|
|||||||
mPackageInfo = mPm.getPackageInfo(mAppEntry.info.packageName,
|
mPackageInfo = mPm.getPackageInfo(mAppEntry.info.packageName,
|
||||||
PackageManager.GET_DISABLED_COMPONENTS |
|
PackageManager.GET_DISABLED_COMPONENTS |
|
||||||
PackageManager.GET_UNINSTALLED_PACKAGES |
|
PackageManager.GET_UNINSTALLED_PACKAGES |
|
||||||
PackageManager.GET_SIGNATURES);
|
PackageManager.GET_SIGNATURES |
|
||||||
|
PackageManager.GET_PERMISSIONS);
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
Log.e(TAG, "Exception when retrieving package:" + mAppEntry.info.packageName, e);
|
Log.e(TAG, "Exception when retrieving package:" + mAppEntry.info.packageName, e);
|
||||||
}
|
}
|
||||||
|
@@ -43,7 +43,8 @@ public abstract class AppStateBaseBridge implements ApplicationsState.Callbacks
|
|||||||
// Running on the same background thread as the ApplicationsState lets
|
// Running on the same background thread as the ApplicationsState lets
|
||||||
// us run in the background and make sure they aren't doing updates at
|
// us run in the background and make sure they aren't doing updates at
|
||||||
// the same time as us as well.
|
// the same time as us as well.
|
||||||
mHandler = new BackgroundHandler(mAppState.getBackgroundLooper());
|
mHandler = new BackgroundHandler(mAppState != null ? mAppState.getBackgroundLooper()
|
||||||
|
: Looper.getMainLooper());
|
||||||
mMainHandler = new MainHandler();
|
mMainHandler = new MainHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,17 +21,26 @@ import android.content.Intent;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Handler;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.util.Log;
|
||||||
|
import com.android.internal.content.PackageMonitor;
|
||||||
import com.android.settings.AppListPreference;
|
import com.android.settings.AppListPreference;
|
||||||
import com.android.settings.PreferenceAvailabilityProvider;
|
import com.android.settings.R;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DefaultBrowserPreference extends AppListPreference {
|
public class DefaultBrowserPreference extends AppListPreference {
|
||||||
|
|
||||||
|
private static final String TAG = "DefaultBrowserPref";
|
||||||
|
|
||||||
|
private static final long DELAY_UPDATE_BROWSER_MILLIS = 500;
|
||||||
|
|
||||||
|
private final Handler mHandler = new Handler();
|
||||||
|
|
||||||
final private PackageManager mPm;
|
final private PackageManager mPm;
|
||||||
|
|
||||||
public DefaultBrowserPreference(Context context, AttributeSet attrs) {
|
public DefaultBrowserPreference(Context context, AttributeSet attrs) {
|
||||||
@@ -41,12 +50,70 @@ public class DefaultBrowserPreference extends AppListPreference {
|
|||||||
refreshBrowserApps();
|
refreshBrowserApps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttached() {
|
||||||
|
super.onAttached();
|
||||||
|
updateDefaultBrowserPreference();
|
||||||
|
mPackageMonitor.register(getContext(), getContext().getMainLooper(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDetached() {
|
||||||
|
mPackageMonitor.unregister();
|
||||||
|
super.onDetached();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean persistString(String newValue) {
|
||||||
|
|
||||||
|
if (newValue == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final CharSequence packageName = (CharSequence) newValue;
|
||||||
|
if (TextUtils.isEmpty(packageName)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
boolean result = mPm.setDefaultBrowserPackageNameAsUser(
|
||||||
|
packageName.toString(), mUserId);
|
||||||
|
if (result) {
|
||||||
|
setSummary("%s");
|
||||||
|
}
|
||||||
|
return result && super.persistString(newValue);
|
||||||
|
}
|
||||||
|
|
||||||
public void refreshBrowserApps() {
|
public void refreshBrowserApps() {
|
||||||
List<String> browsers = resolveBrowserApps();
|
List<String> browsers = resolveBrowserApps();
|
||||||
|
|
||||||
setPackageNames(browsers.toArray(new String[browsers.size()]), null);
|
setPackageNames(browsers.toArray(new String[browsers.size()]), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateDefaultBrowserPreference() {
|
||||||
|
refreshBrowserApps();
|
||||||
|
|
||||||
|
final PackageManager pm = getContext().getPackageManager();
|
||||||
|
|
||||||
|
String packageName = pm.getDefaultBrowserPackageNameAsUser(mUserId);
|
||||||
|
if (!TextUtils.isEmpty(packageName)) {
|
||||||
|
// Check if the default Browser package is still there
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setPackage(packageName);
|
||||||
|
intent.setAction(Intent.ACTION_VIEW);
|
||||||
|
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||||
|
intent.setData(Uri.parse("http:"));
|
||||||
|
|
||||||
|
ResolveInfo info = mPm.resolveActivityAsUser(intent, 0, mUserId);
|
||||||
|
if (info != null) {
|
||||||
|
setValue(packageName);
|
||||||
|
setSummary("%s");
|
||||||
|
} else {
|
||||||
|
setSummary(R.string.default_browser_title_none);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setSummary(R.string.default_browser_title_none);
|
||||||
|
Log.d(TAG, "Cannot set empty default Browser value!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private List<String> resolveBrowserApps() {
|
private List<String> resolveBrowserApps() {
|
||||||
List<String> result = new ArrayList<>();
|
List<String> result = new ArrayList<>();
|
||||||
|
|
||||||
@@ -58,7 +125,7 @@ public class DefaultBrowserPreference extends AppListPreference {
|
|||||||
|
|
||||||
// Resolve that intent and check that the handleAllWebDataURI boolean is set
|
// Resolve that intent and check that the handleAllWebDataURI boolean is set
|
||||||
List<ResolveInfo> list = mPm.queryIntentActivitiesAsUser(intent, PackageManager.MATCH_ALL,
|
List<ResolveInfo> list = mPm.queryIntentActivitiesAsUser(intent, PackageManager.MATCH_ALL,
|
||||||
UserHandle.myUserId());
|
mUserId);
|
||||||
|
|
||||||
final int count = list.size();
|
final int count = list.size();
|
||||||
for (int i=0; i<count; i++) {
|
for (int i=0; i<count; i++) {
|
||||||
@@ -74,10 +141,53 @@ public class DefaultBrowserPreference extends AppListPreference {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AvailabilityProvider implements PreferenceAvailabilityProvider {
|
private final Runnable mUpdateRunnable = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable(Context context) {
|
public void run() {
|
||||||
return true;
|
updateDefaultBrowserPreference();
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private final PackageMonitor mPackageMonitor = new PackageMonitor() {
|
||||||
|
@Override
|
||||||
|
public void onPackageAdded(String packageName, int uid) {
|
||||||
|
sendUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPackageAppeared(String packageName, int reason) {
|
||||||
|
sendUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPackageDisappeared(String packageName, int reason) {
|
||||||
|
sendUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPackageRemoved(String packageName, int uid) {
|
||||||
|
sendUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendUpdate() {
|
||||||
|
mHandler.postDelayed(mUpdateRunnable, DELAY_UPDATE_BROWSER_MILLIS);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public static boolean hasBrowserPreference(String pkg, Context context) {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setAction(Intent.ACTION_VIEW);
|
||||||
|
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||||
|
intent.setData(Uri.parse("http:"));
|
||||||
|
intent.setPackage(pkg);
|
||||||
|
final List<ResolveInfo> resolveInfos =
|
||||||
|
context.getPackageManager().queryIntentActivities(intent, 0);
|
||||||
|
return resolveInfos != null && resolveInfos.size() != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isBrowserDefault(String pkg, Context context) {
|
||||||
|
String defaultPackage = context.getPackageManager()
|
||||||
|
.getDefaultBrowserPackageNameAsUser(UserHandle.myUserId());
|
||||||
|
return defaultPackage != null && defaultPackage.equals(pkg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.applications;
|
package com.android.settings.applications;
|
||||||
|
|
||||||
|
import android.content.ComponentName;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -24,16 +25,14 @@ import android.content.pm.PackageInfo;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.UserManager;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import com.android.internal.telephony.SmsApplication;
|
||||||
import com.android.settings.AppListPreference;
|
import com.android.settings.AppListPreference;
|
||||||
import com.android.settings.PreferenceAvailabilityProvider;
|
import com.android.settings.SelfAvailablePreference;
|
||||||
import com.android.settings.Utils;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -42,7 +41,8 @@ import java.util.Set;
|
|||||||
/**
|
/**
|
||||||
* A preference for choosing the default emergency app
|
* A preference for choosing the default emergency app
|
||||||
*/
|
*/
|
||||||
public class DefaultEmergencyPreference extends AppListPreference {
|
public class DefaultEmergencyPreference extends AppListPreference
|
||||||
|
implements SelfAvailablePreference {
|
||||||
|
|
||||||
private final ContentResolver mContentResolver;
|
private final ContentResolver mContentResolver;
|
||||||
|
|
||||||
@@ -144,12 +144,22 @@ public class DefaultEmergencyPreference extends AppListPreference {
|
|||||||
&& (info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
|
&& (info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AvailabilityProvider implements PreferenceAvailabilityProvider {
|
public boolean isAvailable(Context context) {
|
||||||
@Override
|
return isCapable(context)
|
||||||
public boolean isAvailable(Context context) {
|
&& context.getPackageManager().resolveActivity(QUERY_INTENT, 0) != null;
|
||||||
return isCapable(context)
|
}
|
||||||
&& context.getPackageManager().resolveActivity(QUERY_INTENT, 0) != null
|
|
||||||
&& !Utils.isManagedProfile(UserManager.get(context));
|
public static boolean hasEmergencyPreference(String pkg, Context context) {
|
||||||
}
|
Intent i = new Intent(QUERY_INTENT);
|
||||||
|
i.setPackage(pkg);
|
||||||
|
final List<ResolveInfo> resolveInfos =
|
||||||
|
context.getPackageManager().queryIntentActivities(i, 0);
|
||||||
|
return resolveInfos != null && resolveInfos.size() != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isEmergencyDefault(String pkg, Context context) {
|
||||||
|
String defaultPackage = Settings.Secure.getString(context.getContentResolver(),
|
||||||
|
Settings.Secure.EMERGENCY_ASSISTANCE_APPLICATION);
|
||||||
|
return defaultPackage != null && defaultPackage.equals(pkg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,11 +26,8 @@ import android.content.pm.UserInfo;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
import com.android.settings.AppListPreference;
|
import com.android.settings.AppListPreference;
|
||||||
import com.android.settings.PreferenceAvailabilityProvider;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Utils;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -118,10 +115,23 @@ public class DefaultHomePreference extends AppListPreference {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AvailabilityProvider implements PreferenceAvailabilityProvider {
|
public static boolean hasHomePreference(String pkg, Context context) {
|
||||||
@Override
|
ArrayList<ResolveInfo> homeActivities = new ArrayList<ResolveInfo>();
|
||||||
public boolean isAvailable(Context context) {
|
PackageManager pm = context.getPackageManager();
|
||||||
return !Utils.isManagedProfile(UserManager.get(context));
|
pm.getHomeActivities(homeActivities);
|
||||||
|
for (int i = 0; i < homeActivities.size(); i++) {
|
||||||
|
if (homeActivities.get(i).activityInfo.packageName.equals(pkg)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isHomeDefault(String pkg, Context context) {
|
||||||
|
ArrayList<ResolveInfo> homeActivities = new ArrayList<ResolveInfo>();
|
||||||
|
PackageManager pm = context.getPackageManager();
|
||||||
|
ComponentName def = pm.getHomeActivities(homeActivities);
|
||||||
|
|
||||||
|
return def != null && def.getPackageName().equals(pkg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package com.android.settings.applications;
|
package com.android.settings.applications;
|
||||||
|
|
||||||
import com.android.settings.AppListPreference;
|
|
||||||
|
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -25,20 +23,17 @@ import android.content.Intent;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.content.pm.ServiceInfo;
|
import android.content.pm.ServiceInfo;
|
||||||
import android.os.UserManager;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.service.notification.NotificationAssistantService;
|
import android.service.notification.NotificationAssistantService;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
|
import com.android.settings.AppListPreference;
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.notification.ManagedServiceSettings;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.android.settings.PreferenceAvailabilityProvider;
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.Utils;
|
|
||||||
import com.android.settings.notification.ManagedServiceSettings;
|
|
||||||
|
|
||||||
public class DefaultNotificationAssistantPreference extends AppListPreference {
|
public class DefaultNotificationAssistantPreference extends AppListPreference {
|
||||||
private static final String TAG = "DefaultNotiAssist";
|
private static final String TAG = "DefaultNotiAssist";
|
||||||
|
|
||||||
@@ -111,11 +106,4 @@ public class DefaultNotificationAssistantPreference extends AppListPreference {
|
|||||||
c.emptyText = R.string.no_notification_listeners;
|
c.emptyText = R.string.no_notification_listeners;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AvailabilityProvider implements PreferenceAvailabilityProvider {
|
|
||||||
@Override
|
|
||||||
public boolean isAvailable(Context context) {
|
|
||||||
return !Utils.isManagedProfile(UserManager.get(context));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -17,21 +17,19 @@
|
|||||||
package com.android.settings.applications;
|
package com.android.settings.applications;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.telecom.DefaultDialerManager;
|
import android.telecom.DefaultDialerManager;
|
||||||
import android.telecom.TelecomManager;
|
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
import com.android.settings.AppListPreference;
|
import com.android.settings.AppListPreference;
|
||||||
import com.android.settings.PreferenceAvailabilityProvider;
|
import com.android.settings.SelfAvailablePreference;
|
||||||
import com.android.settings.Utils;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class DefaultPhonePreference extends AppListPreference {
|
public class DefaultPhonePreference extends AppListPreference implements SelfAvailablePreference {
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
|
|
||||||
public DefaultPhonePreference(Context context, AttributeSet attrs) {
|
public DefaultPhonePreference(Context context, AttributeSet attrs) {
|
||||||
@@ -44,7 +42,7 @@ public class DefaultPhonePreference extends AppListPreference {
|
|||||||
@Override
|
@Override
|
||||||
protected boolean persistString(String value) {
|
protected boolean persistString(String value) {
|
||||||
if (!TextUtils.isEmpty(value) && !Objects.equals(value, getDefaultPackage())) {
|
if (!TextUtils.isEmpty(value) && !Objects.equals(value, getDefaultPackage())) {
|
||||||
TelecomManager.from(mContext).setDefaultDialer(value);
|
DefaultDialerManager.setDefaultDialerApplication(getContext(), value, mUserId);
|
||||||
}
|
}
|
||||||
setSummary(getEntry());
|
setSummary(getEntry());
|
||||||
return true;
|
return true;
|
||||||
@@ -52,7 +50,7 @@ public class DefaultPhonePreference extends AppListPreference {
|
|||||||
|
|
||||||
private void loadDialerApps() {
|
private void loadDialerApps() {
|
||||||
List<String> dialerPackages =
|
List<String> dialerPackages =
|
||||||
DefaultDialerManager.getInstalledDialerApplications(getContext());
|
DefaultDialerManager.getInstalledDialerApplications(getContext(), mUserId);
|
||||||
|
|
||||||
final String[] dialers = new String[dialerPackages.size()];
|
final String[] dialers = new String[dialerPackages.size()];
|
||||||
for (int i = 0; i < dialerPackages.size(); i++) {
|
for (int i = 0; i < dialerPackages.size(); i++) {
|
||||||
@@ -62,22 +60,31 @@ public class DefaultPhonePreference extends AppListPreference {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getDefaultPackage() {
|
private String getDefaultPackage() {
|
||||||
return DefaultDialerManager.getDefaultDialerApplication(getContext());
|
return DefaultDialerManager.getDefaultDialerApplication(getContext(), mUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AvailabilityProvider implements PreferenceAvailabilityProvider {
|
@Override
|
||||||
@Override
|
public boolean isAvailable(Context context) {
|
||||||
public boolean isAvailable(Context context) {
|
final TelephonyManager tm =
|
||||||
|
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
final TelephonyManager tm =
|
if (!tm.isVoiceCapable()) {
|
||||||
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
return false;
|
||||||
if (!tm.isVoiceCapable()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final UserManager um =
|
|
||||||
(UserManager) context.getSystemService(Context.USER_SERVICE);
|
|
||||||
return !um.hasUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final UserManager um =
|
||||||
|
(UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||||
|
return !um.hasUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean hasPhonePreference(String pkg, Context context) {
|
||||||
|
List<String> dialerPackages =
|
||||||
|
DefaultDialerManager.getInstalledDialerApplications(context, UserHandle.myUserId());
|
||||||
|
return dialerPackages.contains(pkg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isPhoneDefault(String pkg, Context context) {
|
||||||
|
String def = DefaultDialerManager.getDefaultDialerApplication(context,
|
||||||
|
UserHandle.myUserId());
|
||||||
|
return def != null && def.equals(pkg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,17 +22,15 @@ import android.os.UserManager;
|
|||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
import com.android.internal.telephony.SmsApplication;
|
import com.android.internal.telephony.SmsApplication;
|
||||||
import com.android.internal.telephony.SmsApplication.SmsApplicationData;
|
import com.android.internal.telephony.SmsApplication.SmsApplicationData;
|
||||||
import com.android.settings.AppListPreference;
|
import com.android.settings.AppListPreference;
|
||||||
import com.android.settings.PreferenceAvailabilityProvider;
|
import com.android.settings.SelfAvailablePreference;
|
||||||
import com.android.settings.Utils;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class DefaultSmsPreference extends AppListPreference {
|
public class DefaultSmsPreference extends AppListPreference implements SelfAvailablePreference {
|
||||||
|
|
||||||
public DefaultSmsPreference(Context context, AttributeSet attrs) {
|
public DefaultSmsPreference(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
@@ -70,18 +68,29 @@ public class DefaultSmsPreference extends AppListPreference {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AvailabilityProvider implements PreferenceAvailabilityProvider {
|
@Override
|
||||||
@Override
|
public boolean isAvailable(Context context) {
|
||||||
public boolean isAvailable(Context context) {
|
boolean isRestrictedUser =
|
||||||
boolean isRestrictedUser =
|
UserManager.get(context)
|
||||||
UserManager.get(context)
|
.getUserInfo(UserHandle.myUserId()).isRestricted();
|
||||||
.getUserInfo(UserHandle.myUserId()).isRestricted();
|
TelephonyManager tm =
|
||||||
TelephonyManager tm =
|
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
return !isRestrictedUser && tm.isSmsCapable();
|
||||||
return !isRestrictedUser
|
|
||||||
&& tm.isSmsCapable()
|
|
||||||
&& !Utils.isManagedProfile(UserManager.get(context));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean hasSmsPreference(String pkg, Context context) {
|
||||||
|
Collection<SmsApplicationData> smsApplications =
|
||||||
|
SmsApplication.getApplicationCollection(context);
|
||||||
|
for (SmsApplicationData data : smsApplications) {
|
||||||
|
if (data.mPackageName.equals(pkg)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSmsDefault(String pkg, Context context) {
|
||||||
|
ComponentName appName = SmsApplication.getDefaultSmsApplication(context, true);
|
||||||
|
return appName != null && appName.getPackageName().equals(pkg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -156,13 +156,17 @@ public class DrawOverlayDetails extends AppInfoWithHeader implements OnPreferenc
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static CharSequence getSummary(Context context, AppEntry entry) {
|
public static CharSequence getSummary(Context context, AppEntry entry) {
|
||||||
if (entry.extraInfo != null) {
|
OverlayState state;
|
||||||
return getSummary(context, new OverlayState((PermissionState)entry.extraInfo));
|
if (entry.extraInfo instanceof OverlayState) {
|
||||||
|
state = (OverlayState) entry.extraInfo;
|
||||||
|
} else if (entry.extraInfo instanceof PermissionState) {
|
||||||
|
state = new OverlayState((PermissionState) entry.extraInfo);
|
||||||
|
} else {
|
||||||
|
state = new AppStateOverlayBridge(context, null, null).getOverlayInfo(
|
||||||
|
entry.info.packageName, entry.info.uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fallback if for whatever reason entry.extrainfo is null - the result
|
return getSummary(context, state);
|
||||||
// may be less accurate
|
|
||||||
return getSummary(context, entry.info.packageName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CharSequence getSummary(Context context, OverlayState overlayState) {
|
public static CharSequence getSummary(Context context, OverlayState overlayState) {
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.applications;
|
package com.android.settings.applications;
|
||||||
|
|
||||||
|
import android.Manifest.permission;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
@@ -51,6 +52,8 @@ import android.os.UserHandle;
|
|||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.Preference.OnPreferenceClickListener;
|
import android.support.v7.preference.Preference.OnPreferenceClickListener;
|
||||||
|
import android.support.v7.preference.PreferenceCategory;
|
||||||
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
import android.text.format.Formatter;
|
import android.text.format.Formatter;
|
||||||
@@ -285,6 +288,7 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
|
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
addPreferencesFromResource(R.xml.installed_app_details);
|
addPreferencesFromResource(R.xml.installed_app_details);
|
||||||
|
addDynamicPrefs();
|
||||||
|
|
||||||
if (Utils.isBandwidthControlEnabled()) {
|
if (Utils.isBandwidthControlEnabled()) {
|
||||||
INetworkStatsService statsService = INetworkStatsService.Stub.asInterface(
|
INetworkStatsService statsService = INetworkStatsService.Stub.asInterface(
|
||||||
@@ -321,6 +325,7 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
}
|
}
|
||||||
new BatteryUpdater().execute();
|
new BatteryUpdater().execute();
|
||||||
new MemoryUpdater().execute();
|
new MemoryUpdater().execute();
|
||||||
|
updateDynamicPrefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -806,6 +811,119 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addDynamicPrefs() {
|
||||||
|
if (Utils.isManagedProfile(UserManager.get(getContext()))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final PreferenceScreen screen = getPreferenceScreen();
|
||||||
|
if (DefaultHomePreference.hasHomePreference(mPackageName, getContext())) {
|
||||||
|
screen.addPreference(new ShortcutPreference(getPrefContext(),
|
||||||
|
AdvancedAppSettings.class, "default_home", R.string.home_app,
|
||||||
|
R.string.configure_apps));
|
||||||
|
}
|
||||||
|
if (DefaultBrowserPreference.hasBrowserPreference(mPackageName, getContext())) {
|
||||||
|
screen.addPreference(new ShortcutPreference(getPrefContext(),
|
||||||
|
AdvancedAppSettings.class, "default_browser", R.string.default_browser_title,
|
||||||
|
R.string.configure_apps));
|
||||||
|
}
|
||||||
|
if (DefaultPhonePreference.hasPhonePreference(mPackageName, getContext())) {
|
||||||
|
screen.addPreference(new ShortcutPreference(getPrefContext(),
|
||||||
|
AdvancedAppSettings.class, "default_phone_app", R.string.default_phone_title,
|
||||||
|
R.string.configure_apps));
|
||||||
|
}
|
||||||
|
if (DefaultEmergencyPreference.hasEmergencyPreference(mPackageName, getContext())) {
|
||||||
|
screen.addPreference(new ShortcutPreference(getPrefContext(),
|
||||||
|
AdvancedAppSettings.class, "default_emergency_app",
|
||||||
|
R.string.default_emergency_app, R.string.configure_apps));
|
||||||
|
}
|
||||||
|
if (DefaultSmsPreference.hasSmsPreference(mPackageName, getContext())) {
|
||||||
|
screen.addPreference(new ShortcutPreference(getPrefContext(),
|
||||||
|
AdvancedAppSettings.class, "default_sms_app", R.string.sms_application_title,
|
||||||
|
R.string.configure_apps));
|
||||||
|
}
|
||||||
|
boolean hasDrawOverOtherApps = hasPermission(permission.SYSTEM_ALERT_WINDOW);
|
||||||
|
boolean hasWriteSettings = hasPermission(permission.WRITE_SETTINGS);
|
||||||
|
if (hasDrawOverOtherApps || hasWriteSettings) {
|
||||||
|
PreferenceCategory category = new PreferenceCategory(getPrefContext());
|
||||||
|
category.setTitle(R.string.advanced_apps);
|
||||||
|
screen.addPreference(category);
|
||||||
|
|
||||||
|
if (hasDrawOverOtherApps) {
|
||||||
|
Preference pref = new Preference(getPrefContext());
|
||||||
|
pref.setTitle(R.string.draw_overlay);
|
||||||
|
pref.setKey("system_alert_window");
|
||||||
|
pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
startAppInfoFragment(DrawOverlayDetails.class,
|
||||||
|
getString(R.string.draw_overlay));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
category.addPreference(pref);
|
||||||
|
}
|
||||||
|
if (hasWriteSettings) {
|
||||||
|
Preference pref = new Preference(getPrefContext());
|
||||||
|
pref.setTitle(R.string.write_settings);
|
||||||
|
pref.setKey("write_settings_apps");
|
||||||
|
pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
startAppInfoFragment(WriteSettingsDetails.class,
|
||||||
|
getString(R.string.write_settings));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
category.addPreference(pref);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasPermission(String permission) {
|
||||||
|
for (int i = 0; i < mPackageInfo.requestedPermissions.length; i++) {
|
||||||
|
if (mPackageInfo.requestedPermissions[i].equals(permission)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateDynamicPrefs() {
|
||||||
|
Preference pref = findPreference("default_home");
|
||||||
|
if (pref != null) {
|
||||||
|
pref.setSummary(DefaultHomePreference.isHomeDefault(mPackageName, getContext())
|
||||||
|
? R.string.yes : R.string.no);
|
||||||
|
}
|
||||||
|
pref = findPreference("default_browser");
|
||||||
|
if (pref != null) {
|
||||||
|
pref.setSummary(DefaultBrowserPreference.isBrowserDefault(mPackageName, getContext())
|
||||||
|
? R.string.yes : R.string.no);
|
||||||
|
}
|
||||||
|
pref = findPreference("default_phone_app");
|
||||||
|
if (pref != null) {
|
||||||
|
pref.setSummary(DefaultPhonePreference.isPhoneDefault(mPackageName, getContext())
|
||||||
|
? R.string.yes : R.string.no);
|
||||||
|
}
|
||||||
|
pref = findPreference("default_emergency_app");
|
||||||
|
if (pref != null) {
|
||||||
|
pref.setSummary(DefaultEmergencyPreference.isEmergencyDefault(mPackageName,
|
||||||
|
getContext()) ? R.string.yes : R.string.no);
|
||||||
|
}
|
||||||
|
pref = findPreference("default_sms_app");
|
||||||
|
if (pref != null) {
|
||||||
|
pref.setSummary(DefaultSmsPreference.isSmsDefault(mPackageName, getContext())
|
||||||
|
? R.string.yes : R.string.no);
|
||||||
|
}
|
||||||
|
pref = findPreference("system_alert_window");
|
||||||
|
if (pref != null) {
|
||||||
|
pref.setSummary(DrawOverlayDetails.getSummary(getContext(), mAppEntry));
|
||||||
|
}
|
||||||
|
pref = findPreference("write_settings_apps");
|
||||||
|
if (pref != null) {
|
||||||
|
pref.setSummary(WriteSettingsDetails.getSummary(getContext(), mAppEntry));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void setupAppSnippet(View appSnippet, CharSequence label, Drawable icon,
|
public static void setupAppSnippet(View appSnippet, CharSequence label, Drawable icon,
|
||||||
CharSequence versionName) {
|
CharSequence versionName) {
|
||||||
LayoutInflater.from(appSnippet.getContext()).inflate(R.layout.widget_text_views,
|
LayoutInflater.from(appSnippet.getContext()).inflate(R.layout.widget_text_views,
|
||||||
|
@@ -18,20 +18,15 @@ package com.android.settings.applications;
|
|||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.UserManager;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.v14.preference.SwitchPreference;
|
import android.support.v14.preference.SwitchPreference;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
|
|
||||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||||
import com.android.settings.PreferenceAvailabilityProvider;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
import com.android.settings.Utils;
|
|
||||||
import com.android.settings.voice.VoiceInputListPreference;
|
import com.android.settings.voice.VoiceInputListPreference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -179,11 +174,4 @@ public class ManageAssist extends SettingsPreferenceFragment
|
|||||||
mDefaultAssitPref.setValue(assistPackage);
|
mDefaultAssitPref.setValue(assistPackage);
|
||||||
updateUi();
|
updateUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AvailabilityProvider implements PreferenceAvailabilityProvider {
|
|
||||||
@Override
|
|
||||||
public boolean isAvailable(Context context) {
|
|
||||||
return !Utils.isManagedProfile(UserManager.get(context));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,281 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.settings.applications;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.content.pm.ResolveInfo;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.UserHandle;
|
|
||||||
import android.provider.SearchIndexableResource;
|
|
||||||
import android.provider.Settings;
|
|
||||||
import android.support.v4.util.ArrayMap;
|
|
||||||
import android.support.v7.preference.Preference;
|
|
||||||
import android.support.v7.preference.PreferenceScreen;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.android.internal.content.PackageMonitor;
|
|
||||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
|
||||||
import com.android.settings.PreferenceAvailabilityProvider;
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
|
||||||
import com.android.settings.search.Index;
|
|
||||||
import com.android.settings.search.Indexable;
|
|
||||||
import com.android.settings.utils.ProfileSettingsPreferenceFragment;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ManageDefaultApps extends ProfileSettingsPreferenceFragment
|
|
||||||
implements Preference.OnPreferenceClickListener, Indexable {
|
|
||||||
|
|
||||||
private static final String TAG = ManageDefaultApps.class.getSimpleName();
|
|
||||||
|
|
||||||
private static final String KEY_DEFAULT_HOME = "default_home";
|
|
||||||
private static final String KEY_ASSIST_AND_VOICE_INPUT = "assist_and_voice_input";
|
|
||||||
private static final String KEY_DEFAULT_BROWSER = "default_browser";
|
|
||||||
private static final String KEY_DEFAULT_PHONE_APP = "default_phone_app";
|
|
||||||
private static final String KEY_DEFAULT_EMERGENCY_APP = "default_emergency_app";
|
|
||||||
private static final String KEY_SMS_APPLICATION = "default_sms_app";
|
|
||||||
private static final String KEY_DEFAULT_NOTIFICATION_ASST = "default_notification_asst_app";
|
|
||||||
private static final String[] PREFERENCE_KEYS = new String[] {
|
|
||||||
KEY_DEFAULT_HOME, KEY_ASSIST_AND_VOICE_INPUT, KEY_DEFAULT_BROWSER,
|
|
||||||
KEY_DEFAULT_PHONE_APP, KEY_DEFAULT_EMERGENCY_APP, KEY_SMS_APPLICATION,
|
|
||||||
KEY_DEFAULT_NOTIFICATION_ASST
|
|
||||||
};
|
|
||||||
|
|
||||||
private DefaultBrowserPreference mDefaultBrowserPreference;
|
|
||||||
private PackageManager mPm;
|
|
||||||
private int myUserId;
|
|
||||||
|
|
||||||
private static final long DELAY_UPDATE_BROWSER_MILLIS = 500;
|
|
||||||
|
|
||||||
private final Handler mHandler = new Handler();
|
|
||||||
|
|
||||||
private final Runnable mUpdateRunnable = new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
updateDefaultBrowserPreference();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private final PackageMonitor mPackageMonitor = new PackageMonitor() {
|
|
||||||
@Override
|
|
||||||
public void onPackageAdded(String packageName, int uid) {
|
|
||||||
sendUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPackageAppeared(String packageName, int reason) {
|
|
||||||
sendUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPackageDisappeared(String packageName, int reason) {
|
|
||||||
sendUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPackageRemoved(String packageName, int uid) {
|
|
||||||
sendUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendUpdate() {
|
|
||||||
mHandler.postDelayed(mUpdateRunnable, DELAY_UPDATE_BROWSER_MILLIS);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private void updateDefaultBrowserPreference() {
|
|
||||||
mDefaultBrowserPreference.refreshBrowserApps();
|
|
||||||
|
|
||||||
final PackageManager pm = getPackageManager();
|
|
||||||
|
|
||||||
String packageName = pm.getDefaultBrowserPackageNameAsUser(UserHandle.myUserId());
|
|
||||||
if (!TextUtils.isEmpty(packageName)) {
|
|
||||||
// Check if the default Browser package is still there
|
|
||||||
Intent intent = new Intent();
|
|
||||||
intent.setPackage(packageName);
|
|
||||||
intent.setAction(Intent.ACTION_VIEW);
|
|
||||||
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
|
||||||
intent.setData(Uri.parse("http:"));
|
|
||||||
|
|
||||||
ResolveInfo info = mPm.resolveActivityAsUser(intent, 0, myUserId);
|
|
||||||
if (info != null) {
|
|
||||||
mDefaultBrowserPreference.setValue(packageName);
|
|
||||||
CharSequence label = info.loadLabel(pm);
|
|
||||||
mDefaultBrowserPreference.setSummary(label);
|
|
||||||
} else {
|
|
||||||
mDefaultBrowserPreference.setSummary(R.string.default_browser_title_none);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mDefaultBrowserPreference.setSummary(R.string.default_browser_title_none);
|
|
||||||
Log.d(TAG, "Cannot set empty default Browser value!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle icicle) {
|
|
||||||
super.onCreate(icicle);
|
|
||||||
|
|
||||||
addPreferencesFromResource(R.xml.default_apps);
|
|
||||||
|
|
||||||
mPm = getPackageManager();
|
|
||||||
myUserId = UserHandle.myUserId();
|
|
||||||
|
|
||||||
|
|
||||||
mDefaultBrowserPreference = (DefaultBrowserPreference) findPreference(KEY_DEFAULT_BROWSER);
|
|
||||||
mDefaultBrowserPreference.setOnPreferenceChangeListener(
|
|
||||||
new Preference.OnPreferenceChangeListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
|
||||||
|
|
||||||
if (newValue == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final CharSequence packageName = (CharSequence) newValue;
|
|
||||||
if (TextUtils.isEmpty(packageName)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
boolean result = mPm.setDefaultBrowserPackageNameAsUser(
|
|
||||||
packageName.toString(), myUserId);
|
|
||||||
if (result) {
|
|
||||||
mDefaultBrowserPreference.setValue(packageName.toString());
|
|
||||||
final CharSequence appName = mDefaultBrowserPreference.getEntry();
|
|
||||||
mDefaultBrowserPreference.setSummary(appName);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
updatePreferenceVisibility();
|
|
||||||
// Update the index.
|
|
||||||
Index.getInstance(getActivity()).updateFromClassNameResource(
|
|
||||||
ManageDefaultApps.class.getName(), true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Iterate all preferences and hide it if it is unavailable.
|
|
||||||
*/
|
|
||||||
private void updatePreferenceVisibility() {
|
|
||||||
PreferenceScreen preferenceScreen = getPreferenceScreen();
|
|
||||||
int count = preferenceScreen.getPreferenceCount();
|
|
||||||
List<String> preferenceKeys = new ArrayList<>();
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
String preferenceKey = preferenceScreen.getPreference(i).getKey();
|
|
||||||
if (!TextUtils.isEmpty(preferenceKey)) {
|
|
||||||
preferenceKeys.add(preferenceKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (String preferenceKey : preferenceKeys) {
|
|
||||||
boolean isAvailable = getPreferenceAvailability(getContext(), preferenceKey);
|
|
||||||
if (!isAvailable) {
|
|
||||||
Preference preference = preferenceScreen.findPreference(preferenceKey);
|
|
||||||
preferenceScreen.removePreference(preference);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get availability of preference from {@link PreferenceAvailabilityProvider}.
|
|
||||||
*/
|
|
||||||
private static boolean getPreferenceAvailability(Context context,
|
|
||||||
String preferenceKey) {
|
|
||||||
// Consider the preference is unavailable if no corresponding provider is found.
|
|
||||||
PreferenceAvailabilityProvider provider = getPreferenceAvailabilityProvider(preferenceKey);
|
|
||||||
return (provider == null) ? false : provider.isAvailable(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static PreferenceAvailabilityProvider getPreferenceAvailabilityProvider(
|
|
||||||
String preferenceKey) {
|
|
||||||
switch (preferenceKey) {
|
|
||||||
case KEY_ASSIST_AND_VOICE_INPUT:
|
|
||||||
return new ManageAssist.AvailabilityProvider();
|
|
||||||
case KEY_DEFAULT_BROWSER:
|
|
||||||
return new DefaultBrowserPreference.AvailabilityProvider();
|
|
||||||
case KEY_DEFAULT_EMERGENCY_APP:
|
|
||||||
return new DefaultEmergencyPreference.AvailabilityProvider();
|
|
||||||
case KEY_DEFAULT_HOME:
|
|
||||||
return new DefaultHomePreference.AvailabilityProvider();
|
|
||||||
case KEY_DEFAULT_NOTIFICATION_ASST:
|
|
||||||
return new DefaultNotificationAssistantPreference.AvailabilityProvider();
|
|
||||||
case KEY_DEFAULT_PHONE_APP:
|
|
||||||
return new DefaultPhonePreference.AvailabilityProvider();
|
|
||||||
case KEY_SMS_APPLICATION:
|
|
||||||
return new DefaultSmsPreference.AvailabilityProvider();
|
|
||||||
}
|
|
||||||
Log.w(TAG, "getPreferenceAvailabilityProvider: Cannot find provider for " + preferenceKey);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
updateDefaultBrowserPreference();
|
|
||||||
mPackageMonitor.register(getActivity(), getActivity().getMainLooper(), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
|
|
||||||
mPackageMonitor.unregister();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getMetricsCategory() {
|
|
||||||
return MetricsEvent.APPLICATIONS_DEFAULT_APPS;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
|
||||||
new BaseSearchIndexProvider() {
|
|
||||||
@Override
|
|
||||||
public List<SearchIndexableResource> getXmlResourcesToIndex(
|
|
||||||
Context context, boolean enabled) {
|
|
||||||
SearchIndexableResource sir = new SearchIndexableResource(context);
|
|
||||||
sir.xmlResId = R.xml.default_apps;
|
|
||||||
return Arrays.asList(sir);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getNonIndexableKeys(Context context) {
|
|
||||||
// Iterate all preferences to see which is not available.
|
|
||||||
final ArrayList<String> result = new ArrayList<>();
|
|
||||||
for (String key : PREFERENCE_KEYS) {
|
|
||||||
boolean isAvailable = getPreferenceAvailability(context, key);
|
|
||||||
if (!isAvailable) {
|
|
||||||
result.add(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
protected String getIntentActionString() {
|
|
||||||
return Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* 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. 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.applications;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.preference.Preference;
|
||||||
|
import com.android.settings.SettingsActivity;
|
||||||
|
import com.android.settings.Utils;
|
||||||
|
|
||||||
|
public class ShortcutPreference extends Preference {
|
||||||
|
|
||||||
|
private final Class mTarget;
|
||||||
|
private final String mPrefKey;
|
||||||
|
private final int mTitle;
|
||||||
|
|
||||||
|
public ShortcutPreference(Context context, Class target, String prefKey, int prefTitle,
|
||||||
|
int title) {
|
||||||
|
super(context);
|
||||||
|
mTarget = target;
|
||||||
|
mPrefKey = prefKey;
|
||||||
|
mTitle = title;
|
||||||
|
setTitle(prefTitle);
|
||||||
|
setKey(mPrefKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void performClick() {
|
||||||
|
super.performClick();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, mPrefKey);
|
||||||
|
Utils.startWithFragment(getContext(), mTarget.getName(), bundle, null, 0,
|
||||||
|
mTitle, null);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* 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. 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.applications;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import com.android.settings.InstrumentedFragment;
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
|
|
||||||
|
public class SpecialAccessSettings extends SettingsPreferenceFragment {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
|
addPreferencesFromResource(R.xml.special_access);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getMetricsCategory() {
|
||||||
|
return InstrumentedFragment.SPECIAL_ACCESS;
|
||||||
|
}
|
||||||
|
}
|
@@ -158,13 +158,17 @@ public class WriteSettingsDetails extends AppInfoWithHeader implements OnPrefere
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static CharSequence getSummary(Context context, AppEntry entry) {
|
public static CharSequence getSummary(Context context, AppEntry entry) {
|
||||||
if (entry.extraInfo != null) {
|
WriteSettingsState state;
|
||||||
return getSummary(context, new WriteSettingsState((PermissionState)entry
|
if (entry.extraInfo instanceof WriteSettingsState) {
|
||||||
.extraInfo));
|
state = (WriteSettingsState) entry.extraInfo;
|
||||||
|
} else if (entry.extraInfo instanceof PermissionState) {
|
||||||
|
state = new WriteSettingsState((PermissionState) entry.extraInfo);
|
||||||
|
} else {
|
||||||
|
state = new AppStateWriteSettingsBridge(context, null, null).getWriteSettingsInfo(
|
||||||
|
entry.info.packageName, entry.info.uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fallback if entry.extrainfo is null - although this should not happen
|
return getSummary(context, state);
|
||||||
return getSummary(context, entry.info.packageName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CharSequence getSummary(Context context, WriteSettingsState writeSettingsState) {
|
public static CharSequence getSummary(Context context, WriteSettingsState writeSettingsState) {
|
||||||
|
@@ -32,7 +32,7 @@ import com.android.settings.WirelessSettings;
|
|||||||
import com.android.settings.accessibility.AccessibilitySettings;
|
import com.android.settings.accessibility.AccessibilitySettings;
|
||||||
import com.android.settings.accounts.AccountSettings;
|
import com.android.settings.accounts.AccountSettings;
|
||||||
import com.android.settings.applications.AdvancedAppSettings;
|
import com.android.settings.applications.AdvancedAppSettings;
|
||||||
import com.android.settings.applications.ManageDefaultApps;
|
import com.android.settings.applications.SpecialAccessSettings;
|
||||||
import com.android.settings.bluetooth.BluetoothSettings;
|
import com.android.settings.bluetooth.BluetoothSettings;
|
||||||
import com.android.settings.datausage.DataUsageMeteredSettings;
|
import com.android.settings.datausage.DataUsageMeteredSettings;
|
||||||
import com.android.settings.datausage.DataUsageSummary;
|
import com.android.settings.datausage.DataUsageSummary;
|
||||||
@@ -148,7 +148,7 @@ public final class Ranking {
|
|||||||
|
|
||||||
// Advanced app settings
|
// Advanced app settings
|
||||||
sRankMap.put(AdvancedAppSettings.class.getName(), RANK_APPS);
|
sRankMap.put(AdvancedAppSettings.class.getName(), RANK_APPS);
|
||||||
sRankMap.put(ManageDefaultApps.class.getName(), RANK_APPS);
|
sRankMap.put(SpecialAccessSettings.class.getName(), RANK_APPS);
|
||||||
|
|
||||||
// Users
|
// Users
|
||||||
sRankMap.put(UserSettings.class.getName(), RANK_USERS);
|
sRankMap.put(UserSettings.class.getName(), RANK_USERS);
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.search;
|
package com.android.settings.search;
|
||||||
|
|
||||||
|
import android.provider.SearchIndexableResource;
|
||||||
import com.android.settings.DateTimeSettings;
|
import com.android.settings.DateTimeSettings;
|
||||||
import com.android.settings.DevelopmentSettings;
|
import com.android.settings.DevelopmentSettings;
|
||||||
import com.android.settings.DeviceInfoSettings;
|
import com.android.settings.DeviceInfoSettings;
|
||||||
@@ -32,7 +33,7 @@ import com.android.settings.WirelessSettings;
|
|||||||
import com.android.settings.accessibility.AccessibilitySettings;
|
import com.android.settings.accessibility.AccessibilitySettings;
|
||||||
import com.android.settings.accounts.AccountSettings;
|
import com.android.settings.accounts.AccountSettings;
|
||||||
import com.android.settings.applications.AdvancedAppSettings;
|
import com.android.settings.applications.AdvancedAppSettings;
|
||||||
import com.android.settings.applications.ManageDefaultApps;
|
import com.android.settings.applications.SpecialAccessSettings;
|
||||||
import com.android.settings.bluetooth.BluetoothSettings;
|
import com.android.settings.bluetooth.BluetoothSettings;
|
||||||
import com.android.settings.datausage.DataUsageMeteredSettings;
|
import com.android.settings.datausage.DataUsageMeteredSettings;
|
||||||
import com.android.settings.datausage.DataUsageSummary;
|
import com.android.settings.datausage.DataUsageSummary;
|
||||||
@@ -56,8 +57,6 @@ import com.android.settings.wifi.AdvancedWifiSettings;
|
|||||||
import com.android.settings.wifi.SavedAccessPointsWifiSettings;
|
import com.android.settings.wifi.SavedAccessPointsWifiSettings;
|
||||||
import com.android.settings.wifi.WifiSettings;
|
import com.android.settings.wifi.WifiSettings;
|
||||||
|
|
||||||
import android.provider.SearchIndexableResource;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@@ -212,15 +211,15 @@ public final class SearchIndexableResources {
|
|||||||
sResMap.put(AdvancedAppSettings.class.getName(),
|
sResMap.put(AdvancedAppSettings.class.getName(),
|
||||||
new SearchIndexableResource(
|
new SearchIndexableResource(
|
||||||
Ranking.getRankForClassName(AdvancedAppSettings.class.getName()),
|
Ranking.getRankForClassName(AdvancedAppSettings.class.getName()),
|
||||||
R.xml.advanced_apps,
|
NO_DATA_RES_ID,
|
||||||
AdvancedAppSettings.class.getName(),
|
AdvancedAppSettings.class.getName(),
|
||||||
R.drawable.ic_settings_applications));
|
R.drawable.ic_settings_applications));
|
||||||
|
|
||||||
sResMap.put(ManageDefaultApps.class.getName(),
|
sResMap.put(SpecialAccessSettings.class.getName(),
|
||||||
new SearchIndexableResource(
|
new SearchIndexableResource(
|
||||||
Ranking.getRankForClassName(ManageDefaultApps.class.getName()),
|
Ranking.getRankForClassName(SpecialAccessSettings.class.getName()),
|
||||||
NO_DATA_RES_ID,
|
R.xml.special_access,
|
||||||
ManageDefaultApps.class.getName(),
|
SpecialAccessSettings.class.getName(),
|
||||||
R.drawable.ic_settings_applications));
|
R.drawable.ic_settings_applications));
|
||||||
|
|
||||||
sResMap.put(UserSettings.class.getName(),
|
sResMap.put(UserSettings.class.getName(),
|
||||||
|
Reference in New Issue
Block a user