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

Commit 8b438be8 authored by Xiaowen Lei's avatar Xiaowen Lei
Browse files

Clean up Communal Manager READ_COMMUNAL_STATE APIs.

These are not yet used, and are obsolete now because We will no longer
be shipping SLS in T.

Ignore-AOSP-First: tied to launch of new upcoming hardware.

Test: atest FrameworksMockingServicesTests:CommunalManagerServiceTest

Bug: 206054365
Change-Id: I51ffbfe5ddc89008d660fab7cfd5808cb827d300
parent 787445d9
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -226,7 +226,6 @@ package android {
    field public static final String READ_APP_SPECIFIC_LOCALES = "android.permission.READ_APP_SPECIFIC_LOCALES";
    field public static final String READ_CARRIER_APP_INFO = "android.permission.READ_CARRIER_APP_INFO";
    field public static final String READ_CELL_BROADCASTS = "android.permission.READ_CELL_BROADCASTS";
    field public static final String READ_COMMUNAL_STATE = "android.permission.READ_COMMUNAL_STATE";
    field public static final String READ_CONTENT_RATING_SYSTEMS = "android.permission.READ_CONTENT_RATING_SYSTEMS";
    field public static final String READ_DEVICE_CONFIG = "android.permission.READ_DEVICE_CONFIG";
    field public static final String READ_DREAM_STATE = "android.permission.READ_DREAM_STATE";
@@ -1391,13 +1390,6 @@ package android.app.backup {
package android.app.communal {
  public final class CommunalManager {
    method @RequiresPermission(android.Manifest.permission.READ_COMMUNAL_STATE) public void addCommunalModeListener(@NonNull java.util.concurrent.Executor, @NonNull android.app.communal.CommunalManager.CommunalModeListener);
    method @RequiresPermission(android.Manifest.permission.READ_COMMUNAL_STATE) public boolean isCommunalMode();
    method @RequiresPermission(android.Manifest.permission.READ_COMMUNAL_STATE) public void removeCommunalModeListener(@NonNull android.app.communal.CommunalManager.CommunalModeListener);
  }
  @java.lang.FunctionalInterface public static interface CommunalManager.CommunalModeListener {
    method public void onCommunalModeChanged(boolean);
  }
}
+0 −74
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package android.app.communal;

import android.Manifest;
import android.annotation.NonNull;
import android.annotation.RequiresFeature;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
@@ -26,9 +25,6 @@ import android.annotation.TestApi;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.RemoteException;
import android.util.ArrayMap;

import java.util.concurrent.Executor;

/**
 * System private class for talking with the
@@ -41,12 +37,10 @@ import java.util.concurrent.Executor;
@RequiresFeature(PackageManager.FEATURE_COMMUNAL_MODE)
public final class CommunalManager {
    private final ICommunalManager mService;
    private final ArrayMap<CommunalModeListener, ICommunalModeListener> mCommunalModeListeners;

    /** @hide */
    public CommunalManager(ICommunalManager service) {
        mService = service;
        mCommunalModeListeners = new ArrayMap<>();
    }

    /**
@@ -65,72 +59,4 @@ public final class CommunalManager {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Checks whether or not the communal view is currently showing over the lockscreen.
     */
    @RequiresPermission(Manifest.permission.READ_COMMUNAL_STATE)
    public boolean isCommunalMode() {
        try {
            return mService.isCommunalMode();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Listener for communal state changes.
     */
    @FunctionalInterface
    public interface CommunalModeListener {
        /**
         * Callback function that executes when the communal state changes.
         */
        void onCommunalModeChanged(boolean isCommunalMode);
    }

    /**
     * Registers a callback to execute when the communal state changes.
     *
     * @param listener The listener to add to receive communal state changes.
     * @param executor {@link Executor} to dispatch to. To dispatch the callback to the main
     *                 thread of your application, use
     *                 {@link android.content.Context#getMainExecutor()}.
     */
    @RequiresPermission(Manifest.permission.READ_COMMUNAL_STATE)
    public void addCommunalModeListener(@NonNull Executor executor,
            @NonNull CommunalModeListener listener) {
        synchronized (mCommunalModeListeners) {
            try {
                ICommunalModeListener iListener = new ICommunalModeListener.Stub() {
                    @Override
                    public void onCommunalModeChanged(boolean isCommunalMode) {
                        executor.execute(() -> listener.onCommunalModeChanged(isCommunalMode));
                    }
                };
                mService.addCommunalModeListener(iListener);
                mCommunalModeListeners.put(listener, iListener);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
    }

    /**
     * Unregisters a callback that executes when communal state changes.
     */
    @RequiresPermission(Manifest.permission.READ_COMMUNAL_STATE)
    public void removeCommunalModeListener(@NonNull CommunalModeListener listener) {
        synchronized (mCommunalModeListeners) {
            ICommunalModeListener iListener = mCommunalModeListeners.get(listener);
            if (iListener != null) {
                try {
                    mService.removeCommunalModeListener(iListener);
                    mCommunalModeListeners.remove(listener);
                } catch (RemoteException e) {
                    throw e.rethrowFromSystemServer();
                }
            }
        }
    }
}
+0 −5
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package android.app.communal;

import android.app.communal.ICommunalModeListener;

/**
 * System private API for talking with the communal manager service that handles communal mode
 * state.
@@ -26,7 +24,4 @@ import android.app.communal.ICommunalModeListener;
 */
interface ICommunalManager {
    oneway void setCommunalViewShowing(boolean isShowing);
    boolean isCommunalMode();
    void addCommunalModeListener(in ICommunalModeListener listener);
    void removeCommunalModeListener(in ICommunalModeListener listener);
}
 No newline at end of file
+0 −26
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.app.communal;

/**
 * System private API to be notified about communal mode changes.
 *
 * @hide
 */
oneway interface ICommunalModeListener {
    void onCommunalModeChanged(boolean isCommunalMode);
}
 No newline at end of file
+0 −7
Original line number Diff line number Diff line
@@ -5580,13 +5580,6 @@
    <permission android:name="android.permission.WRITE_COMMUNAL_STATE"
                android:protectionLevel="signature" />

    <!-- Allows an application to view information from the currently active
         {@link com.android.server.communal.CommunalManagerService}.
         @hide
         @SystemApi -->
    <permission android:name="android.permission.READ_COMMUNAL_STATE"
                android:protectionLevel="signature|privileged"/>

    <!-- Allows the holder to manage whether the system can bind to services
         provided by instant apps. This permission is intended to protect
         test/development fucntionality and should be used only in such cases.
Loading