Skip to content

Commit 2d3d1f3

Browse files
quh4gko8thestinger
authored andcommitted
Settings definition for cross profile clipboard access
1 parent 7bab6f3 commit 2d3d1f3

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package android.ext.settings;
2+
3+
import android.annotation.NonNull;
4+
import android.content.Context;
5+
import android.provider.Settings;
6+
7+
/** @hide */
8+
public class CrossProfileClipboardAccessSettings {
9+
10+
public static final int FOLLOW_DEFAULT = 0;
11+
public static final int ALLOW_IMPORT_DEFAULTS_ONLY = 1;
12+
public static final int ALLOW_EXPORT_DEFAULTS_ONLY = 2;
13+
public static final int BLOCK = 3;
14+
15+
public static final IntSetting CROSS_PROFILE_CLIPBOARD_ACCESS_SETTINGS = new IntSetting(
16+
Setting.Scope.PER_USER, Settings.Secure.CROSS_PROFILE_CLIPBOARD_ACCESS,
17+
// default
18+
FOLLOW_DEFAULT,
19+
// valid values
20+
FOLLOW_DEFAULT, ALLOW_IMPORT_DEFAULTS_ONLY, ALLOW_EXPORT_DEFAULTS_ONLY, BLOCK
21+
);
22+
23+
public static boolean isExportAccessAllowed(@NonNull Context ctx, int userId) {
24+
int curSetting = CROSS_PROFILE_CLIPBOARD_ACCESS_SETTINGS.get(ctx, userId);
25+
return curSetting == FOLLOW_DEFAULT || curSetting == ALLOW_EXPORT_DEFAULTS_ONLY;
26+
}
27+
28+
public static boolean isImportAccessAllowed(@NonNull Context ctx, int userId) {
29+
int curSetting = CROSS_PROFILE_CLIPBOARD_ACCESS_SETTINGS.get(ctx, userId);
30+
return curSetting == FOLLOW_DEFAULT || curSetting == ALLOW_IMPORT_DEFAULTS_ONLY;
31+
}
32+
}

core/java/android/provider/Settings.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7072,6 +7072,10 @@ public static final class Secure extends NameValueTable {
70727072
@Protected(read = KnownSystemPackage.SYSTEM_UI, readWrite = KnownSystemPackage.SETTINGS)
70737073
public static final String SCRAMBLE_SIM_PIN_LAYOUT = "scramble_sim_pin_layout";
70747074

7075+
/** @hide */
7076+
@Protected(readWrite = KnownSystemPackage.SETTINGS)
7077+
public static final String CROSS_PROFILE_CLIPBOARD_ACCESS = "cross_profile_clipboard_access";
7078+
70757079
// ExtSettings END
70767080

70777081
// NOTE: If you add new settings here, be sure to add them to

0 commit comments

Comments
 (0)