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

Commit 5b0acf0d authored by Adrian Roos's avatar Adrian Roos
Browse files

Hide camera icon in navbar when disabled by DPM.

Hides the camera icon in the keyguard more reliably if the device policy disables it.

Bug: 11655611
Change-Id: Ic66f41b6703bf2028edc269cf10f9c167a22081d
parent 93899a59
Loading
Loading
Loading
Loading
+24 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package com.android.systemui.statusbar.phone;
package com.android.systemui.statusbar.phone;


import com.google.android.collect.Lists;

import android.content.ComponentName;
import android.content.ComponentName;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
@@ -28,6 +30,8 @@ import android.view.MotionEvent;


import com.android.internal.policy.IKeyguardService;
import com.android.internal.policy.IKeyguardService;


import java.util.List;



/**
/**
 * Facilitates event communication between navigation bar and keyguard.  Currently used to
 * Facilitates event communication between navigation bar and keyguard.  Currently used to
@@ -40,6 +44,8 @@ public class KeyguardTouchDelegate {
    static final String KEYGUARD_CLASS = "com.android.keyguard.KeyguardService";
    static final String KEYGUARD_CLASS = "com.android.keyguard.KeyguardService";


    private static KeyguardTouchDelegate sInstance;
    private static KeyguardTouchDelegate sInstance;
    private static final List<OnKeyguardConnectionListener> sConnectionListeners =
            Lists.newArrayList();


    private volatile IKeyguardService mService;
    private volatile IKeyguardService mService;


@@ -52,6 +58,10 @@ public class KeyguardTouchDelegate {
            Slog.v(TAG, "Connected to keyguard");
            Slog.v(TAG, "Connected to keyguard");
            mService = IKeyguardService.Stub.asInterface(service);
            mService = IKeyguardService.Stub.asInterface(service);


            for (int i = 0; i < sConnectionListeners.size(); i++) {
                OnKeyguardConnectionListener listener = sConnectionListeners.get(i);
                listener.onKeyguardServiceConnected(KeyguardTouchDelegate.this);
            }
        }
        }


        @Override
        @Override
@@ -59,6 +69,11 @@ public class KeyguardTouchDelegate {
            Slog.v(TAG, "Disconnected from keyguard");
            Slog.v(TAG, "Disconnected from keyguard");
            mService = null;
            mService = null;
            sInstance = null; // force reconnection if this goes away
            sInstance = null; // force reconnection if this goes away

            for (int i = 0; i < sConnectionListeners.size(); i++) {
                OnKeyguardConnectionListener listener = sConnectionListeners.get(i);
                listener.onKeyguardServiceDisconnected(KeyguardTouchDelegate.this);
            }
        }
        }


    };
    };
@@ -182,4 +197,13 @@ public class KeyguardTouchDelegate {
        }
        }
    }
    }


    public static void addListener(OnKeyguardConnectionListener listener) {
        sConnectionListeners.add(listener);
    }

    public interface OnKeyguardConnectionListener {

        void onKeyguardServiceConnected(KeyguardTouchDelegate keyguardTouchDelegate);
        void onKeyguardServiceDisconnected(KeyguardTouchDelegate keyguardTouchDelegate);
    }
}
}
+22 −0
Original line number Original line Diff line number Diff line
@@ -57,6 +57,8 @@ import com.android.systemui.statusbar.policy.KeyButtonView;
import java.io.FileDescriptor;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.io.PrintWriter;


import static com.android.systemui.statusbar.phone.KeyguardTouchDelegate.OnKeyguardConnectionListener;

public class NavigationBarView extends LinearLayout {
public class NavigationBarView extends LinearLayout {
    final static boolean DEBUG = false;
    final static boolean DEBUG = false;
    final static String TAG = "PhoneStatusBar/NavigationBarView";
    final static String TAG = "PhoneStatusBar/NavigationBarView";
@@ -172,6 +174,25 @@ public class NavigationBarView extends LinearLayout {
        }
        }
    };
    };


    private final OnKeyguardConnectionListener mKeyguardConnectionListener =
            new OnKeyguardConnectionListener() {
                @Override
                public void onKeyguardServiceConnected(
                        KeyguardTouchDelegate keyguardTouchDelegate) {
                    post(new Runnable() {
                        @Override
                        public void run() {
                            mCameraDisabledByDpm = isCameraDisabledByDpm();
                        }
                    });
                }

                @Override
                public void onKeyguardServiceDisconnected(
                        KeyguardTouchDelegate keyguardTouchDelegate) {
                }
            };

    private class H extends Handler {
    private class H extends Handler {
        public void handleMessage(Message m) {
        public void handleMessage(Message m) {
            switch (m.what) {
            switch (m.what) {
@@ -211,6 +232,7 @@ public class NavigationBarView extends LinearLayout {


        mBarTransitions = new NavigationBarTransitions(this);
        mBarTransitions = new NavigationBarTransitions(this);


        KeyguardTouchDelegate.addListener(mKeyguardConnectionListener);
        mCameraDisabledByDpm = isCameraDisabledByDpm();
        mCameraDisabledByDpm = isCameraDisabledByDpm();
        watchForDevicePolicyChanges();
        watchForDevicePolicyChanges();
    }
    }