Merge "Don't show unsupported sdk warning in test harness." into pi-dev

This commit is contained in:
Wale Ogunwale
2018-03-23 23:32:54 +00:00
committed by Android (Google) Code Review
5 changed files with 54 additions and 0 deletions

View File

@@ -20,6 +20,7 @@ package android.app {
public class ActivityManager {
method public void addOnUidImportanceListener(android.app.ActivityManager.OnUidImportanceListener, int);
method public void alwaysShowUnsupportedCompileSdkWarning(android.content.ComponentName);
method public int getPackageImportance(java.lang.String);
method public long getTotalRam();
method public int getUidImportance(int);

View File

@@ -3744,6 +3744,24 @@ public class ActivityManager {
return SystemProperties.getBoolean("ro.test_harness", false);
}
/**
* Unsupported compiled sdk warning should always be shown for the intput activity
* even in cases where the system would normally not show the warning. E.g. when running in a
* test harness.
*
* @param activity The component name of the activity to always show the warning for.
*
* @hide
*/
@TestApi
public void alwaysShowUnsupportedCompileSdkWarning(ComponentName activity) {
try {
getService().alwaysShowUnsupportedCompileSdkWarning(activity);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Returns the launch count of each installed package.
*

View File

@@ -703,4 +703,7 @@ interface IActivityManager {
*/
void registerRemoteAnimationForNextActivityStart(in String packageName,
in RemoteAnimationAdapter adapter);
/** @see android.app.ActivityManager#alwaysShowUnsupportedCompileSdkWarning */
void alwaysShowUnsupportedCompileSdkWarning(in ComponentName activity);
}

View File

@@ -26704,4 +26704,17 @@ public class ActivityManagerService extends IActivityManager.Stub
}
}
}
/** @see android.app.ActivityManager#alwaysShowUnsupportedCompileSdkWarning */
@Override
public void alwaysShowUnsupportedCompileSdkWarning(ComponentName activity) {
synchronized (this) {
final long origId = Binder.clearCallingIdentity();
try {
mAppWarnings.alwaysShowUnsupportedCompileSdkWarning(activity);
} finally {
Binder.restoreCallingIdentity(origId);
}
}
}
}

View File

@@ -17,6 +17,8 @@
package com.android.server.am;
import android.annotation.UiThread;
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Build;
@@ -39,6 +41,7 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
/**
@@ -64,6 +67,15 @@ class AppWarnings {
private UnsupportedCompileSdkDialog mUnsupportedCompileSdkDialog;
private DeprecatedTargetSdkVersionDialog mDeprecatedTargetSdkVersionDialog;
/** @see android.app.ActivityManager#alwaysShowUnsupportedCompileSdkWarning */
private HashSet<ComponentName> mAlwaysShowUnsupportedCompileSdkWarningActivities =
new HashSet<>();
/** @see android.app.ActivityManager#alwaysShowUnsupportedCompileSdkWarning */
void alwaysShowUnsupportedCompileSdkWarning(ComponentName activity) {
mAlwaysShowUnsupportedCompileSdkWarningActivities.add(activity);
}
/**
* Creates a new warning dialog manager.
* <p>
@@ -110,6 +122,13 @@ class AppWarnings {
return;
}
if (ActivityManager.isRunningInTestHarness()
&& !mAlwaysShowUnsupportedCompileSdkWarningActivities.contains(r.realActivity)) {
// Don't show warning if we are running in a test harness and we don't have to always
// show for this activity.
return;
}
// If the application was built against an pre-release SDK that's older than the current
// platform OR if the current platform is pre-release and older than the SDK against which
// the application was built OR both are pre-release with the same SDK_INT but different