Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e9b3997f authored by Sayantan Roychowdhury's avatar Sayantan Roychowdhury
Browse files

send broadcast to parental control on successful login

parent fb379e8f
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -54,6 +54,11 @@ android {
        buildConfigField "String", "BUILD_ID", "\"${getGitHash() + "." + getDate()}\""
        buildConfigField("String", "SENTRY_DSN", "\"${getSentryDsn()}\"")

        def parentalControlPkgName = "foundation.e.parentalcontrol"

        manifestPlaceholders = [parentalControlPkgName: parentalControlPkgName]
        buildConfigField "String", "PACKAGE_NAME_PARENTAL_CONTROL", "\"${parentalControlPkgName}\""

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

+6 −0
Original line number Diff line number Diff line
@@ -49,6 +49,12 @@
    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
    <uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />

    <uses-permission android:name="${parentalControlPkgName}.broadcast_permission" />

    <queries>
        <package android:name="${parentalControlPkgName}" />
    </queries>

    <permission android:name="${applicationId}.provider.READ" />

    <application
+19 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@

package foundation.e.apps

import android.content.Intent
import android.os.Build.VERSION
import android.os.Build.VERSION_CODES
import android.os.Bundle
@@ -40,6 +41,7 @@ import com.aurora.gplayapi.exceptions.ApiException
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.snackbar.Snackbar
import dagger.hilt.android.AndroidEntryPoint
import foundation.e.apps.data.Constants
import foundation.e.apps.data.install.models.AppInstall
import foundation.e.apps.data.login.AuthObject
import foundation.e.apps.data.login.LoginViewModel
@@ -47,6 +49,7 @@ import foundation.e.apps.data.login.PlayStoreAuthenticator
import foundation.e.apps.data.login.exceptions.GPlayValidationException
import foundation.e.apps.databinding.ActivityMainBinding
import foundation.e.apps.install.updates.UpdatesNotifier
import foundation.e.apps.provider.ProviderConstants.Companion.LOGIN_TYPE
import foundation.e.apps.ui.MainActivityViewModel
import foundation.e.apps.ui.application.subFrags.ApplicationDialogFragment
import foundation.e.apps.ui.purchase.AppPurchaseFragmentDirections
@@ -320,7 +323,9 @@ class MainActivity : AppCompatActivity() {
                else -> {}
            }

            it.find { it is AuthObject.GPlayAuth }?.result?.run {
            val gPlayAuthObject = it.find { it is AuthObject.GPlayAuth }

            gPlayAuthObject?.result?.run {
                if (isSuccess()) {
                    viewModel.gPlayAuthData = data as AuthData
                } else if (exception is GPlayValidationException) {
@@ -333,7 +338,20 @@ class MainActivity : AppCompatActivity() {
                    Timber.e(exception, "Login failed! message: ${exception?.localizedMessage}")
                }
            }

            // Broadcast if not gplay type login or successful gplay login
            if (gPlayAuthObject == null || gPlayAuthObject.result.isSuccess()) {
                broadcastGPlayLogin()
            }
        }
    }

    private fun broadcastGPlayLogin() {
        val intent = Intent(Constants.ACTION_PARENTAL_CONTROL_APP_LOUNGE_LOGIN).apply {
            setPackage(BuildConfig.PACKAGE_NAME_PARENTAL_CONTROL)
            putExtra(LOGIN_TYPE, viewModel.getUser().name)
        }
        sendBroadcast(intent)
    }

    private fun setupViewModels() {
+5 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@

package foundation.e.apps.data

import foundation.e.apps.BuildConfig

object Constants {
    const val timeoutDurationInMillis: Long = 10000

@@ -30,4 +32,7 @@ object Constants {

    const val ACTION_DUMP_APP_INSTALL_STATE = "foundation.e.apps.action.APP_INSTALL_STATE"
    const val TAG_APP_INSTALL_STATE = "APP_INSTALL_STATE"

    const val ACTION_PARENTAL_CONTROL_APP_LOUNGE_LOGIN =
        "${BuildConfig.PACKAGE_NAME_PARENTAL_CONTROL}.action.APP_LOUNGE_LOGIN"
}