summaryrefslogtreecommitdiff
path: root/packages/SettingsLib/src
diff options
context:
space:
mode:
authorBrian Orr <brianorr@google.com>2021-06-15 12:47:53 -0700
committerDaniel Norman <danielnorman@google.com>2021-06-17 13:37:54 -0700
commit71c831703ae59baf47e0afe611fecd714c481cdf (patch)
tree06731a987032723085b9e1a65951cf96abbc19cf /packages/SettingsLib/src
parent065c9e9a6e9d61d4383a91721eb56a3de253bdbe (diff)
parent81833820d54b9a6b27894f9f8dfd72222d416992 (diff)
Merge SP1A.210604.001
Change-Id: I5200ee05285ae422d5e9c1c00f45709a5d6188be
Diffstat (limited to 'packages/SettingsLib/src')
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/RestrictedPreferenceHelper.java11
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java9
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/core/instrumentation/MetricsFeatureProvider.java2
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/enterprise/ActionDisabledByAdminController.java57
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/enterprise/ActionDisabledByAdminControllerFactory.java48
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/enterprise/ActionDisabledLearnMoreButtonLauncher.java115
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/enterprise/BaseActionDisabledByAdminController.java56
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/enterprise/DeviceAdminStringProvider.java75
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/enterprise/FinancedDeviceActionDisabledByAdminController.java50
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/enterprise/ManagedDeviceActionDisabledByAdminController.java79
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/location/RecentLocationAccesses.java4
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/media/InfoMediaManager.java37
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/media/LocalMediaManager.java7
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/net/DataUsageUtils.java3
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/wifi/WifiStatusTracker.java51
15 files changed, 575 insertions, 29 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/RestrictedPreferenceHelper.java b/packages/SettingsLib/src/com/android/settingslib/RestrictedPreferenceHelper.java
index 2dbfef039197..83a6973ffec6 100644
--- a/packages/SettingsLib/src/com/android/settingslib/RestrictedPreferenceHelper.java
+++ b/packages/SettingsLib/src/com/android/settingslib/RestrictedPreferenceHelper.java
@@ -139,6 +139,17 @@ public class RestrictedPreferenceHelper {
}
/**
+ * @return EnforcedAdmin if we have been passed the restriction in the xml.
+ */
+ public EnforcedAdmin checkRestrictionEnforced() {
+ if (mAttrUserRestriction == null) {
+ return null;
+ }
+ return RestrictedLockUtilsInternal.checkIfRestrictionEnforced(mContext,
+ mAttrUserRestriction, UserHandle.myUserId());
+ }
+
+ /**
* Disable this preference based on the enforce admin.
*
* @param admin details of the admin who enforced the restriction. If it is
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
index 8e1cb9c978b6..f3dcc1bc677a 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
@@ -1363,19 +1363,22 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
*/
public Pair<Drawable, String> getDrawableWithDescription() {
Uri uri = BluetoothUtils.getUriMetaData(mDevice, BluetoothDevice.METADATA_MAIN_ICON);
+ Pair<Drawable, String> pair = BluetoothUtils.getBtClassDrawableWithDescription(
+ mContext, this);
+
if (BluetoothUtils.isAdvancedDetailsHeader(mDevice) && uri != null) {
BitmapDrawable drawable = mDrawableCache.get(uri.toString());
if (drawable != null) {
Resources resources = mContext.getResources();
return new Pair<>(new AdaptiveOutlineDrawable(
- resources, drawable.getBitmap()),
- BluetoothUtils.getBtClassDrawableWithDescription(mContext, this).second);
+ resources, drawable.getBitmap()), pair.second);
}
refresh();
}
- return BluetoothUtils.getBtRainbowDrawableWithDescription(mContext, this);
+ return new Pair<>(BluetoothUtils.buildBtRainbowDrawable(
+ mContext, pair.first, getAddress().hashCode()), pair.second);
}
void releaseLruCache() {
diff --git a/packages/SettingsLib/src/com/android/settingslib/core/instrumentation/MetricsFeatureProvider.java b/packages/SettingsLib/src/com/android/settingslib/core/instrumentation/MetricsFeatureProvider.java
index bd0b9e93b09d..6cb60d1aaf0e 100644
--- a/packages/SettingsLib/src/com/android/settingslib/core/instrumentation/MetricsFeatureProvider.java
+++ b/packages/SettingsLib/src/com/android/settingslib/core/instrumentation/MetricsFeatureProvider.java
@@ -98,7 +98,7 @@ public class MetricsFeatureProvider {
/**
* Logs a simple action without page id or attribution
*/
- public void action(Context context, int category, Pair<Integer, Object>... taggedData) {
+ public void action(Context context, int category, Pair<Integer, Object>... taggedData) {
for (LogWriter writer : mLoggerWriters) {
writer.action(context, category, taggedData);
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/enterprise/ActionDisabledByAdminController.java b/packages/SettingsLib/src/com/android/settingslib/enterprise/ActionDisabledByAdminController.java
new file mode 100644
index 000000000000..a5373944474c
--- /dev/null
+++ b/packages/SettingsLib/src/com/android/settingslib/enterprise/ActionDisabledByAdminController.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2021 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.settingslib.enterprise;
+
+import android.annotation.UserIdInt;
+import android.content.Context;
+
+import androidx.annotation.Nullable;
+
+import com.android.settingslib.RestrictedLockUtils;
+
+/**
+ * A controller used to customize the action disabled by admin dialog.
+ */
+public interface ActionDisabledByAdminController {
+
+ /**
+ * Sets the {@link ActionDisabledLearnMoreButtonLauncher}.
+ */
+ void initialize(ActionDisabledLearnMoreButtonLauncher launcher);
+
+ /**
+ * Handles the adding and setting up of the learn more button. If button is not needed, then
+ * this method can be left empty.
+ */
+ void setupLearnMoreButton(Context context);
+
+ /**
+ * Returns the admin support dialog's title resource id.
+ */
+ String getAdminSupportTitle(@Nullable String restriction);
+
+ /**
+ * Returns the admin support dialog's content string.
+ */
+ CharSequence getAdminSupportContentString(Context context,
+ @Nullable CharSequence supportMessage);
+
+ /**
+ * Updates the enforced admin
+ */
+ void updateEnforcedAdmin(RestrictedLockUtils.EnforcedAdmin admin, @UserIdInt int adminUserId);
+}
diff --git a/packages/SettingsLib/src/com/android/settingslib/enterprise/ActionDisabledByAdminControllerFactory.java b/packages/SettingsLib/src/com/android/settingslib/enterprise/ActionDisabledByAdminControllerFactory.java
new file mode 100644
index 000000000000..da42e330b8b4
--- /dev/null
+++ b/packages/SettingsLib/src/com/android/settingslib/enterprise/ActionDisabledByAdminControllerFactory.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2021 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.settingslib.enterprise;
+
+import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_FINANCED;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.Context;
+
+/**
+ * A factory that returns the relevant instance of {@link ActionDisabledByAdminController}.
+ */
+public final class ActionDisabledByAdminControllerFactory {
+
+ /**
+ * Returns the relevant instance of {@link ActionDisabledByAdminController}.
+ */
+ public static ActionDisabledByAdminController createInstance(Context context,
+ DeviceAdminStringProvider stringProvider) {
+ return isFinancedDevice(context)
+ ? new FinancedDeviceActionDisabledByAdminController(stringProvider)
+ : new ManagedDeviceActionDisabledByAdminController(stringProvider);
+ }
+
+ private static boolean isFinancedDevice(Context context) {
+ DevicePolicyManager dpm = context.getSystemService(DevicePolicyManager.class);
+ return dpm.isDeviceManaged() && dpm.getDeviceOwnerType(
+ dpm.getDeviceOwnerComponentOnAnyUser()) == DEVICE_OWNER_TYPE_FINANCED;
+ }
+
+ private ActionDisabledByAdminControllerFactory() {
+ throw new UnsupportedOperationException("provides only static methods");
+ }
+}
diff --git a/packages/SettingsLib/src/com/android/settingslib/enterprise/ActionDisabledLearnMoreButtonLauncher.java b/packages/SettingsLib/src/com/android/settingslib/enterprise/ActionDisabledLearnMoreButtonLauncher.java
new file mode 100644
index 000000000000..78a42bef2d7b
--- /dev/null
+++ b/packages/SettingsLib/src/com/android/settingslib/enterprise/ActionDisabledLearnMoreButtonLauncher.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2021 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.settingslib.enterprise;
+
+import static java.util.Objects.requireNonNull;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.UserHandle;
+import android.os.UserManager;
+
+import com.android.internal.annotations.VisibleForTesting;
+import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+
+/**
+ * Helper class meant to set up the "Learn more" button in the action disabled dialog.
+ */
+public abstract class ActionDisabledLearnMoreButtonLauncher {
+
+ /**
+ * Sets up a "learn more" button which shows a screen with device policy settings
+ */
+ public final void setupLearnMoreButtonToShowAdminPolicies(Context context,
+ int enforcementAdminUserId, EnforcedAdmin enforcedAdmin) {
+ requireNonNull(context, "context cannot be null");
+ requireNonNull(enforcedAdmin, "enforcedAdmin cannot be null");
+
+ // The "Learn more" button appears only if the restriction is enforced by an admin in the
+ // same profile group. Otherwise the admin package and its policies are not accessible to
+ // the current user.
+ if (isSameProfileGroup(context, enforcementAdminUserId)) {
+ setLearnMoreButton(() -> showAdminPolicies(context, enforcedAdmin));
+ }
+ }
+
+ /**
+ * Sets up a "learn more" button which launches a help page
+ */
+ public final void setupLearnMoreButtonToLaunchHelpPage(Context context, String url) {
+ requireNonNull(context, "context cannot be null");
+ requireNonNull(url, "url cannot be null");
+
+ setLearnMoreButton(() -> showHelpPage(context, url));
+ }
+
+ /**
+ * Sets the "learning more" button.
+ *
+ * @param action action to be run when the button is tapped.
+ */
+ public abstract void setLearnMoreButton(Runnable action);
+
+ /**
+ * Launches the settings page with info about the given admin.
+ */
+ protected abstract void launchShowAdminPolicies(Context context, UserHandle user,
+ ComponentName admin);
+
+ /**
+ * Launches the settings page that shows all admins.
+ */
+ protected abstract void launchShowAdminSettings(Context context);
+
+ /**
+ * Callback to finish the activity associated with the launcher.
+ */
+ protected void finishSelf() {
+ }
+
+ @VisibleForTesting
+ protected boolean isSameProfileGroup(Context context, int enforcementAdminUserId) {
+ UserManager um = context.getSystemService(UserManager.class);
+
+ return um.isSameProfileGroup(enforcementAdminUserId, um.getUserHandle());
+ }
+
+ /**
+ * Shows the help page using the given {@code url}.
+ */
+ @VisibleForTesting
+ public void showHelpPage(Context context, String url) {
+ context.startActivityAsUser(createLearnMoreIntent(url), UserHandle.of(context.getUserId()));
+ finishSelf();
+ }
+
+ private void showAdminPolicies(Context context, EnforcedAdmin enforcedAdmin) {
+ if (enforcedAdmin.component != null) {
+ launchShowAdminPolicies(context, enforcedAdmin.user, enforcedAdmin.component);
+ } else {
+ launchShowAdminSettings(context);
+ }
+ finishSelf();
+ }
+
+ private static Intent createLearnMoreIntent(String url) {
+ return new Intent(Intent.ACTION_VIEW, Uri.parse(url)).setFlags(
+ Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
+ }
+}
diff --git a/packages/SettingsLib/src/com/android/settingslib/enterprise/BaseActionDisabledByAdminController.java b/packages/SettingsLib/src/com/android/settingslib/enterprise/BaseActionDisabledByAdminController.java
new file mode 100644
index 000000000000..dd71557ef148
--- /dev/null
+++ b/packages/SettingsLib/src/com/android/settingslib/enterprise/BaseActionDisabledByAdminController.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2021 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.settingslib.enterprise;
+
+import static java.util.Objects.requireNonNull;
+
+import android.annotation.UserIdInt;
+
+import com.android.internal.util.Preconditions;
+import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+
+/**
+ * Base class for {@link ActionDisabledByAdminController} implementations.
+ */
+abstract class BaseActionDisabledByAdminController
+ implements ActionDisabledByAdminController {
+
+ protected @UserIdInt int mEnforcementAdminUserId;
+ protected EnforcedAdmin mEnforcedAdmin;
+ protected ActionDisabledLearnMoreButtonLauncher mLauncher;
+ protected final DeviceAdminStringProvider mStringProvider;
+
+ BaseActionDisabledByAdminController(DeviceAdminStringProvider stringProvider) {
+ mStringProvider = stringProvider;
+ }
+
+ @Override
+ public final void initialize(ActionDisabledLearnMoreButtonLauncher launcher) {
+ mLauncher = requireNonNull(launcher, "launcher cannot be null");
+ }
+
+ @Override
+ public final void updateEnforcedAdmin(EnforcedAdmin admin, int adminUserId) {
+ assertInitialized();
+ mEnforcementAdminUserId = adminUserId;
+ mEnforcedAdmin = requireNonNull(admin, "admin cannot be null");
+ }
+
+ protected final void assertInitialized() {
+ Preconditions.checkState(mLauncher != null, "must call initialize() first");
+ }
+}
diff --git a/packages/SettingsLib/src/com/android/settingslib/enterprise/DeviceAdminStringProvider.java b/packages/SettingsLib/src/com/android/settingslib/enterprise/DeviceAdminStringProvider.java
new file mode 100644
index 000000000000..c47d789a514d
--- /dev/null
+++ b/packages/SettingsLib/src/com/android/settingslib/enterprise/DeviceAdminStringProvider.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2021 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.settingslib.enterprise;
+
+/**
+ * A {@code String} provider for the action disabled by admin dialog.
+ */
+public interface DeviceAdminStringProvider {
+
+ /**
+ * Returns the default dialog title for the case when an action is disabled by policy on a
+ * managed device.
+ */
+ String getDefaultDisabledByPolicyTitle();
+
+ /**
+ * Returns the dialog title for the case when volume adjusting is disabled.
+ */
+ String getDisallowAdjustVolumeTitle();
+
+ /**
+ * Returns the dialog title for the case when outgoing calls are disabled.
+ */
+ String getDisallowOutgoingCallsTitle();
+
+ /**
+ * Returns the dialog title for the case when sending SMS is disabled.
+ */
+ String getDisallowSmsTitle();
+
+ /**
+ * Returns the dialog title for the case when the camera is disabled.
+ */
+ String getDisableCameraTitle();
+
+ /**
+ * Returns the dialog title for the case when screen capturing is disabled.
+ */
+ String getDisableScreenCaptureTitle();
+
+ /**
+ * Returns the dialog title for the case when suspending apps is disabled.
+ */
+ String getSuspendPackagesTitle();
+
+ /**
+ * Returns the default dialog content for the case when an action is disabled by policy.
+ */
+ String getDefaultDisabledByPolicyContent();
+
+ /**
+ * Returns the URL for the page to be shown when the learn more button is chosen.
+ */
+ String getLearnMoreHelpPageUrl();
+
+ /**
+ * Returns the default dialog title for the case when an action is disabled by policy on
+ * a financed device.
+ */
+ String getDisabledByPolicyTitleForFinancedDevice();
+}
diff --git a/packages/SettingsLib/src/com/android/settingslib/enterprise/FinancedDeviceActionDisabledByAdminController.java b/packages/SettingsLib/src/com/android/settingslib/enterprise/FinancedDeviceActionDisabledByAdminController.java
new file mode 100644
index 000000000000..2ed0dc46b340
--- /dev/null
+++ b/packages/SettingsLib/src/com/android/settingslib/enterprise/FinancedDeviceActionDisabledByAdminController.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2021 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.settingslib.enterprise;
+
+import android.content.Context;
+
+import androidx.annotation.Nullable;
+
+/**
+ * An {@link ActionDisabledByAdminController} to be used with financed devices.
+ */
+final class FinancedDeviceActionDisabledByAdminController
+ extends BaseActionDisabledByAdminController {
+
+ FinancedDeviceActionDisabledByAdminController(DeviceAdminStringProvider stringProvider) {
+ super(stringProvider);
+ }
+
+ @Override
+ public void setupLearnMoreButton(Context context) {
+ assertInitialized();
+
+ mLauncher.setupLearnMoreButtonToShowAdminPolicies(context, mEnforcementAdminUserId,
+ mEnforcedAdmin);
+ }
+
+ @Override
+ public String getAdminSupportTitle(@Nullable String restriction) {
+ return mStringProvider.getDisabledByPolicyTitleForFinancedDevice();
+ }
+
+ @Override
+ public CharSequence getAdminSupportContentString(Context context, CharSequence supportMessage) {
+ return supportMessage;
+ }
+}
diff --git a/packages/SettingsLib/src/com/android/settingslib/enterprise/ManagedDeviceActionDisabledByAdminController.java b/packages/SettingsLib/src/com/android/settingslib/enterprise/ManagedDeviceActionDisabledByAdminController.java
new file mode 100644
index 000000000000..df6bab74e014
--- /dev/null
+++ b/packages/SettingsLib/src/com/android/settingslib/enterprise/ManagedDeviceActionDisabledByAdminController.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2021 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.settingslib.enterprise;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.Context;
+import android.os.UserManager;
+import android.text.TextUtils;
+
+import androidx.annotation.Nullable;
+
+
+/**
+ * An {@link ActionDisabledByAdminController} to be used with managed devices.
+ */
+final class ManagedDeviceActionDisabledByAdminController
+ extends BaseActionDisabledByAdminController {
+
+ ManagedDeviceActionDisabledByAdminController(DeviceAdminStringProvider stringProvider) {
+ super(stringProvider);
+ }
+
+ @Override
+ public void setupLearnMoreButton(Context context) {
+ assertInitialized();
+
+ String url = mStringProvider.getLearnMoreHelpPageUrl();
+ if (TextUtils.isEmpty(url)) {
+ mLauncher.setupLearnMoreButtonToShowAdminPolicies(context, mEnforcementAdminUserId,
+ mEnforcedAdmin);
+ } else {
+ mLauncher.setupLearnMoreButtonToLaunchHelpPage(context, url);
+ }
+ }
+
+ @Override
+ public String getAdminSupportTitle(@Nullable String restriction) {
+ if (restriction == null) {
+ return mStringProvider.getDefaultDisabledByPolicyTitle();
+ }
+ switch (restriction) {
+ case UserManager.DISALLOW_ADJUST_VOLUME:
+ return mStringProvider.getDisallowAdjustVolumeTitle();
+ case UserManager.DISALLOW_OUTGOING_CALLS:
+ return mStringProvider.getDisallowOutgoingCallsTitle();
+ case UserManager.DISALLOW_SMS:
+ return mStringProvider.getDisallowSmsTitle();
+ case DevicePolicyManager.POLICY_DISABLE_CAMERA:
+ return mStringProvider.getDisableCameraTitle();
+ case DevicePolicyManager.POLICY_DISABLE_SCREEN_CAPTURE:
+ return mStringProvider.getDisableScreenCaptureTitle();
+ case DevicePolicyManager.POLICY_SUSPEND_PACKAGES:
+ return mStringProvider.getSuspendPackagesTitle();
+ default:
+ return mStringProvider.getDefaultDisabledByPolicyTitle();
+ }
+ }
+
+ @Override
+ public CharSequence getAdminSupportContentString(Context context, CharSequence supportMessage) {
+ return supportMessage != null
+ ? supportMessage
+ : mStringProvider.getDefaultDisabledByPolicyContent();
+ }
+}
diff --git a/packages/SettingsLib/src/com/android/settingslib/location/RecentLocationAccesses.java b/packages/SettingsLib/src/com/android/settingslib/location/RecentLocationAccesses.java
index 35499c9b449a..877dd2dfa26e 100644
--- a/packages/SettingsLib/src/com/android/settingslib/location/RecentLocationAccesses.java
+++ b/packages/SettingsLib/src/com/android/settingslib/location/RecentLocationAccesses.java
@@ -25,6 +25,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.drawable.Drawable;
import android.os.UserHandle;
import android.os.UserManager;
+import android.permission.PermissionManager;
import android.text.format.DateUtils;
import android.util.IconDrawableFactory;
import android.util.Log;
@@ -132,7 +133,8 @@ public class RecentLocationAccesses {
}
}
}
- if (showApp) {
+ if (showApp && PermissionManager.shouldShowPackageForIndicatorCached(mContext,
+ packageName)) {
Access access = getAccessFromOps(now, ops);
if (access != null) {
accesses.add(access);
diff --git a/packages/SettingsLib/src/com/android/settingslib/media/InfoMediaManager.java b/packages/SettingsLib/src/com/android/settingslib/media/InfoMediaManager.java
index 6cf53d0bcc75..6b1e282ecdd8 100644
--- a/packages/SettingsLib/src/com/android/settingslib/media/InfoMediaManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/media/InfoMediaManager.java
@@ -15,6 +15,7 @@
*/
package com.android.settingslib.media;
+import static android.media.MediaRoute2Info.FEATURE_REMOTE_GROUP_PLAYBACK;
import static android.media.MediaRoute2Info.TYPE_BLUETOOTH_A2DP;
import static android.media.MediaRoute2Info.TYPE_BUILTIN_SPEAKER;
import static android.media.MediaRoute2Info.TYPE_DOCK;
@@ -31,6 +32,7 @@ import static android.media.MediaRoute2Info.TYPE_WIRED_HEADPHONES;
import static android.media.MediaRoute2Info.TYPE_WIRED_HEADSET;
import static android.media.MediaRoute2ProviderService.REASON_UNKNOWN_ERROR;
+import android.annotation.TargetApi;
import android.app.Notification;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
@@ -38,6 +40,7 @@ import android.content.Context;
import android.media.MediaRoute2Info;
import android.media.MediaRouter2Manager;
import android.media.RoutingSessionInfo;
+import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
@@ -84,12 +87,14 @@ public class InfoMediaManager extends MediaManager {
public void startScan() {
mMediaDevices.clear();
mRouterManager.registerCallback(mExecutor, mMediaRouterCallback);
+ mRouterManager.startScan();
refreshDevices();
}
@Override
public void stopScan() {
mRouterManager.unregisterCallback(mMediaRouterCallback);
+ mRouterManager.stopScan();
}
/**
@@ -391,6 +396,38 @@ public class InfoMediaManager extends MediaManager {
return shouldDisableMediaOutput;
}
+ @TargetApi(Build.VERSION_CODES.R)
+ boolean shouldEnableVolumeSeekBar(RoutingSessionInfo sessionInfo) {
+ if (sessionInfo == null) {
+ Log.w(TAG, "shouldEnableVolumeSeekBar() package name is null or empty!");
+ return false;
+ }
+ final List<MediaRoute2Info> mediaRoute2Infos =
+ mRouterManager.getSelectedRoutes(sessionInfo);
+ // More than one selected route
+ if (mediaRoute2Infos.size() > 1) {
+ if (DEBUG) {
+ Log.d(TAG, "shouldEnableVolumeSeekBar() package name : "
+ + sessionInfo.getClientPackageName()
+ + ", mediaRoute2Infos.size() " + mediaRoute2Infos.size());
+ }
+ return false;
+ }
+ // Route contains group feature
+ for (MediaRoute2Info mediaRoute2Info : mediaRoute2Infos) {
+ final List<String> features = mediaRoute2Info.getFeatures();
+ if (features.contains(FEATURE_REMOTE_GROUP_PLAYBACK)) {
+ if (DEBUG) {
+ Log.d(TAG, "shouldEnableVolumeSeekBar() package name : "
+ + mediaRoute2Info.getClientPackageName()
+ + "contain group playback ");
+ }
+ return false;
+ }
+ }
+ return true;
+ }
+
private void refreshDevices() {
mMediaDevices.clear();
mCurrentConnectedDevice = null;
diff --git a/packages/SettingsLib/src/com/android/settingslib/media/LocalMediaManager.java b/packages/SettingsLib/src/com/android/settingslib/media/LocalMediaManager.java
index 1f3e0e9fe038..a8da2c0ba269 100644
--- a/packages/SettingsLib/src/com/android/settingslib/media/LocalMediaManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/media/LocalMediaManager.java
@@ -408,6 +408,13 @@ public class LocalMediaManager implements BluetoothCallback {
return mInfoMediaManager.shouldDisableMediaOutput(packageName);
}
+ /**
+ * Returns {@code true} if needed to enable volume seekbar, otherwise returns {@code false}.
+ */
+ public boolean shouldEnableVolumeSeekBar(RoutingSessionInfo sessionInfo) {
+ return mInfoMediaManager.shouldEnableVolumeSeekBar(sessionInfo);
+ }
+
@VisibleForTesting
MediaDevice updateCurrentConnectedDevice() {
MediaDevice connectedDevice = null;
diff --git a/packages/SettingsLib/src/com/android/settingslib/net/DataUsageUtils.java b/packages/SettingsLib/src/com/android/settingslib/net/DataUsageUtils.java
index b1234f291b74..51e533abebd2 100644
--- a/packages/SettingsLib/src/com/android/settingslib/net/DataUsageUtils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/net/DataUsageUtils.java
@@ -73,6 +73,7 @@ public class DataUsageUtils {
private static NetworkTemplate getMobileTemplateForSubId(
TelephonyManager telephonyManager, int subId) {
- return NetworkTemplate.buildTemplateMobileAll(telephonyManager.getSubscriberId(subId));
+ return NetworkTemplate.buildTemplateCarrierMetered(
+ telephonyManager.getSubscriberId(subId));
}
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiStatusTracker.java b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiStatusTracker.java
index ce4e799656e4..314110cb5d45 100644
--- a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiStatusTracker.java
+++ b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiStatusTracker.java
@@ -80,36 +80,41 @@ public class WifiStatusTracker {
@Override
public void onCapabilitiesChanged(
Network network, NetworkCapabilities networkCapabilities) {
- if (!mNetworks.contains(network.getNetId())) {
- // New network
- boolean isVcnOverWifi =
- networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)
- && (Utils.tryGetWifiInfoForVcn(networkCapabilities) != null);
- boolean isWifi =
- networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI);
- if (isVcnOverWifi || isWifi) {
- mNetworks.add(network.getNetId());
- }
- }
-
+ boolean isVcnOverWifi = false;
+ boolean isWifi = false;
WifiInfo wifiInfo = null;
if (networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) {
wifiInfo = Utils.tryGetWifiInfoForVcn(networkCapabilities);
+ isVcnOverWifi = (wifiInfo != null);
} else if (networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
wifiInfo = (WifiInfo) networkCapabilities.getTransportInfo();
+ isWifi = true;
}
- String log = new StringBuilder()
- .append(SSDF.format(System.currentTimeMillis())).append(",")
- .append("onCapabilitiesChanged: ")
- .append("network=").append(network).append(",")
- .append("networkCapabilities=").append(networkCapabilities)
- .toString();
- recordLastWifiNetwork(log);
- if (wifiInfo != null) {
- updateWifiInfo(wifiInfo);
- updateStatusLabel();
- mCallback.run();
+ // As long as it is a WiFi network, we will log it in the dumpsys for debugging.
+ if (isVcnOverWifi || isWifi) {
+ String log = new StringBuilder()
+ .append(SSDF.format(System.currentTimeMillis())).append(",")
+ .append("onCapabilitiesChanged: ")
+ .append("network=").append(network).append(",")
+ .append("networkCapabilities=").append(networkCapabilities)
+ .toString();
+ recordLastWifiNetwork(log);
+ }
+ // Ignore the WiFi network if it doesn't contain any valid WifiInfo, or it is not the
+ // primary WiFi.
+ if (wifiInfo == null || !wifiInfo.isPrimary()) {
+ // Remove the network from the tracking list once it becomes non-primary.
+ if (mNetworks.contains(network.getNetId())) {
+ mNetworks.remove(network.getNetId());
+ }
+ return;
}
+ if (!mNetworks.contains(network.getNetId())) {
+ mNetworks.add(network.getNetId());
+ }
+ updateWifiInfo(wifiInfo);
+ updateStatusLabel();
+ mCallback.run();
}
@Override