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

Commit 31616f5

Browse files
committed
added hidl interface
updated dependencies
1 parent ae559dd commit 31616f5

43 files changed

Lines changed: 4745 additions & 646 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Android.bp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
android_app {
2+
name: "BootControl",
3+
srcs: [
4+
"app/src/main/java/**/*.kt",
5+
// TODO: fix setActiveBootSlot
6+
"app/src/main/java/**/*.java",
7+
"app/src/main/aidl/**/*.aidl",
8+
],
9+
resource_dirs: ["app/src/main/res"],
10+
manifest: "app/src/main/AndroidManifest.xml",
11+
static_libs: [
12+
"androidx.activity_activity-compose",
13+
"androidx.activity_activity-ktx",
14+
"androidx.appcompat_appcompat",
15+
"androidx.compose.foundation_foundation-layout",
16+
"androidx.compose.material3_material3",
17+
"androidx.compose.material_material-icons-extended",
18+
"androidx.compose.material_material",
19+
"androidx.compose.runtime_runtime",
20+
"androidx.compose.ui_ui",
21+
"androidx.core_core-ktx",
22+
"androidx.core_core-splashscreen",
23+
"androidx.lifecycle_lifecycle-runtime-ktx",
24+
"androidx.lifecycle_lifecycle-viewmodel-compose",
25+
"androidx.navigation_navigation-compose",
26+
"com.google.android.material_material",
27+
"hwbinder.stubs",
28+
"com.github.topjohnwu.libsu_service",
29+
"com.github.topjohnwu.libsu_core",
30+
],
31+
// TODO: build for api 29
32+
platform_apis: true,
33+
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Boot Control
22

3-
Boot Control is an Android app that toggles the active slot. It first attempts to modify the `devinfo` partition, if a valid one is found, then falls back on modifying the partition table entries of the `boot` partitions.
3+
Boot Control is an Android app that toggles the active boot slot.
44

55
## Usage
66

7-
Pressing the `Activate` button on the inactive slot will toggle the active slot.
7+
Pressing the `Activate` button will toggle the active boot slot.

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/build
2+
/release

app/build.gradle

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ plugins {
44
}
55

66
android {
7-
compileSdk 31
7+
compileSdk 33
88

99
defaultConfig {
1010
applicationId "com.github.capntrips.bootcontrol"
11-
minSdk 31
12-
targetSdk 31
11+
minSdk 29
12+
targetSdk 33
1313
versionCode 2
14-
versionName "1.0.0-alpha01"
14+
versionName "1.0.0-alpha02"
1515

1616
vectorDrawables {
1717
useSupportLibrary true
@@ -20,7 +20,8 @@ android {
2020

2121
buildTypes {
2222
release {
23-
minifyEnabled true
23+
// TODO: fix minify
24+
minifyEnabled false
2425
}
2526
}
2627
compileOptions {
@@ -29,10 +30,10 @@ android {
2930
}
3031
kotlinOptions {
3132
jvmTarget = '1.8'
32-
useIR = true
3333
}
3434
buildFeatures {
3535
compose true
36+
aidl true
3637
}
3738
composeOptions {
3839
kotlinCompilerExtensionVersion compose_version
@@ -49,20 +50,18 @@ dependencies {
4950
implementation "androidx.activity:activity-compose:$activity_version"
5051
implementation "androidx.activity:activity-ktx:$activity_version"
5152
implementation "androidx.appcompat:appcompat:$appcompat_version"
53+
implementation "androidx.compose.foundation:foundation-layout:$foundation_version"
5254
implementation "androidx.compose.material3:material3:$material3_version"
5355
implementation "androidx.compose.material:material-icons-extended:$compose_version"
5456
implementation "androidx.compose.material:material:$compose_version"
55-
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
5657
implementation "androidx.compose.ui:ui:$compose_version"
5758
implementation "androidx.core:core-ktx:$core_version"
5859
implementation "androidx.core:core-splashscreen:$splashscreen_version"
5960
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
6061
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"
62+
implementation "androidx.navigation:navigation-compose:$nav_version"
6163
implementation "com.github.topjohnwu.libsu:core:$libsuVersion"
62-
implementation "com.github.topjohnwu.libsu:io:$libsuVersion"
63-
implementation "com.google.accompanist:accompanist-insets-ui:$accompanist_version"
64-
implementation "com.google.accompanist:accompanist-swiperefresh:$accompanist_version"
65-
implementation "com.google.accompanist:accompanist-systemuicontroller:$accompanist_version"
64+
implementation "com.github.topjohnwu.libsu:service:$libsuVersion"
6665
implementation "com.google.android.material:material:$material_version"
67-
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
66+
implementation files('libs/hwbinder.stubs.jar')
6867
}

app/libs/hwbinder.stubs.jar

8.59 KB
Binary file not shown.

app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
34
package="com.github.capntrips.bootcontrol">
45

56
<application
@@ -8,7 +9,9 @@
89
android:label="@string/app_name"
910
android:roundIcon="@mipmap/ic_launcher_round"
1011
android:supportsRtl="true"
11-
android:theme="@style/Theme.Material3.DayNight.NoActionBar">
12+
android:theme="@style/Theme.BootControl"
13+
android:dataExtractionRules="@xml/data_extraction_rules"
14+
tools:targetApi="s">
1215
<activity
1316
android:name="com.github.capntrips.bootcontrol.MainActivity"
1417
android:exported="true"
@@ -19,5 +22,4 @@
1922
</intent-filter>
2023
</activity>
2124
</application>
22-
2325
</manifest>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.github.capntrips.bootcontrol;
2+
3+
interface IBootControlService {
4+
String halInfo();
5+
float halVersion();
6+
int getNumberSlots();
7+
int getCurrentSlot();
8+
boolean setActiveBootSlot(int slot);
9+
boolean isSlotBootable(int slot);
10+
boolean isSlotMarkedSuccessful(int slot);
11+
String getSuffix(int slot);
12+
int getActiveBootSlot();
13+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package android.hardware.boot.V1_0;
2+
3+
4+
public final class BoolResult {
5+
public static final int FALSE = 0;
6+
public static final int TRUE = 1;
7+
public static final int INVALID_SLOT = -1 /* -1 */;
8+
public static final String toString(int o) {
9+
if (o == FALSE) {
10+
return "FALSE";
11+
}
12+
if (o == TRUE) {
13+
return "TRUE";
14+
}
15+
if (o == INVALID_SLOT) {
16+
return "INVALID_SLOT";
17+
}
18+
return "0x" + Integer.toHexString(o);
19+
}
20+
21+
public static final String dumpBitfield(int o) {
22+
java.util.ArrayList<String> list = new java.util.ArrayList<>();
23+
int flipped = 0;
24+
list.add("FALSE"); // FALSE == 0
25+
if ((o & TRUE) == TRUE) {
26+
list.add("TRUE");
27+
flipped |= TRUE;
28+
}
29+
if ((o & INVALID_SLOT) == INVALID_SLOT) {
30+
list.add("INVALID_SLOT");
31+
flipped |= INVALID_SLOT;
32+
}
33+
if (o != flipped) {
34+
list.add("0x" + Integer.toHexString(o & (~flipped)));
35+
}
36+
return String.join(" | ", list);
37+
}
38+
39+
};
40+
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
package android.hardware.boot.V1_0;
2+
3+
4+
public final class CommandResult {
5+
public boolean success = false;
6+
public String errMsg = new String();
7+
8+
@Override
9+
public final boolean equals(Object otherObject) {
10+
if (this == otherObject) {
11+
return true;
12+
}
13+
if (otherObject == null) {
14+
return false;
15+
}
16+
if (otherObject.getClass() != android.hardware.boot.V1_0.CommandResult.class) {
17+
return false;
18+
}
19+
android.hardware.boot.V1_0.CommandResult other = (android.hardware.boot.V1_0.CommandResult)otherObject;
20+
if (this.success != other.success) {
21+
return false;
22+
}
23+
if (!android.os.HidlSupport.deepEquals(this.errMsg, other.errMsg)) {
24+
return false;
25+
}
26+
return true;
27+
}
28+
29+
@Override
30+
public final int hashCode() {
31+
return java.util.Objects.hash(
32+
android.os.HidlSupport.deepHashCode(this.success),
33+
android.os.HidlSupport.deepHashCode(this.errMsg));
34+
}
35+
36+
@Override
37+
public final String toString() {
38+
java.lang.StringBuilder builder = new java.lang.StringBuilder();
39+
builder.append("{");
40+
builder.append(".success = ");
41+
builder.append(this.success);
42+
builder.append(", .errMsg = ");
43+
builder.append(this.errMsg);
44+
builder.append("}");
45+
return builder.toString();
46+
}
47+
48+
public final void readFromParcel(android.os.HwParcel parcel) {
49+
android.os.HwBlob blob = parcel.readBuffer(24 /* size */);
50+
readEmbeddedFromParcel(parcel, blob, 0 /* parentOffset */);
51+
}
52+
53+
public static final java.util.ArrayList<CommandResult> readVectorFromParcel(android.os.HwParcel parcel) {
54+
java.util.ArrayList<CommandResult> _hidl_vec = new java.util.ArrayList();
55+
android.os.HwBlob _hidl_blob = parcel.readBuffer(16 /* sizeof hidl_vec<T> */);
56+
57+
{
58+
int _hidl_vec_size = _hidl_blob.getInt32(0 + 8 /* offsetof(hidl_vec<T>, mSize) */);
59+
android.os.HwBlob childBlob = parcel.readEmbeddedBuffer(
60+
_hidl_vec_size * 24,_hidl_blob.handle(),
61+
0 + 0 /* offsetof(hidl_vec<T>, mBuffer) */,true /* nullable */);
62+
63+
_hidl_vec.clear();
64+
for (int _hidl_index_0 = 0; _hidl_index_0 < _hidl_vec_size; ++_hidl_index_0) {
65+
android.hardware.boot.V1_0.CommandResult _hidl_vec_element = new android.hardware.boot.V1_0.CommandResult();
66+
((android.hardware.boot.V1_0.CommandResult) _hidl_vec_element).readEmbeddedFromParcel(parcel, childBlob, _hidl_index_0 * 24);
67+
_hidl_vec.add(_hidl_vec_element);
68+
}
69+
}
70+
71+
return _hidl_vec;
72+
}
73+
74+
public final void readEmbeddedFromParcel(
75+
android.os.HwParcel parcel, android.os.HwBlob _hidl_blob, long _hidl_offset) {
76+
success = _hidl_blob.getBool(_hidl_offset + 0);
77+
errMsg = _hidl_blob.getString(_hidl_offset + 8);
78+
79+
parcel.readEmbeddedBuffer(
80+
((String) errMsg).getBytes().length + 1,
81+
_hidl_blob.handle(),
82+
_hidl_offset + 8 + 0 /* offsetof(hidl_string, mBuffer) */,false /* nullable */);
83+
84+
}
85+
86+
public final void writeToParcel(android.os.HwParcel parcel) {
87+
android.os.HwBlob _hidl_blob = new android.os.HwBlob(24 /* size */);
88+
writeEmbeddedToBlob(_hidl_blob, 0 /* parentOffset */);
89+
parcel.writeBuffer(_hidl_blob);
90+
}
91+
92+
public static final void writeVectorToParcel(
93+
android.os.HwParcel parcel, java.util.ArrayList<CommandResult> _hidl_vec) {
94+
android.os.HwBlob _hidl_blob = new android.os.HwBlob(16 /* sizeof(hidl_vec<T>) */);
95+
{
96+
int _hidl_vec_size = _hidl_vec.size();
97+
_hidl_blob.putInt32(0 + 8 /* offsetof(hidl_vec<T>, mSize) */, _hidl_vec_size);
98+
_hidl_blob.putBool(0 + 12 /* offsetof(hidl_vec<T>, mOwnsBuffer) */, false);
99+
android.os.HwBlob childBlob = new android.os.HwBlob((int)(_hidl_vec_size * 24));
100+
for (int _hidl_index_0 = 0; _hidl_index_0 < _hidl_vec_size; ++_hidl_index_0) {
101+
_hidl_vec.get(_hidl_index_0).writeEmbeddedToBlob(childBlob, _hidl_index_0 * 24);
102+
}
103+
_hidl_blob.putBlob(0 + 0 /* offsetof(hidl_vec<T>, mBuffer) */, childBlob);
104+
}
105+
106+
parcel.writeBuffer(_hidl_blob);
107+
}
108+
109+
public final void writeEmbeddedToBlob(
110+
android.os.HwBlob _hidl_blob, long _hidl_offset) {
111+
_hidl_blob.putBool(_hidl_offset + 0, success);
112+
_hidl_blob.putString(_hidl_offset + 8, errMsg);
113+
}
114+
};
115+

0 commit comments

Comments
 (0)