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

Commit 1c0cddb1 authored by Hakjun Choi's avatar Hakjun Choi Committed by Android (Google) Code Review
Browse files

Merge "Add lock and exception handling for startPointingUI" into main

parents 82b980d2 412c8b21
Loading
Loading
Loading
Loading
+18 −9
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import android.telephony.satellite.SatelliteManager;
import android.text.TextUtils;

import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.flags.FeatureFlags;

@@ -69,6 +70,9 @@ public class PointingAppController {
    private boolean mLastNeedFullScreenPointingUI;
    private boolean mLastIsDemoMode;
    private boolean mLastIsEmergency;

    private final Object mListenerForPointingUIRegisteredLock = new Object();
    @GuardedBy("mListenerForPointingUIRegisteredLock")
    private boolean mListenerForPointingUIRegistered;
    @NonNull private String mPointingUiPackageName = "";
    @NonNull private String mPointingUiClassName = "";
@@ -415,17 +419,20 @@ public class PointingAppController {
        launchIntent.putExtra("isEmergency", isEmergency);

        try {
            synchronized (mListenerForPointingUIRegisteredLock) {
                if (!mListenerForPointingUIRegistered) {
                    mActivityManager.addOnUidImportanceListener(mUidImportanceListener,
                            IMPORTANCE_GONE);
                    mListenerForPointingUIRegistered = true;
                }
            }
            mLastNeedFullScreenPointingUI = needFullScreenPointingUI;
            mLastIsDemoMode = isDemoMode;
            mLastIsEmergency = isEmergency;
            mContext.startActivityAsUser(launchIntent, UserHandle.CURRENT);
        } catch (ActivityNotFoundException ex) {
            ploge("startPointingUI: Pointing UI app activity is not found, ex=" + ex);
        } catch (ActivityNotFoundException | IllegalArgumentException ex) {
            ploge("startPointingUI: Unable to start Pointing UI activity due to an exception, ex="
                    + ex);
        }
    }

@@ -433,11 +440,13 @@ public class PointingAppController {
     * Remove the Importance Listener For Pointing UI App once the satellite is disabled
     */
    public void removeListenerForPointingUI() {
        synchronized (mListenerForPointingUIRegisteredLock) {
            if (mListenerForPointingUIRegistered) {
                mActivityManager.removeOnUidImportanceListener(mUidImportanceListener);
                mListenerForPointingUIRegistered = false;
            }
        }
    }

    public void updateSendDatagramTransferState(int subId,
            @SatelliteManager.DatagramType int datagramType,