MediaProjectionMgr.smali
.class public Lio/agora/rtc2/extensions/MediaProjectionMgr;
.super Ljava/lang/Object;
.source "MediaProjectionMgr.java"
# interfaces
.implements Landroid/content/ServiceConnection;
# annotations
.annotation system Ldalvik/annotation/MemberClasses;
value = {
Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService;,
Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenCaptureAssistantActivity;,
Lio/agora/rtc2/extensions/MediaProjectionMgr$ConfigurationChangedListener;,
Lio/agora/rtc2/extensions/MediaProjectionMgr$RequestListener;,
Lio/agora/rtc2/extensions/MediaProjectionMgr$AudioFrameListener;,
Lio/agora/rtc2/extensions/MediaProjectionMgr$AudioRecordErrorCallback;,
Lio/agora/rtc2/extensions/MediaProjectionMgr$IScreenCapture;,
Lio/agora/rtc2/extensions/MediaProjectionMgr$IAudioCapture;,
Lio/agora/rtc2/extensions/MediaProjectionMgr$ScreenCaptureConfigFactory;,
Lio/agora/rtc2/extensions/MediaProjectionMgr$ScreenCaptureActionListener;
}
.end annotation
# static fields
.field private static final TAG:Ljava/lang/String; = "MediaProjectionMgr"
.field private static captureActionListener:Lio/agora/rtc2/extensions/MediaProjectionMgr$ScreenCaptureActionListener;
.field private static final displayChangeRunnable:Ljava/lang/Runnable;
.field private static instance:Lio/agora/rtc2/extensions/MediaProjectionMgr;
.field private static screenCaptureConfigFactory:Lio/agora/rtc2/extensions/MediaProjectionMgr$ScreenCaptureConfigFactory;
# instance fields
.field private final configurationChangedListenerRef:Ljava/lang/ref/WeakReference;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/lang/ref/WeakReference<",
"Lio/agora/rtc2/extensions/MediaProjectionMgr$ConfigurationChangedListener;",
">;"
}
.end annotation
.end field
.field private final handlerWeakRef:Ljava/lang/ref/WeakReference;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/lang/ref/WeakReference<",
"Landroid/os/Handler;",
">;"
}
.end annotation
.end field
.field private final projectionManager:Landroid/media/projection/MediaProjectionManager;
.field private final requestListenerRef:Ljava/lang/ref/WeakReference;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/lang/ref/WeakReference<",
"Lio/agora/rtc2/extensions/MediaProjectionMgr$RequestListener;",
">;"
}
.end annotation
.end field
.field private volatile requesting:Z
# direct methods
.method static constructor <clinit>()V
.registers 1
.line 368
new-instance v0, Lio/agora/rtc2/extensions/MediaProjectionMgr$1;
invoke-direct {v0}, Lio/agora/rtc2/extensions/MediaProjectionMgr$1;-><init>()V
sput-object v0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->displayChangeRunnable:Ljava/lang/Runnable;
return-void
.end method
.method public constructor <init>(Lio/agora/rtc2/extensions/MediaProjectionMgr$RequestListener;Lio/agora/rtc2/extensions/MediaProjectionMgr$ConfigurationChangedListener;)V
.registers 5
.line 123
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
const/4 v0, 0x0
.line 120
iput-boolean v0, p0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->requesting:Z
.line 125
invoke-static {}, Lio/agora/rtc2/extensions/MediaProjectionMgr;->getContext()Landroid/content/Context;
move-result-object v0
const-string v1, "media_projection"
invoke-virtual {v0, v1}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;
move-result-object v0
check-cast v0, Landroid/media/projection/MediaProjectionManager;
iput-object v0, p0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->projectionManager:Landroid/media/projection/MediaProjectionManager;
.line 126
new-instance v0, Ljava/lang/ref/WeakReference;
invoke-direct {v0, p1}, Ljava/lang/ref/WeakReference;-><init>(Ljava/lang/Object;)V
iput-object v0, p0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->requestListenerRef:Ljava/lang/ref/WeakReference;
.line 127
new-instance p1, Ljava/lang/ref/WeakReference;
invoke-direct {p1, p2}, Ljava/lang/ref/WeakReference;-><init>(Ljava/lang/Object;)V
iput-object p1, p0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->configurationChangedListenerRef:Ljava/lang/ref/WeakReference;
.line 129
new-instance p1, Landroid/os/HandlerThread;
const-string p2, "ScreenCapture"
invoke-direct {p1, p2}, Landroid/os/HandlerThread;-><init>(Ljava/lang/String;)V
.line 130
invoke-virtual {p1}, Landroid/os/HandlerThread;->start()V
.line 131
new-instance p2, Ljava/lang/ref/WeakReference;
new-instance v0, Landroid/os/Handler;
invoke-virtual {p1}, Landroid/os/HandlerThread;->getLooper()Landroid/os/Looper;
move-result-object p1
invoke-direct {v0, p1}, Landroid/os/Handler;-><init>(Landroid/os/Looper;)V
invoke-direct {p2, v0}, Ljava/lang/ref/WeakReference;-><init>(Ljava/lang/Object;)V
iput-object p2, p0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->handlerWeakRef:Ljava/lang/ref/WeakReference;
.line 132
sput-object p0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->instance:Lio/agora/rtc2/extensions/MediaProjectionMgr;
return-void
.end method
.method static synthetic access$000()Lio/agora/rtc2/extensions/MediaProjectionMgr;
.registers 1
.line 41
sget-object v0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->instance:Lio/agora/rtc2/extensions/MediaProjectionMgr;
return-object v0
.end method
.method static synthetic access$100(Lio/agora/rtc2/extensions/MediaProjectionMgr;)Landroid/media/projection/MediaProjectionManager;
.registers 1
.line 41
iget-object p0, p0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->projectionManager:Landroid/media/projection/MediaProjectionManager;
return-object p0
.end method
.method static synthetic access$200()Lio/agora/rtc2/extensions/MediaProjectionMgr$ScreenCaptureActionListener;
.registers 1
.line 41
sget-object v0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->captureActionListener:Lio/agora/rtc2/extensions/MediaProjectionMgr$ScreenCaptureActionListener;
return-object v0
.end method
.method static synthetic access$300(Lio/agora/rtc2/extensions/MediaProjectionMgr;)Ljava/lang/ref/WeakReference;
.registers 1
.line 41
iget-object p0, p0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->configurationChangedListenerRef:Ljava/lang/ref/WeakReference;
return-object p0
.end method
.method static synthetic access$400(I)V
.registers 1
.line 41
invoke-static {p0}, Lio/agora/rtc2/extensions/MediaProjectionMgr;->executeDisplayChange(I)V
return-void
.end method
.method static synthetic access$500()Lio/agora/rtc2/extensions/MediaProjectionMgr$ScreenCaptureConfigFactory;
.registers 1
.line 41
sget-object v0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->screenCaptureConfigFactory:Lio/agora/rtc2/extensions/MediaProjectionMgr$ScreenCaptureConfigFactory;
return-object v0
.end method
.method private static executeDisplayChange(I)V
.registers 5
.line 383
sget-object v0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->instance:Lio/agora/rtc2/extensions/MediaProjectionMgr;
if-nez v0, :cond_5
return-void
.line 386
:cond_5
iget-object v0, v0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->handlerWeakRef:Ljava/lang/ref/WeakReference;
invoke-virtual {v0}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;
move-result-object v0
check-cast v0, Landroid/os/Handler;
if-nez v0, :cond_10
return-void
.line 390
:cond_10
sget-object v1, Lio/agora/rtc2/extensions/MediaProjectionMgr;->displayChangeRunnable:Ljava/lang/Runnable;
int-to-long v2, p0
invoke-virtual {v0, v1, v2, v3}, Landroid/os/Handler;->postDelayed(Ljava/lang/Runnable;J)Z
return-void
.end method
.method static getContext()Landroid/content/Context;
.registers 2
.line 137
invoke-static {}, Lio/agora/base/internal/ContextUtils;->getApplicationContext()Landroid/content/Context;
move-result-object v0
if-eqz v0, :cond_7
return-object v0
.line 139
:cond_7
new-instance v0, Ljava/lang/IllegalStateException;
const-string v1, "context null"
invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw v0
.end method
.method public static setCaptureActionListener(Lio/agora/rtc2/extensions/MediaProjectionMgr$ScreenCaptureActionListener;)V
.registers 1
.line 58
sput-object p0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->captureActionListener:Lio/agora/rtc2/extensions/MediaProjectionMgr$ScreenCaptureActionListener;
return-void
.end method
.method public static setConfigFactory(Lio/agora/rtc2/extensions/MediaProjectionMgr$ScreenCaptureConfigFactory;)V
.registers 1
.line 102
sput-object p0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->screenCaptureConfigFactory:Lio/agora/rtc2/extensions/MediaProjectionMgr$ScreenCaptureConfigFactory;
return-void
.end method
# virtual methods
.method dispose()V
.registers 2
.line 171
iget-object v0, p0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->requestListenerRef:Ljava/lang/ref/WeakReference;
invoke-virtual {v0}, Ljava/lang/ref/WeakReference;->clear()V
.line 172
iget-object v0, p0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->configurationChangedListenerRef:Ljava/lang/ref/WeakReference;
invoke-virtual {v0}, Ljava/lang/ref/WeakReference;->clear()V
.line 173
iget-object v0, p0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->handlerWeakRef:Ljava/lang/ref/WeakReference;
invoke-virtual {v0}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;
move-result-object v0
if-eqz v0, :cond_21
.line 174
iget-object v0, p0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->handlerWeakRef:Ljava/lang/ref/WeakReference;
invoke-virtual {v0}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;
move-result-object v0
check-cast v0, Landroid/os/Handler;
invoke-virtual {v0}, Landroid/os/Handler;->getLooper()Landroid/os/Looper;
move-result-object v0
invoke-virtual {v0}, Landroid/os/Looper;->quit()V
.line 176
:cond_21
iget-object v0, p0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->handlerWeakRef:Ljava/lang/ref/WeakReference;
invoke-virtual {v0}, Ljava/lang/ref/WeakReference;->clear()V
.line 177
invoke-static {}, Lio/agora/rtc2/extensions/MediaProjectionMgr;->getContext()Landroid/content/Context;
move-result-object v0
invoke-virtual {v0, p0}, Landroid/content/Context;->unbindService(Landroid/content/ServiceConnection;)V
const/4 v0, 0x0
.line 178
sput-object v0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->instance:Lio/agora/rtc2/extensions/MediaProjectionMgr;
.line 180
sget-object v0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->captureActionListener:Lio/agora/rtc2/extensions/MediaProjectionMgr$ScreenCaptureActionListener;
if-eqz v0, :cond_37
.line 181
invoke-interface {v0}, Lio/agora/rtc2/extensions/MediaProjectionMgr$ScreenCaptureActionListener;->dispose()V
:cond_37
return-void
.end method
.method onRequestResult(ILandroid/content/Intent;)V
.registers 5
const-string v0, "MediaProjectionMgr"
const-string v1, "onRequestSuccess()"
.line 159
invoke-static {v0, v1}, Lio/agora/rtc2/extensions/MediaProjectionSource;->logD(Ljava/lang/String;Ljava/lang/String;)V
.line 160
iget-object v0, p0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->requestListenerRef:Ljava/lang/ref/WeakReference;
invoke-virtual {v0}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;
move-result-object v0
check-cast v0, Lio/agora/rtc2/extensions/MediaProjectionMgr$RequestListener;
const/4 v1, 0x0
.line 161
iput-boolean v1, p0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->requesting:Z
if-nez v0, :cond_15
return-void
.line 165
:cond_15
iget-object v1, p0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->projectionManager:Landroid/media/projection/MediaProjectionManager;
invoke-virtual {v1, p1, p2}, Landroid/media/projection/MediaProjectionManager;->getMediaProjection(ILandroid/content/Intent;)Landroid/media/projection/MediaProjection;
move-result-object p1
.line 166
invoke-interface {v0, p1}, Lio/agora/rtc2/extensions/MediaProjectionMgr$RequestListener;->onProjectionResult(Landroid/media/projection/MediaProjection;)V
return-void
.end method
.method public onServiceConnected(Landroid/content/ComponentName;Landroid/os/IBinder;)V
.registers 4
const-string p1, "MediaProjectionMgr"
const-string p2, "local onServiceConnected"
.line 187
invoke-static {p1, p2}, Lio/agora/rtc2/extensions/MediaProjectionSource;->logD(Ljava/lang/String;Ljava/lang/String;)V
.line 188
invoke-static {}, Lio/agora/rtc2/extensions/MediaProjectionMgr;->getContext()Landroid/content/Context;
move-result-object p1
.line 189
new-instance p2, Landroid/content/Intent;
const-class v0, Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenCaptureAssistantActivity;
invoke-direct {p2, p1, v0}, Landroid/content/Intent;-><init>(Landroid/content/Context;Ljava/lang/Class;)V
const/high16 v0, 0x10000000
.line 190
invoke-virtual {p2, v0}, Landroid/content/Intent;->addFlags(I)Landroid/content/Intent;
.line 191
invoke-virtual {p1, p2}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V
return-void
.end method
.method public onServiceDisconnected(Landroid/content/ComponentName;)V
.registers 3
const-string p1, "MediaProjectionMgr"
const-string v0, "local onServiceDisconnected"
.line 197
invoke-static {p1, v0}, Lio/agora/rtc2/extensions/MediaProjectionSource;->logD(Ljava/lang/String;Ljava/lang/String;)V
return-void
.end method
.method requestPermission()V
.registers 5
const-string v0, "MediaProjectionMgr"
const-string v1, "requestPermission()"
.line 145
invoke-static {v0, v1}, Lio/agora/rtc2/extensions/MediaProjectionSource;->logD(Ljava/lang/String;Ljava/lang/String;)V
.line 146
iget-boolean v1, p0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->requesting:Z
if-eqz v1, :cond_11
const-string v1, "mediaProjection request already sent. just waiting..."
.line 147
invoke-static {v0, v1}, Lio/agora/rtc2/extensions/MediaProjectionSource;->logW(Ljava/lang/String;Ljava/lang/String;)V
return-void
:cond_11
const/4 v0, 0x1
.line 151
iput-boolean v0, p0, Lio/agora/rtc2/extensions/MediaProjectionMgr;->requesting:Z
.line 152
invoke-static {}, Lio/agora/rtc2/extensions/MediaProjectionMgr;->getContext()Landroid/content/Context;
move-result-object v1
.line 153
new-instance v2, Landroid/content/Intent;
const-class v3, Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService;
invoke-direct {v2, v1, v3}, Landroid/content/Intent;-><init>(Landroid/content/Context;Ljava/lang/Class;)V
.line 154
invoke-virtual {v1, v2, p0, v0}, Landroid/content/Context;->bindService(Landroid/content/Intent;Landroid/content/ServiceConnection;I)Z
return-void
.end method