ClipCascade icon indicating copy to clipboard operation
ClipCascade copied to clipboard

[FEATURE REQUEST] Android App - Rooted or Shizuku Mode?

Open GraphicHealer opened this issue 1 year ago • 30 comments

Hello!

I read on your main Readme that the android app is restricted to not being able to read the clipboard by the system, would it be possible at all to make a root-compatible mode or version of the app that would allow full direct clipboard synchronization? For those of us (including myself) who run rooted/modded android devices, this would be an AWESOME feature.

Another possibility is to include a Shizuku compatible mode (see this: https://github.com/RikkaApps/Shizuku), which allows the app to access System-Level APIs through ADB. This would also be available to people without root, or with an unrootable phone. (Looking at YOU SAMSUNG. 😡 )

Thanks! - G

GraphicHealer avatar Sep 27 '24 12:09 GraphicHealer

If possible, this sounds like an amazing idea to decrease steps to copying text

applesoff avatar Sep 29 '24 04:09 applesoff

Yes, I will be working on this and will add a workaround if possible.

Sathvik-Rao avatar Sep 29 '24 05:09 Sathvik-Rao

Awesome! The root mode would be REALLY nice at a minimum, but Shizuku would be a nice addition for the people with no root available.

Also, do try to make sure the app requests root directly, as some root implementations have a way to "Request" root (Eg: Magisk: https://github.com/topjohnwu/Magisk), and others just provide it directly when the selected app has root enabled (Eg: KernelSU: https://github.com/tiann/KernelSU).

I'd look at how AdAway is getting it's root access, as it works with both implementations flawlessly. https://github.com/AdAway/AdAway

Otherwise, I hope you can figure something out, as I would love to use this as a full clipboard sync option! It's a pretty cool concept!

GraphicHealer avatar Oct 01 '24 13:10 GraphicHealer

Hi @GraphicHealer

I have great news! I implemented a workaround for both rooted and non-rooted devices. The only thing users need to do is execute three ADB commands, and everything will be set. I plan to release it in a few days, along with some tweaks to the desktop app as well.

Sathvik-Rao avatar Oct 03 '24 02:10 Sathvik-Rao

I looked at the branch for 0.2.0 and downloaded the apk. I took a route of installing termux for shizuku to use for adb commands and followed the instructions in the 0.2.0 app. I tested copying contents to android clipboard and it worked perfectly. Nice Job!

If clipcascade can be added to shizuku and have these commands run automatically it would save a few steps, but your workaround works great until a reboot.

Thanks again!

applesoff avatar Oct 04 '24 00:10 applesoff

I have tried the new 0.2.0 release on my Samsung with Android 14 and executed the adb commands, but it does not register them except when I am in the app and copy the comands. In the app info I see the disabled battery optimisation and from windows to android its working fine even in the background.

archef2000 avatar Oct 05 '24 15:10 archef2000

Hi @archef2000

After executing three ADB commands and disabling battery optimization, do you see this message when you click the Start button?

Sathvik-Rao avatar Oct 05 '24 16:10 Sathvik-Rao

No didn't see it once.

archef2000 avatar Oct 05 '24 20:10 archef2000

Hi @archef2000,

Try uninstalling and reinstalling the app and follow the adb steps. If that doesn't work, check the logs using adb logcat.

When you try to copy text, you should see something like this:

E ClipboardService: Denying clipboard access to com.clipcascade, application is not in focus nor is it a system service for user 0
...
W ActivityTaskManager: Background activity start for com.clipcascade allowed because SYSTEM_ALERT_WINDOW permission is granted.
...
I ClipboardService: ClipCascade pasted from your clipboard

Copy the logs to a file and search for the keyword clipcascade.

Sathvik-Rao avatar Oct 05 '24 21:10 Sathvik-Rao

So now I have redownloaded the 0.2.0 apk Installed it Logged into my account disabled battery optimization Executed every adb command in the docs Opened the app Started the service No popup Sharing works Still not working outside the app

logcat shows multiple entries with many apps under which is ClipCascade:

E ClipboardService: Denying clipboard access to com.clipcascade, application is not in focus nor is it a system service for user 0

archef2000 avatar Oct 06 '24 11:10 archef2000

Hi @archef2000,

All the steps are correct, and as per your logs, you didn't find:

W ActivityTaskManager: Background activity start for com.clipcascade allowed because SYSTEM_ALERT_WINDOW permission is granted.

This means the workaround is not working. It might be something related to Samsung, but I'll look into it further.

Sathvik-Rao avatar Oct 06 '24 15:10 Sathvik-Rao

Hi @archef2000,

Could you please run the following two ADB commands to check the Android version and the permissions for ClipCascade? Also, please share the output.

  1. adb shell getprop ro.build.version.sdk

  2. adb shell dumpsys package com.clipcascade | grep -i permission

Thank you!

Sathvik-Rao avatar Oct 06 '24 16:10 Sathvik-Rao

sdk version is: 34 SYSTEM_ALERT_WINDOW is not in the logcat anywhere and the permissions are:

    android.app.action.SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED:
      85ce236 com.clipcascade/app.notifee.core.AlarmPermissionBroadcastReceiver filter 83cf537
              Action: "android.app.action.SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED"
Permissions:
Permission [com.clipcascade.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION] (bb3553d):
  perm=PermissionInfo{f8da8b1 com.clipcascade.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION}
  installPermissionsFixed=true
  declared permissions:
    com.clipcascade.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION: prot=signature
  requested permissions:
    android.permission.INTERNET
    android.permission.POST_NOTIFICATIONS
    android.permission.FOREGROUND_SERVICE
    android.permission.FOREGROUND_SERVICE_REMOTE_MESSAGING
    android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
    android.permission.SYSTEM_ALERT_WINDOW
    android.permission.READ_LOGS
    android.permission.WAKE_LOCK
    android.permission.ACCESS_NETWORK_STATE
    android.permission.RECEIVE_BOOT_COMPLETED
    com.clipcascade.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION
    android.permission.VIBRATE
    android.permission.SCHEDULE_EXACT_ALARM
    android.permission.ACCESS_NOTIFICATION_POLICY
  install permissions:
    android.permission.ACCESS_NOTIFICATION_POLICY: granted=true
    com.clipcascade.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION: granted=true
    android.permission.SYSTEM_ALERT_WINDOW: granted=false
    android.permission.FOREGROUND_SERVICE: granted=true
    android.permission.RECEIVE_BOOT_COMPLETED: granted=true
    android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS: granted=true
    android.permission.INTERNET: granted=true
    android.permission.FOREGROUND_SERVICE_REMOTE_MESSAGING: granted=true
    android.permission.ACCESS_NETWORK_STATE: granted=true
    android.permission.READ_LOGS: granted=true
    android.permission.READ_LOGS: granted=false, userId=150
    android.permission.SCHEDULE_EXACT_ALARM: granted=false
    android.permission.VIBRATE: granted=true
    android.permission.WAKE_LOCK: granted=true
    runtime permissions:
      android.permission.POST_NOTIFICATIONS: granted=true, flags=[ USER_SET|USER_SENSITIVE_WHEN_GRANTED|USER_SENSITIVE_WHEN_DENIED]
    runtime permissions:
      android.permission.POST_NOTIFICATIONS: granted=false
    com.google.android.permissioncontroller:

archef2000 avatar Oct 06 '24 17:10 archef2000

It appears that READ_LOGS permission is granted, but not for user ID 150:

android.permission.READ_LOGS: granted=true
android.permission.READ_LOGS: granted=false, userId=150

Try running the following command:

adb -d shell pm grant --user 150 com.clipcascade android.permission.READ_LOGS

Sathvik-Rao avatar Oct 06 '24 17:10 Sathvik-Rao

Seems like I can't grant that permission to that user.

Exception occurred while executing 'grant':
java.lang.SecurityException: Shell does not have permission to access user 150
 com.android.server.am.ActivityManagerService.handleIncomingUser:15970 android.app.ActivityManager.handleIncomingUser:5152 com.android.server.pm.PackageManagerShellCommand.translateUserId:3733
        at com.android.server.am.UserController.handleIncomingUser(UserController.java:2892)
        at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:15970)
        at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:5152)
        at com.android.server.pm.PackageManagerShellCommand.translateUserId(PackageManagerShellCommand.java:3733)
        at com.android.server.pm.PackageManagerShellCommand.runGrantRevokePermission(PackageManagerShellCommand.java:2724)
        at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:304)
        at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
        at android.os.ShellCommand.exec(ShellCommand.java:38)
        at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onShellCommand(PackageManagerService.java:7136)
        at android.os.Binder.shellCommand(Binder.java:1104)
        at android.os.Binder.onTransact(Binder.java:914)
        at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4905)
        at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onTransact(PackageManagerService.java:7120)
        at android.os.Binder.execTransactInternal(Binder.java:1380)
        at android.os.Binder.execTransact(Binder.java:1311)

