Address code warnings in the android.app package.
- Make fields that are only assigned once private. - Fix typos. - Remove unnecessary boxed types. - Remove unused default value variable assignemnts. - Merge repetitive exception handling. Test: m dist -j && acloud create --local-instance --local-image Change-Id: Idc2aa16798d6cf4fe9df0a13f37e002667a1de41
This commit is contained in:
@@ -959,7 +959,7 @@ public class Activity extends ContextThemeWrapper
|
||||
private int mDefaultKeyMode = DEFAULT_KEYS_DISABLE;
|
||||
private SpannableStringBuilder mDefaultKeySsb = null;
|
||||
|
||||
private ActivityManager.TaskDescription mTaskDescription =
|
||||
private final ActivityManager.TaskDescription mTaskDescription =
|
||||
new ActivityManager.TaskDescription();
|
||||
|
||||
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;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
ActivityTransitionState mActivityTransitionState = new ActivityTransitionState();
|
||||
final ActivityTransitionState mActivityTransitionState = new ActivityTransitionState();
|
||||
SharedElementCallback mEnterTransitionListener = SharedElementCallback.NULL_CALLBACK;
|
||||
SharedElementCallback mExitTransitionListener = SharedElementCallback.NULL_CALLBACK;
|
||||
|
||||
@@ -1839,7 +1839,7 @@ public class Activity extends ContextThemeWrapper
|
||||
final int numDialogs = ids.length;
|
||||
mManagedDialogs = new SparseArray<ManagedDialog>(numDialogs);
|
||||
for (int i = 0; i < numDialogs; i++) {
|
||||
final Integer dialogId = ids[i];
|
||||
final int dialogId = ids[i];
|
||||
Bundle dialogState = b.getBundle(savedDialogKeyFor(dialogId));
|
||||
if (dialogState != null) {
|
||||
// Calling onRestoreInstanceState() below will invoke dispatchOnCreate
|
||||
@@ -1909,7 +1909,7 @@ public class Activity extends ContextThemeWrapper
|
||||
* <code>persistAcrossReboots</code>.
|
||||
*
|
||||
* @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)}.
|
||||
*
|
||||
* @see #onCreate
|
||||
@@ -5058,7 +5058,7 @@ public class Activity extends ContextThemeWrapper
|
||||
* 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
|
||||
* 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
|
||||
* {@link #startSearch startSearch(null, false, null, false)}, which launches
|
||||
* search for the current activity as specified in its manifest, see {@link SearchManager}.
|
||||
@@ -8797,7 +8797,7 @@ public class Activity extends ContextThemeWrapper
|
||||
* @see Activity#convertFromTranslucent()
|
||||
* @see Activity#convertToTranslucent(TranslucentConversionListener, ActivityOptions)
|
||||
*/
|
||||
public void onTranslucentConversionComplete(boolean drawComplete);
|
||||
void onTranslucentConversionComplete(boolean drawComplete);
|
||||
}
|
||||
|
||||
private void dispatchRequestPermissionsResult(int requestCode, Intent data) {
|
||||
@@ -8920,7 +8920,7 @@ public class Activity extends ContextThemeWrapper
|
||||
/**
|
||||
* 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.
|
||||
* @hide
|
||||
*/
|
||||
|
||||
@@ -266,7 +266,6 @@ public final class ActivityThread extends ClientTransactionHandler
|
||||
implements ActivityThreadInternal {
|
||||
/** @hide */
|
||||
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 DEBUG_MESSAGES = false;
|
||||
/** @hide */
|
||||
@@ -368,7 +367,7 @@ public final class ActivityThread extends ClientTransactionHandler
|
||||
private final AtomicInteger mNumLaunchingActivities = new AtomicInteger();
|
||||
@GuardedBy("mAppThread")
|
||||
private int mLastProcessState = PROCESS_STATE_UNKNOWN;
|
||||
ArrayList<WeakReference<AssistStructure>> mLastAssistStructures = new ArrayList<>();
|
||||
final ArrayList<WeakReference<AssistStructure>> mLastAssistStructures = new ArrayList<>();
|
||||
private int mLastSessionId;
|
||||
final ArrayMap<IBinder, CreateServiceData> mServicesData = new ArrayMap<>();
|
||||
@UnsupportedAppUsage
|
||||
@@ -564,7 +563,7 @@ public final class ActivityThread extends ClientTransactionHandler
|
||||
Configuration createdConfig;
|
||||
Configuration overrideConfig;
|
||||
// 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.
|
||||
ViewRootImpl.ActivityConfigCallback activityConfigCallback;
|
||||
ActivityClientRecord nextIdle;
|
||||
@@ -769,7 +768,7 @@ public final class ActivityThread extends ClientTransactionHandler
|
||||
}
|
||||
}
|
||||
|
||||
final class ProviderClientRecord {
|
||||
static final class ProviderClientRecord {
|
||||
final String[] mNames;
|
||||
@UnsupportedAppUsage
|
||||
final IContentProvider mProvider;
|
||||
@@ -796,7 +795,7 @@ public final class ActivityThread extends ClientTransactionHandler
|
||||
}
|
||||
|
||||
@UnsupportedAppUsage
|
||||
Intent intent;
|
||||
final Intent intent;
|
||||
@UnsupportedAppUsage
|
||||
ActivityInfo info;
|
||||
@UnsupportedAppUsage
|
||||
@@ -3336,11 +3335,8 @@ public final class ActivityThread extends ClientTransactionHandler
|
||||
public void registerOnActivityPausedListener(Activity activity,
|
||||
OnActivityPausedListener listener) {
|
||||
synchronized (mOnPauseListeners) {
|
||||
ArrayList<OnActivityPausedListener> list = mOnPauseListeners.get(activity);
|
||||
if (list == null) {
|
||||
list = new ArrayList<OnActivityPausedListener>();
|
||||
mOnPauseListeners.put(activity, list);
|
||||
}
|
||||
ArrayList<OnActivityPausedListener> list =
|
||||
mOnPauseListeners.computeIfAbsent(activity, k -> new ArrayList<>());
|
||||
list.add(listener);
|
||||
}
|
||||
}
|
||||
@@ -5400,7 +5396,7 @@ public final class ActivityThread extends ClientTransactionHandler
|
||||
/** Core implementation of activity destroy call. */
|
||||
void performDestroyActivity(ActivityClientRecord r, boolean finishing,
|
||||
int configChanges, boolean getNonConfigInstance, String reason) {
|
||||
Class<? extends Activity> activityClass = null;
|
||||
Class<? extends Activity> activityClass;
|
||||
if (localLOGV) Slog.v(TAG, "Performing finish of " + r);
|
||||
activityClass = r.activity.getClass();
|
||||
r.activity.mConfigChangeFlags |= configChanges;
|
||||
@@ -7051,7 +7047,7 @@ public final class ActivityThread extends ClientTransactionHandler
|
||||
// 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
|
||||
// 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);
|
||||
try {
|
||||
synchronized (key) {
|
||||
@@ -7105,11 +7101,7 @@ public final class ActivityThread extends ClientTransactionHandler
|
||||
private ProviderKey getGetProviderKey(String auth, int userId) {
|
||||
final ProviderKey key = new ProviderKey(auth, userId);
|
||||
synchronized (mGetProviderKeys) {
|
||||
ProviderKey lock = mGetProviderKeys.get(key);
|
||||
if (lock == null) {
|
||||
lock = key;
|
||||
mGetProviderKeys.put(key, lock);
|
||||
}
|
||||
ProviderKey lock = mGetProviderKeys.computeIfAbsent(key, k -> k);
|
||||
return lock;
|
||||
}
|
||||
}
|
||||
@@ -7744,7 +7736,7 @@ public final class ActivityThread extends ClientTransactionHandler
|
||||
if (!DEPRECATE_DATA_COLUMNS) return;
|
||||
|
||||
// Install interception and make sure it sticks!
|
||||
Os def = null;
|
||||
Os def;
|
||||
do {
|
||||
def = Os.getDefault();
|
||||
} while (!Os.compareAndSetDefault(def, new AndroidOs(def)));
|
||||
|
||||
@@ -16,9 +16,6 @@
|
||||
|
||||
package android.app;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
@@ -29,13 +26,16 @@ import android.util.Xml;
|
||||
|
||||
import com.android.internal.util.XmlUtils;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Stub activity that launches another activity (and then finishes itself)
|
||||
* based on information in its component's manifest meta-data. This is a
|
||||
* simple way to implement an alias-like mechanism.
|
||||
*
|
||||
*
|
||||
* 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
|
||||
* resource describing an intent that launches the real application.
|
||||
@@ -51,11 +51,11 @@ public class AliasActivity extends Activity {
|
||||
* {@hide}
|
||||
*/
|
||||
public final String ALIAS_META_DATA = "android.app.alias";
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
XmlResourceParser parser = null;
|
||||
try {
|
||||
ActivityInfo ai = getPackageManager().getActivityInfo(
|
||||
@@ -66,21 +66,17 @@ public class AliasActivity extends Activity {
|
||||
throw new RuntimeException("Alias requires a meta-data field "
|
||||
+ ALIAS_META_DATA);
|
||||
}
|
||||
|
||||
|
||||
Intent intent = parseAlias(parser);
|
||||
if (intent == null) {
|
||||
throw new RuntimeException(
|
||||
"No <intent> tag found in alias description");
|
||||
}
|
||||
|
||||
|
||||
startActivity(intent);
|
||||
finish();
|
||||
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
throw new RuntimeException("Error parsing alias", e);
|
||||
} catch (XmlPullParserException e) {
|
||||
throw new RuntimeException("Error parsing alias", e);
|
||||
} catch (IOException e) {
|
||||
|
||||
} catch (PackageManager.NameNotFoundException | XmlPullParserException | IOException e) {
|
||||
throw new RuntimeException("Error parsing alias", e);
|
||||
} finally {
|
||||
if (parser != null) parser.close();
|
||||
@@ -90,21 +86,21 @@ public class AliasActivity extends Activity {
|
||||
private Intent parseAlias(XmlPullParser parser)
|
||||
throws XmlPullParserException, IOException {
|
||||
AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||
|
||||
|
||||
Intent intent = null;
|
||||
|
||||
|
||||
int type;
|
||||
while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
|
||||
&& type != XmlPullParser.START_TAG) {
|
||||
}
|
||||
|
||||
|
||||
String nodeName = parser.getName();
|
||||
if (!"alias".equals(nodeName)) {
|
||||
throw new RuntimeException(
|
||||
"Alias meta-data must start with <alias> tag; found"
|
||||
+ nodeName + " at " + parser.getPositionDescription());
|
||||
}
|
||||
|
||||
|
||||
int outerDepth = parser.getDepth();
|
||||
while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
|
||||
&& (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
|
||||
@@ -120,8 +116,8 @@ public class AliasActivity extends Activity {
|
||||
XmlUtils.skipCurrentTag(parser);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return intent;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -535,7 +535,7 @@ public final class SearchableInfo implements Parcelable {
|
||||
*/
|
||||
public static SearchableInfo getActivityMetaData(Context context, ActivityInfo activityInfo,
|
||||
int userId) {
|
||||
Context userContext = null;
|
||||
Context userContext;
|
||||
try {
|
||||
userContext = context.createPackageContextAsUser("system", 0,
|
||||
new UserHandle(userId));
|
||||
|
||||
@@ -1629,7 +1629,6 @@ public class WallpaperManager {
|
||||
mContext.getUserId());
|
||||
if (fd != null) {
|
||||
FileOutputStream fos = null;
|
||||
boolean ok = false;
|
||||
try {
|
||||
fos = new ParcelFileDescriptor.AutoCloseOutputStream(fd);
|
||||
copyStreamToWallpaperFile(resources.openRawResource(resid), fos);
|
||||
|
||||
Reference in New Issue
Block a user