Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Configurable clipboard autoclear timeout support - #353

Closed
secrecyflag wants to merge 1 commit into
GrapheneOS-Archive:13from
secrecyflag:13
Closed

Configurable clipboard autoclear timeout support#353
secrecyflag wants to merge 1 commit into
GrapheneOS-Archive:13from
secrecyflag:13

Conversation

@secrecyflag

@secrecyflag secrecyflag commented Mar 28, 2023

Copy link
Copy Markdown

Dependent on: GrapheneOS/platform_packages_apps_Settings#158
Needs testing!

@x86pup x86pup left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs some changes, needs to be rebased, and I think we want this to be per-user instead of global unless due to some limitation.

I did type these suggestions on GitHub which may be incorrect / hard to understand, so if you want I can push my requested changes to my fork.

* The amount of time in milliseconds before the clipboard is cleared.
* @hide
*/
public static final String CLIPBOARD_AUTO_CLEAR_TIMEOUT = "clipboard_auto_clear_timeout";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ExtSettings infrastructure does not touch Settings.java, you need to define this in ExtSettings.java instead

return DeviceConfig.getLong(DeviceConfig.NAMESPACE_CLIPBOARD,
PROPERTY_AUTO_CLEAR_TIMEOUT,
DEFAULT_CLIPBOARD_TIMEOUT_MILLIS);
return Settings.Global.getLong(mContext.getContentResolver(), Settings.Global.CLIPBOARD_AUTO_CLEAR_TIMEOUT, DEFAULT_CLIPBOARD_TIMEOUT_MILLIS);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ExtSettings checks should import import android.ext.settings.ExtSettings; and do:

ExtSettings.<key>.get(<context>)

In this case:

return ExtSettings.CLIPBOARD_AUTO_CLEAR_TIMEOUT.get(mContext)

As we're not using Settings.java.

Comment thread core/java/android/ext/settings/ExtSettings.java Outdated
Setting.Scope.PER_USER, "lockscreen_scramble_pin_layout", false);

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we also want this to be per-user instead of global

@secrecyflag

Copy link
Copy Markdown
Author

Should be ready for testing on a pixel.

@x86pup

x86pup commented Apr 1, 2023

Copy link
Copy Markdown
Contributor

Still needs to be rebased

@x86pup

x86pup commented Apr 1, 2023

Copy link
Copy Markdown
Contributor

Toggle doesn't seem to show up in my Pixel 6 after building.

(See review in Settings for solution)

@x86pup x86pup left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to replace mContext with getContext() method, and get the userId as the Context is not per-user

@@ -429,9 +430,7 @@ private void scheduleAutoClear(@UserIdInt int userId, int intendingUid) {
}

private long getTimeoutForAutoClear() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this isn't a per-user Context (and mContext seems invalid here, build error) which will cause the settings in the Owner profile to apply across all profiles irrespective of the current profile's setting, so you'll need to specify the uid this is for.

Suggested change
private long getTimeoutForAutoClear() {
private long getTimeoutForAutoClear(int userId) {
return ExtSettings.CLIPBOARD_AUTO_CLEAR_TIMEOUT.get(getContext(), userId);

And where getTimeoutForAutoClear method is called, pass the userId argument:

getTimeoutForAutoClear(userId)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't catch that build error as I'm currently using m Settings. Waiting for a new SSD to arrive (don't have enough space on device).

@secrecyflag

Copy link
Copy Markdown
Author

Closing this pull request as it became messy. Will open a new one and send here.

@secrecyflag secrecyflag closed this Apr 1, 2023
@secrecyflag

Copy link
Copy Markdown
Author

#357 @r3g-5z

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants