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

Commit d2aeed66 authored by Jacqueline Bronger's avatar Jacqueline Bronger Committed by Automerger Merge Worker
Browse files

Merge "Enable sensor use notification on TVs." into sc-dev am: b4044c5f

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15079802

Change-Id: I4c98c3ec6fe2583cce88b25d131917ff85112139
parents a3a9dbe1 b4044c5f
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.drawable.Icon;
import android.hardware.ISensorPrivacyListener;
import android.hardware.ISensorPrivacyManager;
@@ -611,9 +612,19 @@ public final class SensorPrivacyService extends SystemService {
                                    new Intent(Settings.ACTION_PRIVACY_SETTINGS),
                                    PendingIntent.FLAG_IMMUTABLE
                                            | PendingIntent.FLAG_UPDATE_CURRENT))
                            .extend(new Notification.TvExtender())
                            .setTimeoutAfter(isTelevision(mContext)
                                    ? /* dismiss immediately */ 1
                                    : /* no timeout */ 0)
                            .build());
        }

        private boolean isTelevision(Context context) {
            int uiMode = context.getResources().getConfiguration().uiMode;
            return (uiMode & Configuration.UI_MODE_TYPE_MASK)
                    == Configuration.UI_MODE_TYPE_TELEVISION;
        }

        /**
         * Sets the sensor privacy to the provided state and notifies all listeners of the new
         * state.