Clean up CommunalManagerService
This system service is no longer needed, as there is no longer a shared lockscreen. Test: locally on device Bug: 206054365 Ignore-AOSP-First: cleanup Change-Id: Ib2db06c377cf632da77dc41c629debfe658bfc48
This commit is contained in:
@@ -1423,13 +1423,6 @@ package android.app.backup {
|
||||
|
||||
}
|
||||
|
||||
package android.app.communal {
|
||||
|
||||
public final class CommunalManager {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package android.app.compat {
|
||||
|
||||
public final class CompatChanges {
|
||||
@@ -2646,7 +2639,6 @@ package android.content {
|
||||
field public static final String BATTERY_STATS_SERVICE = "batterystats";
|
||||
field @Deprecated public static final int BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS = 1048576; // 0x100000
|
||||
field public static final int BIND_ALLOW_FOREGROUND_SERVICE_STARTS_FROM_BACKGROUND = 262144; // 0x40000
|
||||
field public static final String COMMUNAL_SERVICE = "communal";
|
||||
field public static final String CONTENT_SUGGESTIONS_SERVICE = "content_suggestions";
|
||||
field public static final String CONTEXTHUB_SERVICE = "contexthub";
|
||||
field public static final String ETHERNET_SERVICE = "ethernet";
|
||||
|
||||
@@ -43,7 +43,6 @@ package android {
|
||||
field public static final String TEST_BIOMETRIC = "android.permission.TEST_BIOMETRIC";
|
||||
field public static final String TEST_MANAGE_ROLLBACKS = "android.permission.TEST_MANAGE_ROLLBACKS";
|
||||
field public static final String UPGRADE_RUNTIME_PERMISSIONS = "android.permission.UPGRADE_RUNTIME_PERMISSIONS";
|
||||
field public static final String WRITE_COMMUNAL_STATE = "android.permission.WRITE_COMMUNAL_STATE";
|
||||
field public static final String WRITE_DEVICE_CONFIG = "android.permission.WRITE_DEVICE_CONFIG";
|
||||
field @Deprecated public static final String WRITE_MEDIA_STORAGE = "android.permission.WRITE_MEDIA_STORAGE";
|
||||
field public static final String WRITE_OBB = "android.permission.WRITE_OBB";
|
||||
@@ -557,14 +556,6 @@ package android.app.blob {
|
||||
|
||||
}
|
||||
|
||||
package android.app.communal {
|
||||
|
||||
public final class CommunalManager {
|
||||
method @RequiresPermission(android.Manifest.permission.WRITE_COMMUNAL_STATE) public void setCommunalViewShowing(boolean);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package android.app.contentsuggestions {
|
||||
|
||||
public final class ContentSuggestionsManager {
|
||||
|
||||
@@ -26,8 +26,6 @@ import android.app.admin.DevicePolicyManager;
|
||||
import android.app.admin.IDevicePolicyManager;
|
||||
import android.app.appsearch.AppSearchManagerFrameworkInitializer;
|
||||
import android.app.blob.BlobStoreManagerFrameworkInitializer;
|
||||
import android.app.communal.CommunalManager;
|
||||
import android.app.communal.ICommunalManager;
|
||||
import android.app.contentsuggestions.ContentSuggestionsManager;
|
||||
import android.app.contentsuggestions.IContentSuggestionsManager;
|
||||
import android.app.job.JobSchedulerFrameworkInitializer;
|
||||
@@ -1519,21 +1517,6 @@ public final class SystemServiceRegistry {
|
||||
}
|
||||
});
|
||||
|
||||
registerService(Context.COMMUNAL_SERVICE, CommunalManager.class,
|
||||
new CachedServiceFetcher<CommunalManager>() {
|
||||
@Override
|
||||
public CommunalManager createService(ContextImpl ctx) {
|
||||
if (!ctx.getPackageManager().hasSystemFeature(
|
||||
PackageManager.FEATURE_COMMUNAL_MODE)) {
|
||||
return null;
|
||||
}
|
||||
IBinder iBinder =
|
||||
ServiceManager.getService(Context.COMMUNAL_SERVICE);
|
||||
return iBinder != null ? new CommunalManager(
|
||||
ICommunalManager.Stub.asInterface(iBinder)) : null;
|
||||
}
|
||||
});
|
||||
|
||||
sInitializing = true;
|
||||
try {
|
||||
// Note: the following functions need to be @SystemApis, once they become mainline
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.RequiresFeature;
|
||||
import android.annotation.RequiresPermission;
|
||||
import android.annotation.SystemApi;
|
||||
import android.annotation.SystemService;
|
||||
import android.annotation.TestApi;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.RemoteException;
|
||||
|
||||
/**
|
||||
* System private class for talking with the
|
||||
* {@link com.android.server.communal.CommunalManagerService} that handles communal mode state.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi(client = SystemApi.Client.PRIVILEGED_APPS)
|
||||
@SystemService(Context.COMMUNAL_SERVICE)
|
||||
@RequiresFeature(PackageManager.FEATURE_COMMUNAL_MODE)
|
||||
public final class CommunalManager {
|
||||
private final ICommunalManager mService;
|
||||
|
||||
/** @hide */
|
||||
public CommunalManager(ICommunalManager service) {
|
||||
mService = service;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates whether or not the communal view is currently showing over the lockscreen.
|
||||
*
|
||||
* @param isShowing Whether communal view is showing.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
@RequiresPermission(Manifest.permission.WRITE_COMMUNAL_STATE)
|
||||
public void setCommunalViewShowing(boolean isShowing) {
|
||||
try {
|
||||
mService.setCommunalViewShowing(isShowing);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* 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 for talking with the communal manager service that handles communal mode
|
||||
* state.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
interface ICommunalManager {
|
||||
oneway void setCommunalViewShowing(boolean isShowing);
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
brycelee@google.com
|
||||
justinkoh@google.com
|
||||
lusilva@google.com
|
||||
xilei@google.com
|
||||
@@ -5880,17 +5880,6 @@ public abstract class Context {
|
||||
*/
|
||||
public static final String DISPLAY_HASH_SERVICE = "display_hash";
|
||||
|
||||
/**
|
||||
* Use with {@link #getSystemService(String)} to retrieve a
|
||||
* {@link android.app.communal.CommunalManager} for interacting with the global system state.
|
||||
*
|
||||
* @see #getSystemService(String)
|
||||
* @see android.app.communal.CommunalManager
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public static final String COMMUNAL_SERVICE = "communal";
|
||||
|
||||
/**
|
||||
* Use with {@link #getSystemService(String)} to retrieve a
|
||||
* {@link android.app.LocaleManager}.
|
||||
|
||||
@@ -5603,13 +5603,6 @@
|
||||
<permission android:name="android.permission.VIEW_INSTANT_APPS"
|
||||
android:protectionLevel="signature|preinstalled" />
|
||||
|
||||
<!-- Allows an application to interact with the currently active
|
||||
{@link com.android.server.communal.CommunalManagerService}.
|
||||
@hide
|
||||
@TestApi -->
|
||||
<permission android:name="android.permission.WRITE_COMMUNAL_STATE"
|
||||
android:protectionLevel="signature" />
|
||||
|
||||
<!-- 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.
|
||||
|
||||
@@ -150,9 +150,6 @@
|
||||
<uses-permission android:name="android.permission.CONTROL_KEYGUARD_SECURE_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.GET_RUNTIME_PERMISSIONS" />
|
||||
|
||||
<!-- Communal mode -->
|
||||
<uses-permission android:name="android.permission.WRITE_COMMUNAL_STATE" />
|
||||
|
||||
<!-- Needed for WallpaperManager.clear in ImageWallpaper.updateWallpaperLocked -->
|
||||
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
|
||||
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* 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 com.android.systemui.communal;
|
||||
|
||||
import android.app.communal.CommunalManager;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.systemui.CoreStartable;
|
||||
import com.android.systemui.dagger.SysUISingleton;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* The {@link CommunalManagerUpdater} is responsible for forwarding state from SystemUI to
|
||||
* the {@link CommunalManager} system service.
|
||||
*/
|
||||
@SysUISingleton
|
||||
public class CommunalManagerUpdater extends CoreStartable {
|
||||
private static final String TAG = "CommunalManagerUpdater";
|
||||
|
||||
private final CommunalManager mCommunalManager;
|
||||
private final CommunalSourceMonitor mMonitor;
|
||||
|
||||
private final CommunalSourceMonitor.Callback mSourceCallback =
|
||||
new CommunalSourceMonitor.Callback() {
|
||||
@Override
|
||||
public void onSourceAvailable(WeakReference<CommunalSource> source) {
|
||||
try {
|
||||
mCommunalManager.setCommunalViewShowing(
|
||||
source != null && source.get() != null);
|
||||
} catch (RuntimeException e) {
|
||||
Log.e(TAG, "Error updating communal manager service state", e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Inject
|
||||
public CommunalManagerUpdater(Context context, CommunalSourceMonitor monitor) {
|
||||
super(context);
|
||||
mCommunalManager = context.getSystemService(CommunalManager.class);
|
||||
mMonitor = monitor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if (mCommunalManager != null) {
|
||||
mMonitor.addCallback(mSourceCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,6 @@ import com.android.systemui.accessibility.SystemActions;
|
||||
import com.android.systemui.accessibility.WindowMagnification;
|
||||
import com.android.systemui.biometrics.AuthController;
|
||||
import com.android.systemui.clipboardoverlay.ClipboardListener;
|
||||
import com.android.systemui.communal.CommunalManagerUpdater;
|
||||
import com.android.systemui.dreams.DreamOverlayRegistrant;
|
||||
import com.android.systemui.dreams.appwidgets.ComplicationPrimer;
|
||||
import com.android.systemui.globalactions.GlobalActionsComponent;
|
||||
@@ -220,11 +219,4 @@ public abstract class SystemUIBinder {
|
||||
@ClassKey(ComplicationPrimer.class)
|
||||
public abstract CoreStartable bindAppWidgetOverlayPrimer(
|
||||
ComplicationPrimer complicationPrimer);
|
||||
|
||||
/** Inject into CommunalManagerUpdater. */
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ClassKey(CommunalManagerUpdater.class)
|
||||
public abstract CoreStartable bindCommunalManagerUpdater(
|
||||
CommunalManagerUpdater communalManagerUpdater);
|
||||
}
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* 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 com.android.systemui.communal;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.clearInvocations;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.app.communal.CommunalManager;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.util.concurrency.FakeExecutor;
|
||||
import com.android.systemui.util.condition.Monitor;
|
||||
import com.android.systemui.util.time.FakeSystemClock;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
public class CommunalManagerUpdaterTest extends SysuiTestCase {
|
||||
private CommunalSourceMonitor mMonitor;
|
||||
@Mock
|
||||
private CommunalManager mCommunalManager;
|
||||
@Mock
|
||||
private Monitor mCommunalConditionsMonitor;
|
||||
|
||||
private FakeExecutor mExecutor = new FakeExecutor(new FakeSystemClock());
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext.addMockSystemService(CommunalManager.class, mCommunalManager);
|
||||
|
||||
doAnswer(invocation -> {
|
||||
final Monitor.Callback callback = invocation.getArgument(0);
|
||||
callback.onConditionsChanged(true);
|
||||
return null;
|
||||
}).when(mCommunalConditionsMonitor).addCallback(any());
|
||||
|
||||
mMonitor = new CommunalSourceMonitor(mExecutor, mCommunalConditionsMonitor);
|
||||
final CommunalManagerUpdater updater = new CommunalManagerUpdater(mContext, mMonitor);
|
||||
updater.start();
|
||||
clearInvocations(mCommunalManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateSystemService_false() {
|
||||
mMonitor.setSource(null);
|
||||
mExecutor.runAllReady();
|
||||
verify(mCommunalManager).setCommunalViewShowing(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateSystemService_true() {
|
||||
final CommunalSource source = mock(CommunalSource.class);
|
||||
mMonitor.setSource(source);
|
||||
mExecutor.runAllReady();
|
||||
verify(mCommunalManager).setCommunalViewShowing(true);
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* 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 com.android.server.communal;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.RequiresPermission;
|
||||
import android.app.communal.ICommunalManager;
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.server.SystemService;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* System service for handling Communal Mode state.
|
||||
*/
|
||||
public final class CommunalManagerService extends SystemService {
|
||||
private final Context mContext;
|
||||
private final AtomicBoolean mCommunalViewIsShowing = new AtomicBoolean(false);
|
||||
private final BinderService mBinderService;
|
||||
|
||||
public CommunalManagerService(Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
mBinderService = new BinderService();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
BinderService getBinderServiceInstance() {
|
||||
return mBinderService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
publishBinderService(Context.COMMUNAL_SERVICE, mBinderService);
|
||||
}
|
||||
|
||||
private final class BinderService extends ICommunalManager.Stub {
|
||||
/**
|
||||
* Sets whether or not we are in communal mode.
|
||||
*/
|
||||
@RequiresPermission(Manifest.permission.WRITE_COMMUNAL_STATE)
|
||||
@Override
|
||||
public void setCommunalViewShowing(boolean isShowing) {
|
||||
mContext.enforceCallingPermission(Manifest.permission.WRITE_COMMUNAL_STATE,
|
||||
Manifest.permission.WRITE_COMMUNAL_STATE
|
||||
+ "permission required to modify communal state.");
|
||||
if (mCommunalViewIsShowing.get() == isShowing) {
|
||||
return;
|
||||
}
|
||||
mCommunalViewIsShowing.set(isShowing);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
brycelee@google.com
|
||||
justinkoh@google.com
|
||||
lusilva@google.com
|
||||
xilei@google.com
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"presubmit": [
|
||||
{
|
||||
"name": "FrameworksMockingServicesTests",
|
||||
"options": [
|
||||
{
|
||||
"include-filter": "com.android.server.communal"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -53,7 +53,6 @@ public abstract class ActivityInterceptorCallback {
|
||||
*/
|
||||
@IntDef(suffix = { "_ORDERED_ID" }, value = {
|
||||
FIRST_ORDERED_ID,
|
||||
COMMUNAL_MODE_ORDERED_ID,
|
||||
PERMISSION_POLICY_ORDERED_ID,
|
||||
VIRTUAL_DEVICE_SERVICE_ORDERED_ID,
|
||||
LAST_ORDERED_ID // Update this when adding new ids
|
||||
@@ -66,15 +65,10 @@ public abstract class ActivityInterceptorCallback {
|
||||
*/
|
||||
static final int FIRST_ORDERED_ID = 0;
|
||||
|
||||
/**
|
||||
* The identifier for {@link com.android.server.communal.CommunalManagerService} interceptor.
|
||||
*/
|
||||
public static final int COMMUNAL_MODE_ORDERED_ID = 1;
|
||||
|
||||
/**
|
||||
* The identifier for {@link com.android.server.policy.PermissionPolicyService} interceptor
|
||||
*/
|
||||
public static final int PERMISSION_POLICY_ORDERED_ID = 2;
|
||||
public static final int PERMISSION_POLICY_ORDERED_ID = 1;
|
||||
|
||||
/**
|
||||
* The identifier for {@link com.android.server.companion.virtual.VirtualDeviceManagerService}
|
||||
|
||||
@@ -115,7 +115,6 @@ import com.android.server.biometrics.sensors.iris.IrisService;
|
||||
import com.android.server.broadcastradio.BroadcastRadioService;
|
||||
import com.android.server.camera.CameraServiceProxy;
|
||||
import com.android.server.clipboard.ClipboardService;
|
||||
import com.android.server.communal.CommunalManagerService;
|
||||
import com.android.server.compat.PlatformCompat;
|
||||
import com.android.server.compat.PlatformCompatNative;
|
||||
import com.android.server.connectivity.PacProxyService;
|
||||
@@ -2747,12 +2746,6 @@ public final class SystemServer implements Dumpable {
|
||||
mSystemServiceManager.startService(APP_COMPAT_OVERRIDES_SERVICE_CLASS);
|
||||
t.traceEnd();
|
||||
|
||||
if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_COMMUNAL_MODE)) {
|
||||
t.traceBegin("CommunalManagerService");
|
||||
mSystemServiceManager.startService(CommunalManagerService.class);
|
||||
t.traceEnd();
|
||||
}
|
||||
|
||||
// These are needed to propagate to the runnable below.
|
||||
final NetworkManagementService networkManagementF = networkManagement;
|
||||
final NetworkStatsService networkStatsF = networkStats;
|
||||
|
||||
Reference in New Issue
Block a user