MediaProjectionMgr$LocalScreenSharingService.smali

.class public Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService;
.super Landroid/app/Service;
.source "MediaProjectionMgr.java"


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lio/agora/rtc2/extensions/MediaProjectionMgr;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x9
    name = "LocalScreenSharingService"
.end annotation

.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService$ConfigurationCallbacks;
    }
.end annotation


# static fields
.field private static final CHANNEL_ID:Ljava/lang/String; = "dummy_channel_id"

.field private static final NOTIFICATION_ID:I = 0xbc614e


# instance fields
.field private componentCallbacks:Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService$ConfigurationCallbacks;


# direct methods
.method public constructor <init>()V
    .registers 1

    .line 237
    invoke-direct {p0}, Landroid/app/Service;-><init>()V

    return-void
.end method

.method private getDefaultNotification()Landroid/app/Notification;
    .registers 8

    const-string v0, "Couldn\'t load icon from icon of applicationInfo, use android default"

    const-string v1, "MediaProjectionMgr"

    .line 291
    invoke-virtual {p0}, Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService;->getApplicationContext()Landroid/content/Context;

    move-result-object v2

    invoke-virtual {v2}, Landroid/content/Context;->getApplicationInfo()Landroid/content/pm/ApplicationInfo;

    move-result-object v2

    .line 293
    invoke-virtual {p0}, Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService;->getApplicationContext()Landroid/content/Context;

    move-result-object v3

    invoke-virtual {v3}, Landroid/content/Context;->getPackageManager()Landroid/content/pm/PackageManager;

    move-result-object v3

    invoke-virtual {v3, v2}, Landroid/content/pm/PackageManager;->getApplicationLabel(Landroid/content/pm/ApplicationInfo;)Ljava/lang/CharSequence;

    move-result-object v3

    invoke-interface {v3}, Ljava/lang/CharSequence;->toString()Ljava/lang/String;

    move-result-object v3

    .line 294
    iget v2, v2, Landroid/content/pm/ApplicationInfo;->icon:I

    const/high16 v4, 0x10d0000

    .line 296
    :try_start_20
    invoke-virtual {p0}, Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService;->getApplicationContext()Landroid/content/Context;

    move-result-object v5

    invoke-virtual {v5}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v5

    invoke-static {v5, v2}, Landroid/graphics/BitmapFactory;->decodeResource(Landroid/content/res/Resources;I)Landroid/graphics/Bitmap;

    move-result-object v5

    if-eqz v5, :cond_34

    .line 297
    invoke-virtual {v5}, Landroid/graphics/Bitmap;->getByteCount()I

    move-result v5

    if-nez v5, :cond_38

    .line 298
    :cond_34
    invoke-static {v1, v0}, Lio/agora/rtc2/extensions/MediaProjectionSource;->logW(Ljava/lang/String;Ljava/lang/String;)V
    :try_end_37
    .catch Ljava/lang/Exception; {:try_start_20 .. :try_end_37} :catch_3a

    move v2, v4

    :cond_38
    move v4, v2

    goto :goto_3d

    .line 302
    :catch_3a
    invoke-static {v1, v0}, Lio/agora/rtc2/extensions/MediaProjectionSource;->logW(Ljava/lang/String;Ljava/lang/String;)V

    .line 307
    :goto_3d
    sget v0, Landroid/os/Build$VERSION;->SDK_INT:I

    const-string v1, "dummy_channel_id"

    const/16 v2, 0x1a

    if-lt v0, v2, :cond_56

    .line 309
    new-instance v0, Landroid/app/NotificationChannel;

    const/4 v5, 0x3

    invoke-direct {v0, v1, v3, v5}, Landroid/app/NotificationChannel;-><init>(Ljava/lang/String;Ljava/lang/CharSequence;I)V

    const-string v5, "notification"

    .line 314
    invoke-virtual {p0, v5}, Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v5

    check-cast v5, Landroid/app/NotificationManager;

    .line 315
    invoke-virtual {v5, v0}, Landroid/app/NotificationManager;->createNotificationChannel(Landroid/app/NotificationChannel;)V

    .line 320
    :cond_56
    sget v0, Landroid/os/Build$VERSION;->SDK_INT:I

    const/16 v5, 0x17

    const/4 v6, 0x0

    if-lt v0, v5, :cond_69

    .line 321
    new-instance v0, Landroid/content/Intent;

    invoke-direct {v0}, Landroid/content/Intent;-><init>()V

    const/high16 v5, 0xc000000

    invoke-static {p0, v6, v0, v5}, Landroid/app/PendingIntent;->getActivity(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;

    move-result-object v0

    goto :goto_74

    .line 324
    :cond_69
    new-instance v0, Landroid/content/Intent;

    invoke-direct {v0}, Landroid/content/Intent;-><init>()V

    const/high16 v5, 0x8000000

    .line 325
    invoke-static {p0, v6, v0, v5}, Landroid/app/PendingIntent;->getActivity(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;

    move-result-object v0

    .line 328
    :goto_74
    new-instance v5, Landroid/app/Notification$Builder;

    invoke-direct {v5, p0}, Landroid/app/Notification$Builder;-><init>(Landroid/content/Context;)V

    .line 329
    invoke-virtual {v5, v4, v3, v0}, Landroid/app/Notification$Builder;->addAction(ILjava/lang/CharSequence;Landroid/app/PendingIntent;)Landroid/app/Notification$Builder;

    move-result-object v0

    .line 330
    invoke-virtual {v0, v3}, Landroid/app/Notification$Builder;->setContentText(Ljava/lang/CharSequence;)Landroid/app/Notification$Builder;

    move-result-object v0

    const/4 v5, 0x1

    .line 331
    invoke-virtual {v0, v5}, Landroid/app/Notification$Builder;->setOngoing(Z)Landroid/app/Notification$Builder;

    move-result-object v0

    .line 332
    invoke-virtual {v0, v5}, Landroid/app/Notification$Builder;->setPriority(I)Landroid/app/Notification$Builder;

    move-result-object v0

    .line 333
    invoke-virtual {v0, v4}, Landroid/app/Notification$Builder;->setSmallIcon(I)Landroid/app/Notification$Builder;

    move-result-object v0

    .line 334
    invoke-virtual {v0, v3}, Landroid/app/Notification$Builder;->setTicker(Ljava/lang/CharSequence;)Landroid/app/Notification$Builder;

    move-result-object v0

    .line 335
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v3

    invoke-virtual {v0, v3, v4}, Landroid/app/Notification$Builder;->setWhen(J)Landroid/app/Notification$Builder;

    move-result-object v0

    .line 338
    sget v3, Landroid/os/Build$VERSION;->SDK_INT:I

    if-lt v3, v2, :cond_a1

    .line 339
    invoke-virtual {v0, v1}, Landroid/app/Notification$Builder;->setChannelId(Ljava/lang/String;)Landroid/app/Notification$Builder;

    .line 341
    :cond_a1
    invoke-virtual {v0}, Landroid/app/Notification$Builder;->build()Landroid/app/Notification;

    move-result-object v0

    return-object v0
.end method

.method private getNotification()Landroid/app/Notification;
    .registers 2

    .line 283
    # getter for: Lio/agora/rtc2/extensions/MediaProjectionMgr;->screenCaptureConfigFactory:Lio/agora/rtc2/extensions/MediaProjectionMgr$ScreenCaptureConfigFactory;
    invoke-static {}, Lio/agora/rtc2/extensions/MediaProjectionMgr;->access$500()Lio/agora/rtc2/extensions/MediaProjectionMgr$ScreenCaptureConfigFactory;

    move-result-object v0

    if-nez v0, :cond_8

    const/4 v0, 0x0

    return-object v0

    .line 286
    :cond_8
    # getter for: Lio/agora/rtc2/extensions/MediaProjectionMgr;->screenCaptureConfigFactory:Lio/agora/rtc2/extensions/MediaProjectionMgr$ScreenCaptureConfigFactory;
    invoke-static {}, Lio/agora/rtc2/extensions/MediaProjectionMgr;->access$500()Lio/agora/rtc2/extensions/MediaProjectionMgr$ScreenCaptureConfigFactory;

    move-result-object v0

    invoke-interface {v0}, Lio/agora/rtc2/extensions/MediaProjectionMgr$ScreenCaptureConfigFactory;->createNotification()Landroid/app/Notification;

    move-result-object v0

    return-object v0
.end method


# virtual methods
.method public onBind(Landroid/content/Intent;)Landroid/os/IBinder;
    .registers 3

    const-string p1, "MediaProjectionMgr"

    const-string v0, "onBind()"

    .line 267
    invoke-static {p1, v0}, Lio/agora/rtc2/extensions/MediaProjectionSource;->logD(Ljava/lang/String;Ljava/lang/String;)V

    .line 268
    invoke-direct {p0}, Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService;->getNotification()Landroid/app/Notification;

    move-result-object p1

    const v0, 0xbc614e    # 1.729998E-38f

    if-nez p1, :cond_18

    .line 270
    invoke-direct {p0}, Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService;->getDefaultNotification()Landroid/app/Notification;

    move-result-object p1

    invoke-virtual {p0, v0, p1}, Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService;->startForeground(ILandroid/app/Notification;)V

    goto :goto_1b

    .line 272
    :cond_18
    invoke-virtual {p0, v0, p1}, Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService;->startForeground(ILandroid/app/Notification;)V

    .line 274
    :goto_1b
    iget-object p1, p0, Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService;->componentCallbacks:Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService$ConfigurationCallbacks;

    if-nez p1, :cond_29

    .line 275
    new-instance p1, Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService$ConfigurationCallbacks;

    invoke-direct {p1}, Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService$ConfigurationCallbacks;-><init>()V

    iput-object p1, p0, Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService;->componentCallbacks:Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService$ConfigurationCallbacks;

    .line 276
    invoke-virtual {p0, p1}, Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService;->registerComponentCallbacks(Landroid/content/ComponentCallbacks;)V

    .line 278
    :cond_29
    new-instance p1, Landroid/os/Binder;

    invoke-direct {p1}, Landroid/os/Binder;-><init>()V

    return-object p1
.end method

.method public onConfigurationChanged(Landroid/content/res/Configuration;)V
    .registers 3

    .line 355
    invoke-super {p0, p1}, Landroid/app/Service;->onConfigurationChanged(Landroid/content/res/Configuration;)V

    .line 356
    # getter for: Lio/agora/rtc2/extensions/MediaProjectionMgr;->instance:Lio/agora/rtc2/extensions/MediaProjectionMgr;
    invoke-static {}, Lio/agora/rtc2/extensions/MediaProjectionMgr;->access$000()Lio/agora/rtc2/extensions/MediaProjectionMgr;

    move-result-object v0

    if-nez v0, :cond_a

    return-void

    .line 359
    :cond_a
    # getter for: Lio/agora/rtc2/extensions/MediaProjectionMgr;->instance:Lio/agora/rtc2/extensions/MediaProjectionMgr;
    invoke-static {}, Lio/agora/rtc2/extensions/MediaProjectionMgr;->access$000()Lio/agora/rtc2/extensions/MediaProjectionMgr;

    move-result-object v0

    # getter for: Lio/agora/rtc2/extensions/MediaProjectionMgr;->configurationChangedListenerRef:Ljava/lang/ref/WeakReference;
    invoke-static {v0}, Lio/agora/rtc2/extensions/MediaProjectionMgr;->access$300(Lio/agora/rtc2/extensions/MediaProjectionMgr;)Ljava/lang/ref/WeakReference;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lio/agora/rtc2/extensions/MediaProjectionMgr$ConfigurationChangedListener;

    if-nez v0, :cond_1b

    return-void

    .line 363
    :cond_1b
    invoke-interface {v0, p1}, Lio/agora/rtc2/extensions/MediaProjectionMgr$ConfigurationChangedListener;->onConfigurationChanged(Landroid/content/res/Configuration;)V

    const/16 p1, 0xc8

    .line 364
    # invokes: Lio/agora/rtc2/extensions/MediaProjectionMgr;->executeDisplayChange(I)V
    invoke-static {p1}, Lio/agora/rtc2/extensions/MediaProjectionMgr;->access$400(I)V

    return-void
.end method

.method public onDestroy()V
    .registers 2

    .line 346
    invoke-super {p0}, Landroid/app/Service;->onDestroy()V

    .line 347
    iget-object v0, p0, Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService;->componentCallbacks:Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService$ConfigurationCallbacks;

    if-eqz v0, :cond_d

    .line 348
    invoke-virtual {p0, v0}, Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService;->unregisterComponentCallbacks(Landroid/content/ComponentCallbacks;)V

    const/4 v0, 0x0

    .line 349
    iput-object v0, p0, Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService;->componentCallbacks:Lio/agora/rtc2/extensions/MediaProjectionMgr$LocalScreenSharingService$ConfigurationCallbacks;

    :cond_d
    return-void
.end method