Merge "Register most app info related controllers in xml" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
4ae4cd5c8d
@@ -17,9 +17,9 @@
|
|||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||||
android:key="installed_app_detail_settings_screen"
|
android:key="installed_app_detail_settings_screen"
|
||||||
app:initialExpandedChildrenCount="6">
|
settings:initialExpandedChildrenCount="6">
|
||||||
|
|
||||||
<com.android.settings.applications.LayoutPreference
|
<com.android.settings.applications.LayoutPreference
|
||||||
android:key="header_view"
|
android:key="header_view"
|
||||||
@@ -39,33 +39,38 @@
|
|||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="notification_settings"
|
android:key="notification_settings"
|
||||||
android:title="@string/notifications_label" />
|
android:title="@string/notifications_label"
|
||||||
|
settings:controller="com.android.settings.applications.appinfo.AppNotificationPreferenceController" />
|
||||||
|
|
||||||
<com.android.settings.widget.FixedLineSummaryPreference
|
<com.android.settings.widget.FixedLineSummaryPreference
|
||||||
android:key="permission_settings"
|
android:key="permission_settings"
|
||||||
android:title="@string/permissions_label"
|
android:title="@string/permissions_label"
|
||||||
android:summary="@string/summary_placeholder"
|
android:summary="@string/summary_placeholder"
|
||||||
app:summaryLineCount="1" />
|
settings:summaryLineCount="1"
|
||||||
|
settings:controller="com.android.settings.applications.appinfo.AppPermissionPreferenceController" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="storage_settings"
|
android:key="storage_settings"
|
||||||
android:title="@string/storage_settings"
|
android:title="@string/storage_settings"
|
||||||
android:summary="@string/summary_placeholder" />
|
android:summary="@string/summary_placeholder"
|
||||||
|
settings:controller="com.android.settings.applications.appinfo.AppStoragePreferenceController" />
|
||||||
|
|
||||||
<com.android.settings.applications.AppDomainsPreference
|
<com.android.settings.applications.AppDomainsPreference
|
||||||
android:key="instant_app_launch_supported_domain_urls"
|
android:key="instant_app_launch_supported_domain_urls"
|
||||||
android:title="@string/app_launch_supported_domain_urls_title"
|
android:title="@string/app_launch_supported_domain_urls_title"
|
||||||
android:selectable="true" />
|
android:selectable="true"
|
||||||
|
settings:controller="com.android.settings.applications.appinfo.InstantAppDomainsPreferenceController" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="data_settings"
|
android:key="data_settings"
|
||||||
android:title="@string/data_usage_summary_title"
|
android:title="@string/data_usage_summary_title"
|
||||||
android:summary="@string/summary_placeholder" />
|
android:summary="@string/summary_placeholder"
|
||||||
|
settings:controller="com.android.settings.applications.appinfo.AppDataUsagePreferenceController" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="time_spent_in_app"
|
android:key="time_spent_in_app"
|
||||||
android:title="@string/time_spent_in_app_pref_title"
|
android:title="@string/time_spent_in_app_pref_title"
|
||||||
app:controller="com.android.settings.applications.appinfo.TimeSpentInAppPreferenceController" />
|
settings:controller="com.android.settings.applications.appinfo.TimeSpentInAppPreferenceController" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="battery"
|
android:key="battery"
|
||||||
@@ -76,7 +81,8 @@
|
|||||||
android:key="preferred_settings"
|
android:key="preferred_settings"
|
||||||
android:title="@string/launch_by_default"
|
android:title="@string/launch_by_default"
|
||||||
android:summary="@string/summary_placeholder"
|
android:summary="@string/summary_placeholder"
|
||||||
android:selectable="true" />
|
android:selectable="true"
|
||||||
|
settings:controller="com.android.settings.applications.appinfo.AppOpenByDefaultPreferenceController" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="memory"
|
android:key="memory"
|
||||||
@@ -113,44 +119,52 @@
|
|||||||
<!-- Advanced apps settings -->
|
<!-- Advanced apps settings -->
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="advanced_app_info"
|
android:key="advanced_app_info"
|
||||||
android:title="@string/advanced_apps">
|
android:title="@string/advanced_apps"
|
||||||
|
settings:controller="com.android.settings.applications.appinfo.AdvancedAppInfoPreferenceCategoryController">
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="system_alert_window"
|
android:key="system_alert_window"
|
||||||
android:title="@string/draw_overlay"
|
android:title="@string/draw_overlay"
|
||||||
android:summary="@string/summary_placeholder" />
|
android:summary="@string/summary_placeholder"
|
||||||
|
settings:controller="com.android.settings.applications.appinfo.DrawOverlayDetailPreferenceController" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="write_settings_apps"
|
android:key="write_settings_apps"
|
||||||
android:title="@string/write_settings"
|
android:title="@string/write_settings"
|
||||||
android:summary="@string/summary_placeholder" />
|
android:summary="@string/summary_placeholder"
|
||||||
|
settings:controller="com.android.settings.applications.appinfo.WriteSystemSettingsPreferenceController" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="picture_in_picture"
|
android:key="picture_in_picture"
|
||||||
android:title="@string/picture_in_picture_app_detail_title"
|
android:title="@string/picture_in_picture_app_detail_title"
|
||||||
android:summary="@string/summary_placeholder" />
|
android:summary="@string/summary_placeholder"
|
||||||
|
settings:controller="com.android.settings.applications.appinfo.PictureInPictureDetailPreferenceController" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="install_other_apps"
|
android:key="install_other_apps"
|
||||||
android:title="@string/install_other_apps"
|
android:title="@string/install_other_apps"
|
||||||
android:summary="@string/summary_placeholder" />
|
android:summary="@string/summary_placeholder"
|
||||||
|
settings:controller="com.android.settings.applications.appinfo.ExternalSourceDetailPreferenceController" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<!-- App installer info -->
|
<!-- App installer info -->
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="app_installer"
|
android:key="app_installer"
|
||||||
android:title="@string/app_install_details_group_title">
|
android:title="@string/app_install_details_group_title"
|
||||||
|
settings:controller="com.android.settings.applications.appinfo.AppInstallerPreferenceCategoryController">
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="app_info_store"
|
android:key="app_info_store"
|
||||||
android:title="@string/app_install_details_title" />
|
android:title="@string/app_install_details_title"
|
||||||
|
settings:controller="com.android.settings.applications.appinfo.AppInstallerInfoPreferenceController" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="app_version"
|
android:key="app_version"
|
||||||
android:selectable="false"
|
android:selectable="false"
|
||||||
android:order="9999" />
|
android:order="9999"
|
||||||
|
settings:controller="com.android.settings.applications.appinfo.AppVersionPreferenceController" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
@@ -76,7 +76,7 @@ public class DefaultAppSettings extends DashboardFragment {
|
|||||||
workControllers.add(new DefaultWorkBrowserPreferenceController(context));
|
workControllers.add(new DefaultWorkBrowserPreferenceController(context));
|
||||||
controllers.addAll(workControllers);
|
controllers.addAll(workControllers);
|
||||||
controllers.add(new PreferenceCategoryController(
|
controllers.add(new PreferenceCategoryController(
|
||||||
context, KEY_DEFAULT_WORK_CATEGORY, workControllers));
|
context, KEY_DEFAULT_WORK_CATEGORY).setChildren(workControllers));
|
||||||
controllers.add(new DefaultAssistPreferenceController(context, KEY_ASSIST_VOICE_INPUT,
|
controllers.add(new DefaultAssistPreferenceController(context, KEY_ASSIST_VOICE_INPUT,
|
||||||
false /* showSetting */));
|
false /* showSetting */));
|
||||||
controllers.add(new DefaultBrowserPreferenceController(context));
|
controllers.add(new DefaultBrowserPreferenceController(context));
|
||||||
|
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.applications.appinfo;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.android.settings.widget.PreferenceCategoryController;
|
||||||
|
|
||||||
|
public class AdvancedAppInfoPreferenceCategoryController extends PreferenceCategoryController {
|
||||||
|
|
||||||
|
public AdvancedAppInfoPreferenceCategoryController(Context context, String key) {
|
||||||
|
super(context, key);
|
||||||
|
}
|
||||||
|
}
|
@@ -38,7 +38,6 @@ import com.android.settings.datausage.AppDataUsage;
|
|||||||
import com.android.settings.datausage.DataUsageList;
|
import com.android.settings.datausage.DataUsageList;
|
||||||
import com.android.settings.datausage.DataUsageUtils;
|
import com.android.settings.datausage.DataUsageUtils;
|
||||||
import com.android.settingslib.AppItem;
|
import com.android.settingslib.AppItem;
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
|
||||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnPause;
|
import com.android.settingslib.core.lifecycle.events.OnPause;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnResume;
|
import com.android.settingslib.core.lifecycle.events.OnResume;
|
||||||
@@ -48,16 +47,11 @@ import com.android.settingslib.net.ChartDataLoader;
|
|||||||
public class AppDataUsagePreferenceController extends AppInfoPreferenceControllerBase
|
public class AppDataUsagePreferenceController extends AppInfoPreferenceControllerBase
|
||||||
implements LoaderManager.LoaderCallbacks<ChartData>, LifecycleObserver, OnResume, OnPause {
|
implements LoaderManager.LoaderCallbacks<ChartData>, LifecycleObserver, OnResume, OnPause {
|
||||||
|
|
||||||
private static final String KEY_DATA = "data_settings";
|
|
||||||
private ChartData mChartData;
|
private ChartData mChartData;
|
||||||
private INetworkStatsSession mStatsSession;
|
private INetworkStatsSession mStatsSession;
|
||||||
|
|
||||||
public AppDataUsagePreferenceController(Context context, AppInfoDashboardFragment parent,
|
public AppDataUsagePreferenceController(Context context,String key) {
|
||||||
Lifecycle lifecycle) {
|
super(context, key);
|
||||||
super(context, parent, KEY_DATA);
|
|
||||||
if (lifecycle != null) {
|
|
||||||
lifecycle.addObserver(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -55,7 +55,6 @@ import com.android.settings.applications.manageapplications.ManageApplications;
|
|||||||
import com.android.settings.core.SubSettingLauncher;
|
import com.android.settings.core.SubSettingLauncher;
|
||||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
import com.android.settings.widget.PreferenceCategoryController;
|
|
||||||
import com.android.settings.wrapper.DevicePolicyManagerWrapper;
|
import com.android.settings.wrapper.DevicePolicyManagerWrapper;
|
||||||
import com.android.settingslib.RestrictedLockUtils;
|
import com.android.settingslib.RestrictedLockUtils;
|
||||||
import com.android.settingslib.applications.AppUtils;
|
import com.android.settingslib.applications.AppUtils;
|
||||||
@@ -84,8 +83,10 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
|||||||
private static final String TAG = "AppInfoDashboard";
|
private static final String TAG = "AppInfoDashboard";
|
||||||
|
|
||||||
// Menu identifiers
|
// Menu identifiers
|
||||||
@VisibleForTesting static final int UNINSTALL_ALL_USERS_MENU = 1;
|
@VisibleForTesting
|
||||||
@VisibleForTesting static final int UNINSTALL_UPDATES = 2;
|
static final int UNINSTALL_ALL_USERS_MENU = 1;
|
||||||
|
@VisibleForTesting
|
||||||
|
static final int UNINSTALL_UPDATES = 2;
|
||||||
static final int INSTALL_INSTANT_APP_MENU = 3;
|
static final int INSTALL_INSTANT_APP_MENU = 3;
|
||||||
|
|
||||||
// Result code identifiers
|
// Result code identifiers
|
||||||
@@ -106,8 +107,6 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
|||||||
private static final int DLG_SPECIAL_DISABLE = DLG_BASE + 3;
|
private static final int DLG_SPECIAL_DISABLE = DLG_BASE + 3;
|
||||||
static final int DLG_CLEAR_INSTANT_APP = DLG_BASE + 4;
|
static final int DLG_CLEAR_INSTANT_APP = DLG_BASE + 4;
|
||||||
|
|
||||||
private static final String KEY_ADVANCED_APP_INFO_CATEGORY = "advanced_app_info";
|
|
||||||
|
|
||||||
public static final String ARG_PACKAGE_NAME = "package";
|
public static final String ARG_PACKAGE_NAME = "package";
|
||||||
public static final String ARG_PACKAGE_UID = "uid";
|
public static final String ARG_PACKAGE_UID = "uid";
|
||||||
|
|
||||||
@@ -156,7 +155,42 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onAttach(Context context) {
|
public void onAttach(Context context) {
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
use(TimeSpentInAppPreferenceController.class).setPackageName(getPackageName());
|
final String packageName = getPackageName();
|
||||||
|
use(TimeSpentInAppPreferenceController.class).setPackageName(packageName);
|
||||||
|
|
||||||
|
use(AppDataUsagePreferenceController.class).setParentFragment(this);
|
||||||
|
final AppInstallerInfoPreferenceController installer =
|
||||||
|
use(AppInstallerInfoPreferenceController.class);
|
||||||
|
installer.setPackageName(packageName);
|
||||||
|
installer.setParentFragment(this);
|
||||||
|
use(AppInstallerPreferenceCategoryController.class).setChildren(Arrays.asList(installer));
|
||||||
|
use(AppNotificationPreferenceController.class).setParentFragment(this);
|
||||||
|
use(AppOpenByDefaultPreferenceController.class).setParentFragment(this);
|
||||||
|
use(AppPermissionPreferenceController.class).setParentFragment(this);
|
||||||
|
use(AppPermissionPreferenceController.class).setPackageName(packageName);
|
||||||
|
use(AppStoragePreferenceController.class).setParentFragment(this);
|
||||||
|
use(AppVersionPreferenceController.class).setParentFragment(this);
|
||||||
|
use(InstantAppDomainsPreferenceController.class).setParentFragment(this);
|
||||||
|
|
||||||
|
final WriteSystemSettingsPreferenceController writeSystemSettings =
|
||||||
|
use(WriteSystemSettingsPreferenceController.class);
|
||||||
|
writeSystemSettings.setParentFragment(this);
|
||||||
|
|
||||||
|
final DrawOverlayDetailPreferenceController drawOverlay =
|
||||||
|
use(DrawOverlayDetailPreferenceController.class);
|
||||||
|
drawOverlay.setParentFragment(this);
|
||||||
|
|
||||||
|
final PictureInPictureDetailPreferenceController pip =
|
||||||
|
use(PictureInPictureDetailPreferenceController.class);
|
||||||
|
pip.setPackageName(packageName);
|
||||||
|
pip.setParentFragment(this);
|
||||||
|
final ExternalSourceDetailPreferenceController externalSource =
|
||||||
|
use(ExternalSourceDetailPreferenceController.class);
|
||||||
|
externalSource.setPackageName(packageName);
|
||||||
|
externalSource.setParentFragment(this);
|
||||||
|
|
||||||
|
use(AdvancedAppInfoPreferenceCategoryController.class).setChildren(Arrays.asList(
|
||||||
|
writeSystemSettings, drawOverlay, pip, externalSource));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -227,16 +261,6 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
|||||||
// when app state changes.
|
// when app state changes.
|
||||||
controllers.add(
|
controllers.add(
|
||||||
new AppHeaderViewPreferenceController(context, this, packageName, lifecycle));
|
new AppHeaderViewPreferenceController(context, this, packageName, lifecycle));
|
||||||
controllers.add(new AppStoragePreferenceController(context, this, lifecycle));
|
|
||||||
controllers.add(new AppDataUsagePreferenceController(context, this, lifecycle));
|
|
||||||
controllers.add(new AppNotificationPreferenceController(context, this));
|
|
||||||
controllers.add(new AppOpenByDefaultPreferenceController(context, this));
|
|
||||||
controllers.add(new AppPermissionPreferenceController(context, this, packageName));
|
|
||||||
controllers.add(new AppVersionPreferenceController(context, this));
|
|
||||||
controllers.add(new InstantAppDomainsPreferenceController(context, this));
|
|
||||||
final AppInstallerInfoPreferenceController appInstallerInfoPreferenceController =
|
|
||||||
new AppInstallerInfoPreferenceController(context, this, packageName);
|
|
||||||
controllers.add(appInstallerInfoPreferenceController);
|
|
||||||
mAppActionButtonPreferenceController =
|
mAppActionButtonPreferenceController =
|
||||||
new AppActionButtonPreferenceController(context, this, packageName);
|
new AppActionButtonPreferenceController(context, this, packageName);
|
||||||
controllers.add(mAppActionButtonPreferenceController);
|
controllers.add(mAppActionButtonPreferenceController);
|
||||||
@@ -258,23 +282,15 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
|||||||
controllers.add(new DefaultEmergencyShortcutPreferenceController(context, packageName));
|
controllers.add(new DefaultEmergencyShortcutPreferenceController(context, packageName));
|
||||||
controllers.add(new DefaultSmsShortcutPreferenceController(context, packageName));
|
controllers.add(new DefaultSmsShortcutPreferenceController(context, packageName));
|
||||||
|
|
||||||
final List<AbstractPreferenceController> advancedAppInfoControllers = new ArrayList<>();
|
|
||||||
advancedAppInfoControllers.add(new DrawOverlayDetailPreferenceController(context, this));
|
|
||||||
advancedAppInfoControllers.add(new WriteSystemSettingsPreferenceController(context, this));
|
|
||||||
advancedAppInfoControllers.add(
|
|
||||||
new PictureInPictureDetailPreferenceController(context, this, packageName));
|
|
||||||
advancedAppInfoControllers.add(
|
|
||||||
new ExternalSourceDetailPreferenceController(context, this, packageName));
|
|
||||||
controllers.addAll(advancedAppInfoControllers);
|
|
||||||
controllers.add(new PreferenceCategoryController(
|
|
||||||
context, KEY_ADVANCED_APP_INFO_CATEGORY, advancedAppInfoControllers));
|
|
||||||
|
|
||||||
controllers.add(new AppInstallerPreferenceCategoryController(
|
|
||||||
context, Arrays.asList(appInstallerInfoPreferenceController)));
|
|
||||||
|
|
||||||
return controllers;
|
return controllers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void addToCallbackList(Callback callback) {
|
||||||
|
if (callback != null) {
|
||||||
|
mCallbacks.add(callback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ApplicationsState.AppEntry getAppEntry() {
|
ApplicationsState.AppEntry getAppEntry() {
|
||||||
return mAppEntry;
|
return mAppEntry;
|
||||||
}
|
}
|
||||||
@@ -291,7 +307,7 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
|||||||
public void onPackageSizeChanged(String packageName) {
|
public void onPackageSizeChanged(String packageName) {
|
||||||
if (!TextUtils.equals(packageName, mPackageName)) {
|
if (!TextUtils.equals(packageName, mPackageName)) {
|
||||||
Log.d(TAG, "Package change irrelevant, skipping");
|
Log.d(TAG, "Package change irrelevant, skipping");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
refreshUi();
|
refreshUi();
|
||||||
}
|
}
|
||||||
@@ -429,7 +445,7 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
|||||||
if (!mInitialized) {
|
if (!mInitialized) {
|
||||||
// First time init: are we displaying an uninstalled app?
|
// First time init: are we displaying an uninstalled app?
|
||||||
mInitialized = true;
|
mInitialized = true;
|
||||||
mShowUninstalled = (mAppEntry.info.flags&ApplicationInfo.FLAG_INSTALLED) == 0;
|
mShowUninstalled = (mAppEntry.info.flags & ApplicationInfo.FLAG_INSTALLED) == 0;
|
||||||
} else {
|
} else {
|
||||||
// All other times: if the app no longer exists then we want
|
// All other times: if the app no longer exists then we want
|
||||||
// to go away.
|
// to go away.
|
||||||
@@ -437,12 +453,12 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
|||||||
final ApplicationInfo ainfo = getActivity().getPackageManager().getApplicationInfo(
|
final ApplicationInfo ainfo = getActivity().getPackageManager().getApplicationInfo(
|
||||||
mAppEntry.info.packageName,
|
mAppEntry.info.packageName,
|
||||||
PackageManager.MATCH_DISABLED_COMPONENTS
|
PackageManager.MATCH_DISABLED_COMPONENTS
|
||||||
| PackageManager.MATCH_ANY_USER);
|
| PackageManager.MATCH_ANY_USER);
|
||||||
if (!mShowUninstalled) {
|
if (!mShowUninstalled) {
|
||||||
// If we did not start out with the app uninstalled, then
|
// If we did not start out with the app uninstalled, then
|
||||||
// it transitioning to the uninstalled state for the current
|
// it transitioning to the uninstalled state for the current
|
||||||
// user means we should go away as well.
|
// user means we should go away as well.
|
||||||
return (ainfo.flags&ApplicationInfo.FLAG_INSTALLED) != 0;
|
return (ainfo.flags & ApplicationInfo.FLAG_INSTALLED) != 0;
|
||||||
}
|
}
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
return false;
|
return false;
|
||||||
@@ -460,15 +476,17 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
|||||||
.setMessage(getActivity().getText(R.string.app_disable_dlg_text))
|
.setMessage(getActivity().getText(R.string.app_disable_dlg_text))
|
||||||
.setPositiveButton(R.string.app_disable_dlg_positive,
|
.setPositiveButton(R.string.app_disable_dlg_positive,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
// Disable the app
|
// Disable the app
|
||||||
mMetricsFeatureProvider.action(getContext(),
|
mMetricsFeatureProvider.action(getContext(),
|
||||||
MetricsEvent.ACTION_SETTINGS_DISABLE_APP);
|
MetricsEvent.ACTION_SETTINGS_DISABLE_APP);
|
||||||
new DisableChanger(AppInfoDashboardFragment.this, mAppEntry.info,
|
new DisableChanger(AppInfoDashboardFragment.this,
|
||||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER)
|
mAppEntry.info,
|
||||||
.execute((Object)null);
|
PackageManager
|
||||||
}
|
.COMPONENT_ENABLED_STATE_DISABLED_USER)
|
||||||
})
|
.execute((Object) null);
|
||||||
|
}
|
||||||
|
})
|
||||||
.setNegativeButton(R.string.dlg_cancel, null)
|
.setNegativeButton(R.string.dlg_cancel, null)
|
||||||
.create();
|
.create();
|
||||||
case DLG_SPECIAL_DISABLE:
|
case DLG_SPECIAL_DISABLE:
|
||||||
@@ -476,14 +494,14 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
|||||||
.setMessage(getActivity().getText(R.string.app_disable_dlg_text))
|
.setMessage(getActivity().getText(R.string.app_disable_dlg_text))
|
||||||
.setPositiveButton(R.string.app_disable_dlg_positive,
|
.setPositiveButton(R.string.app_disable_dlg_positive,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
// Disable the app and ask for uninstall
|
// Disable the app and ask for uninstall
|
||||||
mMetricsFeatureProvider.action(getContext(),
|
mMetricsFeatureProvider.action(getContext(),
|
||||||
MetricsEvent.ACTION_SETTINGS_DISABLE_APP);
|
MetricsEvent.ACTION_SETTINGS_DISABLE_APP);
|
||||||
uninstallPkg(mAppEntry.info.packageName,
|
uninstallPkg(mAppEntry.info.packageName,
|
||||||
false, true);
|
false, true);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.dlg_cancel, null)
|
.setNegativeButton(R.string.dlg_cancel, null)
|
||||||
.create();
|
.create();
|
||||||
case DLG_FORCE_STOP:
|
case DLG_FORCE_STOP:
|
||||||
@@ -504,8 +522,8 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
|||||||
|
|
||||||
private void uninstallPkg(String packageName, boolean allUsers, boolean andDisable) {
|
private void uninstallPkg(String packageName, boolean allUsers, boolean andDisable) {
|
||||||
stopListeningToPackageRemove();
|
stopListeningToPackageRemove();
|
||||||
// Create new intent to launch Uninstaller activity
|
// Create new intent to launch Uninstaller activity
|
||||||
final Uri packageURI = Uri.parse("package:"+packageName);
|
final Uri packageURI = Uri.parse("package:" + packageName);
|
||||||
final Intent uninstallIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageURI);
|
final Intent uninstallIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageURI);
|
||||||
uninstallIntent.putExtra(Intent.EXTRA_UNINSTALL_ALL_USERS, allUsers);
|
uninstallIntent.putExtra(Intent.EXTRA_UNINSTALL_ALL_USERS, allUsers);
|
||||||
mMetricsFeatureProvider.action(
|
mMetricsFeatureProvider.action(
|
||||||
@@ -632,7 +650,7 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
|||||||
if ((info.flags & ApplicationInfo.FLAG_INSTALLED) != 0) {
|
if ((info.flags & ApplicationInfo.FLAG_INSTALLED) != 0) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
} catch(NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
Log.e(TAG, "Package: " + packageName + " not found for user: " + userInfo.id);
|
Log.e(TAG, "Package: " + packageName + " not found for user: " + userInfo.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -707,10 +725,10 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setIntentAndFinish(boolean finish, boolean appChanged) {
|
private void setIntentAndFinish(boolean finish, boolean appChanged) {
|
||||||
if (localLOGV) Log.i(TAG, "appChanged="+appChanged);
|
if (localLOGV) Log.i(TAG, "appChanged=" + appChanged);
|
||||||
final Intent intent = new Intent();
|
final Intent intent = new Intent();
|
||||||
intent.putExtra(ManageApplications.APP_CHG, appChanged);
|
intent.putExtra(ManageApplications.APP_CHG, appChanged);
|
||||||
final SettingsActivity sa = (SettingsActivity)getActivity();
|
final SettingsActivity sa = (SettingsActivity) getActivity();
|
||||||
sa.finishPreferencePanel(Activity.RESULT_OK, intent);
|
sa.finishPreferencePanel(Activity.RESULT_OK, intent);
|
||||||
mFinishing = true;
|
mFinishing = true;
|
||||||
}
|
}
|
||||||
|
@@ -32,16 +32,14 @@ import com.android.settings.core.BasePreferenceController;
|
|||||||
public abstract class AppInfoPreferenceControllerBase extends BasePreferenceController
|
public abstract class AppInfoPreferenceControllerBase extends BasePreferenceController
|
||||||
implements AppInfoDashboardFragment.Callback {
|
implements AppInfoDashboardFragment.Callback {
|
||||||
|
|
||||||
protected final AppInfoDashboardFragment mParent;
|
protected AppInfoDashboardFragment mParent;
|
||||||
private final Class<? extends SettingsPreferenceFragment> mDetailFragmenClass;
|
|
||||||
|
|
||||||
protected Preference mPreference;
|
protected Preference mPreference;
|
||||||
|
|
||||||
public AppInfoPreferenceControllerBase(Context context, AppInfoDashboardFragment parent,
|
private final Class<? extends SettingsPreferenceFragment> mDetailFragmentClass;
|
||||||
String preferenceKey) {
|
|
||||||
|
public AppInfoPreferenceControllerBase(Context context, String preferenceKey) {
|
||||||
super(context, preferenceKey);
|
super(context, preferenceKey);
|
||||||
mParent = parent;
|
mDetailFragmentClass = getDetailFragmentClass();
|
||||||
mDetailFragmenClass = getDetailFragmentClass();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -57,9 +55,9 @@ public abstract class AppInfoPreferenceControllerBase extends BasePreferenceCont
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||||
if (TextUtils.equals(preference.getKey(), mPreferenceKey) && mDetailFragmenClass != null) {
|
if (TextUtils.equals(preference.getKey(), mPreferenceKey) && mDetailFragmentClass != null) {
|
||||||
AppInfoDashboardFragment.startAppInfoFragment(
|
AppInfoDashboardFragment.startAppInfoFragment(
|
||||||
mDetailFragmenClass, -1, getArguments(), mParent, mParent.getAppEntry());
|
mDetailFragmentClass, -1, getArguments(), mParent, mParent.getAppEntry());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -70,6 +68,11 @@ public abstract class AppInfoPreferenceControllerBase extends BasePreferenceCont
|
|||||||
updateState(mPreference);
|
updateState(mPreference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setParentFragment(AppInfoDashboardFragment parent) {
|
||||||
|
mParent = parent;
|
||||||
|
parent.addToCallbackList(this);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the fragment class to be launched when the preference is clicked.
|
* Gets the fragment class to be launched when the preference is clicked.
|
||||||
* @return the fragment to launch
|
* @return the fragment to launch
|
||||||
|
@@ -28,18 +28,12 @@ import com.android.settingslib.applications.AppUtils;
|
|||||||
|
|
||||||
public class AppInstallerInfoPreferenceController extends AppInfoPreferenceControllerBase {
|
public class AppInstallerInfoPreferenceController extends AppInfoPreferenceControllerBase {
|
||||||
|
|
||||||
private static final String KEY_APP_INSTALLER_INFO = "app_info_store";
|
private String mPackageName;
|
||||||
|
private String mInstallerPackage;
|
||||||
|
private CharSequence mInstallerLabel;
|
||||||
|
|
||||||
private final String mPackageName;
|
public AppInstallerInfoPreferenceController(Context context, String key) {
|
||||||
private final String mInstallerPackage;
|
super(context, key);
|
||||||
private final CharSequence mInstallerLabel;
|
|
||||||
|
|
||||||
public AppInstallerInfoPreferenceController(Context context, AppInfoDashboardFragment parent,
|
|
||||||
String packageName) {
|
|
||||||
super(context, parent, KEY_APP_INSTALLER_INFO);
|
|
||||||
mPackageName = packageName;
|
|
||||||
mInstallerPackage = AppStoreUtil.getInstallerPackageName(mContext, mPackageName);
|
|
||||||
mInstallerLabel = Utils.getApplicationLabel(mContext, mInstallerPackage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -47,7 +41,7 @@ public class AppInstallerInfoPreferenceController extends AppInfoPreferenceContr
|
|||||||
if (UserManager.get(mContext).isManagedProfile()) {
|
if (UserManager.get(mContext).isManagedProfile()) {
|
||||||
return DISABLED_FOR_USER;
|
return DISABLED_FOR_USER;
|
||||||
}
|
}
|
||||||
return mInstallerLabel!= null ? AVAILABLE : DISABLED_FOR_USER;
|
return mInstallerLabel != null ? AVAILABLE : DISABLED_FOR_USER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -65,4 +59,9 @@ public class AppInstallerInfoPreferenceController extends AppInfoPreferenceContr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPackageName(String packageName) {
|
||||||
|
mPackageName = packageName;
|
||||||
|
mInstallerPackage = AppStoreUtil.getInstallerPackageName(mContext, mPackageName);
|
||||||
|
mInstallerLabel = Utils.getApplicationLabel(mContext, mInstallerPackage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,17 +19,11 @@ package com.android.settings.applications.appinfo;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import com.android.settings.widget.PreferenceCategoryController;
|
import com.android.settings.widget.PreferenceCategoryController;
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class AppInstallerPreferenceCategoryController extends PreferenceCategoryController {
|
public class AppInstallerPreferenceCategoryController extends PreferenceCategoryController {
|
||||||
|
|
||||||
private static final String KEY_APP_INSTALLER_INFO_CATEGORY = "app_installer";
|
public AppInstallerPreferenceCategoryController(Context context, String key) {
|
||||||
|
super(context, key);
|
||||||
public AppInstallerPreferenceCategoryController(Context context,
|
|
||||||
List<AbstractPreferenceController> childrenControllers) {
|
|
||||||
super(context, KEY_APP_INSTALLER_INFO_CATEGORY, childrenControllers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -29,14 +29,18 @@ import com.android.settingslib.applications.ApplicationsState;
|
|||||||
|
|
||||||
public class AppNotificationPreferenceController extends AppInfoPreferenceControllerBase {
|
public class AppNotificationPreferenceController extends AppInfoPreferenceControllerBase {
|
||||||
|
|
||||||
private static final String KEY_NOTIFICATION = "notification_settings";
|
|
||||||
private String mChannelId = null;
|
private String mChannelId = null;
|
||||||
|
|
||||||
// Used for updating notification preference.
|
// Used for updating notification preference.
|
||||||
private final NotificationBackend mBackend = new NotificationBackend();
|
private final NotificationBackend mBackend = new NotificationBackend();
|
||||||
|
|
||||||
public AppNotificationPreferenceController(Context context, AppInfoDashboardFragment parent) {
|
public AppNotificationPreferenceController(Context context, String key) {
|
||||||
super(context, parent, KEY_NOTIFICATION);
|
super(context, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setParentFragment(AppInfoDashboardFragment parent) {
|
||||||
|
super.setParentFragment(parent);
|
||||||
if (parent != null && parent.getActivity() != null
|
if (parent != null && parent.getActivity() != null
|
||||||
&& parent.getActivity().getIntent() != null) {
|
&& parent.getActivity().getIntent() != null) {
|
||||||
mChannelId = parent.getActivity().getIntent().getStringExtra(EXTRA_FRAGMENT_ARG_KEY);
|
mChannelId = parent.getActivity().getIntent().getStringExtra(EXTRA_FRAGMENT_ARG_KEY);
|
||||||
@@ -63,6 +67,7 @@ public class AppNotificationPreferenceController extends AppInfoPreferenceContro
|
|||||||
return bundle;
|
return bundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private CharSequence getNotificationSummary(ApplicationsState.AppEntry appEntry,
|
private CharSequence getNotificationSummary(ApplicationsState.AppEntry appEntry,
|
||||||
Context context, NotificationBackend backend) {
|
Context context, NotificationBackend backend) {
|
||||||
NotificationBackend.AppRow appRow =
|
NotificationBackend.AppRow appRow =
|
||||||
|
@@ -32,13 +32,11 @@ import com.android.settingslib.applications.ApplicationsState;
|
|||||||
|
|
||||||
public class AppOpenByDefaultPreferenceController extends AppInfoPreferenceControllerBase {
|
public class AppOpenByDefaultPreferenceController extends AppInfoPreferenceControllerBase {
|
||||||
|
|
||||||
private static final String KEY_LAUNCH = "preferred_settings";
|
|
||||||
|
|
||||||
private IUsbManager mUsbManager;
|
private IUsbManager mUsbManager;
|
||||||
private PackageManager mPackageManager;
|
private PackageManager mPackageManager;
|
||||||
|
|
||||||
public AppOpenByDefaultPreferenceController(Context context, AppInfoDashboardFragment parent) {
|
public AppOpenByDefaultPreferenceController(Context context, String key) {
|
||||||
super(context, parent, KEY_LAUNCH);
|
super(context, key);
|
||||||
mUsbManager = IUsbManager.Stub.asInterface(ServiceManager.getService(Context.USB_SERVICE));
|
mUsbManager = IUsbManager.Stub.asInterface(ServiceManager.getService(Context.USB_SERVICE));
|
||||||
mPackageManager = context.getPackageManager();
|
mPackageManager = context.getPackageManager();
|
||||||
}
|
}
|
||||||
@@ -49,9 +47,9 @@ public class AppOpenByDefaultPreferenceController extends AppInfoPreferenceContr
|
|||||||
final ApplicationsState.AppEntry appEntry = mParent.getAppEntry();
|
final ApplicationsState.AppEntry appEntry = mParent.getAppEntry();
|
||||||
if (appEntry == null || appEntry.info == null) {
|
if (appEntry == null || appEntry.info == null) {
|
||||||
mPreference.setEnabled(false);
|
mPreference.setEnabled(false);
|
||||||
} else if ((appEntry.info.flags& ApplicationInfo.FLAG_INSTALLED) == 0
|
} else if ((appEntry.info.flags & ApplicationInfo.FLAG_INSTALLED) == 0
|
||||||
|| !appEntry.info.enabled) {
|
|| !appEntry.info.enabled) {
|
||||||
mPreference.setEnabled(false);
|
mPreference.setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -34,10 +34,9 @@ import java.util.List;
|
|||||||
public class AppPermissionPreferenceController extends AppInfoPreferenceControllerBase {
|
public class AppPermissionPreferenceController extends AppInfoPreferenceControllerBase {
|
||||||
|
|
||||||
private static final String TAG = "PermissionPrefControl";
|
private static final String TAG = "PermissionPrefControl";
|
||||||
private static final String KEY_PERMISSION = "permission_settings";
|
|
||||||
private static final String EXTRA_HIDE_INFO_BUTTON = "hideInfoButton";
|
private static final String EXTRA_HIDE_INFO_BUTTON = "hideInfoButton";
|
||||||
|
|
||||||
private final String mPackageName;
|
private String mPackageName;
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
final PermissionsSummaryHelper.PermissionsResultCallback mPermissionCallback
|
final PermissionsSummaryHelper.PermissionsResultCallback mPermissionCallback
|
||||||
@@ -76,10 +75,8 @@ public class AppPermissionPreferenceController extends AppInfoPreferenceControll
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public AppPermissionPreferenceController(Context context, AppInfoDashboardFragment parent,
|
public AppPermissionPreferenceController(Context context, String key) {
|
||||||
String packageName) {
|
super(context, key);
|
||||||
super(context, parent, KEY_PERMISSION);
|
|
||||||
mPackageName = packageName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -89,13 +86,17 @@ public class AppPermissionPreferenceController extends AppInfoPreferenceControll
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||||
if (KEY_PERMISSION.equals(preference.getKey())) {
|
if (getPreferenceKey().equals(preference.getKey())) {
|
||||||
startManagePermissionsActivity();
|
startManagePermissionsActivity();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPackageName(String packageName) {
|
||||||
|
mPackageName = packageName;
|
||||||
|
}
|
||||||
|
|
||||||
private void startManagePermissionsActivity() {
|
private void startManagePermissionsActivity() {
|
||||||
// start new activity to manage app permissions
|
// start new activity to manage app permissions
|
||||||
final Intent intent = new Intent(Intent.ACTION_MANAGE_APP_PERMISSIONS);
|
final Intent intent = new Intent(Intent.ACTION_MANAGE_APP_PERMISSIONS);
|
||||||
@@ -107,5 +108,4 @@ public class AppPermissionPreferenceController extends AppInfoPreferenceControll
|
|||||||
Log.w(TAG, "No app can handle android.intent.action.MANAGE_APP_PERMISSIONS");
|
Log.w(TAG, "No app can handle android.intent.action.MANAGE_APP_PERMISSIONS");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -31,7 +31,6 @@ import com.android.settings.SettingsPreferenceFragment;
|
|||||||
import com.android.settings.applications.AppStorageSettings;
|
import com.android.settings.applications.AppStorageSettings;
|
||||||
import com.android.settings.applications.FetchPackageStorageAsyncLoader;
|
import com.android.settings.applications.FetchPackageStorageAsyncLoader;
|
||||||
import com.android.settingslib.applications.StorageStatsSource;
|
import com.android.settingslib.applications.StorageStatsSource;
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
|
||||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnPause;
|
import com.android.settingslib.core.lifecycle.events.OnPause;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnResume;
|
import com.android.settingslib.core.lifecycle.events.OnResume;
|
||||||
@@ -40,15 +39,10 @@ public class AppStoragePreferenceController extends AppInfoPreferenceControllerB
|
|||||||
implements LoaderManager.LoaderCallbacks<StorageStatsSource.AppStorageStats>,
|
implements LoaderManager.LoaderCallbacks<StorageStatsSource.AppStorageStats>,
|
||||||
LifecycleObserver, OnResume, OnPause {
|
LifecycleObserver, OnResume, OnPause {
|
||||||
|
|
||||||
private static final String KEY_STORAGE = "storage_settings";
|
|
||||||
private StorageStatsSource.AppStorageStats mLastResult;
|
private StorageStatsSource.AppStorageStats mLastResult;
|
||||||
|
|
||||||
public AppStoragePreferenceController(Context context, AppInfoDashboardFragment parent,
|
public AppStoragePreferenceController(Context context, String key) {
|
||||||
Lifecycle lifecycle) {
|
super(context, key);
|
||||||
super(context, parent, KEY_STORAGE);
|
|
||||||
if (lifecycle != null) {
|
|
||||||
lifecycle.addObserver(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -17,23 +17,19 @@
|
|||||||
package com.android.settings.applications.appinfo;
|
package com.android.settings.applications.appinfo;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.v7.preference.Preference;
|
|
||||||
import android.text.BidiFormatter;
|
import android.text.BidiFormatter;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
public class AppVersionPreferenceController extends AppInfoPreferenceControllerBase {
|
public class AppVersionPreferenceController extends AppInfoPreferenceControllerBase {
|
||||||
|
|
||||||
private static final String KEY_VERSION = "app_version";
|
public AppVersionPreferenceController(Context context, String key) {
|
||||||
|
super(context, key);
|
||||||
public AppVersionPreferenceController(Context context, AppInfoDashboardFragment parent) {
|
|
||||||
super(context, parent, KEY_VERSION);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateState(Preference preference) {
|
public CharSequence getSummary() {
|
||||||
preference.setSummary(mContext.getString(R.string.version_text,
|
return mContext.getString(R.string.version_text,
|
||||||
BidiFormatter.getInstance().unicodeWrap(mParent.getPackageInfo().versionName)));
|
BidiFormatter.getInstance().unicodeWrap(mParent.getPackageInfo().versionName));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -26,10 +26,8 @@ import com.android.settings.SettingsPreferenceFragment;
|
|||||||
|
|
||||||
public class DrawOverlayDetailPreferenceController extends AppInfoPreferenceControllerBase {
|
public class DrawOverlayDetailPreferenceController extends AppInfoPreferenceControllerBase {
|
||||||
|
|
||||||
private static final String KEY = "system_alert_window";
|
public DrawOverlayDetailPreferenceController(Context context, String key) {
|
||||||
|
super(context, key);
|
||||||
public DrawOverlayDetailPreferenceController(Context context, AppInfoDashboardFragment parent) {
|
|
||||||
super(context, parent, KEY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -26,14 +26,10 @@ import com.android.settings.applications.AppStateInstallAppsBridge;
|
|||||||
|
|
||||||
public class ExternalSourceDetailPreferenceController extends AppInfoPreferenceControllerBase {
|
public class ExternalSourceDetailPreferenceController extends AppInfoPreferenceControllerBase {
|
||||||
|
|
||||||
private static final String KEY = "install_other_apps";
|
private String mPackageName;
|
||||||
|
|
||||||
private final String mPackageName;
|
public ExternalSourceDetailPreferenceController(Context context, String key) {
|
||||||
|
super(context, key);
|
||||||
public ExternalSourceDetailPreferenceController(Context context,
|
|
||||||
AppInfoDashboardFragment parent, String packageName) {
|
|
||||||
super(context, parent, KEY);
|
|
||||||
mPackageName = packageName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -67,4 +63,7 @@ public class ExternalSourceDetailPreferenceController extends AppInfoPreferenceC
|
|||||||
return appState.isPotentialAppSource();
|
return appState.isPotentialAppSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPackageName(String packageName) {
|
||||||
|
mPackageName = packageName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,13 +28,10 @@ import java.util.Set;
|
|||||||
|
|
||||||
public class InstantAppDomainsPreferenceController extends AppInfoPreferenceControllerBase {
|
public class InstantAppDomainsPreferenceController extends AppInfoPreferenceControllerBase {
|
||||||
|
|
||||||
private static final String KEY_INSTANT_APP_SUPPORTED_LINKS =
|
|
||||||
"instant_app_launch_supported_domain_urls";
|
|
||||||
|
|
||||||
private PackageManager mPackageManager;
|
private PackageManager mPackageManager;
|
||||||
|
|
||||||
public InstantAppDomainsPreferenceController(Context context, AppInfoDashboardFragment parent) {
|
public InstantAppDomainsPreferenceController(Context context, String key) {
|
||||||
super(context, parent, KEY_INSTANT_APP_SUPPORTED_LINKS);
|
super(context, key);
|
||||||
mPackageManager = mContext.getPackageManager();
|
mPackageManager = mContext.getPackageManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -28,17 +28,15 @@ import com.android.settings.SettingsPreferenceFragment;
|
|||||||
|
|
||||||
public class PictureInPictureDetailPreferenceController extends AppInfoPreferenceControllerBase {
|
public class PictureInPictureDetailPreferenceController extends AppInfoPreferenceControllerBase {
|
||||||
|
|
||||||
private static final String KEY = "picture_in_picture";
|
|
||||||
private static final String TAG = "PicInPicDetailControl";
|
private static final String TAG = "PicInPicDetailControl";
|
||||||
|
|
||||||
private final PackageManager mPackageManager;
|
private final PackageManager mPackageManager;
|
||||||
private final String mPackageName;
|
|
||||||
|
|
||||||
public PictureInPictureDetailPreferenceController(Context context,
|
private String mPackageName;
|
||||||
AppInfoDashboardFragment parent, String packageName) {
|
|
||||||
super(context, parent, KEY);
|
public PictureInPictureDetailPreferenceController(Context context, String key) {
|
||||||
|
super(context, key);
|
||||||
mPackageManager = context.getPackageManager();
|
mPackageManager = context.getPackageManager();
|
||||||
mPackageName = packageName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -78,4 +76,8 @@ public class PictureInPictureDetailPreferenceController extends AppInfoPreferenc
|
|||||||
return PictureInPictureDetails.getPreferenceSummary(mContext,
|
return PictureInPictureDetails.getPreferenceSummary(mContext,
|
||||||
mParent.getPackageInfo().applicationInfo.uid, mPackageName);
|
mParent.getPackageInfo().applicationInfo.uid, mPackageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPackageName(String packageName) {
|
||||||
|
mPackageName = packageName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,11 +26,8 @@ import com.android.settings.SettingsPreferenceFragment;
|
|||||||
|
|
||||||
public class WriteSystemSettingsPreferenceController extends AppInfoPreferenceControllerBase {
|
public class WriteSystemSettingsPreferenceController extends AppInfoPreferenceControllerBase {
|
||||||
|
|
||||||
private static final String KEY = "write_settings_apps";
|
public WriteSystemSettingsPreferenceController(Context context, String prefKey) {
|
||||||
|
super(context, prefKey);
|
||||||
public WriteSystemSettingsPreferenceController(Context context,
|
|
||||||
AppInfoDashboardFragment parent) {
|
|
||||||
super(context, parent, KEY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -83,8 +83,8 @@ public class EnterprisePrivacySettings extends DashboardFragment {
|
|||||||
exposureChangesCategoryControllers.add(new CaCertsManagedProfilePreferenceController(
|
exposureChangesCategoryControllers.add(new CaCertsManagedProfilePreferenceController(
|
||||||
context));
|
context));
|
||||||
controllers.addAll(exposureChangesCategoryControllers);
|
controllers.addAll(exposureChangesCategoryControllers);
|
||||||
controllers.add(new PreferenceCategoryController(context, "exposure_changes_category",
|
controllers.add(new PreferenceCategoryController(context, "exposure_changes_category")
|
||||||
exposureChangesCategoryControllers));
|
.setChildren(exposureChangesCategoryControllers));
|
||||||
controllers.add(new FailedPasswordWipeCurrentUserPreferenceController(context));
|
controllers.add(new FailedPasswordWipeCurrentUserPreferenceController(context));
|
||||||
controllers.add(new FailedPasswordWipeManagedProfilePreferenceController(context));
|
controllers.add(new FailedPasswordWipeManagedProfilePreferenceController(context));
|
||||||
return controllers;
|
return controllers;
|
||||||
|
@@ -105,7 +105,7 @@ public class LanguageAndInputSettings extends DashboardFragment {
|
|||||||
controllers.add(virtualKeyboardPreferenceController);
|
controllers.add(virtualKeyboardPreferenceController);
|
||||||
controllers.add(physicalKeyboardPreferenceController);
|
controllers.add(physicalKeyboardPreferenceController);
|
||||||
controllers.add(new PreferenceCategoryController(context,
|
controllers.add(new PreferenceCategoryController(context,
|
||||||
KEY_KEYBOARDS_CATEGORY,
|
KEY_KEYBOARDS_CATEGORY).setChildren(
|
||||||
Arrays.asList(virtualKeyboardPreferenceController,
|
Arrays.asList(virtualKeyboardPreferenceController,
|
||||||
physicalKeyboardPreferenceController)));
|
physicalKeyboardPreferenceController)));
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ public class LanguageAndInputSettings extends DashboardFragment {
|
|||||||
final PointerSpeedController pointerController = new PointerSpeedController(context);
|
final PointerSpeedController pointerController = new PointerSpeedController(context);
|
||||||
controllers.add(pointerController);
|
controllers.add(pointerController);
|
||||||
controllers.add(new PreferenceCategoryController(context,
|
controllers.add(new PreferenceCategoryController(context,
|
||||||
KEY_POINTER_AND_TTS_CATEGORY,
|
KEY_POINTER_AND_TTS_CATEGORY).setChildren(
|
||||||
Arrays.asList(pointerController, ttsPreferenceController)));
|
Arrays.asList(pointerController, ttsPreferenceController)));
|
||||||
|
|
||||||
// Input Assistance
|
// Input Assistance
|
||||||
@@ -132,7 +132,7 @@ public class LanguageAndInputSettings extends DashboardFragment {
|
|||||||
}
|
}
|
||||||
controllers.add(gameControllerPreferenceController);
|
controllers.add(gameControllerPreferenceController);
|
||||||
controllers.add(new PreferenceCategoryController(context,
|
controllers.add(new PreferenceCategoryController(context,
|
||||||
KEY_GAME_CONTROLLER_CATEGORY,
|
KEY_GAME_CONTROLLER_CATEGORY).setChildren(
|
||||||
Arrays.asList(gameControllerPreferenceController)));
|
Arrays.asList(gameControllerPreferenceController)));
|
||||||
|
|
||||||
return controllers;
|
return controllers;
|
||||||
|
@@ -229,7 +229,7 @@ public class SoundSettings extends DashboardFragment {
|
|||||||
controllers.add(bootSoundPreferenceController);
|
controllers.add(bootSoundPreferenceController);
|
||||||
controllers.add(emergencyTonePreferenceController);
|
controllers.add(emergencyTonePreferenceController);
|
||||||
controllers.add(new PreferenceCategoryController(context,
|
controllers.add(new PreferenceCategoryController(context,
|
||||||
"other_sounds_and_vibrations_category",
|
"other_sounds_and_vibrations_category").setChildren(
|
||||||
Arrays.asList(dialPadTonePreferenceController,
|
Arrays.asList(dialPadTonePreferenceController,
|
||||||
screenLockSoundPreferenceController,
|
screenLockSoundPreferenceController,
|
||||||
chargingSoundPreferenceController,
|
chargingSoundPreferenceController,
|
||||||
|
@@ -70,7 +70,7 @@ public class EncryptionAndCredential extends DashboardFragment {
|
|||||||
PREF_KEY_ENCRYPTION_DETAIL_PAGE);
|
PREF_KEY_ENCRYPTION_DETAIL_PAGE);
|
||||||
controllers.add(encryptStatusController);
|
controllers.add(encryptStatusController);
|
||||||
controllers.add(new PreferenceCategoryController(context,
|
controllers.add(new PreferenceCategoryController(context,
|
||||||
"encryption_and_credentials_status_category",
|
"encryption_and_credentials_status_category").setChildren(
|
||||||
Arrays.asList(encryptStatusController)));
|
Arrays.asList(encryptStatusController)));
|
||||||
controllers.add(new CredentialStoragePreferenceController(context));
|
controllers.add(new CredentialStoragePreferenceController(context));
|
||||||
controllers.add(new UserCredentialsPreferenceController(context));
|
controllers.add(new UserCredentialsPreferenceController(context));
|
||||||
|
@@ -128,8 +128,8 @@ public class SecuritySettings extends DashboardFragment {
|
|||||||
securityPreferenceControllers.add(new FingerprintStatusPreferenceController(context));
|
securityPreferenceControllers.add(new FingerprintStatusPreferenceController(context));
|
||||||
securityPreferenceControllers.add(new LockScreenPreferenceController(context, lifecycle));
|
securityPreferenceControllers.add(new LockScreenPreferenceController(context, lifecycle));
|
||||||
securityPreferenceControllers.add(new ChangeScreenLockPreferenceController(context, host));
|
securityPreferenceControllers.add(new ChangeScreenLockPreferenceController(context, host));
|
||||||
controllers.add(new PreferenceCategoryController(context, SECURITY_CATEGORY,
|
controllers.add(new PreferenceCategoryController(context, SECURITY_CATEGORY)
|
||||||
securityPreferenceControllers));
|
.setChildren(securityPreferenceControllers));
|
||||||
controllers.addAll(securityPreferenceControllers);
|
controllers.addAll(securityPreferenceControllers);
|
||||||
|
|
||||||
final List<AbstractPreferenceController> profileSecurityControllers = new ArrayList<>();
|
final List<AbstractPreferenceController> profileSecurityControllers = new ArrayList<>();
|
||||||
@@ -139,8 +139,8 @@ public class SecuritySettings extends DashboardFragment {
|
|||||||
profileSecurityControllers.add(new VisiblePatternProfilePreferenceController(
|
profileSecurityControllers.add(new VisiblePatternProfilePreferenceController(
|
||||||
context, lifecycle));
|
context, lifecycle));
|
||||||
profileSecurityControllers.add(new FingerprintProfileStatusPreferenceController(context));
|
profileSecurityControllers.add(new FingerprintProfileStatusPreferenceController(context));
|
||||||
controllers.add(new PreferenceCategoryController(context, WORK_PROFILE_SECURITY_CATEGORY,
|
controllers.add(new PreferenceCategoryController(context, WORK_PROFILE_SECURITY_CATEGORY)
|
||||||
profileSecurityControllers));
|
.setChildren(profileSecurityControllers));
|
||||||
controllers.addAll(profileSecurityControllers);
|
controllers.addAll(profileSecurityControllers);
|
||||||
|
|
||||||
return controllers;
|
return controllers;
|
||||||
|
@@ -22,6 +22,7 @@ import static com.android.settings.slices.SettingsSliceProvider.ACTION_WIFI_CHAN
|
|||||||
import static com.android.settings.slices.SettingsSliceProvider.EXTRA_SLICE_KEY;
|
import static com.android.settings.slices.SettingsSliceProvider.EXTRA_SLICE_KEY;
|
||||||
import static com.android.settings.slices.SettingsSliceProvider.EXTRA_SLICE_PLATFORM_DEFINED;
|
import static com.android.settings.slices.SettingsSliceProvider.EXTRA_SLICE_PLATFORM_DEFINED;
|
||||||
|
|
||||||
|
import android.app.slice.Slice;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -36,8 +37,6 @@ import com.android.settings.core.BasePreferenceController;
|
|||||||
import com.android.settings.core.SliderPreferenceController;
|
import com.android.settings.core.SliderPreferenceController;
|
||||||
import com.android.settings.core.TogglePreferenceController;
|
import com.android.settings.core.TogglePreferenceController;
|
||||||
|
|
||||||
import android.app.slice.Slice;
|
|
||||||
|
|
||||||
import androidx.slice.core.SliceHints;
|
import androidx.slice.core.SliceHints;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -18,9 +18,10 @@ package com.android.settings.widget;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import com.android.settings.core.PreferenceControllerMixin;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,35 +29,42 @@ import java.util.List;
|
|||||||
* not-available, this controller will also report not-available, and subsequently will be hidden by
|
* not-available, this controller will also report not-available, and subsequently will be hidden by
|
||||||
* UI.
|
* UI.
|
||||||
*/
|
*/
|
||||||
public class PreferenceCategoryController extends AbstractPreferenceController
|
public class PreferenceCategoryController extends BasePreferenceController {
|
||||||
implements PreferenceControllerMixin {
|
|
||||||
|
|
||||||
private final String mKey;
|
private final String mKey;
|
||||||
private final List<AbstractPreferenceController> mChildren;
|
private final List<AbstractPreferenceController> mChildren;
|
||||||
|
|
||||||
public PreferenceCategoryController(Context context,
|
public PreferenceCategoryController(Context context, String key) {
|
||||||
String key, List<AbstractPreferenceController> childrenControllers) {
|
super(context, key);
|
||||||
super(context);
|
|
||||||
mKey = key;
|
mKey = key;
|
||||||
mChildren = childrenControllers;
|
mChildren = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable() {
|
public int getAvailabilityStatus() {
|
||||||
if (mChildren == null || mChildren.isEmpty()) {
|
if (mChildren == null || mChildren.isEmpty()) {
|
||||||
return true;
|
return DISABLED_DEPENDENT_SETTING;
|
||||||
}
|
}
|
||||||
// Category is available if any child is available
|
// Category is available if any child is available
|
||||||
for (AbstractPreferenceController controller : mChildren) {
|
for (AbstractPreferenceController controller : mChildren) {
|
||||||
if (controller.isAvailable()) {
|
if (controller.isAvailable()) {
|
||||||
return true;
|
return AVAILABLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return DISABLED_DEPENDENT_SETTING;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPreferenceKey() {
|
public String getPreferenceKey() {
|
||||||
return mKey;
|
return mKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PreferenceCategoryController setChildren(
|
||||||
|
List<AbstractPreferenceController> childrenController) {
|
||||||
|
mChildren.clear();
|
||||||
|
if (childrenController != null) {
|
||||||
|
mChildren.addAll(childrenController);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,20 +1,8 @@
|
|||||||
com.android.settings.applications.appinfo.AppActionButtonPreferenceController
|
com.android.settings.applications.appinfo.AppActionButtonPreferenceController
|
||||||
com.android.settings.applications.appinfo.AppBatteryPreferenceController
|
com.android.settings.applications.appinfo.AppBatteryPreferenceController
|
||||||
com.android.settings.applications.appinfo.AppDataUsagePreferenceController
|
|
||||||
com.android.settings.applications.appinfo.AppHeaderViewPreferenceController
|
com.android.settings.applications.appinfo.AppHeaderViewPreferenceController
|
||||||
com.android.settings.applications.appinfo.AppInstallerInfoPreferenceController
|
|
||||||
com.android.settings.applications.appinfo.AppMemoryPreferenceController
|
com.android.settings.applications.appinfo.AppMemoryPreferenceController
|
||||||
com.android.settings.applications.appinfo.AppNotificationPreferenceController
|
|
||||||
com.android.settings.applications.appinfo.AppOpenByDefaultPreferenceController
|
|
||||||
com.android.settings.applications.appinfo.AppPermissionPreferenceController
|
|
||||||
com.android.settings.applications.appinfo.AppStoragePreferenceController
|
|
||||||
com.android.settings.applications.appinfo.AppVersionPreferenceController
|
|
||||||
com.android.settings.applications.appinfo.DrawOverlayDetailPreferenceController
|
|
||||||
com.android.settings.applications.appinfo.ExternalSourceDetailPreferenceController
|
|
||||||
com.android.settings.applications.appinfo.InstantAppButtonsPreferenceController
|
com.android.settings.applications.appinfo.InstantAppButtonsPreferenceController
|
||||||
com.android.settings.applications.appinfo.InstantAppDomainsPreferenceController
|
|
||||||
com.android.settings.applications.appinfo.PictureInPictureDetailPreferenceController
|
|
||||||
com.android.settings.applications.appinfo.WriteSystemSettingsPreferenceController
|
|
||||||
com.android.settings.bluetooth.BluetoothDeviceNamePreferenceController
|
com.android.settings.bluetooth.BluetoothDeviceNamePreferenceController
|
||||||
com.android.settings.bluetooth.BluetoothDeviceRenamePreferenceController
|
com.android.settings.bluetooth.BluetoothDeviceRenamePreferenceController
|
||||||
com.android.settings.bluetooth.BluetoothSwitchPreferenceController
|
com.android.settings.bluetooth.BluetoothSwitchPreferenceController
|
||||||
|
@@ -63,8 +63,8 @@ public class AppDataUsagePreferenceControllerTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
|
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
|
||||||
mController = spy(
|
mController = spy(new AppDataUsagePreferenceController(mContext, "test_key"));
|
||||||
new AppDataUsagePreferenceController(mContext, mFragment, null /* lifecycle */));
|
mController.setParentFragment(mFragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -102,7 +102,8 @@ public class AppInfoPreferenceControllerBaseTest {
|
|||||||
private boolean preferenceUpdated;
|
private boolean preferenceUpdated;
|
||||||
|
|
||||||
private TestPreferenceController(AppInfoDashboardFragment parent) {
|
private TestPreferenceController(AppInfoDashboardFragment parent) {
|
||||||
super(RuntimeEnvironment.application, parent, "TestKey");
|
super(RuntimeEnvironment.application, "TestKey");
|
||||||
|
setParentFragment(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -74,7 +74,9 @@ public class AppInstallerInfoPreferenceControllerTest {
|
|||||||
when(mPackageManager.getInstallerPackageName(anyString())).thenReturn(installerPackage);
|
when(mPackageManager.getInstallerPackageName(anyString())).thenReturn(installerPackage);
|
||||||
when(mPackageManager.getApplicationInfo(eq(installerPackage), anyInt()))
|
when(mPackageManager.getApplicationInfo(eq(installerPackage), anyInt()))
|
||||||
.thenReturn(mAppInfo);
|
.thenReturn(mAppInfo);
|
||||||
mController = new AppInstallerInfoPreferenceController(mContext, mFragment, "Package1");
|
mController = new AppInstallerInfoPreferenceController(mContext, "test_key");
|
||||||
|
mController.setPackageName("Package1");
|
||||||
|
mController.setParentFragment(mFragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -82,7 +84,7 @@ public class AppInstallerInfoPreferenceControllerTest {
|
|||||||
when(mUserManager.isManagedProfile()).thenReturn(true);
|
when(mUserManager.isManagedProfile()).thenReturn(true);
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
assertThat(mController.getAvailabilityStatus())
|
||||||
.isEqualTo(BasePreferenceController.DISABLED_FOR_USER);
|
.isEqualTo(BasePreferenceController.DISABLED_FOR_USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -90,17 +92,19 @@ public class AppInstallerInfoPreferenceControllerTest {
|
|||||||
when(mUserManager.isManagedProfile()).thenReturn(false);
|
when(mUserManager.isManagedProfile()).thenReturn(false);
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
assertThat(mController.getAvailabilityStatus())
|
||||||
.isEqualTo(BasePreferenceController.DISABLED_FOR_USER);
|
.isEqualTo(BasePreferenceController.DISABLED_FOR_USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAvailabilityStatus_hasAppLabel_shouldReturnAvailable() {
|
public void getAvailabilityStatus_hasAppLabel_shouldReturnAvailable() {
|
||||||
when(mUserManager.isManagedProfile()).thenReturn(false);
|
when(mUserManager.isManagedProfile()).thenReturn(false);
|
||||||
when(mAppInfo.loadLabel(mPackageManager)).thenReturn("Label1");
|
when(mAppInfo.loadLabel(mPackageManager)).thenReturn("Label1");
|
||||||
mController = new AppInstallerInfoPreferenceController(mContext, mFragment, "Package1");
|
mController = new AppInstallerInfoPreferenceController(mContext, "test_key");
|
||||||
|
mController.setPackageName("Package1");
|
||||||
|
mController.setParentFragment(mFragment);
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
assertThat(mController.getAvailabilityStatus())
|
||||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
.isEqualTo(BasePreferenceController.AVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -17,7 +17,6 @@
|
|||||||
package com.android.settings.applications.appinfo;
|
package com.android.settings.applications.appinfo;
|
||||||
|
|
||||||
import static com.android.settings.SettingsActivity.EXTRA_FRAGMENT_ARG_KEY;
|
import static com.android.settings.SettingsActivity.EXTRA_FRAGMENT_ARG_KEY;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
@@ -62,7 +61,8 @@ public class AppNotificationPreferenceControllerTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = RuntimeEnvironment.application;
|
mContext = RuntimeEnvironment.application;
|
||||||
mController = spy(new AppNotificationPreferenceController(mContext, mFragment));
|
mController = spy(new AppNotificationPreferenceController(mContext, "test_key"));
|
||||||
|
mController.setParentFragment(mFragment);
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
final String key = mController.getPreferenceKey();
|
final String key = mController.getPreferenceKey();
|
||||||
when(mPreference.getKey()).thenReturn(key);
|
when(mPreference.getKey()).thenReturn(key);
|
||||||
@@ -99,7 +99,8 @@ public class AppNotificationPreferenceControllerTest {
|
|||||||
when(mFragment.getActivity()).thenReturn(activity);
|
when(mFragment.getActivity()).thenReturn(activity);
|
||||||
when(activity.getIntent()).thenReturn(intent);
|
when(activity.getIntent()).thenReturn(intent);
|
||||||
AppNotificationPreferenceController controller =
|
AppNotificationPreferenceController controller =
|
||||||
new AppNotificationPreferenceController(mContext, mFragment);
|
new AppNotificationPreferenceController(mContext, "test");
|
||||||
|
controller.setParentFragment(mFragment);
|
||||||
|
|
||||||
assertThat(controller.getArguments().containsKey(EXTRA_FRAGMENT_ARG_KEY)).isTrue();
|
assertThat(controller.getArguments().containsKey(EXTRA_FRAGMENT_ARG_KEY)).isTrue();
|
||||||
assertThat(controller.getArguments().getString(EXTRA_FRAGMENT_ARG_KEY)).isEqualTo("test");
|
assertThat(controller.getArguments().getString(EXTRA_FRAGMENT_ARG_KEY)).isEqualTo("test");
|
||||||
|
@@ -61,7 +61,8 @@ public class AppOpenByDefaultPreferenceControllerTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = RuntimeEnvironment.application.getApplicationContext();
|
mContext = RuntimeEnvironment.application.getApplicationContext();
|
||||||
mController = spy(new AppOpenByDefaultPreferenceController(mContext, mFragment));
|
mController = spy(new AppOpenByDefaultPreferenceController(mContext, "preferred_app"));
|
||||||
|
mController.setParentFragment(mFragment);
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -63,7 +63,10 @@ public class AppPermissionPreferenceControllerTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = RuntimeEnvironment.application;
|
mContext = RuntimeEnvironment.application;
|
||||||
mController = new AppPermissionPreferenceController(mContext, mFragment, "Package1");
|
mController = new AppPermissionPreferenceController(mContext, "permission_settings");
|
||||||
|
mController.setPackageName("package1");
|
||||||
|
mController.setParentFragment(mFragment);
|
||||||
|
|
||||||
when(mScreen.findPreference(any())).thenReturn(mPreference);
|
when(mScreen.findPreference(any())).thenReturn(mPreference);
|
||||||
final String key = mController.getPreferenceKey();
|
final String key = mController.getPreferenceKey();
|
||||||
when(mPreference.getKey()).thenReturn(key);
|
when(mPreference.getKey()).thenReturn(key);
|
||||||
@@ -133,7 +136,7 @@ public class AppPermissionPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.handlePreferenceTreeClick(mPreference);
|
mController.handlePreferenceTreeClick(mPreference);
|
||||||
|
|
||||||
verify(mActivity).startActivityForResult(argThat(intent-> intent != null &&
|
verify(mActivity).startActivityForResult(argThat(intent -> intent != null &&
|
||||||
Intent.ACTION_MANAGE_APP_PERMISSIONS.equals(intent.getAction())), anyInt());
|
Intent.ACTION_MANAGE_APP_PERMISSIONS.equals(intent.getAction())), anyInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -57,8 +57,8 @@ public class AppStoragePreferenceControllerTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = RuntimeEnvironment.application.getApplicationContext();
|
mContext = RuntimeEnvironment.application.getApplicationContext();
|
||||||
mController =
|
mController = spy(new AppStoragePreferenceController(mContext, "key"));
|
||||||
spy(new AppStoragePreferenceController(mContext, mFragment, null /* lifecycle */));
|
mController.setParentFragment(mFragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -48,7 +48,8 @@ public class AppVersionPreferenceControllerTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = RuntimeEnvironment.application;
|
mContext = RuntimeEnvironment.application;
|
||||||
mController = new AppVersionPreferenceController(mContext, mFragment);
|
mController = new AppVersionPreferenceController(mContext, "test_key");
|
||||||
|
mController.setParentFragment(mFragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -57,7 +57,8 @@ public class DrawOverlayDetailPreferenceControllerTest {
|
|||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = spy(RuntimeEnvironment.application);
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
|
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
|
||||||
mController = spy(new DrawOverlayDetailPreferenceController(mContext, mFragment));
|
mController = spy(new DrawOverlayDetailPreferenceController(mContext, "key"));
|
||||||
|
mController.setParentFragment(mFragment);
|
||||||
final String key = mController.getPreferenceKey();
|
final String key = mController.getPreferenceKey();
|
||||||
when(mPreference.getKey()).thenReturn(key);
|
when(mPreference.getKey()).thenReturn(key);
|
||||||
}
|
}
|
||||||
@@ -67,7 +68,7 @@ public class DrawOverlayDetailPreferenceControllerTest {
|
|||||||
when(mUserManager.isManagedProfile()).thenReturn(true);
|
when(mUserManager.isManagedProfile()).thenReturn(true);
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
assertThat(mController.getAvailabilityStatus())
|
||||||
.isEqualTo(BasePreferenceController.DISABLED_FOR_USER);
|
.isEqualTo(BasePreferenceController.DISABLED_FOR_USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -76,7 +77,7 @@ public class DrawOverlayDetailPreferenceControllerTest {
|
|||||||
when(mFragment.getPackageInfo()).thenReturn(new PackageInfo());
|
when(mFragment.getPackageInfo()).thenReturn(new PackageInfo());
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
assertThat(mController.getAvailabilityStatus())
|
||||||
.isEqualTo(BasePreferenceController.DISABLED_FOR_USER);
|
.isEqualTo(BasePreferenceController.DISABLED_FOR_USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -87,7 +88,7 @@ public class DrawOverlayDetailPreferenceControllerTest {
|
|||||||
when(mFragment.getPackageInfo()).thenReturn(info);
|
when(mFragment.getPackageInfo()).thenReturn(info);
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
assertThat(mController.getAvailabilityStatus())
|
||||||
.isEqualTo(BasePreferenceController.DISABLED_FOR_USER);
|
.isEqualTo(BasePreferenceController.DISABLED_FOR_USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -98,7 +99,7 @@ public class DrawOverlayDetailPreferenceControllerTest {
|
|||||||
when(mFragment.getPackageInfo()).thenReturn(info);
|
when(mFragment.getPackageInfo()).thenReturn(info);
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
assertThat(mController.getAvailabilityStatus())
|
||||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
.isEqualTo(BasePreferenceController.AVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -54,8 +54,9 @@ public class ExternalSourceDetailPreferenceControllerTest {
|
|||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = spy(RuntimeEnvironment.application);
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
|
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
|
||||||
mController = spy(
|
mController = spy(new ExternalSourceDetailPreferenceController(mContext, "test_key"));
|
||||||
new ExternalSourceDetailPreferenceController(mContext, mFragment, "Package1"));
|
mController.setPackageName("Package1");
|
||||||
|
mController.setParentFragment(mFragment);
|
||||||
final String key = mController.getPreferenceKey();
|
final String key = mController.getPreferenceKey();
|
||||||
when(mPreference.getKey()).thenReturn(key);
|
when(mPreference.getKey()).thenReturn(key);
|
||||||
}
|
}
|
||||||
@@ -65,7 +66,7 @@ public class ExternalSourceDetailPreferenceControllerTest {
|
|||||||
when(mUserManager.isManagedProfile()).thenReturn(true);
|
when(mUserManager.isManagedProfile()).thenReturn(true);
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
assertThat(mController.getAvailabilityStatus())
|
||||||
.isEqualTo(BasePreferenceController.DISABLED_FOR_USER);
|
.isEqualTo(BasePreferenceController.DISABLED_FOR_USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -74,7 +75,7 @@ public class ExternalSourceDetailPreferenceControllerTest {
|
|||||||
doReturn(false).when(mController).isPotentialAppSource();
|
doReturn(false).when(mController).isPotentialAppSource();
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
assertThat(mController.getAvailabilityStatus())
|
||||||
.isEqualTo(BasePreferenceController.DISABLED_FOR_USER);
|
.isEqualTo(BasePreferenceController.DISABLED_FOR_USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -83,7 +84,7 @@ public class ExternalSourceDetailPreferenceControllerTest {
|
|||||||
doReturn(true).when(mController).isPotentialAppSource();
|
doReturn(true).when(mController).isPotentialAppSource();
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
assertThat(mController.getAvailabilityStatus())
|
||||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
.isEqualTo(BasePreferenceController.AVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -62,7 +62,7 @@ public class InstantAppDomainsPreferenceControllerTest {
|
|||||||
private InstantAppDomainsPreferenceController mController;
|
private InstantAppDomainsPreferenceController mController;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws PackageManager.NameNotFoundException {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = spy(RuntimeEnvironment.application);
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
when(mContext.getPackageManager()).thenReturn(mPackageManager);
|
when(mContext.getPackageManager()).thenReturn(mPackageManager);
|
||||||
@@ -70,7 +70,8 @@ public class InstantAppDomainsPreferenceControllerTest {
|
|||||||
packageInfo.applicationInfo = mAppInfo;
|
packageInfo.applicationInfo = mAppInfo;
|
||||||
packageInfo.packageName = "Package1";
|
packageInfo.packageName = "Package1";
|
||||||
when(mFragment.getPackageInfo()).thenReturn(packageInfo);
|
when(mFragment.getPackageInfo()).thenReturn(packageInfo);
|
||||||
mController = new InstantAppDomainsPreferenceController(mContext, mFragment);
|
mController = new InstantAppDomainsPreferenceController(mContext, "test_key");
|
||||||
|
mController.setParentFragment(mFragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -79,7 +80,7 @@ public class InstantAppDomainsPreferenceControllerTest {
|
|||||||
(InstantAppDataProvider) (i -> false));
|
(InstantAppDataProvider) (i -> false));
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
assertThat(mController.getAvailabilityStatus())
|
||||||
.isEqualTo(BasePreferenceController.DISABLED_FOR_USER);
|
.isEqualTo(BasePreferenceController.DISABLED_FOR_USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -88,12 +89,12 @@ public class InstantAppDomainsPreferenceControllerTest {
|
|||||||
(InstantAppDataProvider) (i -> true));
|
(InstantAppDataProvider) (i -> true));
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
assertThat(mController.getAvailabilityStatus())
|
||||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
.isEqualTo(BasePreferenceController.AVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_shouldSetPreferenceTitle() {
|
public void updateState_shouldSetPreferenceTitle() {
|
||||||
final String[] domain = { "Domain1" };
|
final String[] domain = {"Domain1"};
|
||||||
final ArraySet<String> domains = new ArraySet<>();
|
final ArraySet<String> domains = new ArraySet<>();
|
||||||
domains.add(domain[0]);
|
domains.add(domain[0]);
|
||||||
final List<IntentFilterVerificationInfo> infoList = new ArrayList<>();
|
final List<IntentFilterVerificationInfo> infoList = new ArrayList<>();
|
||||||
|
@@ -52,8 +52,10 @@ public class PictureInPictureDetailPreferenceControllerTest {
|
|||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = spy(RuntimeEnvironment.application);
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
|
|
||||||
mController = spy(
|
mController = spy(new PictureInPictureDetailPreferenceController(mContext, "test_key"));
|
||||||
new PictureInPictureDetailPreferenceController(mContext, mFragment, "Package1"));
|
mController.setPackageName("Package1");
|
||||||
|
mController.setParentFragment(mFragment);
|
||||||
|
|
||||||
final String key = mController.getPreferenceKey();
|
final String key = mController.getPreferenceKey();
|
||||||
when(mPreference.getKey()).thenReturn(key);
|
when(mPreference.getKey()).thenReturn(key);
|
||||||
}
|
}
|
||||||
@@ -63,7 +65,7 @@ public class PictureInPictureDetailPreferenceControllerTest {
|
|||||||
doReturn(false).when(mController).hasPictureInPictureActivites();
|
doReturn(false).when(mController).hasPictureInPictureActivites();
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
assertThat(mController.getAvailabilityStatus())
|
||||||
.isEqualTo(BasePreferenceController.DISABLED_FOR_USER);
|
.isEqualTo(BasePreferenceController.DISABLED_FOR_USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -71,7 +73,7 @@ public class PictureInPictureDetailPreferenceControllerTest {
|
|||||||
doReturn(true).when(mController).hasPictureInPictureActivites();
|
doReturn(true).when(mController).hasPictureInPictureActivites();
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
assertThat(mController.getAvailabilityStatus())
|
||||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
.isEqualTo(BasePreferenceController.AVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -57,7 +57,8 @@ public class WriteSystemSettingsPreferenceControllerTest {
|
|||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = spy(RuntimeEnvironment.application);
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
|
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
|
||||||
mController = spy(new WriteSystemSettingsPreferenceController(mContext, mFragment));
|
mController = spy(new WriteSystemSettingsPreferenceController(mContext, "test_key"));
|
||||||
|
mController.setParentFragment(mFragment);
|
||||||
final String key = mController.getPreferenceKey();
|
final String key = mController.getPreferenceKey();
|
||||||
when(mPreference.getKey()).thenReturn(key);
|
when(mPreference.getKey()).thenReturn(key);
|
||||||
}
|
}
|
||||||
|
@@ -44,12 +44,12 @@ public class PreferenceCategoryControllerTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
mContext = RuntimeEnvironment.application;
|
mContext = RuntimeEnvironment.application;
|
||||||
mChildren = new ArrayList<>();
|
mChildren = new ArrayList<>();
|
||||||
mController = new PreferenceCategoryController(mContext, "pref_key", mChildren);
|
mController = new PreferenceCategoryController(mContext, "pref_key").setChildren(mChildren);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isAvailable_noChildren_true() {
|
public void isAvailable_noChildren_false() {
|
||||||
assertThat(mController.isAvailable()).isTrue();
|
assertThat(mController.isAvailable()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -57,6 +57,7 @@ public class PreferenceCategoryControllerTest {
|
|||||||
final AbstractPreferenceController child = mock(AbstractPreferenceController.class);
|
final AbstractPreferenceController child = mock(AbstractPreferenceController.class);
|
||||||
when(child.isAvailable()).thenReturn(true);
|
when(child.isAvailable()).thenReturn(true);
|
||||||
mChildren.add(child);
|
mChildren.add(child);
|
||||||
|
mController.setChildren(mChildren);
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isTrue();
|
assertThat(mController.isAvailable()).isTrue();
|
||||||
}
|
}
|
||||||
@@ -66,6 +67,7 @@ public class PreferenceCategoryControllerTest {
|
|||||||
final AbstractPreferenceController child = mock(AbstractPreferenceController.class);
|
final AbstractPreferenceController child = mock(AbstractPreferenceController.class);
|
||||||
when(child.isAvailable()).thenReturn(false);
|
when(child.isAvailable()).thenReturn(false);
|
||||||
mChildren.add(child);
|
mChildren.add(child);
|
||||||
|
mController.setChildren(mChildren);
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isFalse();
|
assertThat(mController.isAvailable()).isFalse();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user