Merge "Hide emergency app settings on non-voice deivces"
This commit is contained in:
@@ -37,6 +37,7 @@ import android.os.ServiceManager;
|
||||
import android.os.UserHandle;
|
||||
import android.preference.Preference;
|
||||
import android.preference.Preference.OnPreferenceClickListener;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -49,12 +50,14 @@ import com.android.settings.applications.ApplicationsState.AppEntry;
|
||||
import com.android.settings.applications.ApplicationsState.Callbacks;
|
||||
import com.android.settings.applications.ApplicationsState.Session;
|
||||
import com.android.settings.applications.PermissionsInfo.Callback;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AdvancedAppSettings extends SettingsPreferenceFragment implements Callbacks,
|
||||
DialogInterface.OnClickListener, DialogInterface.OnDismissListener, Callback {
|
||||
DialogInterface.OnClickListener, DialogInterface.OnDismissListener, Callback, Indexable {
|
||||
|
||||
static final String TAG = "AdvancedAppSettings";
|
||||
static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||
@@ -63,6 +66,7 @@ public class AdvancedAppSettings extends SettingsPreferenceFragment implements C
|
||||
private static final String KEY_ALL_APPS = "all_apps";
|
||||
private static final String KEY_APP_DOMAIN_URLS = "domain_urls";
|
||||
private static final String KEY_RESET_ALL = "reset_all";
|
||||
private static final String KEY_DEFAULT_EMERGENCY_APP = "default_emergency_app";
|
||||
private static final String EXTRA_RESET_DIALOG = "resetDialog";
|
||||
|
||||
private ApplicationsState mApplicationsState;
|
||||
@@ -111,6 +115,10 @@ public class AdvancedAppSettings extends SettingsPreferenceFragment implements C
|
||||
mNpm = NetworkPolicyManager.from(getActivity());
|
||||
mAom = (AppOpsManager)getActivity().getSystemService(Context.APP_OPS_SERVICE);
|
||||
mHandler = new Handler(getActivity().getMainLooper());
|
||||
|
||||
if (!DefaultEmergencyPreference.isAvailable(getActivity())) {
|
||||
removePreference(KEY_DEFAULT_EMERGENCY_APP);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateUI() {
|
||||
@@ -295,4 +303,25 @@ public class AdvancedAppSettings extends SettingsPreferenceFragment implements C
|
||||
mPermissionsInfo.getRuntimePermAppsCount()));
|
||||
}
|
||||
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
ArrayList<SearchIndexableResource> result = new ArrayList<>(1);
|
||||
SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.advanced_apps;
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNonIndexableKeys(Context context) {
|
||||
ArrayList<String> result = new ArrayList<>(1);
|
||||
if (!DefaultEmergencyPreference.isAvailable(context)) {
|
||||
result.add(KEY_DEFAULT_EMERGENCY_APP);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@@ -46,7 +46,10 @@ public class DefaultEmergencyPreference extends ListPreference {
|
||||
public DefaultEmergencyPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mContentResolver = context.getContentResolver();
|
||||
load();
|
||||
|
||||
if (isAvailable(context)) {
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -149,6 +152,11 @@ public class DefaultEmergencyPreference extends ListPreference {
|
||||
return packages;
|
||||
}
|
||||
|
||||
public static boolean isAvailable(Context context) {
|
||||
return context.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_voice_capable);
|
||||
}
|
||||
|
||||
private static boolean isSystemApp(PackageInfo info) {
|
||||
return info.applicationInfo != null
|
||||
&& (info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
|
||||
|
@@ -209,7 +209,7 @@ public final class SearchIndexableResources {
|
||||
sResMap.put(AdvancedAppSettings.class.getName(),
|
||||
new SearchIndexableResource(
|
||||
Ranking.getRankForClassName(AdvancedAppSettings.class.getName()),
|
||||
R.xml.advanced_apps,
|
||||
NO_DATA_RES_ID,
|
||||
AdvancedAppSettings.class.getName(),
|
||||
R.drawable.ic_settings_applications));
|
||||
|
||||
|
Reference in New Issue
Block a user