src/api-impl: fix up code style, mainly for code imported from AOSP

used the following (plus manual edits):
`clang-format --style="{BasedOnStyle: LLVM, IndentWidth: 8, UseTab: Always, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: true, ColumnLimit: 0}`
This commit is contained in:
Mis012
2023-06-22 11:45:46 +02:00
parent 824b821f5a
commit 0a9591c474
208 changed files with 154568 additions and 150150 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -16,20 +16,24 @@
package android.annotation; package android.annotation;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/** /**
* Indicates a constant field value should be exported to be used in the SDK tools. * Indicates a constant field value should be exported to be used in the SDK tools.
* @hide * @hide
*/ */
@Target({ ElementType.FIELD }) @Target({ElementType.FIELD})
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
public @interface SdkConstant { public @interface SdkConstant {
public static enum SdkConstantType { public static enum SdkConstantType {
ACTIVITY_INTENT_ACTION, BROADCAST_INTENT_ACTION, SERVICE_ACTION, INTENT_CATEGORY, FEATURE; ACTIVITY_INTENT_ACTION,
BROADCAST_INTENT_ACTION,
SERVICE_ACTION,
INTENT_CATEGORY,
FEATURE;
} }
SdkConstantType value(); SdkConstantType value();

View File

@@ -26,7 +26,9 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
/** Indicates that Lint should ignore the specified warnings for the annotated element. */ /**
* Indicates that Lint should ignore the specified warnings for the annotated element.
*/
@Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE}) @Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE})
@Retention(RetentionPolicy.CLASS) @Retention(RetentionPolicy.CLASS)
public @interface SuppressLint { public @interface SuppressLint {

View File

@@ -23,8 +23,10 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
/** Indicates that Lint should treat this type as targeting a given API level, no matter what the /**
project target is. */ Indicates that Lint should treat this type as targeting a given API level, no matter what the
project target is.
*/
@Target({TYPE, METHOD, CONSTRUCTOR}) @Target({TYPE, METHOD, CONSTRUCTOR})
@Retention(RetentionPolicy.CLASS) @Retention(RetentionPolicy.CLASS)
public @interface TargetApi { public @interface TargetApi {

View File

@@ -16,10 +16,10 @@
package android.annotation; package android.annotation;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/** /**
* Indicates a class is a widget usable by application developers to create UI. * Indicates a class is a widget usable by application developers to create UI.
@@ -31,7 +31,7 @@ import java.lang.annotation.RetentionPolicy;
* </ul> * </ul>
* @hide * @hide
*/ */
@Target({ ElementType.TYPE }) @Target({ElementType.TYPE})
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
public @interface Widget { public @interface Widget {
} }

View File

@@ -1,31 +1,27 @@
package android.app; package android.app;
import android.content.Context;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.XmlResourceParser; import android.content.res.XmlResourceParser;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.TextView;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.LayoutInflater;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.WindowManagerImpl; import android.view.WindowManagerImpl;
import android.widget.TextView;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserFactory;
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock; import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.StringReader; import java.io.StringReader;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserFactory;
public class Activity extends Context { public class Activity extends Context {
LayoutInflater layout_inflater; LayoutInflater layout_inflater;
@@ -64,7 +60,7 @@ public class Activity extends Context {
public View root_view; public View root_view;
public final Application getApplication () { public final Application getApplication() {
return (Application)getApplicationContext(); return (Application)getApplicationContext();
} }
@@ -89,7 +85,7 @@ public class Activity extends Context {
return requested_orientation; return requested_orientation;
} }
public void setRequestedOrientation (int orientation) { public void setRequestedOrientation(int orientation) {
requested_orientation = orientation; requested_orientation = orientation;
} }
@@ -146,7 +142,7 @@ public class Activity extends Context {
} }
public void onWindowFocusChanged(boolean hasFocus) { public void onWindowFocusChanged(boolean hasFocus) {
System.out.println("- onWindowFocusChanged - yay! (hasFocus: "+hasFocus+")"); System.out.println("- onWindowFocusChanged - yay! (hasFocus: " + hasFocus + ")");
return; return;
} }
@@ -204,7 +200,7 @@ public class Activity extends Context {
View view = View.view_by_id.get(id); View view = View.view_by_id.get(id);
System.out.println("- findViewById - found this: " + view); System.out.println("- findViewById - found this: " + view);
return (T) view; return (T)view;
} }
public void invalidateOptionsMenu() { public void invalidateOptionsMenu() {
@@ -219,10 +215,10 @@ public class Activity extends Context {
action.run(); // FIXME: running synchronously for now action.run(); // FIXME: running synchronously for now
} }
protected void onActivityResult (int requestCode, int resultCode, Intent data) {} protected void onActivityResult(int requestCode, int resultCode, Intent data) {}
public void startActivityForResult (Intent intent, int requestCode) { public void startActivityForResult(Intent intent, int requestCode) {
System.out.println("startActivityForResult("+intent+", "+requestCode+") called, but we don't currently support multiple activities"); System.out.println("startActivityForResult(" + intent + ", " + requestCode + ") called, but we don't currently support multiple activities");
onActivityResult(requestCode, 0 /*RESULT_CANCELED*/, new Intent()); // RESULT_CANCELED is the only pre-defined return value, so hopefully it works out for us onActivityResult(requestCode, 0 /*RESULT_CANCELED*/, new Intent()); // RESULT_CANCELED is the only pre-defined return value, so hopefully it works out for us
} }
} }

View File

@@ -6,37 +6,37 @@ import android.view.View;
public class AlertDialog extends Dialog { public class AlertDialog extends Dialog {
public static class Builder { public static class Builder {
public Builder(Context context){ public Builder(Context context) {
System.out.println("making an AlertDialog$Builder as we speak, my word!"); System.out.println("making an AlertDialog$Builder as we speak, my word!");
} }
public AlertDialog.Builder setPositiveButton (int textId, DialogInterface.OnClickListener listener) { public AlertDialog.Builder setPositiveButton(int textId, DialogInterface.OnClickListener listener) {
return this; return this;
} }
public AlertDialog.Builder setPositiveButton (CharSequence text, DialogInterface.OnClickListener listener) { public AlertDialog.Builder setPositiveButton(CharSequence text, DialogInterface.OnClickListener listener) {
return this; return this;
} }
public AlertDialog.Builder setCancelable (boolean cancelable) { public AlertDialog.Builder setCancelable(boolean cancelable) {
return this; return this;
} }
public AlertDialog.Builder setIcon (int iconId) { public AlertDialog.Builder setIcon(int iconId) {
return this; return this;
} }
public AlertDialog.Builder setTitle (CharSequence title) { public AlertDialog.Builder setTitle(CharSequence title) {
System.out.println("AlertDialog.Builder setTitle called with: '"+title+"'"); System.out.println("AlertDialog.Builder setTitle called with: '" + title + "'");
return this; return this;
} }
public AlertDialog.Builder setMessage (CharSequence message) { public AlertDialog.Builder setMessage(CharSequence message) {
System.out.println("AlertDialog.Builder setMessage called with: '"+message+"'"); System.out.println("AlertDialog.Builder setMessage called with: '" + message + "'");
return this; return this;
} }
public AlertDialog.Builder setView (View view) { public AlertDialog.Builder setView(View view) {
return this; return this;
} }

View File

@@ -4,15 +4,15 @@ import android.content.Context;
public class Dialog { public class Dialog {
public void show() { public void show() {
System.out.println("totally showing the Dialog "+this+" right now, most definitely doing that"); System.out.println("totally showing the Dialog " + this + " right now, most definitely doing that");
} }
public void dismiss() { public void dismiss() {
System.out.println("totally dismissing the Dialog "+this+" right now, which was most definitely being shown just a moment ago"); System.out.println("totally dismissing the Dialog " + this + " right now, which was most definitely being shown just a moment ago");
} }
public class Builder { public class Builder {
public Builder(Context context){ public Builder(Context context) {
System.out.println("making a Dialog$Builder as we speak, my word!"); System.out.println("making a Dialog$Builder as we speak, my word!");
} }
} }

View File

@@ -21,7 +21,7 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.res.AssetManager; import android.content.res.AssetManager;
import android.content.res.Configuration; import android.content.res.Configuration;
//import android.graphics.PixelFormat; // import android.graphics.PixelFormat;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Looper; import android.os.Looper;
@@ -34,15 +34,13 @@ import android.view.SurfaceView;
import android.view.View; import android.view.View;
import android.view.ViewTreeObserver.OnGlobalLayoutListener; import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.WindowManager; import android.view.WindowManager;
//import android.view.inputmethod.InputMethodManager;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock; import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
import com.reandroid.arsc.chunk.xml.ResXmlAttribute; import com.reandroid.arsc.chunk.xml.ResXmlAttribute;
import com.reandroid.arsc.chunk.xml.ResXmlElement; import com.reandroid.arsc.chunk.xml.ResXmlElement;
// import android.view.inputmethod.InputMethodManager;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
/** /**
* Convenience for implementing an activity that will be implemented * Convenience for implementing an activity that will be implemented
@@ -81,7 +79,7 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback,
private static final String KEY_NATIVE_SAVED_STATE = "android:native_state"; private static final String KEY_NATIVE_SAVED_STATE = "android:native_state";
private NativeContentView mNativeContentView; private NativeContentView mNativeContentView;
// private InputMethodManager mIMM; // private InputMethodManager mIMM;
private long mNativeHandle; private long mNativeHandle;
@@ -128,7 +126,7 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback,
} }
public NativeContentView(Context context, AttributeSet attrs) { public NativeContentView(Context context, AttributeSet attrs) {
super(context/*, attrs*/); super(context /*, attrs*/);
} }
} }
@@ -169,20 +167,20 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback,
// parse AndroidManifest.xml to get name and entry of native lib // parse AndroidManifest.xml to get name and entry of native lib
try (InputStream inStream = ClassLoader.getSystemClassLoader().getResourceAsStream("AndroidManifest.xml")) { try (InputStream inStream = ClassLoader.getSystemClassLoader().getResourceAsStream("AndroidManifest.xml")) {
for (ResXmlElement activity: AndroidManifestBlock.load(inStream).listActivities()) { for (ResXmlElement activity : AndroidManifestBlock.load(inStream).listActivities()) {
if (!getClass().getName().equals(activity.searchAttributeByResourceId(AndroidManifestBlock.ID_name).getValueAsString())) { if (!getClass().getName().equals(activity.searchAttributeByResourceId(AndroidManifestBlock.ID_name).getValueAsString())) {
continue; continue;
} }
for (ResXmlElement metaData: activity.listElements(AndroidManifestBlock.TAG_meta_data)) { for (ResXmlElement metaData : activity.listElements(AndroidManifestBlock.TAG_meta_data)) {
ResXmlAttribute name = metaData.searchAttributeByResourceId(AndroidManifestBlock.ID_name); ResXmlAttribute name = metaData.searchAttributeByResourceId(AndroidManifestBlock.ID_name);
ResXmlAttribute value = metaData.searchAttributeByResourceId(AndroidManifestBlock.ID_value); ResXmlAttribute value = metaData.searchAttributeByResourceId(AndroidManifestBlock.ID_value);
if (name == null || value == null){ if (name == null || value == null) {
continue; continue;
} }
if (META_DATA_LIB_NAME.equals(name.getValueAsString())){ if (META_DATA_LIB_NAME.equals(name.getValueAsString())) {
libname = value.getValueAsString(); libname = value.getValueAsString();
} }
if (META_DATA_FUNC_NAME.equals(name.getValueAsString())){ if (META_DATA_FUNC_NAME.equals(name.getValueAsString())) {
funcname = value.getValueAsString(); funcname = value.getValueAsString();
} }
} }
@@ -204,7 +202,8 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback,
} }
byte[] nativeSavedState = savedInstanceState != null byte[] nativeSavedState = savedInstanceState != null
? savedInstanceState.getByteArray(KEY_NATIVE_SAVED_STATE) : null; ? savedInstanceState.getByteArray(KEY_NATIVE_SAVED_STATE)
: null;
mNativeHandle = loadNativeCode(path, funcname, Looper.myQueue(), mNativeHandle = loadNativeCode(path, funcname, Looper.myQueue(),
getAbsolutePath(getFilesDir()), getAbsolutePath(getObbDir()), getAbsolutePath(getFilesDir()), getAbsolutePath(getObbDir()),

View File

@@ -13,9 +13,8 @@ public class PendingIntent {
return null; return null;
} }
public void send (Context context, int code, Intent intent) {} public void send(Context context, int code, Intent intent) {}
public class CanceledException extends Exception { public class CanceledException extends Exception {
} }
} }

View File

@@ -17,19 +17,15 @@
package android.app; package android.app;
import android.content.SharedPreferences; import android.content.SharedPreferences;
//import android.os.FileUtils; import android.system.ErrnoException;
//import android.os.Looper; // import android.os.FileUtils;
// import android.os.Looper;
import android.system.Os; import android.system.Os;
import android.system.StructStat; import android.system.StructStat;
import android.util.Log; import android.util.Log;
// import com.google.android.collect.Maps;
//import com.google.android.collect.Maps;
import com.android.internal.util.XmlUtils; import com.android.internal.util.XmlUtils;
import dalvik.system.BlockGuard; import dalvik.system.BlockGuard;
import org.xmlpull.v1.XmlPullParserException;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@@ -45,9 +41,8 @@ import java.util.Set;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import android.system.ErrnoException;
import libcore.io.IoUtils; import libcore.io.IoUtils;
import org.xmlpull.v1.XmlPullParserException;
public final class SharedPreferencesImpl implements SharedPreferences { public final class SharedPreferencesImpl implements SharedPreferences {
private static final String TAG = "SharedPreferencesImpl"; private static final String TAG = "SharedPreferencesImpl";
@@ -114,7 +109,7 @@ public final class SharedPreferencesImpl implements SharedPreferences {
BufferedInputStream str = null; BufferedInputStream str = null;
try { try {
str = new BufferedInputStream( str = new BufferedInputStream(
new FileInputStream(mFile), 16*1024); new FileInputStream(mFile), 16 * 1024);
map = XmlUtils.readMapXml(str); map = XmlUtils.readMapXml(str);
} catch (XmlPullParserException e) { } catch (XmlPullParserException e) {
Log.w(TAG, "getSharedPreferences", e); Log.w(TAG, "getSharedPreferences", e);
@@ -159,7 +154,8 @@ public final class SharedPreferencesImpl implements SharedPreferences {
synchronized (this) { synchronized (this) {
if (mDiskWritesInFlight > 0) { if (mDiskWritesInFlight > 0) {
// If we know we caused it, it's not unexpected. // If we know we caused it, it's not unexpected.
if (DEBUG) Log.d(TAG, "disk write in flight, not unexpected."); if (DEBUG)
Log.d(TAG, "disk write in flight, not unexpected.");
return false; return false;
} }
} }
@@ -180,13 +176,13 @@ public final class SharedPreferencesImpl implements SharedPreferences {
} }
public void registerOnSharedPreferenceChangeListener(OnSharedPreferenceChangeListener listener) { public void registerOnSharedPreferenceChangeListener(OnSharedPreferenceChangeListener listener) {
synchronized(this) { synchronized (this) {
mListeners.put(listener, mContent); mListeners.put(listener, mContent);
} }
} }
public void unregisterOnSharedPreferenceChangeListener(OnSharedPreferenceChangeListener listener) { public void unregisterOnSharedPreferenceChangeListener(OnSharedPreferenceChangeListener listener) {
synchronized(this) { synchronized (this) {
mListeners.remove(listener); mListeners.remove(listener);
} }
} }
@@ -210,7 +206,7 @@ public final class SharedPreferencesImpl implements SharedPreferences {
System.out.println("\n\n...> getAll()\n\n"); System.out.println("\n\n...> getAll()\n\n");
synchronized (this) { synchronized (this) {
awaitLoadedLocked(); awaitLoadedLocked();
//noinspection unchecked // noinspection unchecked
return new HashMap<String, Object>(mMap); return new HashMap<String, Object>(mMap);
} }
} }
@@ -226,7 +222,7 @@ public final class SharedPreferencesImpl implements SharedPreferences {
public Set<String> getStringSet(String key, Set<String> defValues) { public Set<String> getStringSet(String key, Set<String> defValues) {
synchronized (this) { synchronized (this) {
awaitLoadedLocked(); awaitLoadedLocked();
Set<String> v = (Set<String>) mMap.get(key); Set<String> v = (Set<String>)mMap.get(key);
return v != null ? v : defValues; return v != null ? v : defValues;
} }
} }
@@ -364,14 +360,14 @@ public final class SharedPreferencesImpl implements SharedPreferences {
} }
}; };
// QueuedWork.add(awaitCommit); // QueuedWork.add(awaitCommit);
// since we've made this synchronous, we can't exactly start "waiting" for the commit before we made the commit // since we've made this synchronous, we can't exactly start "waiting" for the commit before we made the commit
// awaitCommit.run(); // awaitCommit.run();
Runnable postWriteRunnable = new Runnable() { Runnable postWriteRunnable = new Runnable() {
public void run() { public void run() {
awaitCommit.run(); awaitCommit.run();
// QueuedWork.remove(awaitCommit); // QueuedWork.remove(awaitCommit);
} }
}; };
@@ -461,7 +457,7 @@ public final class SharedPreferencesImpl implements SharedPreferences {
return mcr.writeToDiskResult; return mcr.writeToDiskResult;
} }
private void notifyListeners(final MemoryCommitResult mcr) {/* private void notifyListeners(final MemoryCommitResult mcr) { /*
if (mcr.listeners == null || mcr.keysModified == null || if (mcr.listeners == null || mcr.keysModified == null ||
mcr.keysModified.size() == 0) { mcr.keysModified.size() == 0) {
return; return;
@@ -483,7 +479,8 @@ public final class SharedPreferencesImpl implements SharedPreferences {
} }
}); });
} }
*/} */
}
} }
/** /**
@@ -533,7 +530,7 @@ public final class SharedPreferencesImpl implements SharedPreferences {
} }
} }
//QueuedWork.singleThreadExecutor().execute(writeToDiskRunnable); // QueuedWork.singleThreadExecutor().execute(writeToDiskRunnable);
writeToDiskRunnable.run(); writeToDiskRunnable.run();
} }
@@ -547,7 +544,7 @@ public final class SharedPreferencesImpl implements SharedPreferences {
Log.e(TAG, "Couldn't create directory for SharedPreferences file " + file); Log.e(TAG, "Couldn't create directory for SharedPreferences file " + file);
return null; return null;
} }
/* FileUtils.setPermissions( /* FileUtils.setPermissions(
parent.getPath(), parent.getPath(),
FileUtils.S_IRWXU|FileUtils.S_IRWXG|FileUtils.S_IXOTH, FileUtils.S_IRWXU|FileUtils.S_IRWXG|FileUtils.S_IXOTH,
-1, -1);*/ -1, -1);*/
@@ -574,8 +571,7 @@ public final class SharedPreferencesImpl implements SharedPreferences {
} }
if (!mBackupFile.exists()) { if (!mBackupFile.exists()) {
if (!mFile.renameTo(mBackupFile)) { if (!mFile.renameTo(mBackupFile)) {
Log.e(TAG, "Couldn't rename file " + mFile Log.e(TAG, "Couldn't rename file " + mFile + " to backup file " + mBackupFile);
+ " to backup file " + mBackupFile);
mcr.setDiskWriteResult(false); mcr.setDiskWriteResult(false);
return; return;
} }

View File

@@ -1,5 +1,4 @@
package android.content; package android.content;
public class ActivityNotFoundException extends Exception { public class ActivityNotFoundException extends Exception {
} }

View File

@@ -1,5 +1,4 @@
package android.content; package android.content;
public class BroadcastReceiver { public class BroadcastReceiver {
} }

View File

@@ -15,10 +15,10 @@
*/ */
package android.content; package android.content;
import android.content.Context; import android.content.Context;
import android.os.Message;
import android.os.RemoteException;
import android.os.Handler; import android.os.Handler;
import android.os.IBinder; import android.os.IBinder;
import android.os.Message;
import android.os.RemoteException;
import android.util.Log; import android.util.Log;
import java.util.ArrayList; import java.util.ArrayList;
@@ -65,7 +65,9 @@ public class ClipboardManager extends android.text.ClipboardManager {
*/ */
void onPrimaryClipChanged(); void onPrimaryClipChanged();
} }
/** {@hide} */ /**
* {@hide}
*/
public ClipboardManager(Context context, Handler handler) { public ClipboardManager(Context context, Handler handler) {
} }
public ClipboardManager() { public ClipboardManager() {

View File

@@ -42,8 +42,10 @@ public final class ComponentName implements Cloneable, Comparable<ComponentName>
* implements the component. Can not be null. * implements the component. Can not be null.
*/ */
public ComponentName(String pkg, String cls) { public ComponentName(String pkg, String cls) {
if (pkg == null) throw new NullPointerException("package name is null"); if (pkg == null)
if (cls == null) throw new NullPointerException("class name is null"); throw new NullPointerException("package name is null");
if (cls == null)
throw new NullPointerException("class name is null");
mPackage = pkg; mPackage = pkg;
mClass = cls; mClass = cls;
} }
@@ -57,7 +59,8 @@ public final class ComponentName implements Cloneable, Comparable<ComponentName>
* implements the component. * implements the component.
*/ */
public ComponentName(Context pkg, String cls) { public ComponentName(Context pkg, String cls) {
if (cls == null) throw new NullPointerException("class name is null"); if (cls == null)
throw new NullPointerException("class name is null");
mPackage = pkg.getPackageName(); mPackage = pkg.getPackageName();
mClass = cls; mClass = cls;
} }
@@ -127,7 +130,7 @@ public final class ComponentName implements Cloneable, Comparable<ComponentName>
int PN = packageName.length(); int PN = packageName.length();
int CN = className.length(); int CN = className.length();
if (CN > PN && className.charAt(PN) == '.') { if (CN > PN && className.charAt(PN) == '.') {
pw.write(className, PN, CN-PN); pw.write(className, PN, CN - PN);
return; return;
} }
} }
@@ -167,18 +170,24 @@ public final class ComponentName implements Cloneable, Comparable<ComponentName>
return sb.toString(); return sb.toString();
} }
/** @hide */ /**
* @hide
*/
public void appendShortString(StringBuilder sb) { public void appendShortString(StringBuilder sb) {
appendShortString(sb, mPackage, mClass); appendShortString(sb, mPackage, mClass);
} }
/** @hide */ /**
* @hide
*/
public static void appendShortString(StringBuilder sb, String packageName, String className) { public static void appendShortString(StringBuilder sb, String packageName, String className) {
sb.append(packageName).append('/'); sb.append(packageName).append('/');
appendShortClassName(sb, packageName, className); appendShortClassName(sb, packageName, className);
} }
/** @hide */ /**
* @hide
*/
public static void printShortString(PrintWriter pw, String packageName, String className) { public static void printShortString(PrintWriter pw, String packageName, String className) {
pw.print(packageName); pw.print(packageName);
pw.print('/'); pw.print('/');
@@ -203,11 +212,11 @@ public final class ComponentName implements Cloneable, Comparable<ComponentName>
*/ */
public static ComponentName unflattenFromString(String str) { public static ComponentName unflattenFromString(String str) {
int sep = str.indexOf('/'); int sep = str.indexOf('/');
if (sep < 0 || (sep+1) >= str.length()) { if (sep < 0 || (sep + 1) >= str.length()) {
return null; return null;
} }
String pkg = str.substring(0, sep); String pkg = str.substring(0, sep);
String cls = str.substring(sep+1); String cls = str.substring(sep + 1);
if (cls.length() > 0 && cls.charAt(0) == '.') { if (cls.length() > 0 && cls.charAt(0) == '.') {
cls = pkg + cls; cls = pkg + cls;
} }
@@ -234,8 +243,7 @@ public final class ComponentName implements Cloneable, Comparable<ComponentName>
ComponentName other = (ComponentName)obj; ComponentName other = (ComponentName)obj;
// Note: no null checks, because mPackage and mClass can // Note: no null checks, because mPackage and mClass can
// never be null. // never be null.
return mPackage.equals(other.mPackage) return mPackage.equals(other.mPackage) && mClass.equals(other.mClass);
&& mClass.equals(other.mClass);
} }
} catch (ClassCastException e) { } catch (ClassCastException e) {
} }

