Merge "Address code warnings in the android.app package." am: a750dcaaa6 am: 34321c6d9f

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2553030

Change-Id: Ic1015012bad3b9b4a6049dba42ef82f4a27744c2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Mateus Azis
2023-04-21 21:42:01 +00:00
committed by Automerger Merge Worker
5 changed files with 34 additions and 47 deletions

View File

@@ -959,7 +959,7 @@ public class Activity extends ContextThemeWrapper
private int mDefaultKeyMode = DEFAULT_KEYS_DISABLE; private int mDefaultKeyMode = DEFAULT_KEYS_DISABLE;
private SpannableStringBuilder mDefaultKeySsb = null; private SpannableStringBuilder mDefaultKeySsb = null;
private ActivityManager.TaskDescription mTaskDescription = private final ActivityManager.TaskDescription mTaskDescription =
new ActivityManager.TaskDescription(); new ActivityManager.TaskDescription();
protected static final int[] FOCUSED_STATE_SET = {com.android.internal.R.attr.state_focused}; protected static final int[] FOCUSED_STATE_SET = {com.android.internal.R.attr.state_focused};
@@ -970,7 +970,7 @@ public class Activity extends ContextThemeWrapper
private Thread mUiThread; private Thread mUiThread;
@UnsupportedAppUsage @UnsupportedAppUsage
ActivityTransitionState mActivityTransitionState = new ActivityTransitionState(); final ActivityTransitionState mActivityTransitionState = new ActivityTransitionState();
SharedElementCallback mEnterTransitionListener = SharedElementCallback.NULL_CALLBACK; SharedElementCallback mEnterTransitionListener = SharedElementCallback.NULL_CALLBACK;
SharedElementCallback mExitTransitionListener = SharedElementCallback.NULL_CALLBACK; SharedElementCallback mExitTransitionListener = SharedElementCallback.NULL_CALLBACK;
@@ -1840,7 +1840,7 @@ public class Activity extends ContextThemeWrapper
final int numDialogs = ids.length; final int numDialogs = ids.length;
mManagedDialogs = new SparseArray<ManagedDialog>(numDialogs); mManagedDialogs = new SparseArray<ManagedDialog>(numDialogs);
for (int i = 0; i < numDialogs; i++) { for (int i = 0; i < numDialogs; i++) {
final Integer dialogId = ids[i]; final int dialogId = ids[i];
Bundle dialogState = b.getBundle(savedDialogKeyFor(dialogId)); Bundle dialogState = b.getBundle(savedDialogKeyFor(dialogId));
if (dialogState != null) { if (dialogState != null) {
// Calling onRestoreInstanceState() below will invoke dispatchOnCreate // Calling onRestoreInstanceState() below will invoke dispatchOnCreate
@@ -1910,7 +1910,7 @@ public class Activity extends ContextThemeWrapper
* <code>persistAcrossReboots</code>. * <code>persistAcrossReboots</code>.
* *
* @param savedInstanceState The data most recently supplied in {@link #onSaveInstanceState} * @param savedInstanceState The data most recently supplied in {@link #onSaveInstanceState}
* @param persistentState The data caming from the PersistableBundle first * @param persistentState The data coming from the PersistableBundle first
* saved in {@link #onSaveInstanceState(Bundle, PersistableBundle)}. * saved in {@link #onSaveInstanceState(Bundle, PersistableBundle)}.
* *
* @see #onCreate * @see #onCreate
@@ -5059,7 +5059,7 @@ public class Activity extends ContextThemeWrapper
* This hook is called when the user signals the desire to start a search. * This hook is called when the user signals the desire to start a search.
* *
* <p>You can use this function as a simple way to launch the search UI, in response to a * <p>You can use this function as a simple way to launch the search UI, in response to a
* menu item, search button, or other widgets within your activity. Unless overidden, * menu item, search button, or other widgets within your activity. Unless overridden,
* calling this function is the same as calling * calling this function is the same as calling
* {@link #startSearch startSearch(null, false, null, false)}, which launches * {@link #startSearch startSearch(null, false, null, false)}, which launches
* search for the current activity as specified in its manifest, see {@link SearchManager}. * search for the current activity as specified in its manifest, see {@link SearchManager}.
@@ -8798,7 +8798,7 @@ public class Activity extends ContextThemeWrapper
* @see Activity#convertFromTranslucent() * @see Activity#convertFromTranslucent()
* @see Activity#convertToTranslucent(TranslucentConversionListener, ActivityOptions) * @see Activity#convertToTranslucent(TranslucentConversionListener, ActivityOptions)
*/ */
public void onTranslucentConversionComplete(boolean drawComplete); void onTranslucentConversionComplete(boolean drawComplete);
} }
private void dispatchRequestPermissionsResult(int requestCode, Intent data) { private void dispatchRequestPermissionsResult(int requestCode, Intent data) {
@@ -8921,7 +8921,7 @@ public class Activity extends ContextThemeWrapper
/** /**
* Registers remote animations per transition type for this activity. * Registers remote animations per transition type for this activity.
* *
* @param definition The remote animation definition that defines which transition whould run * @param definition The remote animation definition that defines which transition would run
* which remote animation. * which remote animation.
* @hide * @hide
*/ */

View File

@@ -269,7 +269,6 @@ public final class ActivityThread extends ClientTransactionHandler
implements ActivityThreadInternal { implements ActivityThreadInternal {
/** @hide */ /** @hide */
public static final String TAG = "ActivityThread"; public static final String TAG = "ActivityThread";
private static final android.graphics.Bitmap.Config THUMBNAIL_FORMAT = Bitmap.Config.RGB_565;
static final boolean localLOGV = false; static final boolean localLOGV = false;
static final boolean DEBUG_MESSAGES = false; static final boolean DEBUG_MESSAGES = false;
/** @hide */ /** @hide */
@@ -371,7 +370,7 @@ public final class ActivityThread extends ClientTransactionHandler
private final AtomicInteger mNumLaunchingActivities = new AtomicInteger(); private final AtomicInteger mNumLaunchingActivities = new AtomicInteger();
@GuardedBy("mAppThread") @GuardedBy("mAppThread")
private int mLastProcessState = PROCESS_STATE_UNKNOWN; private int mLastProcessState = PROCESS_STATE_UNKNOWN;
ArrayList<WeakReference<AssistStructure>> mLastAssistStructures = new ArrayList<>(); final ArrayList<WeakReference<AssistStructure>> mLastAssistStructures = new ArrayList<>();
private int mLastSessionId; private int mLastSessionId;
final ArrayMap<IBinder, CreateServiceData> mServicesData = new ArrayMap<>(); final ArrayMap<IBinder, CreateServiceData> mServicesData = new ArrayMap<>();
@UnsupportedAppUsage @UnsupportedAppUsage
@@ -567,7 +566,7 @@ public final class ActivityThread extends ClientTransactionHandler
Configuration createdConfig; Configuration createdConfig;
Configuration overrideConfig; Configuration overrideConfig;
// Used for consolidating configs before sending on to Activity. // Used for consolidating configs before sending on to Activity.
private Configuration tmpConfig = new Configuration(); private final Configuration tmpConfig = new Configuration();
// Callback used for updating activity override config and camera compat control state. // Callback used for updating activity override config and camera compat control state.
ViewRootImpl.ActivityConfigCallback activityConfigCallback; ViewRootImpl.ActivityConfigCallback activityConfigCallback;
ActivityClientRecord nextIdle; ActivityClientRecord nextIdle;
@@ -772,7 +771,7 @@ public final class ActivityThread extends ClientTransactionHandler
} }
} }
final class ProviderClientRecord { static final class ProviderClientRecord {
final String[] mNames; final String[] mNames;
@UnsupportedAppUsage @UnsupportedAppUsage
final IContentProvider mProvider; final IContentProvider mProvider;
@@ -799,7 +798,7 @@ public final class ActivityThread extends ClientTransactionHandler
} }
@UnsupportedAppUsage @UnsupportedAppUsage
Intent intent; final Intent intent;
@UnsupportedAppUsage @UnsupportedAppUsage
ActivityInfo info; ActivityInfo info;
@UnsupportedAppUsage @UnsupportedAppUsage
@@ -3339,11 +3338,8 @@ public final class ActivityThread extends ClientTransactionHandler
public void registerOnActivityPausedListener(Activity activity, public void registerOnActivityPausedListener(Activity activity,
OnActivityPausedListener listener) { OnActivityPausedListener listener) {
synchronized (mOnPauseListeners) { synchronized (mOnPauseListeners) {
ArrayList<OnActivityPausedListener> list = mOnPauseListeners.get(activity); ArrayList<OnActivityPausedListener> list =
if (list == null) { mOnPauseListeners.computeIfAbsent(activity, k -> new ArrayList<>());
list = new ArrayList<OnActivityPausedListener>();
mOnPauseListeners.put(activity, list);
}
list.add(listener); list.add(listener);
} }
} }
@@ -5403,7 +5399,7 @@ public final class ActivityThread extends ClientTransactionHandler
/** Core implementation of activity destroy call. */ /** Core implementation of activity destroy call. */
void performDestroyActivity(ActivityClientRecord r, boolean finishing, void performDestroyActivity(ActivityClientRecord r, boolean finishing,
int configChanges, boolean getNonConfigInstance, String reason) { int configChanges, boolean getNonConfigInstance, String reason) {
Class<? extends Activity> activityClass = null; Class<? extends Activity> activityClass;
if (localLOGV) Slog.v(TAG, "Performing finish of " + r); if (localLOGV) Slog.v(TAG, "Performing finish of " + r);
activityClass = r.activity.getClass(); activityClass = r.activity.getClass();
r.activity.mConfigChangeFlags |= configChanges; r.activity.mConfigChangeFlags |= configChanges;
@@ -7085,7 +7081,7 @@ public final class ActivityThread extends ClientTransactionHandler
// Note that we cannot hold the lock while acquiring and installing the // Note that we cannot hold the lock while acquiring and installing the
// provider since it might take a long time to run and it could also potentially // provider since it might take a long time to run and it could also potentially
// be re-entrant in the case where the provider is in the same process. // be re-entrant in the case where the provider is in the same process.
ContentProviderHolder holder = null; ContentProviderHolder holder;
final ProviderKey key = getGetProviderKey(auth, userId); final ProviderKey key = getGetProviderKey(auth, userId);
try { try {
synchronized (key) { synchronized (key) {
@@ -7139,11 +7135,7 @@ public final class ActivityThread extends ClientTransactionHandler
private ProviderKey getGetProviderKey(String auth, int userId) { private ProviderKey getGetProviderKey(String auth, int userId) {
final ProviderKey key = new ProviderKey(auth, userId); final ProviderKey key = new ProviderKey(auth, userId);
synchronized (mGetProviderKeys) { synchronized (mGetProviderKeys) {
ProviderKey lock = mGetProviderKeys.get(key); ProviderKey lock = mGetProviderKeys.computeIfAbsent(key, k -> k);
if (lock == null) {
lock = key;
mGetProviderKeys.put(key, lock);
}
return lock; return lock;
} }
} }
@@ -7778,7 +7770,7 @@ public final class ActivityThread extends ClientTransactionHandler
if (!DEPRECATE_DATA_COLUMNS) return; if (!DEPRECATE_DATA_COLUMNS) return;
// Install interception and make sure it sticks! // Install interception and make sure it sticks!
Os def = null; Os def;
do { do {
def = Os.getDefault(); def = Os.getDefault();
} while (!Os.compareAndSetDefault(def, new AndroidOs(def))); } while (!Os.compareAndSetDefault(def, new AndroidOs(def)));

View File

@@ -16,9 +16,6 @@
package android.app; package android.app;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
@@ -29,13 +26,16 @@ import android.util.Xml;
import com.android.internal.util.XmlUtils; import com.android.internal.util.XmlUtils;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException; import java.io.IOException;
/** /**
* Stub activity that launches another activity (and then finishes itself) * Stub activity that launches another activity (and then finishes itself)
* based on information in its component's manifest meta-data. This is a * based on information in its component's manifest meta-data. This is a
* simple way to implement an alias-like mechanism. * simple way to implement an alias-like mechanism.
* *
* To use this activity, you should include in the manifest for the associated * To use this activity, you should include in the manifest for the associated
* component an entry named "android.app.alias". It is a reference to an XML * component an entry named "android.app.alias". It is a reference to an XML
* resource describing an intent that launches the real application. * resource describing an intent that launches the real application.
@@ -51,11 +51,11 @@ public class AliasActivity extends Activity {
* {@hide} * {@hide}
*/ */
public final String ALIAS_META_DATA = "android.app.alias"; public final String ALIAS_META_DATA = "android.app.alias";
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
XmlResourceParser parser = null; XmlResourceParser parser = null;
try { try {
ActivityInfo ai = getPackageManager().getActivityInfo( ActivityInfo ai = getPackageManager().getActivityInfo(
@@ -66,21 +66,17 @@ public class AliasActivity extends Activity {
throw new RuntimeException("Alias requires a meta-data field " throw new RuntimeException("Alias requires a meta-data field "
+ ALIAS_META_DATA); + ALIAS_META_DATA);
} }
Intent intent = parseAlias(parser); Intent intent = parseAlias(parser);
if (intent == null) { if (intent == null) {
throw new RuntimeException( throw new RuntimeException(
"No <intent> tag found in alias description"); "No <intent> tag found in alias description");
} }
startActivity(intent); startActivity(intent);
finish(); finish();
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException | XmlPullParserException | IOException e) {
throw new RuntimeException("Error parsing alias", e);
} catch (XmlPullParserException e) {
throw new RuntimeException("Error parsing alias", e);
} catch (IOException e) {
throw new RuntimeException("Error parsing alias", e); throw new RuntimeException("Error parsing alias", e);
} finally { } finally {
if (parser != null) parser.close(); if (parser != null) parser.close();
@@ -90,21 +86,21 @@ public class AliasActivity extends Activity {
private Intent parseAlias(XmlPullParser parser) private Intent parseAlias(XmlPullParser parser)
throws XmlPullParserException, IOException { throws XmlPullParserException, IOException {
AttributeSet attrs = Xml.asAttributeSet(parser); AttributeSet attrs = Xml.asAttributeSet(parser);
Intent intent = null; Intent intent = null;
int type; int type;
while ((type=parser.next()) != XmlPullParser.END_DOCUMENT while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
&& type != XmlPullParser.START_TAG) { && type != XmlPullParser.START_TAG) {
} }
String nodeName = parser.getName(); String nodeName = parser.getName();
if (!"alias".equals(nodeName)) { if (!"alias".equals(nodeName)) {
throw new RuntimeException( throw new RuntimeException(
"Alias meta-data must start with <alias> tag; found" "Alias meta-data must start with <alias> tag; found"
+ nodeName + " at " + parser.getPositionDescription()); + nodeName + " at " + parser.getPositionDescription());
} }
int outerDepth = parser.getDepth(); int outerDepth = parser.getDepth();
while ((type=parser.next()) != XmlPullParser.END_DOCUMENT while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
&& (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
@@ -120,8 +116,8 @@ public class AliasActivity extends Activity {
XmlUtils.skipCurrentTag(parser); XmlUtils.skipCurrentTag(parser);
} }
} }
return intent; return intent;
} }
} }

View File

@@ -535,7 +535,7 @@ public final class SearchableInfo implements Parcelable {
*/ */
public static SearchableInfo getActivityMetaData(Context context, ActivityInfo activityInfo, public static SearchableInfo getActivityMetaData(Context context, ActivityInfo activityInfo,
int userId) { int userId) {
Context userContext = null; Context userContext;
try { try {
userContext = context.createPackageContextAsUser("system", 0, userContext = context.createPackageContextAsUser("system", 0,
new UserHandle(userId)); new UserHandle(userId));

View File

@@ -1629,7 +1629,6 @@ public class WallpaperManager {
mContext.getUserId()); mContext.getUserId());
if (fd != null) { if (fd != null) {
FileOutputStream fos = null; FileOutputStream fos = null;
boolean ok = false;
try { try {
fos = new ParcelFileDescriptor.AutoCloseOutputStream(fd); fos = new ParcelFileDescriptor.AutoCloseOutputStream(fd);
copyStreamToWallpaperFile(resources.openRawResource(resid), fos); copyStreamToWallpaperFile(resources.openRawResource(resid), fos);