Compare commits

..

5 Commits

Author SHA1 Message Date
Romain Vimont
338132986d Expose package manager in Application 2023-11-03 12:15:40 +01:00
Romain Vimont
3d93a099b7 Add log 2023-11-03 11:51:41 +01:00
Romain Vimont
29c305ca5f Initialize FakeContext first 2023-11-03 11:51:32 +01:00
Romain Vimont
65d6bdb237 Attempt to fix #4392
<https://github.com/Genymobile/scrcpy/issues/4392#issuecomment-1790954884>
2023-11-03 09:58:23 +01:00
Romain Vimont
446ea818a4 Update links to v2.2 2023-11-01 18:47:58 +01:00
6 changed files with 48 additions and 13 deletions

View File

@@ -1,4 +1,4 @@
# scrcpy (v2.1.1)
# scrcpy (v2.2)
<img src="app/data/icon.svg" width="128" height="128" alt="scrcpy" align="right" />

View File

@@ -233,10 +233,10 @@ install` must be run as root)._
#### Option 2: Use prebuilt server
- [`scrcpy-server-v2.1.1`][direct-scrcpy-server]
<sub>SHA-256: `9558db6c56743a1dc03b38f59801fb40e91cc891f8fc0c89e5b0b067761f148e`</sub>
- [`scrcpy-server-v2.2`][direct-scrcpy-server]
<sub>SHA-256: `c85c4aa84305efb69115cd497a120ebdd10258993b4cf123a8245b3d99d49874`</sub>
[direct-scrcpy-server]: https://github.com/Genymobile/scrcpy/releases/download/v2.1.1/scrcpy-server-v2.1.1
[direct-scrcpy-server]: https://github.com/Genymobile/scrcpy/releases/download/v2.2/scrcpy-server-v2.2
Download the prebuilt server somewhere, and specify its path during the Meson
configuration:

View File

@@ -4,14 +4,14 @@
Download the [latest release]:
- [`scrcpy-win64-v2.1.1.zip`][direct-win64] (64-bit)
<sub>SHA-256: `f77281e1bce2f9934617699c581f063d5b327f012eff602ee98fb2ef550c25c2`</sub>
- [`scrcpy-win32-v2.1.1.zip`][direct-win32] (32-bit)
<sub>SHA-256: `ef7ae7fbe9449f2643febdc2244fb186d1a746a3c736394150cfd14f06d3c943`</sub>
- [`scrcpy-win64-v2.2.zip`][direct-win64] (64-bit)
<sub>SHA-256: `9f9da88ac4c8319dcb9bf852f2d9bba942bac663413383419cddf64eaa5685bd`</sub>
- [`scrcpy-win32-v2.2.zip`][direct-win32] (32-bit)
<sub>SHA-256: `cb84269fc847b8b880e320879492a1ae6c017b42175f03e199530f7a53be9d74`</sub>
[latest release]: https://github.com/Genymobile/scrcpy/releases/latest
[direct-win64]: https://github.com/Genymobile/scrcpy/releases/download/v2.1.1/scrcpy-win64-v2.1.1.zip
[direct-win32]: https://github.com/Genymobile/scrcpy/releases/download/v2.1.1/scrcpy-win32-v2.1.1.zip
[direct-win64]: https://github.com/Genymobile/scrcpy/releases/download/v2.2/scrcpy-win64-v2.2.zip
[direct-win32]: https://github.com/Genymobile/scrcpy/releases/download/v2.2/scrcpy-win32-v2.2.zip
and extract it.

View File

@@ -2,8 +2,8 @@
set -e
BUILDDIR=build-auto
PREBUILT_SERVER_URL=https://github.com/Genymobile/scrcpy/releases/download/v2.1.1/scrcpy-server-v2.1.1
PREBUILT_SERVER_SHA256=9558db6c56743a1dc03b38f59801fb40e91cc891f8fc0c89e5b0b067761f148e
PREBUILT_SERVER_URL=https://github.com/Genymobile/scrcpy/releases/download/v2.2/scrcpy-server-v2.2
PREBUILT_SERVER_SHA256=c85c4aa84305efb69115cd497a120ebdd10258993b4cf123a8245b3d99d49874
echo "[scrcpy] Downloading prebuilt server..."
wget "$PREBUILT_SERVER_URL" -O scrcpy-server

View File

@@ -18,7 +18,7 @@ public final class FakeContext extends MutableContextWrapper {
}
private FakeContext() {
super(null);
super(Workarounds.retrieveSystemContext());
}
@Override

View File

@@ -7,6 +7,7 @@ import android.content.AttributionSource;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.media.AudioAttributes;
import android.media.AudioManager;
import android.media.AudioRecord;
@@ -30,6 +31,12 @@ public final class Workarounds {
public static void apply(boolean audio, boolean camera) {
Workarounds.prepareMainLooper();
try {
fillActivityThread();
FakeContext.get();
} catch (Exception e) {
throw new AssertionError(e);
}
boolean mustFillAppInfo = false;
boolean mustFillBaseContext = false;
@@ -123,6 +130,22 @@ public final class Workarounds {
ApplicationInfo applicationInfo = new ApplicationInfo();
applicationInfo.packageName = FakeContext.PACKAGE_NAME;
Application application = new Application() {
@Override
public String getOpPackageName() {
return FakeContext.PACKAGE_NAME;
}
@Override
public PackageManager getPackageManager() {
return FakeContext.get().getPackageManager();
}
};
Field initialApplicationField = activityThreadClass.getDeclaredField("mInitialApplication");
initialApplicationField.setAccessible(true);
initialApplicationField.set(activityThread, application);
// appBindData.appInfo = applicationInfo;
Field appInfoField = appBindDataClass.getDeclaredField("appInfo");
appInfoField.setAccessible(true);
@@ -306,4 +329,16 @@ public final class Workarounds {
throw new RuntimeException("Cannot create AudioRecord");
}
}
static Context retrieveSystemContext() {
try {
Method getSystemContextMethod = activityThreadClass.getDeclaredMethod("getSystemContext");
Context ctx = (Context) getSystemContextMethod.invoke(activityThread);
Ln.i("===== " + ctx);
return ctx;
} catch (Exception e) {
Ln.e("Cannot retrieve system context", e);
return null;
}
}
}