archef2000 avatar Oct 06 '24 17:10 archef2000

Did you store the app in a secure folder?

see here

Sathvik-Rao avatar Oct 06 '24 18:10 Sathvik-Rao

No installed it right from the file explorer using the default packet installer.

archef2000 avatar Oct 06 '24 18:10 archef2000

I uninstalled the secure folder and now the READ_LOGS and SYSTEM_ALERT_WINDOW permissions have no exception. Still no background sync from Android to Windows but it works the other way around.

archef2000 avatar Oct 06 '24 18:10 archef2000

can you share the output once again

adb shell dumpsys package com.clipcascade | grep -i permission

Sathvik-Rao avatar Oct 06 '24 19:10 Sathvik-Rao

      android.app.action.SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED:
        dcd654 com.clipcascade/app.notifee.core.AlarmPermissionBroadcastReceiver filter 4d09fd
          Action: "android.app.action.SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED"
Permissions:
  Permission [com.clipcascade.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION] (25facad):
    perm=PermissionInfo{e700eb2 com.clipcascade.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION}
    installPermissionsFixed=true
    declared permissions:
      com.clipcascade.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION: prot=signature
    requested permissions:
      android.permission.INTERNET
      android.permission.POST_NOTIFICATIONS
      android.permission.FOREGROUND_SERVICE
      android.permission.FOREGROUND_SERVICE_REMOTE_MESSAGING
      android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
      android.permission.SYSTEM_ALERT_WINDOW
      android.permission.READ_LOGS
      android.permission.WAKE_LOCK
      android.permission.ACCESS_NETWORK_STATE
      android.permission.RECEIVE_BOOT_COMPLETED
      com.clipcascade.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION
      android.permission.VIBRATE
      android.permission.SCHEDULE_EXACT_ALARM
      android.permission.ACCESS_NOTIFICATION_POLICY
    install permissions:
      android.permission.ACCESS_NOTIFICATION_POLICY: granted=true
      com.clipcascade.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION: granted=true
      android.permission.SYSTEM_ALERT_WINDOW: granted=false
      android.permission.FOREGROUND_SERVICE: granted=true
      android.permission.RECEIVE_BOOT_COMPLETED: granted=true
      android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS: granted=true
      android.permission.INTERNET: granted=true
      android.permission.FOREGROUND_SERVICE_REMOTE_MESSAGING: granted=true
      android.permission.ACCESS_NETWORK_STATE: granted=true
      android.permission.READ_LOGS: granted=true
      android.permission.SCHEDULE_EXACT_ALARM: granted=false
      android.permission.VIBRATE: granted=true
      android.permission.WAKE_LOCK: granted=true
      runtime permissions:
        android.permission.POST_NOTIFICATIONS: granted=true, flags=[ USER_SET|USER_SENSITIVE_WHEN_GRANTED|USER_SENSITIVE_WHEN_DENIED]
      com.google.android.permissioncontroller:

archef2000 avatar Oct 06 '24 19:10 archef2000

Okay, the permissions look good, but if you don't see keyword 'Background activity start for com.clipcascade' in logcat when text is copied, then Samsung may have some restrictions in place.

Sathvik-Rao avatar Oct 06 '24 19:10 Sathvik-Rao

I see this in logcat: I ActivityManager: Background started FGS: Allowed [callingPackage: com.clipcascade; callingUid: 10700; uidState: TOP ; uidBFSL: [BFSL]; intent: Intent { act=app.notifee.core.ForegroundService.START cmp=com.clipcascade/app.notifee.core.ForegroundService (has extras) }; code:PROC_STATE_TOP; tempAllowListReason:<null>; targetSdkVersion:34; callerTargetSdkVersion:34; startForegroundCount:0; bindFromPackage:null: isBindService:false]

archef2000 avatar Oct 06 '24 19:10 archef2000

Did you find this in your log: ClipboardService: ClipCascade pasted from your clipboard

Before that, can you check if ClipCascade has permission to display over other apps in your settings

Sathvik-Rao avatar Oct 06 '24 19:10 Sathvik-Rao

Yes the app can draw over other apps but didn't find it in the log

archef2000 avatar Oct 06 '24 19:10 archef2000

I will try to emulate it on Samsung device and will let you know if any further steps are needed.

Sathvik-Rao avatar Oct 06 '24 19:10 Sathvik-Rao

Ok thanks could also setup a remote session if needed.

archef2000 avatar Oct 06 '24 20:10 archef2000

Hi @archef2000,

I tested on Samsung Galaxy S20 Ultra (Android 12) and Samsung Galaxy S24+ (Android 14) using the official testing page here: Samsung Remote Test Lab.

It is working.

Sathvik-Rao avatar Oct 07 '24 03:10 Sathvik-Rao

I somehow can't login to RTL. Did you do the steps in this order? Or anything that I didn't? I am going to test it on my Tablet. https://github.com/Sathvik-Rao/ClipCascade/issues/6#issuecomment-2395407325

archef2000 avatar Oct 07 '24 05:10 archef2000

I am so sorry. My Tablet worked first try. I rebooted my phone again for a security patch and now it is working.

archef2000 avatar Oct 07 '24 07:10 archef2000

Glad to hear that!

Sathvik-Rao avatar Oct 07 '24 14:10 Sathvik-Rao