Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ implementation 'io.github.iamr0s:AndroidAppProcess:<version>'

```java
AppProcess process = new AppProcess.Default();
process.init(context.getPackageName());
process.init(context);
```

- Root

```java
AppProcess process = new AppProcess.Root();
process.init(context.getPackageName());
process.init(context);
```

### 2. Use it.
Expand All @@ -34,13 +34,13 @@ process.init(context.getPackageName());

```java
AppProcess process = new AppProcess.Root();
process.init(context.getPackageName());
process.init(context);

IPackageManager manager = android.os.ServiceManager.getService("package");
IBinder manager = ServiceManager.getService("package");
IBinder binderWrapper = process.binderWrapper(manager.asBinder());
IPackageManager managerWrapper = IPackageManager.Stub.asInterface(binderWrapper);

managerWrapper.uninstall(...) // will call it in root.
managerWrapper.uninstall(...); // will call it in root.
```

- More
Expand Down
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ android {
}

dependencies {
compileOnly project(":hidden-api")
implementation project(":app-process")
}
46 changes: 46 additions & 0 deletions app/src/main/java/com/rosan/app_process/demo/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,59 @@
package com.rosan.app_process.demo;

import android.app.Activity;
import android.content.pm.IPackageManager;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.widget.TextView;
import android.widget.Toast;

import com.rosan.app_process.AppProcess;

import java.util.Arrays;

public class MainActivity extends Activity {

private void makeText(String msg) {
runOnUiThread(() -> Toast.makeText(this, msg, Toast.LENGTH_SHORT).show());
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

AppProcess process = new AppProcess.Default();
if (!process.init(this)) {
makeText("AppProcess: failed initialize.");
finishAndRemoveTask();
return;
}

IBinder manager = ServiceManager.getService("package");
IBinder binderWrapper;
try {
binderWrapper = process.binderWrapper(manager);
} catch (IllegalStateException ignored) {
makeText("AppProcess: please call init() first.");
finishAndRemoveTask();
return;
}
IPackageManager managerWrapper = IPackageManager.Stub.asInterface(binderWrapper);

String[] libraries = new String[]{"NULL"};
try {
if (managerWrapper != null) {
libraries = managerWrapper.getSystemSharedLibraryNames();
}
} catch (RemoteException ignored) {
makeText("RemoteException occurred.");
}

TextView text = findViewById(R.id.text);
text.setText(Arrays.toString(libraries));

process.close();
}
}
5 changes: 3 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">

<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />

</LinearLayout>
</ScrollView>
4 changes: 4 additions & 0 deletions hidden-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ android {
minSdk = 19
}

buildFeatures {
aidl = true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package android.content.pm;

interface IPackageManager {
String[] getSystemSharedLibraryNames();
}