Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
iamr0s committed Apr 10, 2023
0 parents commit 1f24bdb
Show file tree
Hide file tree
Showing 163 changed files with 5,026 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.iml
.gradle
/local.properties
/.idea
.DS_Store
/build
/captures
/keystore
.externalNativeBuild
.cxx
local.properties
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Dhizuku

## 介绍

参考Shizuku的设计思想,分享 DeviceOwner (设备所有者) 权限给其余应用

## 支持版本

Android 5.0 ~ 13

## 捐赠支持

- [支付宝](https://qr.alipay.com/fkx18580lfpydiop04dze47)
- [微信](https://missuo.ru/file/fee5df1381671c996b127.png)
- [币安](https://missuo.ru/file/fee5df1381671c996b127.png)

## 开源协议

Dhizuku目前基于 [**GNU General Public License v3 (GPL-3)**](http://www.gnu.org/copyleft/gpl.html) 开源,但不保证未来依然继续遵循此协议或开源,有权更改开源协议或开源状态。

当您选择基于Dhizuku进行开发时,需遵循所当前依赖的上游源码所规定的开源协议,不受新上游源码的开源协议影响。
3 changes: 3 additions & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/build
/debug
/release
134 changes: 134 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import java.io.FileInputStream
import java.util.*

@Suppress("DSL_SCOPE_VIOLATION")
plugins {
alias(libs.plugins.agp.app)
alias(libs.plugins.kotlin)
id("kotlin-kapt")
}

val keystoreProps = Properties().apply {
load(FileInputStream(rootProject.file("keystore/r0s.properties")))
}

@Suppress("UnstableApiUsage")
android {
compileSdk = 33

defaultConfig {
// 你如果根据InstallerX的源码进行打包成apk或其他安装包格式
// 请换一个applicationId,不要和官方的任何发布版本产生冲突。
// If you use InstallerX source code, package it into apk or other installation package format
// Please change the applicationId to one that does not conflict with any official release.
applicationId = "com.rosan.dhizuku"
minSdk = 21
targetSdk = 33
versionCode = 2
versionName = "1.0.2"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}

signingConfigs {
getByName("debug") {
keyAlias = keystoreProps.getProperty("keyAlias")
keyPassword = keystoreProps.getProperty("keyPassword")
storeFile = file(keystoreProps.getProperty("storeFile"))
storePassword = keystoreProps.getProperty("storePassword")
enableV1Signing = true
enableV2Signing = true
}

create("release") {
keyAlias = keystoreProps.getProperty("keyAlias")
keyPassword = keystoreProps.getProperty("keyPassword")
storeFile = file(keystoreProps.getProperty("storeFile"))
storePassword = keystoreProps.getProperty("storePassword")
enableV1Signing = true
enableV2Signing = true
}
}

buildTypes {
getByName("debug") {
signingConfig = signingConfigs.getByName("debug")
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}

getByName("release") {
signingConfig = signingConfigs.getByName("release")
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}

compileOptions {
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_11
}

kotlin {
jvmToolchain(11)
}

buildFeatures {
compose = true
}

composeOptions {
// kotlinCompilerExtensionVersion = libs.versions.compose.get()
kotlinCompilerExtensionVersion = "1.4.4"
}

packagingOptions {
resources {
excludes.add("/META-INF/{AL2.0,LGPL2.1}")
}
}
}

dependencies {
implementation(project(":dhizuku-aidl"))
implementation(project(":dhizuku-shared"))

implementation(libs.androidx.core)
implementation(libs.androidx.lifecycle)
implementation(libs.androidx.activity.compose)
implementation(libs.compose.ui)
implementation(libs.compose.material)
implementation(libs.compose.material3)
implementation(libs.compose.uiToolingPreview)

implementation(libs.compose.navigation)
implementation(libs.compose.materialIcons)

implementation(libs.room.runtime)
kapt(libs.room.compiler)
implementation(libs.room.ktx)

implementation(libs.koin.core)
implementation(libs.koin.android)
implementation(libs.koin.compose)

implementation(libs.accompanist)
implementation(libs.accompanist.navigationAnimation)
implementation(libs.accompanist.flowlayout)
implementation(libs.accompanist.drawablepainter)
implementation(libs.accompanist.systemuicontroller)

implementation(libs.xxpermissions)

implementation(libs.rikka.shizuku.api)
implementation(libs.rikka.shizuku.provider)
}
81 changes: 81 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.kts.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

###############################
# kotlinx serialization rules #
###############################
# Keep `Companion` object fields of serializable classes.
# This avoids serializer lookup through `getDeclaredClasses` as done for named companion objects.
-if @kotlinx.serialization.Serializable class **
-keepclassmembers class <1> {
static <1>$Companion Companion;
}

# Keep `serializer()` on companion objects (both default and named) of serializable classes.
-if @kotlinx.serialization.Serializable class ** {
static **$* *;
}
-keepclassmembers class <2>$<3> {
kotlinx.serialization.KSerializer serializer(...);
}

# Keep `INSTANCE.serializer()` of serializable objects.
-if @kotlinx.serialization.Serializable class ** {
public static ** INSTANCE;
}
-keepclassmembers class <1> {
public static <1> INSTANCE;
kotlinx.serialization.KSerializer serializer(...);
}

# @Serializable and @Polymorphic are used at runtime for polymorphic serialization.
-keepattributes RuntimeVisibleAnnotations,AnnotationDefault

# Serializer for classes with named companion objects are retrieved using `getDeclaredClasses`.
# If you have any, uncomment and replace classes with those containing named companion objects.
#-keepattributes InnerClasses # Needed for `getDeclaredClasses`.
#-if @kotlinx.serialization.Serializable class
#com.example.myapplication.HasNamedCompanion, # <-- List serializable classes with named companions.
#com.example.myapplication.HasNamedCompanion2
#{
# static **$* *;
#}
#-keepnames class <1>$$serializer { # -keepnames suffices; class is kept when serializer() is kept.
# static <1>$$serializer INSTANCE;
#}

-keep public class android.** {*;}
-keep public class com.rosan.dhizuku.App {*;}
-keep public class com.rosan.dhizuku.ui.activity.** extends android.app.Activity
-keep public class com.rosan.dhizuku.data.process.model.impl.** {
public static void main(java.lang.String[]);
}
#-keep public class com.rosan.installer.data.process.model.impl.** extends com.rosan.installer.data.process.repo.ProcessRepo {
#public static void main(java.lang.String[]);
#}
#-keep public class com.rosan.installer.** extends android.app.Service
#-keep public class com.rosan.installer.** extends android.content.BroadcastReceiver
#-keep public class com.rosan.installer.** extends android.content.ContentProvider
#-keep class androidx.core.content.FileProvider {*;}
#-keep interface androidx.core.content.FileProvider$PathStrategy {*;}

-keep class rikka.shizuku.ShizukuProvider
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.rosan.dhizuku

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.rosan.installer", appContext.packageName)
}
}
101 changes: 101 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.rosan.dhizuku">

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission
android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />


<uses-sdk tools:overrideLibrary="rikka.shizuku.api, rikka.shizuku.provider, rikka.shizuku.shared, rikka.shizuku.aidl" />

<permission-group
android:name="com.rosan.dhizuku.permission-group.API"
android:description="@string/dhizuku_permission_group_dsp"
android:label="@string/dhizuku_permission_group_label" />

<permission
android:name="com.rosan.dhizuku.permission.API"
android:description="@string/dhizuku_permission_api_dsp"
android:icon="@mipmap/ic_launcher"
android:label="@string/dhizuku_permission_api_label"
android:protectionLevel="normal" />

<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:persistent="true"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Dhizuku">

<activity
android:name=".ui.activity.SettingsActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".ui.activity.RequestPermissionActivity"
android:excludeFromRecents="false"
android:exported="true"
android:permission="com.rosan.dhizuku.permission.API"
android:theme="@style/Theme.Dhizuku.Translucent">
<intent-filter>
<action android:name="${applicationId}.action.request.permission" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<provider
android:name="com.rosan.dhizuku.server.DhizukuProvider"
android:authorities="com.rosan.dhizuku.server.provider"
android:directBootAware="true"
android:enabled="true"
android:exported="true"
android:permission="com.rosan.dhizuku.permission.API">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</provider>

<receiver
android:name=".server.DhizukuDAReceiver"
android:exported="false"
android:permission="android.permission.BIND_DEVICE_ADMIN">
<meta-data
android:name="android.app.device_admin"
android:resource="@xml/device_admin" />
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
<action android:name="android.app.action.DEVICE_ADMIN_DISABLE_REQUESTED" />
<action android:name="android.app.action.DEVICE_ADMIN_DISABLED" />
</intent-filter>
</receiver>

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

</application>

</manifest>
9 changes: 9 additions & 0 deletions app/src/main/aidl/android/content/IIntentReceiver.aidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package android.content;

import android.content.Intent;
import android.os.Bundle;

oneway interface IIntentReceiver {
void performReceive(in Intent intent, int resultCode, String data,
in Bundle extras, boolean ordered, boolean sticky, int sendingUser);
}
Loading

0 comments on commit 1f24bdb

Please sign in to comment.