Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
Revert "Add the Finder shutdown message to AOSP"
Browse files Browse the repository at this point in the history
Revert submission 26334207-finder_shutdown

Reason for revert: Revert in 24d1
Bug: 336916273

Reverted changes: /q/submissionid:26334207-finder_shutdown
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:88da6b2e2f24432069116d46e70dd63c4d08a93a)
Merged-In: I20b3d485a00109060a6ed206503aa3c12c812969
Change-Id: I20b3d485a00109060a6ed206503aa3c12c812969
  • Loading branch information
Fabian Kozynski authored and Android Build Coastguard Worker committed May 2, 2024
1 parent 5a7d46a commit 01bc321
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 192 deletions.
5 changes: 0 additions & 5 deletions packages/SystemUI/res/drawable/bg_shutdown_finder_message.xml

This file was deleted.

14 changes: 0 additions & 14 deletions packages/SystemUI/res/drawable/ic_finder_active.xml

This file was deleted.

72 changes: 0 additions & 72 deletions packages/SystemUI/res/layout/shutdown_dialog_finder_active.xml

This file was deleted.

5 changes: 0 additions & 5 deletions packages/SystemUI/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2240,11 +2240,6 @@
<!-- Tuner string -->
<!-- Tuner string -->

<!-- Message shown during shutdown when Find My Device with Dead Battery Finder is active [CHAR LIMIT=300] -->
<string name="finder_active">You can locate this phone with Find My Device even when powered off</string>
<!-- Shutdown Progress Dialog. This is shown if the user chooses to power off the phone. [CHAR LIMIT=60] -->
<string name="shutdown_progress">Shutting down\u2026</string>

<!-- Text help link for care instructions for overheating devices [CHAR LIMIT=40] -->
<string name="thermal_shutdown_dialog_help_text">See care steps</string>
<!-- URL for care instructions for overheating devices -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
import android.media.projection.IMediaProjectionManager;
import android.media.projection.MediaProjectionManager;
import android.media.session.MediaSessionManager;
import android.nearby.NearbyManager;
import android.net.ConnectivityManager;
import android.net.NetworkScoreManager;
import android.net.wifi.WifiManager;
Expand Down Expand Up @@ -440,12 +439,6 @@ static MediaSessionManager provideMediaSessionManager(Context context) {
return context.getSystemService(MediaSessionManager.class);
}

@Provides
@Singleton
static NearbyManager provideNearbyManager(Context context) {
return context.getSystemService(NearbyManager.class);
}

