Loading core/java/android/app/AppOpsManager.java +25 −1 Original line number Diff line number Diff line Loading @@ -1327,9 +1327,17 @@ public class AppOpsManager { */ public static final int OP_ESTABLISH_VPN_MANAGER = AppProtoEnums.APP_OP_ESTABLISH_VPN_MANAGER; /** * Access restricted settings. * * @hide */ public static final int OP_ACCESS_RESTRICTED_SETTINGS = AppProtoEnums.APP_OP_ACCESS_RESTRICTED_SETTINGS; /** @hide */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) public static final int _NUM_OP = 119; public static final int _NUM_OP = 120; /** Access to coarse location information. */ public static final String OPSTR_COARSE_LOCATION = "android:coarse_location"; Loading Loading @@ -1784,6 +1792,14 @@ public class AppOpsManager { @SystemApi public static final String OPSTR_ESTABLISH_VPN_MANAGER = "android:establish_vpn_manager"; /** * Limit user accessing restricted settings. * * @hide */ public static final String OPSTR_ACCESS_RESTRICTED_SETTINGS = "android:access_restricted_settings"; /** {@link #sAppOpsToNote} not initialized yet for this op */ private static final byte SHOULD_COLLECT_NOTE_OP_NOT_INITIALIZED = 0; /** Should not collect noting of this app-op in {@link #sAppOpsToNote} */ Loading Loading @@ -2004,6 +2020,7 @@ public class AppOpsManager { OP_NEARBY_WIFI_DEVICES, // OP_NEARBY_WIFI_DEVICES OP_ESTABLISH_VPN_SERVICE, // OP_ESTABLISH_VPN_SERVICE OP_ESTABLISH_VPN_MANAGER, // OP_ESTABLISH_VPN_MANAGER OP_ACCESS_RESTRICTED_SETTINGS, // OP_ACCESS_RESTRICTED_SETTINGS }; /** Loading Loading @@ -2129,6 +2146,7 @@ public class AppOpsManager { OPSTR_NEARBY_WIFI_DEVICES, OPSTR_ESTABLISH_VPN_SERVICE, OPSTR_ESTABLISH_VPN_MANAGER, OPSTR_ACCESS_RESTRICTED_SETTINGS, }; /** Loading Loading @@ -2255,6 +2273,7 @@ public class AppOpsManager { "NEARBY_WIFI_DEVICES", "ESTABLISH_VPN_SERVICE", "ESTABLISH_VPN_MANAGER", "ACCESS_RESTRICTED_SETTINGS", }; /** Loading Loading @@ -2382,6 +2401,7 @@ public class AppOpsManager { Manifest.permission.NEARBY_WIFI_DEVICES, null, // no permission for OP_ESTABLISH_VPN_SERVICE null, // no permission for OP_ESTABLISH_VPN_MANAGER null, // no permission for OP_ACCESS_RESTRICTED_SETTINGS, }; /** Loading Loading @@ -2509,6 +2529,7 @@ public class AppOpsManager { null, // NEARBY_WIFI_DEVICES null, // ESTABLISH_VPN_SERVICE null, // ESTABLISH_VPN_MANAGER null, // ACCESS_RESTRICTED_SETTINGS, }; /** Loading Loading @@ -2635,6 +2656,7 @@ public class AppOpsManager { null, // NEARBY_WIFI_DEVICES null, // ESTABLISH_VPN_SERVICE null, // ESTABLISH_VPN_MANAGER null, // ACCESS_RESTRICTED_SETTINGS, }; /** Loading Loading @@ -2760,6 +2782,7 @@ public class AppOpsManager { AppOpsManager.MODE_ALLOWED, // NEARBY_WIFI_DEVICES AppOpsManager.MODE_ALLOWED, // ESTABLISH_VPN_SERVICE AppOpsManager.MODE_ALLOWED, // ESTABLISH_VPN_MANAGER AppOpsManager.MODE_ALLOWED, // ACCESS_RESTRICTED_SETTINGS, }; /** Loading Loading @@ -2889,6 +2912,7 @@ public class AppOpsManager { false, // NEARBY_WIFI_DEVICES false, // OP_ESTABLISH_VPN_SERVICE false, // OP_ESTABLISH_VPN_MANAGER true, // ACCESS_RESTRICTED_SETTINGS }; /** Loading core/java/android/provider/Settings.java +9 −0 Original line number Diff line number Diff line Loading @@ -2385,6 +2385,15 @@ public final class Settings { public static final String ACTION_ENABLE_MMS_DATA_REQUEST = "android.settings.ENABLE_MMS_DATA_REQUEST"; /** * Shows restrict settings dialog when settings is blocked. * * @hide */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String ACTION_SHOW_RESTRICTED_SETTING_DIALOG = "android.settings.SHOW_RESTRICTED_SETTING_DIALOG"; /** * Integer value that specifies the reason triggering enable MMS data notification. * This must be passed as an extra field to the {@link #ACTION_ENABLE_MMS_DATA_REQUEST}. Loading packages/SettingsLib/res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -1164,6 +1164,9 @@ <!-- Summary for settings preference disabled by administrator [CHAR LIMIT=50] --> <string name="disabled_by_admin_summary_text">Controlled by admin</string> <!-- Summary for settings preference disabled by app ops [CHAR LIMIT=50] --> <string name="disabled_by_app_ops_text">Controlled by Restricted Setting</string> <!-- [CHAR LIMIT=25] Manage applications, text telling using an application is disabled. --> <string name="disabled">Disabled</string> <!-- Summary of app trusted to install apps [CHAR LIMIT=45] --> Loading packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtilsInternal.java +24 −0 Original line number Diff line number Diff line Loading @@ -26,14 +26,17 @@ import android.app.AppGlobals; import android.app.admin.DevicePolicyManager; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.IPackageManager; import android.content.pm.PackageManager; import android.content.pm.UserInfo; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.RemoteException; import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.style.ForegroundColorSpan; Loading @@ -42,6 +45,7 @@ import android.util.Log; import android.view.MenuItem; import android.widget.TextView; import androidx.annotation.RequiresApi; import androidx.annotation.VisibleForTesting; import com.android.internal.widget.LockPatternUtils; Loading Loading @@ -728,6 +732,26 @@ public class RestrictedLockUtilsInternal extends RestrictedLockUtils { textView.setText(sb); } /** * Show restricted setting dialog. */ @RequiresApi(Build.VERSION_CODES.TIRAMISU) public static void sendShowRestrictedSettingDialogIntent(Context context, String packageName, int uid) { final Intent intent = getShowRestrictedSettingsIntent(packageName, uid); context.startActivity(intent); } /** * Get restricted settings dialog intent. */ private static Intent getShowRestrictedSettingsIntent(String packageName, int uid) { final Intent intent = new Intent(Settings.ACTION_SHOW_RESTRICTED_SETTING_DIALOG); intent.putExtra(Intent.EXTRA_PACKAGE_NAME, packageName); intent.putExtra(Intent.EXTRA_UID, uid); return intent; } /** * Static {@link LockPatternUtils} and {@link DevicePolicyManager} wrapper for testing purposes. * {@link LockPatternUtils} is an internal API not supported by robolectric. Loading packages/SettingsLib/src/com/android/settingslib/RestrictedPreference.java +27 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.settingslib; import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; import android.content.Context; import android.os.Process; import android.os.UserHandle; import android.util.AttributeSet; import android.view.View; Loading @@ -37,9 +38,14 @@ public class RestrictedPreference extends TwoTargetPreference { RestrictedPreferenceHelper mHelper; public RestrictedPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { int defStyleAttr, int defStyleRes, String packageName, int uid) { super(context, attrs, defStyleAttr, defStyleRes); mHelper = new RestrictedPreferenceHelper(context, this, attrs); mHelper = new RestrictedPreferenceHelper(context, this, attrs, packageName, uid); } public RestrictedPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { this(context, attrs, defStyleAttr, defStyleRes, null, Process.INVALID_UID); } public RestrictedPreference(Context context, AttributeSet attrs, int defStyleAttr) { Loading @@ -55,6 +61,11 @@ public class RestrictedPreference extends TwoTargetPreference { this(context, null); } public RestrictedPreference(Context context, String packageName, int uid) { this(context, null, TypedArrayUtils.getAttr(context, R.attr.preferenceStyle, android.R.attr.preferenceStyle), 0, packageName, uid); } @Override protected int getSecondTargetResId() { return R.layout.restricted_icon; Loading Loading @@ -115,7 +126,21 @@ public class RestrictedPreference extends TwoTargetPreference { } } public void setDisabledByAppOps(boolean disabled) { if (mHelper.setDisabledByAppOps(disabled)) { notifyChanged(); } } public boolean isDisabledByAdmin() { return mHelper.isDisabledByAdmin(); } public int getUid() { return mHelper != null ? mHelper.uid : Process.INVALID_UID; } public String getPackageName() { return mHelper != null ? mHelper.packageName : null; } } Loading
core/java/android/app/AppOpsManager.java +25 −1 Original line number Diff line number Diff line Loading @@ -1327,9 +1327,17 @@ public class AppOpsManager { */ public static final int OP_ESTABLISH_VPN_MANAGER = AppProtoEnums.APP_OP_ESTABLISH_VPN_MANAGER; /** * Access restricted settings. * * @hide */ public static final int OP_ACCESS_RESTRICTED_SETTINGS = AppProtoEnums.APP_OP_ACCESS_RESTRICTED_SETTINGS; /** @hide */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) public static final int _NUM_OP = 119; public static final int _NUM_OP = 120; /** Access to coarse location information. */ public static final String OPSTR_COARSE_LOCATION = "android:coarse_location"; Loading Loading @@ -1784,6 +1792,14 @@ public class AppOpsManager { @SystemApi public static final String OPSTR_ESTABLISH_VPN_MANAGER = "android:establish_vpn_manager"; /** * Limit user accessing restricted settings. * * @hide */ public static final String OPSTR_ACCESS_RESTRICTED_SETTINGS = "android:access_restricted_settings"; /** {@link #sAppOpsToNote} not initialized yet for this op */ private static final byte SHOULD_COLLECT_NOTE_OP_NOT_INITIALIZED = 0; /** Should not collect noting of this app-op in {@link #sAppOpsToNote} */ Loading Loading @@ -2004,6 +2020,7 @@ public class AppOpsManager { OP_NEARBY_WIFI_DEVICES, // OP_NEARBY_WIFI_DEVICES OP_ESTABLISH_VPN_SERVICE, // OP_ESTABLISH_VPN_SERVICE OP_ESTABLISH_VPN_MANAGER, // OP_ESTABLISH_VPN_MANAGER OP_ACCESS_RESTRICTED_SETTINGS, // OP_ACCESS_RESTRICTED_SETTINGS }; /** Loading Loading @@ -2129,6 +2146,7 @@ public class AppOpsManager { OPSTR_NEARBY_WIFI_DEVICES, OPSTR_ESTABLISH_VPN_SERVICE, OPSTR_ESTABLISH_VPN_MANAGER, OPSTR_ACCESS_RESTRICTED_SETTINGS, }; /** Loading Loading @@ -2255,6 +2273,7 @@ public class AppOpsManager { "NEARBY_WIFI_DEVICES", "ESTABLISH_VPN_SERVICE", "ESTABLISH_VPN_MANAGER", "ACCESS_RESTRICTED_SETTINGS", }; /** Loading Loading @@ -2382,6 +2401,7 @@ public class AppOpsManager { Manifest.permission.NEARBY_WIFI_DEVICES, null, // no permission for OP_ESTABLISH_VPN_SERVICE null, // no permission for OP_ESTABLISH_VPN_MANAGER null, // no permission for OP_ACCESS_RESTRICTED_SETTINGS, }; /** Loading Loading @@ -2509,6 +2529,7 @@ public class AppOpsManager { null, // NEARBY_WIFI_DEVICES null, // ESTABLISH_VPN_SERVICE null, // ESTABLISH_VPN_MANAGER null, // ACCESS_RESTRICTED_SETTINGS, }; /** Loading Loading @@ -2635,6 +2656,7 @@ public class AppOpsManager { null, // NEARBY_WIFI_DEVICES null, // ESTABLISH_VPN_SERVICE null, // ESTABLISH_VPN_MANAGER null, // ACCESS_RESTRICTED_SETTINGS, }; /** Loading Loading @@ -2760,6 +2782,7 @@ public class AppOpsManager { AppOpsManager.MODE_ALLOWED, // NEARBY_WIFI_DEVICES AppOpsManager.MODE_ALLOWED, // ESTABLISH_VPN_SERVICE AppOpsManager.MODE_ALLOWED, // ESTABLISH_VPN_MANAGER AppOpsManager.MODE_ALLOWED, // ACCESS_RESTRICTED_SETTINGS, }; /** Loading Loading @@ -2889,6 +2912,7 @@ public class AppOpsManager { false, // NEARBY_WIFI_DEVICES false, // OP_ESTABLISH_VPN_SERVICE false, // OP_ESTABLISH_VPN_MANAGER true, // ACCESS_RESTRICTED_SETTINGS }; /** Loading
core/java/android/provider/Settings.java +9 −0 Original line number Diff line number Diff line Loading @@ -2385,6 +2385,15 @@ public final class Settings { public static final String ACTION_ENABLE_MMS_DATA_REQUEST = "android.settings.ENABLE_MMS_DATA_REQUEST"; /** * Shows restrict settings dialog when settings is blocked. * * @hide */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String ACTION_SHOW_RESTRICTED_SETTING_DIALOG = "android.settings.SHOW_RESTRICTED_SETTING_DIALOG"; /** * Integer value that specifies the reason triggering enable MMS data notification. * This must be passed as an extra field to the {@link #ACTION_ENABLE_MMS_DATA_REQUEST}. Loading
packages/SettingsLib/res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -1164,6 +1164,9 @@ <!-- Summary for settings preference disabled by administrator [CHAR LIMIT=50] --> <string name="disabled_by_admin_summary_text">Controlled by admin</string> <!-- Summary for settings preference disabled by app ops [CHAR LIMIT=50] --> <string name="disabled_by_app_ops_text">Controlled by Restricted Setting</string> <!-- [CHAR LIMIT=25] Manage applications, text telling using an application is disabled. --> <string name="disabled">Disabled</string> <!-- Summary of app trusted to install apps [CHAR LIMIT=45] --> Loading
packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtilsInternal.java +24 −0 Original line number Diff line number Diff line Loading @@ -26,14 +26,17 @@ import android.app.AppGlobals; import android.app.admin.DevicePolicyManager; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.IPackageManager; import android.content.pm.PackageManager; import android.content.pm.UserInfo; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.RemoteException; import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.style.ForegroundColorSpan; Loading @@ -42,6 +45,7 @@ import android.util.Log; import android.view.MenuItem; import android.widget.TextView; import androidx.annotation.RequiresApi; import androidx.annotation.VisibleForTesting; import com.android.internal.widget.LockPatternUtils; Loading Loading @@ -728,6 +732,26 @@ public class RestrictedLockUtilsInternal extends RestrictedLockUtils { textView.setText(sb); } /** * Show restricted setting dialog. */ @RequiresApi(Build.VERSION_CODES.TIRAMISU) public static void sendShowRestrictedSettingDialogIntent(Context context, String packageName, int uid) { final Intent intent = getShowRestrictedSettingsIntent(packageName, uid); context.startActivity(intent); } /** * Get restricted settings dialog intent. */ private static Intent getShowRestrictedSettingsIntent(String packageName, int uid) { final Intent intent = new Intent(Settings.ACTION_SHOW_RESTRICTED_SETTING_DIALOG); intent.putExtra(Intent.EXTRA_PACKAGE_NAME, packageName); intent.putExtra(Intent.EXTRA_UID, uid); return intent; } /** * Static {@link LockPatternUtils} and {@link DevicePolicyManager} wrapper for testing purposes. * {@link LockPatternUtils} is an internal API not supported by robolectric. Loading
packages/SettingsLib/src/com/android/settingslib/RestrictedPreference.java +27 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.settingslib; import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; import android.content.Context; import android.os.Process; import android.os.UserHandle; import android.util.AttributeSet; import android.view.View; Loading @@ -37,9 +38,14 @@ public class RestrictedPreference extends TwoTargetPreference { RestrictedPreferenceHelper mHelper; public RestrictedPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { int defStyleAttr, int defStyleRes, String packageName, int uid) { super(context, attrs, defStyleAttr, defStyleRes); mHelper = new RestrictedPreferenceHelper(context, this, attrs); mHelper = new RestrictedPreferenceHelper(context, this, attrs, packageName, uid); } public RestrictedPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { this(context, attrs, defStyleAttr, defStyleRes, null, Process.INVALID_UID); } public RestrictedPreference(Context context, AttributeSet attrs, int defStyleAttr) { Loading @@ -55,6 +61,11 @@ public class RestrictedPreference extends TwoTargetPreference { this(context, null); } public RestrictedPreference(Context context, String packageName, int uid) { this(context, null, TypedArrayUtils.getAttr(context, R.attr.preferenceStyle, android.R.attr.preferenceStyle), 0, packageName, uid); } @Override protected int getSecondTargetResId() { return R.layout.restricted_icon; Loading Loading @@ -115,7 +126,21 @@ public class RestrictedPreference extends TwoTargetPreference { } } public void setDisabledByAppOps(boolean disabled) { if (mHelper.setDisabledByAppOps(disabled)) { notifyChanged(); } } public boolean isDisabledByAdmin() { return mHelper.isDisabledByAdmin(); } public int getUid() { return mHelper != null ? mHelper.uid : Process.INVALID_UID; } public String getPackageName() { return mHelper != null ? mHelper.packageName : null; } }