Snap for 12773175 from e306ee4c6c to 25Q2-release
Change-Id: I1cbdba955a2e673fe7766f60e71c2d8b443453d0
This commit is contained in:
@@ -20,6 +20,9 @@ import android.content.Context;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.accessibility.AccessibilityEvent;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@@ -101,6 +104,7 @@ public class BluetoothDashboardFragment extends DashboardFragment {
|
|||||||
SettingsActivity activity = (SettingsActivity) getActivity();
|
SettingsActivity activity = (SettingsActivity) getActivity();
|
||||||
mSwitchBar = activity.getSwitchBar();
|
mSwitchBar = activity.getSwitchBar();
|
||||||
mSwitchBar.setTitle(getContext().getString(R.string.bluetooth_main_switch_title));
|
mSwitchBar.setTitle(getContext().getString(R.string.bluetooth_main_switch_title));
|
||||||
|
mSwitchBar.getRootView().setAccessibilityDelegate(new MainSwitchAccessibilityDelegate());
|
||||||
mController = new BluetoothSwitchPreferenceController(activity,
|
mController = new BluetoothSwitchPreferenceController(activity,
|
||||||
new MainSwitchBarController(mSwitchBar), mFooterPreference);
|
new MainSwitchBarController(mSwitchBar), mFooterPreference);
|
||||||
mController.setAlwaysDiscoverable(isAlwaysDiscoverable(callingAppPackageName, action));
|
mController.setAlwaysDiscoverable(isAlwaysDiscoverable(callingAppPackageName, action));
|
||||||
@@ -127,4 +131,19 @@ public class BluetoothDashboardFragment extends DashboardFragment {
|
|||||||
public @Nullable String getPreferenceScreenBindingKey(@NonNull Context context) {
|
public @Nullable String getPreferenceScreenBindingKey(@NonNull Context context) {
|
||||||
return BluetoothDashboardScreen.KEY;
|
return BluetoothDashboardScreen.KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final class MainSwitchAccessibilityDelegate extends View.AccessibilityDelegate {
|
||||||
|
@Override
|
||||||
|
public boolean onRequestSendAccessibilityEvent(
|
||||||
|
@NonNull ViewGroup host, @NonNull View view, @NonNull AccessibilityEvent event) {
|
||||||
|
if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED
|
||||||
|
&& (event.getContentChangeTypes()
|
||||||
|
& AccessibilityEvent.CONTENT_CHANGE_TYPE_ENABLED)
|
||||||
|
!= 0) {
|
||||||
|
Log.d(TAG, "Skip accessibility event for CONTENT_CHANGE_TYPE_ENABLED");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return super.onRequestSendAccessibilityEvent(host, view, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ public class PrivateSpaceMaintainer {
|
|||||||
private final ActivityManager mActivityManager;
|
private final ActivityManager mActivityManager;
|
||||||
private int mErrorCode;
|
private int mErrorCode;
|
||||||
@GuardedBy("this")
|
@GuardedBy("this")
|
||||||
|
@Nullable
|
||||||
private UserHandle mUserHandle;
|
private UserHandle mUserHandle;
|
||||||
private final KeyguardManager mKeyguardManager;
|
private final KeyguardManager mKeyguardManager;
|
||||||
/** This variable should be accessed via {@link #getProfileBroadcastReceiver()} only. */
|
/** This variable should be accessed via {@link #getProfileBroadcastReceiver()} only. */
|
||||||
@@ -419,12 +420,16 @@ public class PrivateSpaceMaintainer {
|
|||||||
mContext.unregisterReceiver(/* receiver= */ this);
|
mContext.unregisterReceiver(/* receiver= */ this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GuardedBy("PrivateSpaceMaintainer.this")
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(@NonNull Context context, @NonNull Intent intent) {
|
public void onReceive(@NonNull Context context, @NonNull Intent intent) {
|
||||||
UserHandle userHandle = intent.getParcelableExtra(Intent.EXTRA_USER, UserHandle.class);
|
UserHandle userHandle = intent.getParcelableExtra(Intent.EXTRA_USER, UserHandle.class);
|
||||||
if (intent.getAction().equals(Intent.ACTION_PROFILE_REMOVED)) {
|
if (intent.getAction().equals(Intent.ACTION_PROFILE_REMOVED)) {
|
||||||
// This applies to all profiles getting removed, since there is no way to tell if
|
// This applies to all profiles getting removed, since there is no way to tell if
|
||||||
// it is a private profile that got removed.
|
// it is a private profile that got removed.
|
||||||
|
if (userHandle.equals(getPrivateProfileHandle())) {
|
||||||
|
mUserHandle = null;
|
||||||
|
}
|
||||||
removeSettingsAllTasks();
|
removeSettingsAllTasks();
|
||||||
unregisterBroadcastReceiver();
|
unregisterBroadcastReceiver();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ import org.mockito.junit.MockitoJUnit;
|
|||||||
import org.mockito.junit.MockitoRule;
|
import org.mockito.junit.MockitoRule;
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
@Ignore("b/382664790")
|
||||||
public class SatelliteSettingsPreferenceControllerTest {
|
public class SatelliteSettingsPreferenceControllerTest {
|
||||||
private static final String KEY = "key";
|
private static final String KEY = "key";
|
||||||
private static final int TEST_SUB_ID = 0;
|
private static final int TEST_SUB_ID = 0;
|
||||||
|
|||||||
@@ -36,9 +36,11 @@ import android.app.IActivityManager;
|
|||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Flags;
|
import android.os.Flags;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.platform.test.flag.junit.SetFlagsRule;
|
import android.platform.test.flag.junit.SetFlagsRule;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -46,6 +48,7 @@ import android.provider.Settings;
|
|||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
|
import com.android.compatibility.common.util.BlockingBroadcastReceiver;
|
||||||
import com.android.settings.privatespace.PrivateSpaceMaintainer.ErrorDeletingPrivateSpace;
|
import com.android.settings.privatespace.PrivateSpaceMaintainer.ErrorDeletingPrivateSpace;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
@@ -57,6 +60,9 @@ import org.junit.Test;
|
|||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public class PrivateSpaceMaintainerTest {
|
public class PrivateSpaceMaintainerTest {
|
||||||
private static final String TAG = "PSMaintainerTest";
|
private static final String TAG = "PSMaintainerTest";
|
||||||
@@ -506,4 +512,25 @@ public class PrivateSpaceMaintainerTest {
|
|||||||
/* enabled */ 1,
|
/* enabled */ 1,
|
||||||
privateSpaceMaintainer.getPrivateProfileHandle().getIdentifier());
|
privateSpaceMaintainer.getPrivateProfileHandle().getIdentifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void profileRemovedFromUserManager_privateSpaceNoLongerExists() {
|
||||||
|
PrivateSpaceMaintainer privateSpaceMaintainer = PrivateSpaceMaintainer.getInstance(
|
||||||
|
mContext);
|
||||||
|
privateSpaceMaintainer.createPrivateSpace();
|
||||||
|
UserHandle privateSpaceUserHandle = privateSpaceMaintainer.getPrivateProfileHandle();
|
||||||
|
assertThat(privateSpaceMaintainer.doesPrivateSpaceExist()).isTrue();
|
||||||
|
Intent removedIntent = new Intent(Intent.ACTION_PROFILE_REMOVED);
|
||||||
|
assertThat(privateSpaceUserHandle).isNotNull();
|
||||||
|
final BlockingBroadcastReceiver receiver = new BlockingBroadcastReceiver(mContext,
|
||||||
|
removedIntent.getAction());
|
||||||
|
receiver.register();
|
||||||
|
|
||||||
|
Objects.requireNonNull(mContext.getSystemService(UserManager.class)).removeUser(
|
||||||
|
privateSpaceUserHandle);
|
||||||
|
|
||||||
|
receiver.awaitForBroadcast(TimeUnit.SECONDS.toMillis(10));
|
||||||
|
assertThat(privateSpaceMaintainer.doesPrivateSpaceExist()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user