Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
configurable clipboard auto-clear timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
secrecyflag committed Apr 4, 2023
1 parent 9dab90e commit a2e7124
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
7 changes: 7 additions & 0 deletions core/java/android/ext/settings/ClipboardConstants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package android.ext.settings;

/** @hide */
public class ClipboardConstants {
// From com.android.server.clipboard.ClipboardService.DEFAULT_CLIPBOARD_TIMEOUT_MILLIS
public static final int DEFAULT_CLIPBOARD_TIMEOUT_MILLIS = 3600000;
}
4 changes: 4 additions & 0 deletions core/java/android/ext/settings/ExtSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.lang.reflect.Field;
import java.util.Set;

import static android.ext.settings.ClipboardConstants.DEFAULT_CLIPBOARD_TIMEOUT_MILLIS;
import static android.ext.settings.GnssConstants.SUPL_DISABLED;
import static android.ext.settings.GnssConstants.SUPL_SERVER_GRAPHENEOS_PROXY;
import static android.ext.settings.GnssConstants.SUPL_SERVER_STANDARD;
Expand Down Expand Up @@ -31,6 +32,9 @@ public class ExtSettings {
public static final BoolSetting SCRAMBLE_PIN_LAYOUT = new BoolSetting(
Setting.Scope.PER_USER, "lockscreen_scramble_pin_layout", false);

public static final IntSetting CLIPBOARD_AUTO_CLEAR_TIMEOUT = new IntSetting(
Setting.Scope.PER_USER, "clipboard_auto_clear_timeout", DEFAULT_CLIPBOARD_TIMEOUT_MILLIS);

private ExtSettings() {}

// used for making settings defined in this class unreadable by third-party apps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.ext.settings.ExtSettings;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Binder;
Expand Down Expand Up @@ -421,17 +422,15 @@ private void scheduleAutoClear(@UserIdInt int userId, int intendingUid) {
intendingUid,
userId);
mClipboardClearHandler.sendMessageDelayed(clearMessage,
getTimeoutForAutoClear());
getTimeoutForAutoClear(userId));
}
} finally {
Binder.restoreCallingIdentity(oldIdentity);
}
}

private long getTimeoutForAutoClear() {
return DeviceConfig.getLong(DeviceConfig.NAMESPACE_CLIPBOARD,
PROPERTY_AUTO_CLEAR_TIMEOUT,
DEFAULT_CLIPBOARD_TIMEOUT_MILLIS);
private long getTimeoutForAutoClear(int userId) {
return ExtSettings.CLIPBOARD_AUTO_CLEAR_TIMEOUT.get(getContext(), userId);
}

@Override
Expand Down

0 comments on commit a2e7124

Please sign in to comment.