@Provides
@Singleton
static NetworkScoreManager provideNetworkScoreManager(Context context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.android.systemui.dagger;

import com.android.systemui.globalactions.ShutdownUiModule;
import com.android.systemui.keyguard.CustomizationProvider;
import com.android.systemui.statusbar.NotificationInsetsModule;
import com.android.systemui.statusbar.QsFrameTranslateModule;
Expand All @@ -31,6 +32,7 @@
DependencyProvider.class,
NotificationInsetsModule.class,
QsFrameTranslateModule.class,
ShutdownUiModule.class,
SystemUIBinder.class,
SystemUIModule.class,
SystemUICoreStartableModule.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
import android.annotation.StringRes;
import android.app.Dialog;
import android.content.Context;
import android.nearby.NearbyManager;
import android.net.platform.flags.Flags;
import android.os.PowerManager;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
Expand All @@ -41,22 +38,16 @@
import com.android.systemui.statusbar.BlurUtils;
import com.android.systemui.statusbar.phone.ScrimController;

import javax.inject.Inject;

/**
* Provides the UI shown during system shutdown.
*/
public class ShutdownUi {

private Context mContext;
private BlurUtils mBlurUtils;
private NearbyManager mNearbyManager;

@Inject
public ShutdownUi(Context context, BlurUtils blurUtils, NearbyManager nearbyManager) {
public ShutdownUi(Context context, BlurUtils blurUtils) {
mContext = context;
mBlurUtils = blurUtils;
mNearbyManager = nearbyManager;
}

/**
Expand Down Expand Up @@ -141,28 +132,12 @@ public void showShutdownUi(boolean isReboot, String reason) {
/**
* Returns the layout resource to use for UI while shutting down.
* @param isReboot Whether this is a reboot or a shutdown.
* @return
*/
@VisibleForTesting int getShutdownDialogContent(boolean isReboot) {
if (!Flags.poweredOffFindingPlatform()) {
return R.layout.shutdown_dialog;
}
int finderActive = mNearbyManager.getPoweredOffFindingMode();
if (finderActive == NearbyManager.POWERED_OFF_FINDING_MODE_DISABLED
|| finderActive == NearbyManager.POWERED_OFF_FINDING_MODE_UNSUPPORTED) {
// inactive or unsupported, use regular shutdown dialog
return R.layout.shutdown_dialog;
} else if (finderActive == NearbyManager.POWERED_OFF_FINDING_MODE_ENABLED) {
// active, use dialog with finder info if shutting down
return isReboot ? R.layout.shutdown_dialog :
com.android.systemui.res.R.layout.shutdown_dialog_finder_active;
} else {
// that's weird? default to regular dialog
Log.w("ShutdownUi", "Unexpected value for finder active: " + finderActive);
return R.layout.shutdown_dialog;
}
public int getShutdownDialogContent(boolean isReboot) {
return R.layout.shutdown_dialog;
}


@StringRes
@VisibleForTesting int getRebootMessage(boolean isReboot, @Nullable String reason) {
if (reason != null && reason.startsWith(PowerManager.REBOOT_RECOVERY_UPDATE)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (C) 2023 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.globalactions

import android.content.Context
import com.android.systemui.statusbar.BlurUtils
import dagger.Module
import dagger.Provides

/** Provides the UI shown during system shutdown. */
@Module
class ShutdownUiModule {
/** Shutdown UI provider. */
@Provides
fun provideShutdownUi(context: Context?, blurUtils: BlurUtils?): ShutdownUi {
return ShutdownUi(context, blurUtils)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNull;

import static org.mockito.Mockito.when;

import android.nearby.NearbyManager;
import android.net.platform.flags.Flags;
import android.os.PowerManager;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.testing.AndroidTestingRunner;

import androidx.test.filters.SmallTest;
Expand All @@ -38,7 +32,6 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;


@SmallTest
Expand All @@ -48,13 +41,10 @@ public class ShutdownUiTest extends SysuiTestCase {
ShutdownUi mShutdownUi;
@Mock
BlurUtils mBlurUtils;
@Mock
NearbyManager mNearbyManager;

@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mShutdownUi = new ShutdownUi(getContext(), mBlurUtils, mNearbyManager);
mShutdownUi = new ShutdownUi(getContext(), mBlurUtils);
}

@Test
Expand Down Expand Up @@ -92,53 +82,4 @@ public void getRebootMessage_defaultToNone() {
String message = mShutdownUi.getReasonMessage("anything-else");
assertNull(message);
}

@EnableFlags(Flags.FLAG_POWERED_OFF_FINDING_PLATFORM)
@Test
public void getDialog_whenPowerOffFindingModeEnabled_returnsFinderDialog() {
when(mNearbyManager.getPoweredOffFindingMode()).thenReturn(
NearbyManager.POWERED_OFF_FINDING_MODE_ENABLED);

int actualLayout = mShutdownUi.getShutdownDialogContent(false);

int expectedLayout = com.android.systemui.res.R.layout.shutdown_dialog_finder_active;
assertEquals(actualLayout, expectedLayout);
}

@DisableFlags(Flags.FLAG_POWERED_OFF_FINDING_PLATFORM)
@Test
public void getDialog_whenPowerOffFindingModeEnabledFlagDisabled_returnsFinderDialog() {
when(mNearbyManager.getPoweredOffFindingMode()).thenReturn(
NearbyManager.POWERED_OFF_FINDING_MODE_ENABLED);

int actualLayout = mShutdownUi.getShutdownDialogContent(false);

int expectedLayout = R.layout.shutdown_dialog;
assertEquals(actualLayout, expectedLayout);
}

@EnableFlags(Flags.FLAG_POWERED_OFF_FINDING_PLATFORM)
@Test
public void getDialog_whenPowerOffFindingModeDisabled_returnsDefaultDialog() {
when(mNearbyManager.getPoweredOffFindingMode()).thenReturn(
NearbyManager.POWERED_OFF_FINDING_MODE_DISABLED);

int actualLayout = mShutdownUi.getShutdownDialogContent(false);

int expectedLayout = R.layout.shutdown_dialog;
assertEquals(actualLayout, expectedLayout);
}

@EnableFlags(Flags.FLAG_POWERED_OFF_FINDING_PLATFORM)
@Test
public void getDialog_whenPowerOffFindingModeEnabledAndIsReboot_returnsDefaultDialog() {
when(mNearbyManager.getPoweredOffFindingMode()).thenReturn(
NearbyManager.POWERED_OFF_FINDING_MODE_ENABLED);

int actualLayout = mShutdownUi.getShutdownDialogContent(true);

int expectedLayout = R.layout.shutdown_dialog;
assertEquals(actualLayout, expectedLayout);
}

}

0 comments on commit 01bc321

Please sign in to comment.