View File

@@ -1,7 +1,7 @@
package android.content; package android.content;
import android.net.Uri;
import android.database.ContentObserver; import android.database.ContentObserver;
import android.net.Uri;
public class ContentResolver { public class ContentResolver {
public final void registerContentObserver(Uri uri, boolean notifyForDescendants, ContentObserver observer) { public final void registerContentObserver(Uri uri, boolean notifyForDescendants, ContentObserver observer) {

View File

@@ -17,7 +17,6 @@
package android.content; package android.content;
import android.util.Log; import android.util.Log;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -30,7 +29,9 @@ import java.util.Set;
public final class ContentValues { public final class ContentValues {
public static final String TAG = "ContentValues"; public static final String TAG = "ContentValues";
/** Holds the actual values */ /**
* Holds the actual values
*/
private HashMap<String, Object> mValues; private HashMap<String, Object> mValues;
/** /**
@@ -76,7 +77,7 @@ public final class ContentValues {
if (!(object instanceof ContentValues)) { if (!(object instanceof ContentValues)) {
return false; return false;
} }
return mValues.equals(((ContentValues) object).mValues); return mValues.equals(((ContentValues)object).mValues);
} }
@Override @Override
@@ -258,7 +259,7 @@ public final class ContentValues {
public Long getAsLong(String key) { public Long getAsLong(String key) {
Object value = mValues.get(key); Object value = mValues.get(key);
try { try {
return value != null ? ((Number) value).longValue() : null; return value != null ? ((Number)value).longValue() : null;
} catch (ClassCastException e) { } catch (ClassCastException e) {
if (value instanceof CharSequence) { if (value instanceof CharSequence) {
try { try {
@@ -283,7 +284,7 @@ public final class ContentValues {
public Integer getAsInteger(String key) { public Integer getAsInteger(String key) {
Object value = mValues.get(key); Object value = mValues.get(key);
try { try {
return value != null ? ((Number) value).intValue() : null; return value != null ? ((Number)value).intValue() : null;
} catch (ClassCastException e) { } catch (ClassCastException e) {
if (value instanceof CharSequence) { if (value instanceof CharSequence) {
try { try {
@@ -308,7 +309,7 @@ public final class ContentValues {
public Short getAsShort(String key) { public Short getAsShort(String key) {
Object value = mValues.get(key); Object value = mValues.get(key);
try { try {
return value != null ? ((Number) value).shortValue() : null; return value != null ? ((Number)value).shortValue() : null;
} catch (ClassCastException e) { } catch (ClassCastException e) {
if (value instanceof CharSequence) { if (value instanceof CharSequence) {
try { try {
@@ -333,7 +334,7 @@ public final class ContentValues {
public Byte getAsByte(String key) { public Byte getAsByte(String key) {
Object value = mValues.get(key); Object value = mValues.get(key);
try { try {
return value != null ? ((Number) value).byteValue() : null; return value != null ? ((Number)value).byteValue() : null;
} catch (ClassCastException e) { } catch (ClassCastException e) {
if (value instanceof CharSequence) { if (value instanceof CharSequence) {
try { try {
@@ -358,7 +359,7 @@ public final class ContentValues {
public Double getAsDouble(String key) { public Double getAsDouble(String key) {
Object value = mValues.get(key); Object value = mValues.get(key);
try { try {
return value != null ? ((Number) value).doubleValue() : null; return value != null ? ((Number)value).doubleValue() : null;
} catch (ClassCastException e) { } catch (ClassCastException e) {
if (value instanceof CharSequence) { if (value instanceof CharSequence) {
try { try {
@@ -383,7 +384,7 @@ public final class ContentValues {
public Float getAsFloat(String key) { public Float getAsFloat(String key) {
Object value = mValues.get(key); Object value = mValues.get(key);
try { try {
return value != null ? ((Number) value).floatValue() : null; return value != null ? ((Number)value).floatValue() : null;
} catch (ClassCastException e) { } catch (ClassCastException e) {
if (value instanceof CharSequence) { if (value instanceof CharSequence) {
try { try {
@@ -408,12 +409,12 @@ public final class ContentValues {
public Boolean getAsBoolean(String key) { public Boolean getAsBoolean(String key) {
Object value = mValues.get(key); Object value = mValues.get(key);
try { try {
return (Boolean) value; return (Boolean)value;
} catch (ClassCastException e) { } catch (ClassCastException e) {
if (value instanceof CharSequence) { if (value instanceof CharSequence) {
return Boolean.valueOf(value.toString()); return Boolean.valueOf(value.toString());
} else if (value instanceof Number) { } else if (value instanceof Number) {
return ((Number) value).intValue() != 0; return ((Number)value).intValue() != 0;
} else { } else {
Log.e(TAG, "Cannot cast value for " + key + " to a Boolean: " + value, e); Log.e(TAG, "Cannot cast value for " + key + " to a Boolean: " + value, e);
return null; return null;
@@ -431,7 +432,7 @@ public final class ContentValues {
public byte[] getAsByteArray(String key) { public byte[] getAsByteArray(String key) {
Object value = mValues.get(key); Object value = mValues.get(key);
if (value instanceof byte[]) { if (value instanceof byte[]) {
return (byte[]) value; return (byte[])value;
} else { } else {
return null; return null;
} }
@@ -471,7 +472,7 @@ public final class ContentValues {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Deprecated @Deprecated
public ArrayList<String> getStringArrayList(String key) { public ArrayList<String> getStringArrayList(String key) {
return (ArrayList<String>) mValues.get(key); return (ArrayList<String>)mValues.get(key);
} }
/** /**
@@ -483,7 +484,8 @@ public final class ContentValues {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (String name : mValues.keySet()) { for (String name : mValues.keySet()) {
String value = getAsString(name); String value = getAsString(name);
if (sb.length() > 0) sb.append(" "); if (sb.length() > 0)
sb.append(" ");
sb.append(name + "=" + value); sb.append(name + "=" + value);
} }
return sb.toString(); return sb.toString();

View File

@@ -1,40 +1,36 @@
package android.content; package android.content;
import android.util.Log; import android.app.ActivityManager;
import android.app.AlarmManager;
import android.content.pm.PackageManager; import android.app.Application;
import android.app.KeyguardManager;
import android.app.NotificationManager;
import android.app.SharedPreferencesImpl;
import android.content.BroadcastReceiver;
import android.content.ClipboardManager;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.AssetManager; import android.content.res.AssetManager;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.content.Intent; import android.hardware.SensorManager;
import android.content.BroadcastReceiver; import android.hardware.display.DisplayManager;
import android.hardware.usb.UsbManager;
import android.util.AttributeSet; import android.media.AudioManager;
import android.util.DisplayMetrics; import android.media.MediaRouter;
import android.content.SharedPreferences; import android.net.ConnectivityManager;
import android.app.SharedPreferencesImpl;
import android.os.Looper; import android.os.Looper;
import android.os.PowerManager; import android.os.PowerManager;
import android.app.Application; import android.os.Vibrator;
import android.telephony.TelephonyManager;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.WindowManagerImpl; import android.view.WindowManagerImpl;
import android.content.ClipboardManager;
import android.hardware.SensorManager;
import android.net.ConnectivityManager;
import android.app.KeyguardManager;
import android.telephony.TelephonyManager;
import android.media.AudioManager;
import android.app.ActivityManager;
import android.hardware.usb.UsbManager;
import android.os.Vibrator;
import android.hardware.display.DisplayManager;
import android.media.MediaRouter;
import android.app.NotificationManager;
import android.app.AlarmManager;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@@ -77,7 +73,7 @@ public class Context extends Object {
System.out.println("new Context! this one is: " + this); System.out.println("new Context! this one is: " + this);
} }
public int checkPermission (String permission, int pid, int uid) { public int checkPermission(String permission, int pid, int uid) {
return getPackageManager().checkPermission(permission, "dummy"); return getPackageManager().checkPermission(permission, "dummy");
} }
@@ -85,7 +81,7 @@ public class Context extends Object {
return r.newTheme(); return r.newTheme();
} }
public ApplicationInfo getApplicationInfo () { public ApplicationInfo getApplicationInfo() {
// TODO: do this somewhere saner? // TODO: do this somewhere saner?
application_info.nativeLibraryDir = (new File(getDataDirFile(), "lib")).getAbsolutePath(); application_info.nativeLibraryDir = (new File(getDataDirFile(), "lib")).getAbsolutePath();
return application_info; return application_info;
@@ -132,7 +128,7 @@ public class Context extends Object {
case "alarm": case "alarm":
return new AlarmManager(); return new AlarmManager();
default: default:
System.out.println("!!!!!!! getSystemService: case >"+name+"< is not implemented yet"); System.out.println("!!!!!!! getSystemService: case >" + name + "< is not implemented yet");
return null; return null;
} }
} }
@@ -179,7 +175,7 @@ public class Context extends Object {
} }
private File getDataDirFile() { private File getDataDirFile() {
if(data_dir == null) { if (data_dir == null) {
data_dir = android.os.Environment.getExternalStorageDirectory(); data_dir = android.os.Environment.getExternalStorageDirectory();
} }
return data_dir; return data_dir;
@@ -190,7 +186,7 @@ public class Context extends Object {
files_dir = new File(getDataDirFile(), "files"); files_dir = new File(getDataDirFile(), "files");
} }
if (!files_dir.exists()) { if (!files_dir.exists()) {
if(!files_dir.mkdirs()) { if (!files_dir.mkdirs()) {
if (files_dir.exists()) { if (files_dir.exists()) {
// spurious failure; probably racing with another process for this app // spurious failure; probably racing with another process for this app
return files_dir; return files_dir;
@@ -214,7 +210,7 @@ public class Context extends Object {
} }
public File[] getObbDirs() { public File[] getObbDirs() {
return new File[]{getObbDir()}; return new File[] {getObbDir()};
} }
// FIXME: should be something like /tmp/cache, but may need to create that directory // FIXME: should be something like /tmp/cache, but may need to create that directory
@@ -237,7 +233,7 @@ public class Context extends Object {
} }
public SharedPreferences getSharedPreferences(String name, int mode) { public SharedPreferences getSharedPreferences(String name, int mode) {
System.out.println("\n\n...> getSharedPreferences("+name+",)\n\n"); System.out.println("\n\n...> getSharedPreferences(" + name + ",)\n\n");
File prefsFile = getSharedPrefsFile(name); File prefsFile = getSharedPrefsFile(name);
return new SharedPreferencesImpl(prefsFile, mode); return new SharedPreferencesImpl(prefsFile, mode);
} }
@@ -248,7 +244,7 @@ public class Context extends Object {
} }
public ComponentName startService(Intent service) { public ComponentName startService(Intent service) {
return new ComponentName("",""); return new ComponentName("", "");
} }
// FIXME - it should be *trivial* to do actually implement this // FIXME - it should be *trivial* to do actually implement this
@@ -257,12 +253,12 @@ public class Context extends Object {
} }
public FileOutputStream openFileOutput(String name, int mode) throws java.io.FileNotFoundException { public FileOutputStream openFileOutput(String name, int mode) throws java.io.FileNotFoundException {
System.out.println("openFileOutput called for: '"+name+"'"); System.out.println("openFileOutput called for: '" + name + "'");
return new FileOutputStream(android.os.Environment.getExternalStorageDirectory().getPath() + "/files/" + name); return new FileOutputStream(android.os.Environment.getExternalStorageDirectory().getPath() + "/files/" + name);
} }
public int checkCallingOrSelfPermission(String permission) { public int checkCallingOrSelfPermission(String permission) {
System.out.println("!!! app wants to know if it has a permission: >"+permission+"<"); System.out.println("!!! app wants to know if it has a permission: >" + permission + "<");
return -1; // PackageManager.PERMISSION_DENIED return -1; // PackageManager.PERMISSION_DENIED
} }
@@ -270,8 +266,8 @@ public class Context extends Object {
public void registerComponentCallbacks(ComponentCallbacks callbacks) {} public void registerComponentCallbacks(ComponentCallbacks callbacks) {}
// these may not look like typical stubs, but they definitely are stubs // these may not look like typical stubs, but they definitely are stubs
public final TypedArray obtainStyledAttributes (AttributeSet set, int[] attrs) { return new TypedArray(r, new int[1000], new int[1000], 0); } public final TypedArray obtainStyledAttributes(AttributeSet set, int[] attrs) { return new TypedArray(r, new int[1000], new int[1000], 0); }
public final TypedArray obtainStyledAttributes (AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes) { return new TypedArray(r, new int[1000], new int[1000], 0); } public final TypedArray obtainStyledAttributes(AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes) { return new TypedArray(r, new int[1000], new int[1000], 0); }
public final TypedArray obtainStyledAttributes (int resid, int[] attrs) { return new TypedArray(r, new int[1000], new int[1000], 0); } public final TypedArray obtainStyledAttributes(int resid, int[] attrs) { return new TypedArray(r, new int[1000], new int[1000], 0); }
public final TypedArray obtainStyledAttributes (int[] attrs) { return new TypedArray(r, new int[1000], new int[1000], 0); } public final TypedArray obtainStyledAttributes(int[] attrs) { return new TypedArray(r, new int[1000], new int[1000], 0); }
} }

View File

@@ -3,16 +3,15 @@ package android.content;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Parcelable; import android.os.Parcelable;
import java.io.Serializable; import java.io.Serializable;
public class Intent { public class Intent {
public Intent () {} public Intent() {}
public Intent (Intent o) {} public Intent(Intent o) {}
public Intent (String action) {} public Intent(String action) {}
public Intent (String action, Uri uri) {} public Intent(String action, Uri uri) {}
public Intent (Context packageContext, Class<?> cls) {} public Intent(Context packageContext, Class<?> cls) {}
public Intent (String action, Uri uri, Context packageContext, Class<?> cls) {} public Intent(String action, Uri uri, Context packageContext, Class<?> cls) {}
public Intent setFlags(int flags) { public Intent setFlags(int flags) {
return this; //?? return this; //??
@@ -21,7 +20,7 @@ public class Intent {
return this; //?? return this; //??
} }
public Intent putExtra (String name, Parcelable value) { public Intent putExtra(String name, Parcelable value) {
return this; //?? return this; //??
} }

Some files were not shown because too many files have changed in this diff Show More