Skip to content

Commit

Permalink
added hidl interface
Browse files Browse the repository at this point in the history
updated dependencies
  • Loading branch information
capntrips committed Jun 21, 2023
1 parent ae559dd commit 31616f5
Show file tree
Hide file tree
Showing 43 changed files with 4,745 additions and 646 deletions.
33 changes: 33 additions & 0 deletions Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
android_app {
name: "BootControl",
srcs: [
"app/src/main/java/**/*.kt",
// TODO: fix setActiveBootSlot
"app/src/main/java/**/*.java",
"app/src/main/aidl/**/*.aidl",
],
resource_dirs: ["app/src/main/res"],
manifest: "app/src/main/AndroidManifest.xml",
static_libs: [
"androidx.activity_activity-compose",
"androidx.activity_activity-ktx",
"androidx.appcompat_appcompat",
"androidx.compose.foundation_foundation-layout",
"androidx.compose.material3_material3",
"androidx.compose.material_material-icons-extended",
"androidx.compose.material_material",
"androidx.compose.runtime_runtime",
"androidx.compose.ui_ui",
"androidx.core_core-ktx",
"androidx.core_core-splashscreen",
"androidx.lifecycle_lifecycle-runtime-ktx",
"androidx.lifecycle_lifecycle-viewmodel-compose",
"androidx.navigation_navigation-compose",
"com.google.android.material_material",
"hwbinder.stubs",
"com.github.topjohnwu.libsu_service",
"com.github.topjohnwu.libsu_core",
],
// TODO: build for api 29
platform_apis: true,
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Boot Control

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.
Boot Control is an Android app that toggles the active boot slot.

## Usage

Pressing the `Activate` button on the inactive slot will toggle the active slot.
Pressing the `Activate` button will toggle the active boot slot.
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build
/release
23 changes: 11 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ plugins {
}

android {
compileSdk 31
compileSdk 33

defaultConfig {
applicationId "com.github.capntrips.bootcontrol"
minSdk 31
targetSdk 31
minSdk 29
targetSdk 33
versionCode 2
versionName "1.0.0-alpha01"
versionName "1.0.0-alpha02"

vectorDrawables {
useSupportLibrary true
Expand All @@ -20,7 +20,8 @@ android {

buildTypes {
release {
minifyEnabled true
// TODO: fix minify
minifyEnabled false
}
}
compileOptions {
Expand All @@ -29,10 +30,10 @@ android {
}
kotlinOptions {
jvmTarget = '1.8'
useIR = true
}
buildFeatures {
compose true
aidl true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
Expand All @@ -49,20 +50,18 @@ dependencies {
implementation "androidx.activity:activity-compose:$activity_version"
implementation "androidx.activity:activity-ktx:$activity_version"
implementation "androidx.appcompat:appcompat:$appcompat_version"
implementation "androidx.compose.foundation:foundation-layout:$foundation_version"
implementation "androidx.compose.material3:material3:$material3_version"
implementation "androidx.compose.material:material-icons-extended:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.core:core-ktx:$core_version"
implementation "androidx.core:core-splashscreen:$splashscreen_version"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"
implementation "androidx.navigation:navigation-compose:$nav_version"
implementation "com.github.topjohnwu.libsu:core:$libsuVersion"
implementation "com.github.topjohnwu.libsu:io:$libsuVersion"
implementation "com.google.accompanist:accompanist-insets-ui:$accompanist_version"
implementation "com.google.accompanist:accompanist-swiperefresh:$accompanist_version"
implementation "com.google.accompanist:accompanist-systemuicontroller:$accompanist_version"
implementation "com.github.topjohnwu.libsu:service:$libsuVersion"
implementation "com.google.android.material:material:$material_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
implementation files('libs/hwbinder.stubs.jar')
}
Binary file added app/libs/hwbinder.stubs.jar
Binary file not shown.
6 changes: 4 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?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.github.capntrips.bootcontrol">

<application
Expand All @@ -8,7 +9,9 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Material3.DayNight.NoActionBar">
android:theme="@style/Theme.BootControl"
android:dataExtractionRules="@xml/data_extraction_rules"
tools:targetApi="s">
<activity
android:name="com.github.capntrips.bootcontrol.MainActivity"
android:exported="true"
Expand All @@ -19,5 +22,4 @@
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.github.capntrips.bootcontrol;

interface IBootControlService {
String halInfo();
float halVersion();
int getNumberSlots();
int getCurrentSlot();
boolean setActiveBootSlot(int slot);
boolean isSlotBootable(int slot);
boolean isSlotMarkedSuccessful(int slot);
String getSuffix(int slot);
int getActiveBootSlot();
}
40 changes: 40 additions & 0 deletions app/src/main/java/android/hardware/boot/V1_0/BoolResult.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package android.hardware.boot.V1_0;


public final class BoolResult {
public static final int FALSE = 0;
public static final int TRUE = 1;
public static final int INVALID_SLOT = -1 /* -1 */;
public static final String toString(int o) {
if (o == FALSE) {
return "FALSE";
}
if (o == TRUE) {
return "TRUE";
}
if (o == INVALID_SLOT) {
return "INVALID_SLOT";
}
return "0x" + Integer.toHexString(o);
}

public static final String dumpBitfield(int o) {
java.util.ArrayList<String> list = new java.util.ArrayList<>();
int flipped = 0;
list.add("FALSE"); // FALSE == 0
if ((o & TRUE) == TRUE) {
list.add("TRUE");
flipped |= TRUE;
}
if ((o & INVALID_SLOT) == INVALID_SLOT) {
list.add("INVALID_SLOT");
flipped |= INVALID_SLOT;
}
if (o != flipped) {
list.add("0x" + Integer.toHexString(o & (~flipped)));
}
return String.join(" | ", list);
}

};

115 changes: 115 additions & 0 deletions app/src/main/java/android/hardware/boot/V1_0/CommandResult.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package android.hardware.boot.V1_0;


public final class CommandResult {
public boolean success = false;
public String errMsg = new String();

@Override
public final boolean equals(Object otherObject) {
if (this == otherObject) {
return true;
}
if (otherObject == null) {
return false;
}
if (otherObject.getClass() != android.hardware.boot.V1_0.CommandResult.class) {
return false;
}
android.hardware.boot.V1_0.CommandResult other = (android.hardware.boot.V1_0.CommandResult)otherObject;
if (this.success != other.success) {
return false;
}
if (!android.os.HidlSupport.deepEquals(this.errMsg, other.errMsg)) {
return false;
}
return true;
}

@Override
public final int hashCode() {
return java.util.Objects.hash(
android.os.HidlSupport.deepHashCode(this.success),
android.os.HidlSupport.deepHashCode(this.errMsg));
}

@Override
public final String toString() {
java.lang.StringBuilder builder = new java.lang.StringBuilder();
builder.append("{");
builder.append(".success = ");
builder.append(this.success);
builder.append(", .errMsg = ");
builder.append(this.errMsg);
builder.append("}");
return builder.toString();
}

public final void readFromParcel(android.os.HwParcel parcel) {
android.os.HwBlob blob = parcel.readBuffer(24 /* size */);
readEmbeddedFromParcel(parcel, blob, 0 /* parentOffset */);
}

public static final java.util.ArrayList<CommandResult> readVectorFromParcel(android.os.HwParcel parcel) {
java.util.ArrayList<CommandResult> _hidl_vec = new java.util.ArrayList();
android.os.HwBlob _hidl_blob = parcel.readBuffer(16 /* sizeof hidl_vec<T> */);

{
int _hidl_vec_size = _hidl_blob.getInt32(0 + 8 /* offsetof(hidl_vec<T>, mSize) */);
android.os.HwBlob childBlob = parcel.readEmbeddedBuffer(
_hidl_vec_size * 24,_hidl_blob.handle(),
0 + 0 /* offsetof(hidl_vec<T>, mBuffer) */,true /* nullable */);

_hidl_vec.clear();
for (int _hidl_index_0 = 0; _hidl_index_0 < _hidl_vec_size; ++_hidl_index_0) {
android.hardware.boot.V1_0.CommandResult _hidl_vec_element = new android.hardware.boot.V1_0.CommandResult();
((android.hardware.boot.V1_0.CommandResult) _hidl_vec_element).readEmbeddedFromParcel(parcel, childBlob, _hidl_index_0 * 24);
_hidl_vec.add(_hidl_vec_element);
}
}

return _hidl_vec;
}

public final void readEmbeddedFromParcel(
android.os.HwParcel parcel, android.os.HwBlob _hidl_blob, long _hidl_offset) {
success = _hidl_blob.getBool(_hidl_offset + 0);
errMsg = _hidl_blob.getString(_hidl_offset + 8);

parcel.readEmbeddedBuffer(
((String) errMsg).getBytes().length + 1,
_hidl_blob.handle(),
_hidl_offset + 8 + 0 /* offsetof(hidl_string, mBuffer) */,false /* nullable */);

}

public final void writeToParcel(android.os.HwParcel parcel) {
android.os.HwBlob _hidl_blob = new android.os.HwBlob(24 /* size */);
writeEmbeddedToBlob(_hidl_blob, 0 /* parentOffset */);
parcel.writeBuffer(_hidl_blob);
}

public static final void writeVectorToParcel(
android.os.HwParcel parcel, java.util.ArrayList<CommandResult> _hidl_vec) {
android.os.HwBlob _hidl_blob = new android.os.HwBlob(16 /* sizeof(hidl_vec<T>) */);
{
int _hidl_vec_size = _hidl_vec.size();
_hidl_blob.putInt32(0 + 8 /* offsetof(hidl_vec<T>, mSize) */, _hidl_vec_size);
_hidl_blob.putBool(0 + 12 /* offsetof(hidl_vec<T>, mOwnsBuffer) */, false);
android.os.HwBlob childBlob = new android.os.HwBlob((int)(_hidl_vec_size * 24));
for (int _hidl_index_0 = 0; _hidl_index_0 < _hidl_vec_size; ++_hidl_index_0) {
_hidl_vec.get(_hidl_index_0).writeEmbeddedToBlob(childBlob, _hidl_index_0 * 24);
}
_hidl_blob.putBlob(0 + 0 /* offsetof(hidl_vec<T>, mBuffer) */, childBlob);
}

parcel.writeBuffer(_hidl_blob);
}

public final void writeEmbeddedToBlob(
android.os.HwBlob _hidl_blob, long _hidl_offset) {
_hidl_blob.putBool(_hidl_offset + 0, success);
_hidl_blob.putString(_hidl_offset + 8, errMsg);
}
};

Loading

0 comments on commit 31616f5

Please sign in to comment.