[Safer intents] Permission controller
To avoid implicit intents, make intents launch explicitly. Test: build, manual Bug: 323061508 Change-Id: Ib95b417fc8682f690890fc55f321b4fece2c0369
This commit is contained in:
@@ -58,9 +58,7 @@
|
|||||||
android:key="default_apps"
|
android:key="default_apps"
|
||||||
android:title="@string/app_default_dashboard_title"
|
android:title="@string/app_default_dashboard_title"
|
||||||
android:order="-996"
|
android:order="-996"
|
||||||
settings:controller="com.android.settings.applications.DefaultAppsPreferenceController">
|
settings:controller="com.android.settings.applications.DefaultAppsPreferenceController"/>
|
||||||
<intent android:action="android.settings.MANAGE_DEFAULT_APPS_SETTINGS"/>
|
|
||||||
</Preference>
|
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="cloned_apps"
|
android:key="cloned_apps"
|
||||||
@@ -85,9 +83,7 @@
|
|||||||
android:summary="@string/summary_placeholder"
|
android:summary="@string/summary_placeholder"
|
||||||
android:order="15"
|
android:order="15"
|
||||||
settings:keywords="app_hibernation_key"
|
settings:keywords="app_hibernation_key"
|
||||||
settings:controller="com.android.settings.applications.HibernatedAppsPreferenceController">
|
settings:controller="com.android.settings.applications.HibernatedAppsPreferenceController"/>
|
||||||
<intent android:action="android.intent.action.MANAGE_UNUSED_APPS"/>
|
|
||||||
</Preference>
|
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="app_battery_usage"
|
android:key="app_battery_usage"
|
||||||
|
@@ -61,12 +61,7 @@
|
|||||||
<Preference
|
<Preference
|
||||||
android:key="app_level_permissions"
|
android:key="app_level_permissions"
|
||||||
android:title="@string/location_app_level_permissions"
|
android:title="@string/location_app_level_permissions"
|
||||||
settings:controller="com.android.settings.location.AppLocationPermissionPreferenceController">
|
settings:controller="com.android.settings.location.AppLocationPermissionPreferenceController"/>
|
||||||
<intent android:action="android.intent.action.MANAGE_PERMISSION_APPS">
|
|
||||||
<extra android:name="android.intent.extra.PERMISSION_NAME"
|
|
||||||
android:value="android.permission-group.LOCATION"/>
|
|
||||||
</intent>
|
|
||||||
</Preference>
|
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:fragment="com.android.settings.location.LocationServices"
|
android:fragment="com.android.settings.location.LocationServices"
|
||||||
|
@@ -38,14 +38,9 @@
|
|||||||
|
|
||||||
<!-- This preference category gets removed if new_recent_location_ui is disabled -->
|
<!-- This preference category gets removed if new_recent_location_ui is disabled -->
|
||||||
<Preference
|
<Preference
|
||||||
android:key="app_level_permissions"
|
android:key="app_level_permissions_personal"
|
||||||
android:title="@string/location_app_level_permissions"
|
android:title="@string/location_app_level_permissions"
|
||||||
settings:controller="com.android.settings.location.AppLocationPermissionPreferenceController">
|
settings:controller="com.android.settings.location.AppLocationPermissionPreferenceController"/>
|
||||||
<intent android:action="android.intent.action.MANAGE_PERMISSION_APPS">
|
|
||||||
<extra android:name="android.intent.extra.PERMISSION_GROUP_NAME"
|
|
||||||
android:value="android.permission-group.LOCATION"/>
|
|
||||||
</intent>
|
|
||||||
</Preference>
|
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="location_services"
|
android:key="location_services"
|
||||||
|
@@ -46,14 +46,9 @@
|
|||||||
|
|
||||||
<!-- This preference category gets removed if new_recent_location_ui is disabled -->
|
<!-- This preference category gets removed if new_recent_location_ui is disabled -->
|
||||||
<Preference
|
<Preference
|
||||||
android:key="app_level_permissions"
|
android:key="app_level_permissions_work"
|
||||||
android:title="@string/location_app_level_permissions"
|
android:title="@string/location_app_level_permissions"
|
||||||
settings:controller="com.android.settings.location.AppLocationPermissionPreferenceController">
|
settings:controller="com.android.settings.location.AppLocationPermissionPreferenceController"/>
|
||||||
<intent android:action="android.intent.action.MANAGE_PERMISSION_APPS">
|
|
||||||
<extra android:name="android.intent.extra.PERMISSION_GROUP_NAME"
|
|
||||||
android:value="android.permission-group.LOCATION"/>
|
|
||||||
</intent>
|
|
||||||
</Preference>
|
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="location_services_for_work"
|
android:key="location_services_for_work"
|
||||||
|
@@ -74,9 +74,7 @@
|
|||||||
<Preference
|
<Preference
|
||||||
android:key="privacy_accessibility_usage"
|
android:key="privacy_accessibility_usage"
|
||||||
android:title="@string/accessibility_usage_title"
|
android:title="@string/accessibility_usage_title"
|
||||||
settings:controller="com.android.settings.privacy.AccessibilityUsagePreferenceController">
|
settings:controller="com.android.settings.privacy.AccessibilityUsagePreferenceController"/>
|
||||||
<intent android:action="android.intent.action.REVIEW_ACCESSIBILITY_SERVICES"/>
|
|
||||||
</Preference>
|
|
||||||
|
|
||||||
<!-- On lock screen notifications -->
|
<!-- On lock screen notifications -->
|
||||||
<com.android.settings.RestrictedListPreference
|
<com.android.settings.RestrictedListPreference
|
||||||
|
@@ -40,35 +40,28 @@
|
|||||||
<Preference
|
<Preference
|
||||||
android:key="privacy_accessibility_usage"
|
android:key="privacy_accessibility_usage"
|
||||||
android:title="@string/accessibility_usage_title"
|
android:title="@string/accessibility_usage_title"
|
||||||
settings:controller="com.android.settings.privacy.AccessibilityUsagePreferenceController">
|
settings:controller="com.android.settings.privacy.AccessibilityUsagePreferenceController"/>
|
||||||
<intent android:action="android.intent.action.REVIEW_ACCESSIBILITY_SERVICES"/>
|
|
||||||
</Preference>
|
|
||||||
|
|
||||||
<!-- Permissions usage -->
|
<!-- Permissions usage -->
|
||||||
<Preference
|
<Preference
|
||||||
android:key="privacy_permissions_usage"
|
android:key="privacy_permissions_usage"
|
||||||
android:title="@string/permissions_usage_title"
|
android:title="@string/permissions_usage_title"
|
||||||
android:summary="@string/permissions_usage_summary"
|
android:summary="@string/permissions_usage_summary"
|
||||||
settings:controller="com.android.settings.privacy.PrivacyHubPreferenceController">
|
settings:controller="com.android.settings.privacy.PrivacyHubPreferenceController"/>
|
||||||
<intent android:action="android.intent.action.REVIEW_PERMISSION_USAGE"/>
|
|
||||||
</Preference>
|
|
||||||
|
|
||||||
<!-- App permissions -->
|
<!-- App permissions -->
|
||||||
<Preference
|
<Preference
|
||||||
android:key="privacy_manage_perms"
|
android:key="privacy_manage_perms"
|
||||||
android:title="@string/app_permissions"
|
android:title="@string/app_permissions"
|
||||||
android:summary="@string/runtime_permissions_summary_control_app_access">
|
android:summary="@string/runtime_permissions_summary_control_app_access"
|
||||||
<intent android:action="android.intent.action.MANAGE_PERMISSIONS"/>
|
settings:controller="com.android.settings.privacy.ManagePermissionsPreferenceController"/>
|
||||||
</Preference>
|
|
||||||
|
|
||||||
<!-- App Data Sharing Update -->
|
<!-- App Data Sharing Update -->
|
||||||
<Preference
|
<Preference
|
||||||
android:key="privacy_app_data_sharing_updates"
|
android:key="privacy_app_data_sharing_updates"
|
||||||
android:title="@string/app_data_sharing_updates_title"
|
android:title="@string/app_data_sharing_updates_title"
|
||||||
android:summary="@string/app_data_sharing_updates_summary"
|
android:summary="@string/app_data_sharing_updates_summary"
|
||||||
settings:controller="com.android.settings.privacy.AppDataSharingUpdatesPreferenceController">
|
settings:controller="com.android.settings.privacy.AppDataSharingUpdatesPreferenceController"/>
|
||||||
<intent android:action="android.intent.action.REVIEW_APP_DATA_SHARING_UPDATES"/>
|
|
||||||
</Preference>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Camera toggle -->
|
<!-- Camera toggle -->
|
||||||
|
@@ -140,7 +140,8 @@ public class Settings extends SettingsActivity {
|
|||||||
|
|
||||||
if (SafetyCenterManagerWrapper.get().isEnabled(this)) {
|
if (SafetyCenterManagerWrapper.get().isEnabled(this)) {
|
||||||
try {
|
try {
|
||||||
startActivity(new Intent(Intent.ACTION_SAFETY_CENTER));
|
startActivity(new Intent(Intent.ACTION_SAFETY_CENTER)
|
||||||
|
.setPackage(getPackageManager().getPermissionControllerPackageName()));
|
||||||
finish();
|
finish();
|
||||||
} catch (ActivityNotFoundException e) {
|
} catch (ActivityNotFoundException e) {
|
||||||
Log.e(TAG, "Unable to open safety center", e);
|
Log.e(TAG, "Unable to open safety center", e);
|
||||||
@@ -235,7 +236,8 @@ public class Settings extends SettingsActivity {
|
|||||||
if (ACTION_PRIVACY_SETTINGS.equals(getIntent().getAction())
|
if (ACTION_PRIVACY_SETTINGS.equals(getIntent().getAction())
|
||||||
&& SafetyCenterManagerWrapper.get().isEnabled(this)) {
|
&& SafetyCenterManagerWrapper.get().isEnabled(this)) {
|
||||||
try {
|
try {
|
||||||
startActivity(new Intent(Intent.ACTION_SAFETY_CENTER));
|
startActivity(new Intent(Intent.ACTION_SAFETY_CENTER)
|
||||||
|
.setPackage(getPackageManager().getPermissionControllerPackageName()));
|
||||||
finish();
|
finish();
|
||||||
} catch (ActivityNotFoundException e) {
|
} catch (ActivityNotFoundException e) {
|
||||||
Log.e(TAG, "Unable to open safety center", e);
|
Log.e(TAG, "Unable to open safety center", e);
|
||||||
|
@@ -18,11 +18,16 @@ package com.android.settings.applications;
|
|||||||
|
|
||||||
import android.app.role.RoleManager;
|
import android.app.role.RoleManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.icu.text.ListFormatter;
|
import android.icu.text.ListFormatter;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.text.BidiFormatter;
|
import androidx.core.text.BidiFormatter;
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settingslib.applications.AppUtils;
|
import com.android.settingslib.applications.AppUtils;
|
||||||
@@ -47,6 +52,17 @@ public class DefaultAppsPreferenceController extends BasePreferenceController {
|
|||||||
return AVAILABLE;
|
return AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void displayPreference(@NonNull PreferenceScreen screen) {
|
||||||
|
super.displayPreference(screen);
|
||||||
|
|
||||||
|
Preference pref = screen.findPreference(getPreferenceKey());
|
||||||
|
if (pref != null) {
|
||||||
|
pref.setIntent(new Intent(Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS)
|
||||||
|
.setPackage(mPackageManager.getPermissionControllerPackageName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getSummary() {
|
public CharSequence getSummary() {
|
||||||
final List<CharSequence> defaultAppLabels = new ArrayList<>();
|
final List<CharSequence> defaultAppLabels = new ArrayList<>();
|
||||||
|
@@ -21,6 +21,7 @@ import static android.provider.DeviceConfig.NAMESPACE_APP_HIBERNATION;
|
|||||||
import static com.android.settings.Utils.PROPERTY_APP_HIBERNATION_ENABLED;
|
import static com.android.settings.Utils.PROPERTY_APP_HIBERNATION_ENABLED;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.icu.text.MessageFormat;
|
import android.icu.text.MessageFormat;
|
||||||
import android.permission.PermissionControllerManager;
|
import android.permission.PermissionControllerManager;
|
||||||
import android.provider.DeviceConfig;
|
import android.provider.DeviceConfig;
|
||||||
@@ -85,6 +86,12 @@ public final class HibernatedAppsPreferenceController extends BasePreferenceCont
|
|||||||
public void displayPreference(PreferenceScreen screen) {
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
super.displayPreference(screen);
|
super.displayPreference(screen);
|
||||||
mScreen = screen;
|
mScreen = screen;
|
||||||
|
|
||||||
|
Preference pref = screen.findPreference(getPreferenceKey());
|
||||||
|
if (pref != null) {
|
||||||
|
pref.setIntent(new Intent(Intent.ACTION_MANAGE_UNUSED_APPS)
|
||||||
|
.setPackage(mContext.getPackageManager().getPermissionControllerPackageName()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -132,6 +132,7 @@ public class AppPermissionPreferenceController extends AppInfoPreferenceControll
|
|||||||
private void startManagePermissionsActivity() {
|
private void startManagePermissionsActivity() {
|
||||||
// start new activity to manage app permissions
|
// start new activity to manage app permissions
|
||||||
final Intent permIntent = new Intent(Intent.ACTION_MANAGE_APP_PERMISSIONS);
|
final Intent permIntent = new Intent(Intent.ACTION_MANAGE_APP_PERMISSIONS);
|
||||||
|
permIntent.setPackage(mPackageManager.getPermissionControllerPackageName());
|
||||||
permIntent.putExtra(Intent.EXTRA_PACKAGE_NAME, mParent.getAppEntry().info.packageName);
|
permIntent.putExtra(Intent.EXTRA_PACKAGE_NAME, mParent.getAppEntry().info.packageName);
|
||||||
permIntent.putExtra(EXTRA_HIDE_INFO_BUTTON, true);
|
permIntent.putExtra(EXTRA_HIDE_INFO_BUTTON, true);
|
||||||
Activity activity = mParent.getActivity();
|
Activity activity = mParent.getActivity();
|
||||||
|
@@ -105,6 +105,7 @@ public abstract class DefaultAppShortcutPreferenceControllerBase extends BasePre
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final Intent intent = new Intent(Intent.ACTION_MANAGE_DEFAULT_APP)
|
final Intent intent = new Intent(Intent.ACTION_MANAGE_DEFAULT_APP)
|
||||||
|
.setPackage(mContext.getPackageManager().getPermissionControllerPackageName())
|
||||||
.putExtra(Intent.EXTRA_ROLE_NAME, mRoleName);
|
.putExtra(Intent.EXTRA_ROLE_NAME, mRoleName);
|
||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
|
@@ -921,7 +921,9 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
.setResultListener(this, ADVANCED_SETTINGS)
|
.setResultListener(this, ADVANCED_SETTINGS)
|
||||||
.launch();
|
.launch();
|
||||||
} else {
|
} else {
|
||||||
Intent intent = new Intent(Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS);
|
Intent intent = new Intent(Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS)
|
||||||
|
.setPackage(getContext()
|
||||||
|
.getPackageManager().getPermissionControllerPackageName());
|
||||||
startActivityForResult(intent, ADVANCED_SETTINGS);
|
startActivityForResult(intent, ADVANCED_SETTINGS);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@@ -71,7 +71,8 @@ public class DefaultPaymentSettingsPreferenceController extends BasePreferenceCo
|
|||||||
&& mPreferenceKey.equals(preference.getKey())) {
|
&& mPreferenceKey.equals(preference.getKey())) {
|
||||||
RoleManager roleManager = mContext.getSystemService(RoleManager.class);
|
RoleManager roleManager = mContext.getSystemService(RoleManager.class);
|
||||||
if (roleManager.isRoleAvailable(RoleManager.ROLE_WALLET)) {
|
if (roleManager.isRoleAvailable(RoleManager.ROLE_WALLET)) {
|
||||||
Intent intent = new Intent(CardEmulation.ACTION_CHANGE_DEFAULT);
|
Intent intent = new Intent(CardEmulation.ACTION_CHANGE_DEFAULT)
|
||||||
|
.setPackage(mPackageManager.getPermissionControllerPackageName());
|
||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -4,14 +4,18 @@ import static android.Manifest.permission.ACCESS_COARSE_LOCATION;
|
|||||||
import static android.Manifest.permission.ACCESS_FINE_LOCATION;
|
import static android.Manifest.permission.ACCESS_FINE_LOCATION;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.location.LocationManager;
|
import android.location.LocationManager;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.permission.PermissionControllerManager;
|
import android.permission.PermissionControllerManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
@@ -69,6 +73,21 @@ public class AppLocationPermissionPreferenceController extends
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void displayPreference(@NonNull PreferenceScreen screen) {
|
||||||
|
super.displayPreference(screen);
|
||||||
|
|
||||||
|
Preference pref = screen.findPreference(getPreferenceKey());
|
||||||
|
if (pref != null) {
|
||||||
|
pref.setIntent(new Intent(Intent.ACTION_MANAGE_PERMISSION_APPS)
|
||||||
|
.setPackage(mContext.getPackageManager().getPermissionControllerPackageName())
|
||||||
|
.putExtra(TextUtils.equals(pref.getKey(), "app_level_permissions")
|
||||||
|
? Intent.EXTRA_PERMISSION_NAME
|
||||||
|
: Intent.EXTRA_PERMISSION_GROUP_NAME,
|
||||||
|
"android.permission-group.LOCATION"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void setAppCounts(int numTotal, int numHasLocation) {
|
private void setAppCounts(int numTotal, int numHasLocation) {
|
||||||
mNumTotal = numTotal;
|
mNumTotal = numTotal;
|
||||||
mNumHasLocation = numHasLocation;
|
mNumHasLocation = numHasLocation;
|
||||||
|
@@ -67,6 +67,7 @@ public class RecentLocationAccessPreferenceController extends LocationBasePrefer
|
|||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
final Intent intent = new Intent(Intent.ACTION_MANAGE_APP_PERMISSION);
|
final Intent intent = new Intent(Intent.ACTION_MANAGE_APP_PERMISSION);
|
||||||
|
intent.setPackage(mContext.getPackageManager().getPermissionControllerPackageName());
|
||||||
intent.putExtra(Intent.EXTRA_PERMISSION_GROUP_NAME, LOCATION);
|
intent.putExtra(Intent.EXTRA_PERMISSION_GROUP_NAME, LOCATION);
|
||||||
intent.putExtra(Intent.EXTRA_PACKAGE_NAME, mPackage);
|
intent.putExtra(Intent.EXTRA_PACKAGE_NAME, mPackage);
|
||||||
intent.putExtra(Intent.EXTRA_USER, mUserHandle);
|
intent.putExtra(Intent.EXTRA_USER, mUserHandle);
|
||||||
|
@@ -18,10 +18,12 @@ package com.android.settings.privacy;
|
|||||||
|
|
||||||
import android.accessibilityservice.AccessibilityServiceInfo;
|
import android.accessibilityservice.AccessibilityServiceInfo;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.view.accessibility.AccessibilityManager;
|
import android.view.accessibility.AccessibilityManager;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
@@ -64,4 +66,15 @@ public class AccessibilityUsagePreferenceController extends BasePreferenceContro
|
|||||||
return StringUtil.getIcuPluralsString(mContext, mEnabledServiceInfos.size(),
|
return StringUtil.getIcuPluralsString(mContext, mEnabledServiceInfos.size(),
|
||||||
R.string.accessibility_usage_summary);
|
R.string.accessibility_usage_summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void displayPreference(@NonNull PreferenceScreen screen) {
|
||||||
|
super.displayPreference(screen);
|
||||||
|
|
||||||
|
Preference pref = screen.findPreference(getPreferenceKey());
|
||||||
|
if (pref != null) {
|
||||||
|
pref.setIntent(new Intent(Intent.ACTION_REVIEW_ACCESSIBILITY_SERVICES)
|
||||||
|
.setPackage(mContext.getPackageManager().getPermissionControllerPackageName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,9 +19,14 @@ package com.android.settings.privacy;
|
|||||||
import static android.safetylabel.SafetyLabelConstants.SAFETY_LABEL_CHANGE_NOTIFICATIONS_ENABLED;
|
import static android.safetylabel.SafetyLabelConstants.SAFETY_LABEL_CHANGE_NOTIFICATIONS_ENABLED;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.provider.DeviceConfig;
|
import android.provider.DeviceConfig;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,6 +39,17 @@ public class AppDataSharingUpdatesPreferenceController extends BasePreferenceCon
|
|||||||
super(context, preferenceKey);
|
super(context, preferenceKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void displayPreference(@NonNull PreferenceScreen screen) {
|
||||||
|
super.displayPreference(screen);
|
||||||
|
|
||||||
|
Preference pref = screen.findPreference(getPreferenceKey());
|
||||||
|
if (pref != null) {
|
||||||
|
pref.setIntent(new Intent(Intent.ACTION_REVIEW_APP_DATA_SHARING_UPDATES)
|
||||||
|
.setPackage(mContext.getPackageManager().getPermissionControllerPackageName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return isPrivacySafetyLabelChangeNotificationsEnabled(mContext)
|
return isPrivacySafetyLabelChangeNotificationsEnabled(mContext)
|
||||||
|
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 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.privacy;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The preference controller for managing permissions
|
||||||
|
*/
|
||||||
|
public class ManagePermissionsPreferenceController extends BasePreferenceController {
|
||||||
|
|
||||||
|
public ManagePermissionsPreferenceController(@NonNull Context context,
|
||||||
|
@NonNull String preferenceKey) {
|
||||||
|
super(context, preferenceKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void displayPreference(@NonNull PreferenceScreen screen) {
|
||||||
|
super.displayPreference(screen);
|
||||||
|
|
||||||
|
Preference pref = screen.findPreference(getPreferenceKey());
|
||||||
|
if (pref != null) {
|
||||||
|
pref.setIntent(new Intent(Intent.ACTION_MANAGE_PERMISSIONS)
|
||||||
|
.setPackage(mContext.getPackageManager().getPermissionControllerPackageName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAvailabilityStatus() {
|
||||||
|
return AVAILABLE;
|
||||||
|
}
|
||||||
|
}
|
@@ -17,9 +17,12 @@
|
|||||||
package com.android.settings.privacy;
|
package com.android.settings.privacy;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.provider.DeviceConfig;
|
import android.provider.DeviceConfig;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
|
||||||
@@ -38,4 +41,15 @@ public final class PrivacyHubPreferenceController extends BasePreferenceControll
|
|||||||
return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
|
return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
|
||||||
PROPERTY_PRIVACY_HUB_ENABLED, true) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
PROPERTY_PRIVACY_HUB_ENABLED, true) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void displayPreference(@NonNull PreferenceScreen screen) {
|
||||||
|
super.displayPreference(screen);
|
||||||
|
|
||||||
|
Preference pref = screen.findPreference(getPreferenceKey());
|
||||||
|
if (pref != null) {
|
||||||
|
pref.setIntent(new Intent(Intent.ACTION_REVIEW_PERMISSION_USAGE)
|
||||||
|
.setPackage(mContext.getPackageManager().getPermissionControllerPackageName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -50,7 +50,8 @@ public class TopLevelSafetyCenterEntryPreferenceController extends BasePreferenc
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mContext.startActivity(new Intent(Intent.ACTION_SAFETY_CENTER));
|
mContext.startActivity(new Intent(Intent.ACTION_SAFETY_CENTER)
|
||||||
|
.setPackage(mContext.getPackageManager().getPermissionControllerPackageName()));
|
||||||
} catch (ActivityNotFoundException e) {
|
} catch (ActivityNotFoundException e) {
|
||||||
Log.e(TAG, "Unable to open safety center", e);
|
Log.e(TAG, "Unable to open safety center", e);
|
||||||
return false;
|
return false;
|
||||||
|
@@ -20,13 +20,16 @@ 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.doNothing;
|
import static org.mockito.Mockito.doNothing;
|
||||||
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.doThrow;
|
import static org.mockito.Mockito.doThrow;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
@@ -52,7 +55,6 @@ public class TopLevelSafetyCenterEntryPreferenceControllerTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private SafetyCenterManagerWrapper mSafetyCenterManagerWrapper;
|
private SafetyCenterManagerWrapper mSafetyCenterManagerWrapper;
|
||||||
|
|
||||||
@Mock
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@@ -60,7 +62,12 @@ public class TopLevelSafetyCenterEntryPreferenceControllerTest {
|
|||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
SafetyCenterManagerWrapper.sInstance = mSafetyCenterManagerWrapper;
|
SafetyCenterManagerWrapper.sInstance = mSafetyCenterManagerWrapper;
|
||||||
|
|
||||||
mPreference = new Preference(ApplicationProvider.getApplicationContext());
|
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||||
|
PackageManager pm = spy(mContext.getPackageManager());
|
||||||
|
doReturn(pm).when(mContext).getPackageManager();
|
||||||
|
doReturn("com.android.permissioncontroller").when(pm).getPermissionControllerPackageName();
|
||||||
|
|
||||||
|
mPreference = new Preference(mContext);
|
||||||
mPreference.setKey(PREFERENCE_KEY);
|
mPreference.setKey(PREFERENCE_KEY);
|
||||||
|
|
||||||
doNothing().when(mContext).startActivity(any(Intent.class));
|
doNothing().when(mContext).startActivity(any(Intent.class));
|
||||||
@@ -75,7 +82,7 @@ public class TopLevelSafetyCenterEntryPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void handlePreferenceTreeClick_forDifferentPreferenceKey_isNotHandled() {
|
public void handlePreferenceTreeClick_forDifferentPreferenceKey_isNotHandled() {
|
||||||
Preference preference = new Preference(ApplicationProvider.getApplicationContext());
|
Preference preference = new Preference(mContext);
|
||||||
preference.setKey("some_other_preference");
|
preference.setKey("some_other_preference");
|
||||||
|
|
||||||
boolean preferenceHandled =
|
boolean preferenceHandled =
|
||||||
|
@@ -20,6 +20,8 @@ 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.doNothing;
|
import static org.mockito.Mockito.doNothing;
|
||||||
|
import static org.mockito.Mockito.doReturn;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@@ -27,6 +29,7 @@ import static org.mockito.Mockito.when;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
import androidx.test.platform.app.InstrumentationRegistry;
|
import androidx.test.platform.app.InstrumentationRegistry;
|
||||||
@@ -80,6 +83,10 @@ public class SecurityDashboardActivityTest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
doNothing().when(mActivity).startActivity(any(Intent.class));
|
doNothing().when(mActivity).startActivity(any(Intent.class));
|
||||||
|
|
||||||
|
PackageManager pm = mock(PackageManager.class);
|
||||||
|
doReturn(pm).when(mActivity).getPackageManager();
|
||||||
|
doReturn("com.android.permissioncontroller").when(pm).getPermissionControllerPackageName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user