1 Star 0 Fork 0

3ystem / Shizuku-API

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Shizuku-API

API and developer guide for Shizuku and Sui.

The concept is "same API, different implementation", Shizuku and Sui shares the API design. As the application developer, you only need to write the code once to support both Shizuku and Sui.

Introduction

First of all, please read the README of Shizuku and Sui, so that you will have a basic understanding of how Shizuku and Sui works.

The most important functions provided by Shizuku API is "remote binder call" and "user service".

  • Remote binder call

    Call any Android APIs which uses binder (such as getInstalledPackages) as the identity of root (or adb).

  • User service

    Similar to Bound services, but the service runs as the identity of root (or adb). JNI is also supported.

Requirements

Shizuku and Sui requires the user to install something first.

Sui

  • Requires Magisk
  • Requires the user to install two Magisk modules, "Riru" and "Riru - Sui"

Shizuku

  • Requires root or adb
    • For adb, it's required to manually restart with adb everytime on boot
    • For adb, of course, only has limited permissions of adb
  • Requires the user to install a standalone app, Shizuku

Make a choice

For root-only apps, continue to support the old school "su" or not, you may have to make this choice.

Since Sui is possible to be bundled in Magisk in the future (Riru is already in Magisk), abandon old school "su" is not a bad choice.

For existing applications, there is an API that allows you to create a "sh" as root (or adb), so you can always do what was previously possible.

Migrating from "su"

  • Simple applications which only use commands like pm am

    Use "Remote binder call".

  • Complicated applications such as root file managers

    Use "User service".

  • Complicated applications which heavily depend on commands in Linux world

    Use "User service" with JNI or continue to use shell.

Migration guide for existing applications use Shizuku pre-v11

Click to expand

Changes

  • Dependency changed (see Guide below)
  • Self-implemented permission is used from v11, the API is same to runtime permission (see demo, and existing runtime permission still works)
  • Package name is rename to rikka.shizuku (replace all moe.shizuku.api. to rikka.shizuku.)
  • ShizukuService class is renamed to Shizuku
  • Methods in Shizuku class now throw RuntimeException rather than RemoteException like other Android APIs
  • Listeners are moved from ShizukuProvider class to Shizuku class

Add support for Sui

  • Call Sui#init()
  • Do not use ShizukuProvider#isShizukuInstalled since Sui does not have a manager
  • It's better to use check Sui with Sui#isSui before using Shizuku only methods in ShizukuProvider

Guide

Note, something is not mentioned below, please be sure to read the demo.

  1. Add dependency

    repositories {
        mavenCentral()
    }
    def shizuku_version = '11.0.2'
    implementation "dev.rikka.shizuku:api:$shizuku_version"
    
    // add this if you want to support Shizuku
    implementation "dev.rikka.shizuku:provider:$shizuku_version"

    Since all root users using Shizuku will eventually switch to Sui, if your application requires root, it's better not to support Shizuku from the begining.

  2. Add ShizukuProvider (Shizuku only)

    Don't add this if your app only supports Sui.

    Add to your AndroidManifest.xml.

    <provider
         android:name="rikka.shizuku.ShizukuProvider"
         android:authorities="${applicationId}.shizuku"
         android:multiprocess="false"
         android:enabled="true"
         android:exported="true"
         android:permission="android.permission.INTERACT_ACROSS_USERS_FULL" />
  3. Use

    See demo.

MIT License Copyright (c) 2021 RikkaW Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
Java
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/xyz_3ystem/Shizuku-API.git
git@gitee.com:xyz_3ystem/Shizuku-API.git
xyz_3ystem
Shizuku-API
Shizuku-API
master

搜索帮助