Revert "Introduce listUIChanges API for developer UI" am: 9c862eab69
Change-Id: Ib83233f955df8af7b36f48fa07722343baa01a9f
This commit is contained in:
@@ -93,43 +93,6 @@ public class CompatibilityChangeInfo implements Parcelable {
|
|||||||
dest.writeString(mDescription);
|
dest.writeString(mDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder sb = new StringBuilder("CompatibilityChangeInfo(")
|
|
||||||
.append(getId());
|
|
||||||
if (getName() != null) {
|
|
||||||
sb.append("; name=").append(getName());
|
|
||||||
}
|
|
||||||
if (getEnableAfterTargetSdk() != -1) {
|
|
||||||
sb.append("; enableAfterTargetSdk=").append(getEnableAfterTargetSdk());
|
|
||||||
}
|
|
||||||
if (getDisabled()) {
|
|
||||||
sb.append("; disabled");
|
|
||||||
}
|
|
||||||
if (getLoggingOnly()) {
|
|
||||||
sb.append("; loggingOnly");
|
|
||||||
}
|
|
||||||
return sb.append(")").toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || !(o instanceof CompatibilityChangeInfo)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
CompatibilityChangeInfo that = (CompatibilityChangeInfo) o;
|
|
||||||
return this.mChangeId == that.mChangeId
|
|
||||||
&& this.mName.equals(that.mName)
|
|
||||||
&& this.mEnableAfterTargetSdk == that.mEnableAfterTargetSdk
|
|
||||||
&& this.mDisabled == that.mDisabled
|
|
||||||
&& this.mLoggingOnly == that.mLoggingOnly
|
|
||||||
&& this.mDescription.equals(that.mDescription);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Parcelable.Creator<CompatibilityChangeInfo> CREATOR =
|
public static final Parcelable.Creator<CompatibilityChangeInfo> CREATOR =
|
||||||
new Parcelable.Creator<CompatibilityChangeInfo>() {
|
new Parcelable.Creator<CompatibilityChangeInfo>() {
|
||||||
|
|
||||||
|
|||||||
@@ -221,14 +221,6 @@ interface IPlatformCompat
|
|||||||
*/
|
*/
|
||||||
CompatibilityChangeInfo[] listAllChanges();
|
CompatibilityChangeInfo[] listAllChanges();
|
||||||
|
|
||||||
/**
|
|
||||||
* List the compatibility changes that should be present in the UI.
|
|
||||||
* Filters out certain changes like e.g. logging only.
|
|
||||||
*
|
|
||||||
* @return An array of {@link CompatChangeInfo}.
|
|
||||||
*/
|
|
||||||
CompatibilityChangeInfo[] listUIChanges();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an instance that can determine whether a changeid can be overridden for a package name.
|
* Get an instance that can determine whether a changeid can be overridden for a package name.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import android.content.Context;
|
|||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManagerInternal;
|
import android.content.pm.PackageManagerInternal;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
@@ -45,7 +44,6 @@ import com.android.server.LocalServices;
|
|||||||
|
|
||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* System server internal API for gating and reporting compatibility changes.
|
* System server internal API for gating and reporting compatibility changes.
|
||||||
@@ -58,9 +56,6 @@ public class PlatformCompat extends IPlatformCompat.Stub {
|
|||||||
private final ChangeReporter mChangeReporter;
|
private final ChangeReporter mChangeReporter;
|
||||||
private final CompatConfig mCompatConfig;
|
private final CompatConfig mCompatConfig;
|
||||||
|
|
||||||
private static int sMinTargetSdk = Build.VERSION_CODES.P;
|
|
||||||
private static int sMaxTargetSdk = Build.VERSION_CODES.Q;
|
|
||||||
|
|
||||||
public PlatformCompat(Context context) {
|
public PlatformCompat(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mChangeReporter = new ChangeReporter(
|
mChangeReporter = new ChangeReporter(
|
||||||
@@ -225,12 +220,6 @@ public class PlatformCompat extends IPlatformCompat.Stub {
|
|||||||
return mCompatConfig.dumpChanges();
|
return mCompatConfig.dumpChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompatibilityChangeInfo[] listUIChanges() {
|
|
||||||
return Arrays.stream(listAllChanges()).filter(
|
|
||||||
x -> isShownInUI(x)).toArray(CompatibilityChangeInfo[]::new);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the change is known to the compat config.
|
* Check whether the change is known to the compat config.
|
||||||
*
|
*
|
||||||
@@ -350,17 +339,4 @@ public class PlatformCompat extends IPlatformCompat.Stub {
|
|||||||
checkCompatChangeReadPermission();
|
checkCompatChangeReadPermission();
|
||||||
checkCompatChangeLogPermission();
|
checkCompatChangeLogPermission();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isShownInUI(CompatibilityChangeInfo change) {
|
|
||||||
if (change.getLoggingOnly()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (change.getEnableAfterTargetSdk() != 0) {
|
|
||||||
if (change.getEnableAfterTargetSdk() < sMinTargetSdk
|
|
||||||
|| change.getEnableAfterTargetSdk() > sMaxTargetSdk) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,12 +30,10 @@ import static org.testng.Assert.assertThrows;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManagerInternal;
|
import android.content.pm.PackageManagerInternal;
|
||||||
import android.os.Build;
|
|
||||||
|
|
||||||
import androidx.test.runner.AndroidJUnit4;
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
import com.android.internal.compat.AndroidBuildClassifier;
|
import com.android.internal.compat.AndroidBuildClassifier;
|
||||||
import com.android.internal.compat.CompatibilityChangeInfo;
|
|
||||||
import com.android.server.LocalServices;
|
import com.android.server.LocalServices;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -79,47 +77,6 @@ public class PlatformCompatTest {
|
|||||||
LocalServices.addService(PackageManagerInternal.class, mPackageManagerInternal);
|
LocalServices.addService(PackageManagerInternal.class, mPackageManagerInternal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testListAllChanges() {
|
|
||||||
mCompatConfig = CompatConfigBuilder.create(mBuildClassifier, mContext)
|
|
||||||
.addEnabledChangeWithId(1L)
|
|
||||||
.addDisabledChangeWithIdAndName(2L, "change2")
|
|
||||||
.addTargetSdkChangeWithIdAndDescription(Build.VERSION_CODES.O, 3L, "description")
|
|
||||||
.addTargetSdkChangeWithId(Build.VERSION_CODES.P, 4L)
|
|
||||||
.addTargetSdkChangeWithId(Build.VERSION_CODES.Q, 5L)
|
|
||||||
.addTargetSdkChangeWithId(Build.VERSION_CODES.R, 6L)
|
|
||||||
.addLoggingOnlyChangeWithId(7L)
|
|
||||||
.build();
|
|
||||||
mPlatformCompat = new PlatformCompat(mContext, mCompatConfig);
|
|
||||||
assertThat(mPlatformCompat.listAllChanges()).asList().containsExactly(
|
|
||||||
new CompatibilityChangeInfo(1L, "", -1, false, false, ""),
|
|
||||||
new CompatibilityChangeInfo(2L, "change2", -1, true, false, ""),
|
|
||||||
new CompatibilityChangeInfo(3L, "", Build.VERSION_CODES.O, false, false,
|
|
||||||
"description"),
|
|
||||||
new CompatibilityChangeInfo(4L, "", Build.VERSION_CODES.P, false, false, ""),
|
|
||||||
new CompatibilityChangeInfo(5L, "", Build.VERSION_CODES.Q, false, false, ""),
|
|
||||||
new CompatibilityChangeInfo(6L, "", Build.VERSION_CODES.R, false, false, ""),
|
|
||||||
new CompatibilityChangeInfo(7L, "", -1, false, true, ""));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testListUIChanges() {
|
|
||||||
mCompatConfig = CompatConfigBuilder.create(mBuildClassifier, mContext)
|
|
||||||
.addEnabledChangeWithId(1L)
|
|
||||||
.addDisabledChangeWithIdAndName(2L, "change2")
|
|
||||||
.addTargetSdkChangeWithIdAndDescription(Build.VERSION_CODES.O, 3L, "description")
|
|
||||||
.addTargetSdkChangeWithId(Build.VERSION_CODES.P, 4L)
|
|
||||||
.addTargetSdkChangeWithId(Build.VERSION_CODES.Q, 5L)
|
|
||||||
.addTargetSdkChangeWithId(Build.VERSION_CODES.R, 6L)
|
|
||||||
.addLoggingOnlyChangeWithId(7L)
|
|
||||||
.build();
|
|
||||||
mPlatformCompat = new PlatformCompat(mContext, mCompatConfig);
|
|
||||||
assertThat(mPlatformCompat.listUIChanges()).asList().containsExactly(
|
|
||||||
new CompatibilityChangeInfo(1L, "", -1, false, false, ""),
|
|
||||||
new CompatibilityChangeInfo(2L, "change2", -1, true, false, ""),
|
|
||||||
new CompatibilityChangeInfo(4L, "", Build.VERSION_CODES.P, false, false, ""),
|
|
||||||
new CompatibilityChangeInfo(5L, "", Build.VERSION_CODES.Q, false, false, ""));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRegisterListenerToSameIdThrows() throws Exception {
|
public void testRegisterListenerToSameIdThrows() throws Exception {
|
||||||
// Registering a listener to change 1 is successful.
|
// Registering a listener to change 1 is successful.
|
||||||
|
|||||||
Reference in New Issue
Block a user