mirror of
https://github.com/topjohnwu/libsu.git
synced 2025-02-17 10:38:37 +00:00
Several minor changes
This commit is contained in:
parent
23659fa64e
commit
aa3a33143e
@ -14,7 +14,7 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath("com.android.tools.build:gradle:7.0.0")
|
||||
classpath("com.android.tools.build:gradle:7.0.3")
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
@ -24,8 +24,8 @@ buildscript {
|
||||
val dlPackageList by tasks.registering {
|
||||
outputs.upToDateWhen { false }
|
||||
doLast {
|
||||
/* Merge framework packages with AndroidX packages into the same list
|
||||
* so links to Android classes can work properly in Javadoc */
|
||||
// Merge framework packages with AndroidX packages into the same list
|
||||
// so links to Android classes can work properly in Javadoc
|
||||
rootProject.buildDir.mkdirs()
|
||||
File(rootProject.buildDir, "package-list").outputStream().use { out ->
|
||||
URL("https://developer.android.com/reference/package-list")
|
||||
@ -91,13 +91,13 @@ subprojects {
|
||||
|
||||
afterEvaluate {
|
||||
android {
|
||||
compileSdkVersion(30)
|
||||
buildToolsVersion = "30.0.3"
|
||||
compileSdkVersion(31)
|
||||
buildToolsVersion = "31.0.0"
|
||||
|
||||
defaultConfig {
|
||||
if (minSdkVersion == null)
|
||||
minSdk = 14
|
||||
targetSdk = 30
|
||||
targetSdk = 31
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
|
@ -12,6 +12,6 @@ android {
|
||||
|
||||
dependencies {
|
||||
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
|
||||
api("androidx.annotation:annotation:1.1.0")
|
||||
javadocDeps("androidx.annotation:annotation:1.1.0")
|
||||
api("androidx.annotation:annotation:1.3.0")
|
||||
javadocDeps("androidx.annotation:annotation:1.3.0")
|
||||
}
|
||||
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright 2021 John "topjohnwu" Wu
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.topjohnwu.superuser.internal;
|
||||
|
||||
public class Container<T> {
|
||||
public T obj;
|
||||
}
|
@ -9,10 +9,11 @@
|
||||
android:label="LibSUExample"
|
||||
android:supportsRtl="true"
|
||||
tools:ignore="GoogleAppIndexingWarning">
|
||||
<activity android:name=".MainActivity">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
@ -16,6 +16,9 @@
|
||||
|
||||
package com.topjohnwu.superuser.internal;
|
||||
|
||||
import static com.topjohnwu.superuser.internal.IOFactory.JUNK;
|
||||
import static com.topjohnwu.superuser.internal.Utils.UTF_8;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.topjohnwu.superuser.Shell;
|
||||
@ -27,9 +30,6 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.topjohnwu.superuser.internal.IOFactory.JUNK;
|
||||
import static com.topjohnwu.superuser.internal.Utils.UTF_8;
|
||||
|
||||
class ShellIO extends SuRandomAccessFile implements DataInputImpl, DataOutputImpl {
|
||||
|
||||
private static final String TAG = "SHELLIO";
|
||||
@ -191,8 +191,7 @@ class ShellIO extends SuRandomAccessFile implements DataInputImpl, DataOutputImp
|
||||
// fail fast
|
||||
if (eof)
|
||||
return 0;
|
||||
Container<Integer> total = new Container<>();
|
||||
total.obj = 0;
|
||||
int[] total = new int[1];
|
||||
int len = count * bs;
|
||||
Shell.getShell().execTask((in, out, err) -> {
|
||||
int off = _off;
|
||||
@ -204,17 +203,17 @@ class ShellIO extends SuRandomAccessFile implements DataInputImpl, DataOutputImp
|
||||
in.flush();
|
||||
|
||||
// Poll until we read everything
|
||||
while ((total.obj != len && err.available() == 0) || out.available() != 0) {
|
||||
while ((total[0] != len && err.available() == 0) || out.available() != 0) {
|
||||
int read = out.read(b, off, out.available());
|
||||
off += read;
|
||||
total.obj += read;
|
||||
total[0] += read;
|
||||
}
|
||||
// Wait till the operation is done for synchronization
|
||||
err.read(JUNK);
|
||||
});
|
||||
if (total.obj == 0 || total.obj != len)
|
||||
if (total[0] == 0 || total[0] != len)
|
||||
eof = true;
|
||||
return total.obj;
|
||||
return total[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,6 +16,13 @@
|
||||
|
||||
package com.topjohnwu.superuser.ipc;
|
||||
|
||||
import static com.topjohnwu.superuser.internal.IPCMain.getServiceName;
|
||||
import static com.topjohnwu.superuser.ipc.IPCClient.BUNDLE_BINDER_KEY;
|
||||
import static com.topjohnwu.superuser.ipc.IPCClient.INTENT_DEBUG_KEY;
|
||||
import static com.topjohnwu.superuser.ipc.IPCClient.INTENT_EXTRA_KEY;
|
||||
import static com.topjohnwu.superuser.ipc.IPCClient.LOGGING_ENV;
|
||||
import static com.topjohnwu.superuser.ipc.RootService.TAG;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@ -30,7 +37,6 @@ import android.os.RemoteException;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.topjohnwu.superuser.Shell;
|
||||
import com.topjohnwu.superuser.internal.Container;
|
||||
import com.topjohnwu.superuser.internal.IRootIPC;
|
||||
import com.topjohnwu.superuser.internal.UiThreadHandler;
|
||||
import com.topjohnwu.superuser.internal.Utils;
|
||||
@ -38,13 +44,6 @@ import com.topjohnwu.superuser.internal.Utils;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import static com.topjohnwu.superuser.internal.IPCMain.getServiceName;
|
||||
import static com.topjohnwu.superuser.ipc.IPCClient.BUNDLE_BINDER_KEY;
|
||||
import static com.topjohnwu.superuser.ipc.IPCClient.INTENT_DEBUG_KEY;
|
||||
import static com.topjohnwu.superuser.ipc.IPCClient.INTENT_EXTRA_KEY;
|
||||
import static com.topjohnwu.superuser.ipc.IPCClient.LOGGING_ENV;
|
||||
import static com.topjohnwu.superuser.ipc.RootService.TAG;
|
||||
|
||||
class IPCServer extends IRootIPC.Stub implements IBinder.DeathRecipient {
|
||||
|
||||
private final ComponentName mName;
|
||||
@ -147,7 +146,7 @@ class IPCServer extends IRootIPC.Stub implements IBinder.DeathRecipient {
|
||||
mClient = bundle.getBinder(BUNDLE_BINDER_KEY);
|
||||
mClient.linkToDeath(this, 0);
|
||||
|
||||
Container<IBinder> c = new Container<>();
|
||||
IBinder[] b = new IBinder[1];
|
||||
UiThreadHandler.runAndWait(() -> {
|
||||
if (mIntent != null) {
|
||||
Utils.log(TAG, mName + " rebind");
|
||||
@ -156,9 +155,9 @@ class IPCServer extends IRootIPC.Stub implements IBinder.DeathRecipient {
|
||||
Utils.log(TAG, mName + " bind");
|
||||
mIntent = intent.cloneFilter();
|
||||
}
|
||||
c.obj = service.onBind(intent);
|
||||
b[0] = service.onBind(intent);
|
||||
});
|
||||
return c.obj;
|
||||
return b[0];
|
||||
} catch (Exception e) {
|
||||
Utils.err(TAG, e);
|
||||
return null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user