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,21 +16,25 @@
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,13 +26,15 @@ 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 {
/** /**
* The set of warnings (identified by the lint issue id) that should be * The set of warnings (identified by the lint issue id) that should be
* ignored by lint. It is not an error to specify an unrecognized name. * ignored by lint. It is not an error to specify an unrecognized name.
*/ */
String[] value(); String[] value();
} }

View File

@@ -23,13 +23,15 @@ 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 {
/** /**
* This sets the target api level for the type.. * This sets the target api level for the type..
*/ */
int value(); int value();
} }

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();
} }
@@ -86,10 +82,10 @@ public class Activity extends Context {
} }
public int getRequestedOrientation() { public int getRequestedOrientation() {
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;
} }
@@ -162,7 +158,7 @@ public class Activity extends Context {
/* --- */ /* --- */
public void setContentView(int layoutResID) throws Exception { public void setContentView(int layoutResID) throws Exception {
System.out.println("- setContentView - yay!"); System.out.println("- setContentView - yay!");
XmlResourceParser xpp = Context.this_application.getResources().getLayout(layoutResID); XmlResourceParser xpp = Context.this_application.getResources().getLayout(layoutResID);
@@ -183,13 +179,13 @@ public class Activity extends Context {
w.showAll(); w.showAll();
w.connect(new Window.DeleteEvent() { w.connect(new Window.DeleteEvent() {
public boolean onDeleteEvent(Widget source, Event event) { public boolean onDeleteEvent(Widget source, Event event) {
Gtk.mainQuit(); Gtk.mainQuit();
return false; return false;
} }
});*/ });*/
} }
public void setContentView(View view, ViewGroup.LayoutParams layoutParams) { public void setContentView(View view, ViewGroup.LayoutParams layoutParams) {
setContentView(view); setContentView(view);
@@ -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() {
@@ -215,14 +211,14 @@ public class Activity extends Context {
return this.window; return this.window;
} }
public final void runOnUiThread(Runnable action) { public final void runOnUiThread(Runnable action) {
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
@@ -62,7 +60,7 @@ import com.reandroid.arsc.chunk.xml.ResXmlElement;
* {@sample development/ndk/platforms/android-9/samples/native-activity/jni/main.c all} * {@sample development/ndk/platforms/android-9/samples/native-activity/jni/main.c all}
*/ */
public class NativeActivity extends Activity implements SurfaceHolder.Callback, public class NativeActivity extends Activity implements SurfaceHolder.Callback,
InputQueue.Callback, OnGlobalLayoutListener { InputQueue.Callback, OnGlobalLayoutListener {
/** /**
* Optional meta-that can be in the manifest for this component, specifying * Optional meta-that can be in the manifest for this component, specifying
* the name of the native shared library to load. If not specified, * the name of the native shared library to load. If not specified,
@@ -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;
@@ -99,8 +97,8 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback,
private boolean mDestroyed; private boolean mDestroyed;
private native long loadNativeCode(String path, String funcname, MessageQueue queue, private native long loadNativeCode(String path, String funcname, MessageQueue queue,
String internalDataPath, String obbPath, String externalDataPath, int sdkVersion, String internalDataPath, String obbPath, String externalDataPath, int sdkVersion,
AssetManager assetMgr, byte[] savedState); AssetManager assetMgr, byte[] savedState);
private native void unloadNativeCode(long handle); private native void unloadNativeCode(long handle);
private native void onStartNative(long handle); private native void onStartNative(long handle);
@@ -113,7 +111,7 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback,
private native void onWindowFocusChangedNative(long handle, boolean focused); private native void onWindowFocusChangedNative(long handle, boolean focused);
private native void onSurfaceCreatedNative(long handle, Surface surface); private native void onSurfaceCreatedNative(long handle, Surface surface);
private native void onSurfaceChangedNative(long handle, Surface surface, private native void onSurfaceChangedNative(long handle, Surface surface,
int format, int width, int height); int format, int width, int height);
private native void onSurfaceRedrawNeededNative(long handle, Surface surface); private native void onSurfaceRedrawNeededNative(long handle, Surface surface);
private native void onSurfaceDestroyedNative(long handle); private native void onSurfaceDestroyedNative(long handle);
private native void onInputQueueCreatedNative(long handle, long queuePtr); private native void onInputQueueCreatedNative(long handle, long queuePtr);
@@ -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,22 +167,22 @@ 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();
} }
} }
} }
} catch (IOException e) { } catch (IOException e) {
@@ -194,7 +192,7 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback,
String path = null; String path = null;
File libraryFile = new File(new File(android.os.Environment.getExternalStorageDirectory(), "lib"), File libraryFile = new File(new File(android.os.Environment.getExternalStorageDirectory(), "lib"),
System.mapLibraryName(libname)); System.mapLibraryName(libname));
if (libraryFile.exists()) { if (libraryFile.exists()) {
path = libraryFile.getPath(); path = libraryFile.getPath();
} }
@@ -204,12 +202,13 @@ 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()),
getAbsolutePath(getExternalFilesDir(null)), getAbsolutePath(getExternalFilesDir(null)),
Build.VERSION.SDK_INT, getAssets(), nativeSavedState); Build.VERSION.SDK_INT, getAssets(), nativeSavedState);
if (mNativeHandle == 0) { if (mNativeHandle == 0) {
throw new IllegalArgumentException("Unable to load native library: " + path); throw new IllegalArgumentException("Unable to load native library: " + path);

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 {
} }
} }

File diff suppressed because it is too large Load Diff

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;
@@ -49,78 +49,80 @@ class ClipDescription {}
* @see android.content.Context#getSystemService * @see android.content.Context#getSystemService
*/ */
public class ClipboardManager extends android.text.ClipboardManager { public class ClipboardManager extends android.text.ClipboardManager {
static final int MSG_REPORT_PRIMARY_CLIP_CHANGED = 1; static final int MSG_REPORT_PRIMARY_CLIP_CHANGED = 1;
/** /**
* Defines a listener callback that is invoked when the primary clip on the clipboard changes. * Defines a listener callback that is invoked when the primary clip on the clipboard changes.
* Objects that want to register a listener call * Objects that want to register a listener call
* {@link android.content.ClipboardManager#addPrimaryClipChangedListener(OnPrimaryClipChangedListener) * {@link android.content.ClipboardManager#addPrimaryClipChangedListener(OnPrimaryClipChangedListener)
* addPrimaryClipChangedListener()} with an * addPrimaryClipChangedListener()} with an
* object that implements OnPrimaryClipChangedListener. * object that implements OnPrimaryClipChangedListener.
* *
*/ */
public interface OnPrimaryClipChangedListener { public interface OnPrimaryClipChangedListener {
/** /**
* Callback that is invoked by {@link android.content.ClipboardManager} when the primary * Callback that is invoked by {@link android.content.ClipboardManager} when the primary
* clip changes. * clip changes.
*/ */
void onPrimaryClipChanged(); void onPrimaryClipChanged();
} }
/** {@hide} */ /**
public ClipboardManager(Context context, Handler handler) { * {@hide}
} */
public ClipboardManager() { public ClipboardManager(Context context, Handler handler) {
} }
/** public ClipboardManager() {
* Sets the current primary clip on the clipboard. This is the clip that }
* is involved in normal cut and paste operations. /**
* * Sets the current primary clip on the clipboard. This is the clip that
* @param clip The clipped data item to set. * is involved in normal cut and paste operations.
*/ *
public void setPrimaryClip(ClipData clip) { * @param clip The clipped data item to set.
} */
/** public void setPrimaryClip(ClipData clip) {
* Returns the current primary clip on the clipboard. }
*/ /**
public ClipData getPrimaryClip() { * Returns the current primary clip on the clipboard.
return null; */
} public ClipData getPrimaryClip() {
/** return null;
* Returns a description of the current primary clip on the clipboard }
* but not a copy of its data. /**
*/ * Returns a description of the current primary clip on the clipboard
public ClipDescription getPrimaryClipDescription() { * but not a copy of its data.
return null; */
} public ClipDescription getPrimaryClipDescription() {
/** return null;
* Returns true if there is currently a primary clip on the clipboard. }
*/ /**
public boolean hasPrimaryClip() { * Returns true if there is currently a primary clip on the clipboard.
return false; */
} public boolean hasPrimaryClip() {
public void addPrimaryClipChangedListener(OnPrimaryClipChangedListener what) { return false;
} }
public void removePrimaryClipChangedListener(OnPrimaryClipChangedListener what) { public void addPrimaryClipChangedListener(OnPrimaryClipChangedListener what) {
} }
/** public void removePrimaryClipChangedListener(OnPrimaryClipChangedListener what) {
* @deprecated Use {@link #getPrimaryClip()} instead. This retrieves }
* the primary clip and tries to coerce it to a string. /**
*/ * @deprecated Use {@link #getPrimaryClip()} instead. This retrieves
public CharSequence getText() { * the primary clip and tries to coerce it to a string.
return null; */
} public CharSequence getText() {
/** return null;
* @deprecated Use {@link #setPrimaryClip(ClipData)} instead. This }
* creates a ClippedItem holding the given text and sets it as the /**
* primary clip. It has no label or icon. * @deprecated Use {@link #setPrimaryClip(ClipData)} instead. This
*/ * creates a ClippedItem holding the given text and sets it as the
public void setText(CharSequence text) { * primary clip. It has no label or icon.
} */
/** public void setText(CharSequence text) {
* @deprecated Use {@link #hasPrimaryClip()} instead. }
*/ /**
public boolean hasText() { * @deprecated Use {@link #hasPrimaryClip()} instead.
return false; */
} public boolean hasText() {
void reportPrimaryClipChanged() { return false;
} }
void reportPrimaryClipChanged() {
}
} }

View File

@@ -27,236 +27,244 @@ import java.lang.Comparable;
* pieces of information, encapsulated here, are required to identify * pieces of information, encapsulated here, are required to identify
* a component: the package (a String) it exists in, and the class (a String) * a component: the package (a String) it exists in, and the class (a String)
* name inside of that package. * name inside of that package.
* *
*/ */
public final class ComponentName implements Cloneable, Comparable<ComponentName> { public final class ComponentName implements Cloneable, Comparable<ComponentName> {
private final String mPackage; private final String mPackage;
private final String mClass; private final String mClass;
/** /**
* Create a new component identifier. * Create a new component identifier.
* *
* @param pkg The name of the package that the component exists in. Can * @param pkg The name of the package that the component exists in. Can
* not be null. * not be null.
* @param cls The name of the class inside of <var>pkg</var> that * @param cls The name of the class inside of <var>pkg</var> that
* 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");
mPackage = pkg; if (cls == null)
mClass = cls; throw new NullPointerException("class name is null");
} mPackage = pkg;
mClass = cls;
}
/** /**
* Create a new component identifier from a Context and class name. * Create a new component identifier from a Context and class name.
* *
* @param pkg A Context for the package implementing the component, * @param pkg A Context for the package implementing the component,
* from which the actual package name will be retrieved. * from which the actual package name will be retrieved.
* @param cls The name of the class inside of <var>pkg</var> that * @param cls The name of the class inside of <var>pkg</var> that
* 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)
mPackage = pkg.getPackageName(); throw new NullPointerException("class name is null");
mClass = cls; mPackage = pkg.getPackageName();
} mClass = cls;
}
/** /**
* Create a new component identifier from a Context and Class object. * Create a new component identifier from a Context and Class object.
* *
* @param pkg A Context for the package implementing the component, from * @param pkg A Context for the package implementing the component, from
* which the actual package name will be retrieved. * which the actual package name will be retrieved.
* @param cls The Class object of the desired component, from which the * @param cls The Class object of the desired component, from which the
* actual class name will be retrieved. * actual class name will be retrieved.
*/ */
public ComponentName(Context pkg, Class<?> cls) { public ComponentName(Context pkg, Class<?> cls) {
mPackage = pkg.getPackageName(); mPackage = pkg.getPackageName();
mClass = cls.getName(); mClass = cls.getName();
} }
public ComponentName clone() { public ComponentName clone() {
return new ComponentName(mPackage, mClass); return new ComponentName(mPackage, mClass);
} }
/** /**
* Return the package name of this component. * Return the package name of this component.
*/ */
public String getPackageName() { public String getPackageName() {
return mPackage; return mPackage;
} }
/**
* Return the class name of this component.
*/
public String getClassName() {
return mClass;
}
/**
* Return the class name, either fully qualified or in a shortened form
* (with a leading '.') if it is a suffix of the package.
*/
public String getShortClassName() {
if (mClass.startsWith(mPackage)) {
int PN = mPackage.length();
int CN = mClass.length();
if (CN > PN && mClass.charAt(PN) == '.') {
return mClass.substring(PN, CN);
}
}
return mClass;
}
private static void appendShortClassName(StringBuilder sb, String packageName,
String className) {
if (className.startsWith(packageName)) {
int PN = packageName.length();
int CN = className.length();
if (CN > PN && className.charAt(PN) == '.') {
sb.append(className, PN, CN);
return;
}
}
sb.append(className);
}
private static void printShortClassName(PrintWriter pw, String packageName, /**
String className) { * Return the class name of this component.
if (className.startsWith(packageName)) { */
int PN = packageName.length(); public String getClassName() {
int CN = className.length(); return mClass;
if (CN > PN && className.charAt(PN) == '.') { }
pw.write(className, PN, CN-PN);
return;
}
}
pw.print(className);
}
/** /**
* Return a String that unambiguously describes both the package and * Return the class name, either fully qualified or in a shortened form
* class names contained in the ComponentName. You can later recover * (with a leading '.') if it is a suffix of the package.
* the ComponentName from this string through */
* {@link #unflattenFromString(String)}. public String getShortClassName() {
* if (mClass.startsWith(mPackage)) {
* @return Returns a new String holding the package and class names. This int PN = mPackage.length();
* is represented as the package name, concatenated with a '/' and then the int CN = mClass.length();
* class name. if (CN > PN && mClass.charAt(PN) == '.') {
* return mClass.substring(PN, CN);
* @see #unflattenFromString(String) }
*/ }
public String flattenToString() { return mClass;
return mPackage + "/" + mClass; }
}
/**
* The same as {@link #flattenToString()}, but abbreviates the class
* name if it is a suffix of the package. The result can still be used
* with {@link #unflattenFromString(String)}.
*
* @return Returns a new String holding the package and class names. This
* is represented as the package name, concatenated with a '/' and then the
* class name.
*
* @see #unflattenFromString(String)
*/
public String flattenToShortString() {
StringBuilder sb = new StringBuilder(mPackage.length() + mClass.length());
appendShortString(sb, mPackage, mClass);
return sb.toString();
}
/** @hide */ private static void appendShortClassName(StringBuilder sb, String packageName,
public void appendShortString(StringBuilder sb) { String className) {
appendShortString(sb, mPackage, mClass); if (className.startsWith(packageName)) {
} int PN = packageName.length();
int CN = className.length();
if (CN > PN && className.charAt(PN) == '.') {
sb.append(className, PN, CN);
return;
}
}
sb.append(className);
}
/** @hide */ private static void printShortClassName(PrintWriter pw, String packageName,
public static void appendShortString(StringBuilder sb, String packageName, String className) { String className) {
sb.append(packageName).append('/'); if (className.startsWith(packageName)) {
appendShortClassName(sb, packageName, className); int PN = packageName.length();
} int CN = className.length();
if (CN > PN && className.charAt(PN) == '.') {
pw.write(className, PN, CN - PN);
return;
}
}
pw.print(className);
}
/** @hide */ /**
public static void printShortString(PrintWriter pw, String packageName, String className) { * Return a String that unambiguously describes both the package and
pw.print(packageName); * class names contained in the ComponentName. You can later recover
pw.print('/'); * the ComponentName from this string through
printShortClassName(pw, packageName, className); * {@link #unflattenFromString(String)}.
} *
* @return Returns a new String holding the package and class names. This
* is represented as the package name, concatenated with a '/' and then the
* class name.
*
* @see #unflattenFromString(String)
*/
public String flattenToString() {
return mPackage + "/" + mClass;
}
/** /**
* Recover a ComponentName from a String that was previously created with * The same as {@link #flattenToString()}, but abbreviates the class
* {@link #flattenToString()}. It splits the string at the first '/', * name if it is a suffix of the package. The result can still be used
* taking the part before as the package name and the part after as the * with {@link #unflattenFromString(String)}.
* class name. As a special convenience (to use, for example, when *
* parsing component names on the command line), if the '/' is immediately * @return Returns a new String holding the package and class names. This
* followed by a '.' then the final class name will be the concatenation * is represented as the package name, concatenated with a '/' and then the
* of the package name with the string following the '/'. Thus * class name.
* "com.foo/.Blah" becomes package="com.foo" class="com.foo.Blah". *
* * @see #unflattenFromString(String)
* @param str The String that was returned by flattenToString(). */
* @return Returns a new ComponentName containing the package and class public String flattenToShortString() {
* names that were encoded in <var>str</var> StringBuilder sb = new StringBuilder(mPackage.length() + mClass.length());
* appendShortString(sb, mPackage, mClass);
* @see #flattenToString() return sb.toString();
*/ }
public static ComponentName unflattenFromString(String str) {
int sep = str.indexOf('/');
if (sep < 0 || (sep+1) >= str.length()) {
return null;
}
String pkg = str.substring(0, sep);
String cls = str.substring(sep+1);
if (cls.length() > 0 && cls.charAt(0) == '.') {
cls = pkg + cls;
}
return new ComponentName(pkg, cls);
}
/**
* Return string representation of this class without the class's name
* as a prefix.
*/
public String toShortString() {
return "{" + mPackage + "/" + mClass + "}";
}
@Override /**
public String toString() { * @hide
return "ComponentInfo{" + mPackage + "/" + mClass + "}"; */
} public void appendShortString(StringBuilder sb) {
appendShortString(sb, mPackage, mClass);
}
@Override /**
public boolean equals(Object obj) { * @hide
try { */
if (obj != null) { public static void appendShortString(StringBuilder sb, String packageName, String className) {
ComponentName other = (ComponentName)obj; sb.append(packageName).append('/');
// Note: no null checks, because mPackage and mClass can appendShortClassName(sb, packageName, className);
// never be null. }
return mPackage.equals(other.mPackage)
&& mClass.equals(other.mClass);
}
} catch (ClassCastException e) {
}
return false;
}
@Override /**
public int hashCode() { * @hide
return mPackage.hashCode() + mClass.hashCode(); */
} public static void printShortString(PrintWriter pw, String packageName, String className) {
pw.print(packageName);
pw.print('/');
printShortClassName(pw, packageName, className);
}
public int compareTo(ComponentName that) { /**
int v; * Recover a ComponentName from a String that was previously created with
v = this.mPackage.compareTo(that.mPackage); * {@link #flattenToString()}. It splits the string at the first '/',
if (v != 0) { * taking the part before as the package name and the part after as the
return v; * class name. As a special convenience (to use, for example, when
} * parsing component names on the command line), if the '/' is immediately
return this.mClass.compareTo(that.mClass); * followed by a '.' then the final class name will be the concatenation
} * of the package name with the string following the '/'. Thus
* "com.foo/.Blah" becomes package="com.foo" class="com.foo.Blah".
public int describeContents() { *
return 0; * @param str The String that was returned by flattenToString().
} * @return Returns a new ComponentName containing the package and class
* names that were encoded in <var>str</var>
*
* @see #flattenToString()
*/
public static ComponentName unflattenFromString(String str) {
int sep = str.indexOf('/');
if (sep < 0 || (sep + 1) >= str.length()) {
return null;
}
String pkg = str.substring(0, sep);
String cls = str.substring(sep + 1);
if (cls.length() > 0 && cls.charAt(0) == '.') {
cls = pkg + cls;
}
return new ComponentName(pkg, cls);
}
/**
* Return string representation of this class without the class's name
* as a prefix.
*/
public String toShortString() {
return "{" + mPackage + "/" + mClass + "}";
}
@Override
public String toString() {
return "ComponentInfo{" + mPackage + "/" + mClass + "}";
}
@Override
public boolean equals(Object obj) {
try {
if (obj != null) {
ComponentName other = (ComponentName)obj;
// Note: no null checks, because mPackage and mClass can
// never be null.
return mPackage.equals(other.mPackage) && mClass.equals(other.mClass);
}
} catch (ClassCastException e) {
}
return false;
}
@Override
public int hashCode() {
return mPackage.hashCode() + mClass.hashCode();
}
public int compareTo(ComponentName that) {
int v;
v = this.mPackage.compareTo(that.mPackage);
if (v != 0) {
return v;
}
return this.mClass.compareTo(that.mClass);
}
public int describeContents() {
return 0;
}
} }

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) {

File diff suppressed because it is too large Load Diff

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;
} }
} }
@@ -175,11 +171,11 @@ public class Context extends Object {
return new File(base, name); return new File(base, name);
} }
throw new IllegalArgumentException( throw new IllegalArgumentException(
"File " + name + " contains a path separator"); "File " + name + " contains a path separator");
} }
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;
@@ -207,29 +203,29 @@ public class Context extends Object {
} }
public File getObbDir() { public File getObbDir() {
if (obb_dir == null) { if (obb_dir == null) {
obb_dir = new File(getDataDirFile(), "obb"); obb_dir = new File(getDataDirFile(), "obb");
} }
return obb_dir; return obb_dir;
} }
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
public File getCacheDir() { public File getCacheDir() {
if (cache_dir == null) { if (cache_dir == null) {
cache_dir = new File("/tmp/"); cache_dir = new File("/tmp/");
} }
return cache_dir; return cache_dir;
} }
private File getPreferencesDir() { private File getPreferencesDir() {
if (prefs_dir == null) { if (prefs_dir == null) {
prefs_dir = new File(getDataDirFile(), "shared_prefs"); prefs_dir = new File(getDataDirFile(), "shared_prefs");
} }
return prefs_dir; return prefs_dir;
} }
public File getSharedPrefsFile(String name) { public File getSharedPrefsFile(String name) {
@@ -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