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;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
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.
* @hide
*/
@Target({ ElementType.FIELD })
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.SOURCE)
public @interface SdkConstant {
public static enum SdkConstantType {
ACTIVITY_INTENT_ACTION, BROADCAST_INTENT_ACTION, SERVICE_ACTION, INTENT_CATEGORY, FEATURE;
}
public static enum SdkConstantType {
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.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})
@Retention(RetentionPolicy.CLASS)
public @interface SuppressLint {
/**
* 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.
*/
String[] value();
/**
* 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.
*/
String[] value();
}

View File

@@ -23,13 +23,15 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
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})
@Retention(RetentionPolicy.CLASS)
public @interface TargetApi {
/**
* This sets the target api level for the type..
*/
int value();
/**
* This sets the target api level for the type..
*/
int value();
}

View File

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

View File

@@ -1,31 +1,27 @@
package android.app;
import android.content.Context;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.XmlResourceParser;
import android.os.Bundle;
import android.widget.TextView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.LayoutInflater;
import android.view.Window;
import android.view.WindowManager;
import android.view.WindowManagerImpl;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserFactory;
import android.widget.TextView;
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserFactory;
public class Activity extends Context {
LayoutInflater layout_inflater;
@@ -64,7 +60,7 @@ public class Activity extends Context {
public View root_view;
public final Application getApplication () {
public final Application getApplication() {
return (Application)getApplicationContext();
}
@@ -89,7 +85,7 @@ public class Activity extends Context {
return requested_orientation;
}
public void setRequestedOrientation (int orientation) {
public void setRequestedOrientation(int orientation) {
requested_orientation = orientation;
}
@@ -146,7 +142,7 @@ public class Activity extends Context {
}
public void onWindowFocusChanged(boolean hasFocus) {
System.out.println("- onWindowFocusChanged - yay! (hasFocus: "+hasFocus+")");
System.out.println("- onWindowFocusChanged - yay! (hasFocus: " + hasFocus + ")");
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!");
XmlResourceParser xpp = Context.this_application.getResources().getLayout(layoutResID);
@@ -183,13 +179,13 @@ public class Activity extends Context {
w.showAll();
w.connect(new Window.DeleteEvent() {
public boolean onDeleteEvent(Widget source, Event event) {
Gtk.mainQuit();
return false;
}
});*/
}
w.connect(new Window.DeleteEvent() {
public boolean onDeleteEvent(Widget source, Event event) {
Gtk.mainQuit();
return false;
}
});*/
}
public void setContentView(View view, ViewGroup.LayoutParams layoutParams) {
setContentView(view);
@@ -204,7 +200,7 @@ public class Activity extends Context {
View view = View.view_by_id.get(id);
System.out.println("- findViewById - found this: " + view);
return (T) view;
return (T)view;
}
public void invalidateOptionsMenu() {
@@ -215,14 +211,14 @@ public class Activity extends Context {
return this.window;
}
public final void runOnUiThread(Runnable action) {
action.run(); // FIXME: running synchronously for now
}
public final void runOnUiThread(Runnable action) {
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) {
System.out.println("startActivityForResult("+intent+", "+requestCode+") called, but we don't currently support multiple activities");
public void startActivityForResult(Intent intent, int requestCode) {
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
}
}

View File

@@ -6,37 +6,37 @@ import android.view.View;
public class AlertDialog extends Dialog {
public static class Builder {
public Builder(Context context){
public Builder(Context context) {
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;
}
public AlertDialog.Builder setPositiveButton (CharSequence text, DialogInterface.OnClickListener listener) {
public AlertDialog.Builder setPositiveButton(CharSequence text, DialogInterface.OnClickListener listener) {
return this;
}
public AlertDialog.Builder setCancelable (boolean cancelable) {
public AlertDialog.Builder setCancelable(boolean cancelable) {
return this;
}
public AlertDialog.Builder setIcon (int iconId) {
public AlertDialog.Builder setIcon(int iconId) {
return this;
}
public AlertDialog.Builder setTitle (CharSequence title) {
System.out.println("AlertDialog.Builder setTitle called with: '"+title+"'");
public AlertDialog.Builder setTitle(CharSequence title) {
System.out.println("AlertDialog.Builder setTitle called with: '" + title + "'");
return this;
}
public AlertDialog.Builder setMessage (CharSequence message) {
System.out.println("AlertDialog.Builder setMessage called with: '"+message+"'");
public AlertDialog.Builder setMessage(CharSequence message) {
System.out.println("AlertDialog.Builder setMessage called with: '" + message + "'");
return this;
}
public AlertDialog.Builder setView (View view) {
public AlertDialog.Builder setView(View view) {
return this;
}

View File

@@ -4,15 +4,15 @@ import android.content.Context;
public class Dialog {
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() {
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 Builder(Context context){
public Builder(Context context) {
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.res.AssetManager;
import android.content.res.Configuration;
//import android.graphics.PixelFormat;
// import android.graphics.PixelFormat;
import android.os.Build;
import android.os.Bundle;
import android.os.Looper;
@@ -34,15 +34,13 @@ import android.view.SurfaceView;
import android.view.View;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
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.ResXmlAttribute;
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
@@ -62,7 +60,7 @@ import com.reandroid.arsc.chunk.xml.ResXmlElement;
* {@sample development/ndk/platforms/android-9/samples/native-activity/jni/main.c all}
*/
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
* 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 NativeContentView mNativeContentView;
// private InputMethodManager mIMM;
// private InputMethodManager mIMM;
private long mNativeHandle;
@@ -99,8 +97,8 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback,
private boolean mDestroyed;
private native long loadNativeCode(String path, String funcname, MessageQueue queue,
String internalDataPath, String obbPath, String externalDataPath, int sdkVersion,
AssetManager assetMgr, byte[] savedState);
String internalDataPath, String obbPath, String externalDataPath, int sdkVersion,
AssetManager assetMgr, byte[] savedState);
private native void unloadNativeCode(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 onSurfaceCreatedNative(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 onSurfaceDestroyedNative(long handle);
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) {
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
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())) {
continue;
}
for (ResXmlElement metaData: activity.listElements(AndroidManifestBlock.TAG_meta_data)) {
ResXmlAttribute name = metaData.searchAttributeByResourceId(AndroidManifestBlock.ID_name);
ResXmlAttribute value = metaData.searchAttributeByResourceId(AndroidManifestBlock.ID_value);
if (name == null || value == null){
continue;
}
if (META_DATA_LIB_NAME.equals(name.getValueAsString())){
libname = value.getValueAsString();
}
if (META_DATA_FUNC_NAME.equals(name.getValueAsString())){
funcname = value.getValueAsString();
}
for (ResXmlElement metaData : activity.listElements(AndroidManifestBlock.TAG_meta_data)) {
ResXmlAttribute name = metaData.searchAttributeByResourceId(AndroidManifestBlock.ID_name);
ResXmlAttribute value = metaData.searchAttributeByResourceId(AndroidManifestBlock.ID_value);
if (name == null || value == null) {
continue;
}
if (META_DATA_LIB_NAME.equals(name.getValueAsString())) {
libname = value.getValueAsString();
}
if (META_DATA_FUNC_NAME.equals(name.getValueAsString())) {
funcname = value.getValueAsString();
}
}
}
} catch (IOException e) {
@@ -194,7 +192,7 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback,
String path = null;
File libraryFile = new File(new File(android.os.Environment.getExternalStorageDirectory(), "lib"),
System.mapLibraryName(libname));
System.mapLibraryName(libname));
if (libraryFile.exists()) {
path = libraryFile.getPath();
}
@@ -204,12 +202,13 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback,
}
byte[] nativeSavedState = savedInstanceState != null
? savedInstanceState.getByteArray(KEY_NATIVE_SAVED_STATE) : null;
? savedInstanceState.getByteArray(KEY_NATIVE_SAVED_STATE)
: null;
mNativeHandle = loadNativeCode(path, funcname, Looper.myQueue(),
getAbsolutePath(getFilesDir()), getAbsolutePath(getObbDir()),
getAbsolutePath(getExternalFilesDir(null)),
Build.VERSION.SDK_INT, getAssets(), nativeSavedState);
getAbsolutePath(getFilesDir()), getAbsolutePath(getObbDir()),
getAbsolutePath(getExternalFilesDir(null)),
Build.VERSION.SDK_INT, getAssets(), nativeSavedState);
if (mNativeHandle == 0) {
throw new IllegalArgumentException("Unable to load native library: " + path);

View File

@@ -13,9 +13,8 @@ public class PendingIntent {
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 {
}
}

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@@ -15,10 +15,10 @@
*/
package android.content;
import android.content.Context;
import android.os.Message;
import android.os.RemoteException;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.RemoteException;
import android.util.Log;
import java.util.ArrayList;
@@ -49,78 +49,80 @@ class ClipDescription {}
* @see android.content.Context#getSystemService
*/
public class ClipboardManager extends android.text.ClipboardManager {
static final int MSG_REPORT_PRIMARY_CLIP_CHANGED = 1;
/**
* Defines a listener callback that is invoked when the primary clip on the clipboard changes.
* Objects that want to register a listener call
* {@link android.content.ClipboardManager#addPrimaryClipChangedListener(OnPrimaryClipChangedListener)
* addPrimaryClipChangedListener()} with an
* object that implements OnPrimaryClipChangedListener.
*
*/
public interface OnPrimaryClipChangedListener {
/**
* Callback that is invoked by {@link android.content.ClipboardManager} when the primary
* clip changes.
*/
void onPrimaryClipChanged();
}
/** {@hide} */
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.
*
* @param clip The clipped data item to set.
*/
public void setPrimaryClip(ClipData clip) {
}
/**
* Returns the current primary clip on the clipboard.
*/
public ClipData getPrimaryClip() {
return null;
}
/**
* Returns a description of the current primary clip on the clipboard
* but not a copy of its data.
*/
public ClipDescription getPrimaryClipDescription() {
return null;
}
/**
* Returns true if there is currently a primary clip on the clipboard.
*/
public boolean hasPrimaryClip() {
return false;
}
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.
*/
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.
*/
public void setText(CharSequence text) {
}
/**
* @deprecated Use {@link #hasPrimaryClip()} instead.
*/
public boolean hasText() {
return false;
}
void reportPrimaryClipChanged() {
}
static final int MSG_REPORT_PRIMARY_CLIP_CHANGED = 1;
/**
* Defines a listener callback that is invoked when the primary clip on the clipboard changes.
* Objects that want to register a listener call
* {@link android.content.ClipboardManager#addPrimaryClipChangedListener(OnPrimaryClipChangedListener)
* addPrimaryClipChangedListener()} with an
* object that implements OnPrimaryClipChangedListener.
*
*/
public interface OnPrimaryClipChangedListener {
/**
* Callback that is invoked by {@link android.content.ClipboardManager} when the primary
* clip changes.
*/
void onPrimaryClipChanged();
}
/**
* {@hide}
*/
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.
*
* @param clip The clipped data item to set.
*/
public void setPrimaryClip(ClipData clip) {
}
/**
* Returns the current primary clip on the clipboard.
*/
public ClipData getPrimaryClip() {
return null;
}
/**
* Returns a description of the current primary clip on the clipboard
* but not a copy of its data.
*/
public ClipDescription getPrimaryClipDescription() {
return null;
}
/**
* Returns true if there is currently a primary clip on the clipboard.
*/
public boolean hasPrimaryClip() {
return false;
}
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.
*/
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.
*/
public void setText(CharSequence text) {
}
/**
* @deprecated Use {@link #hasPrimaryClip()} instead.
*/
public boolean hasText() {
return false;
}
void reportPrimaryClipChanged() {
}
}

View File

@@ -30,233 +30,241 @@ import java.lang.Comparable;
*
*/
public final class ComponentName implements Cloneable, Comparable<ComponentName> {
private final String mPackage;
private final String mClass;
private final String mPackage;
private final String mClass;
/**
* Create a new component identifier.
*
* @param pkg The name of the package that the component exists in. Can
* not be null.
* @param cls The name of the class inside of <var>pkg</var> that
* implements the component. Can not be null.
*/
public ComponentName(String pkg, String cls) {
if (pkg == null) throw new NullPointerException("package name is null");
if (cls == null) throw new NullPointerException("class name is null");
mPackage = pkg;
mClass = cls;
}
/**
* Create a new component identifier.
*
* @param pkg The name of the package that the component exists in. Can
* not be null.
* @param cls The name of the class inside of <var>pkg</var> that
* implements the component. Can not be null.
*/
public ComponentName(String pkg, String cls) {
if (pkg == null)
throw new NullPointerException("package name is null");
if (cls == null)
throw new NullPointerException("class name is null");
mPackage = pkg;
mClass = cls;
}
/**
* Create a new component identifier from a Context and class name.
*
* @param pkg A Context for the package implementing the component,
* from which the actual package name will be retrieved.
* @param cls The name of the class inside of <var>pkg</var> that
* implements the component.
*/
public ComponentName(Context pkg, String cls) {
if (cls == null) throw new NullPointerException("class name is null");
mPackage = pkg.getPackageName();
mClass = cls;
}
/**
* Create a new component identifier from a Context and class name.
*
* @param pkg A Context for the package implementing the component,
* from which the actual package name will be retrieved.
* @param cls The name of the class inside of <var>pkg</var> that
* implements the component.
*/
public ComponentName(Context pkg, String cls) {
if (cls == null)
throw new NullPointerException("class name is null");
mPackage = pkg.getPackageName();
mClass = cls;
}
/**
* Create a new component identifier from a Context and Class object.
*
* @param pkg A Context for the package implementing the component, from
* which the actual package name will be retrieved.
* @param cls The Class object of the desired component, from which the
* actual class name will be retrieved.
*/
public ComponentName(Context pkg, Class<?> cls) {
mPackage = pkg.getPackageName();
mClass = cls.getName();
}
/**
* Create a new component identifier from a Context and Class object.
*
* @param pkg A Context for the package implementing the component, from
* which the actual package name will be retrieved.
* @param cls The Class object of the desired component, from which the
* actual class name will be retrieved.
*/
public ComponentName(Context pkg, Class<?> cls) {
mPackage = pkg.getPackageName();
mClass = cls.getName();
}
public ComponentName clone() {
return new ComponentName(mPackage, mClass);
}
public ComponentName clone() {
return new ComponentName(mPackage, mClass);
}
/**
* Return the package name of this component.
*/
public String getPackageName() {
return mPackage;
}
/**
* Return the package name of this component.
*/
public String getPackageName() {
return mPackage;
}
/**
* Return the class name of this component.
*/
public String getClassName() {
return mClass;
}
/**
* 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;
}
/**
* 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 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) {
if (className.startsWith(packageName)) {
int PN = packageName.length();
int CN = className.length();
if (CN > PN && className.charAt(PN) == '.') {
pw.write(className, PN, CN-PN);
return;
}
}
pw.print(className);
}
private static void printShortClassName(PrintWriter pw, String packageName,
String className) {
if (className.startsWith(packageName)) {
int PN = packageName.length();
int CN = className.length();
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
* class names contained in the ComponentName. You can later recover
* the ComponentName from this string through
* {@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;
}
/**
* Return a String that unambiguously describes both the package and
* class names contained in the ComponentName. You can later recover
* the ComponentName from this string through
* {@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;
}
/**
* 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();
}
/**
* 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 */
public void appendShortString(StringBuilder sb) {
appendShortString(sb, mPackage, mClass);
}
/**
* @hide
*/
public void appendShortString(StringBuilder sb) {
appendShortString(sb, mPackage, mClass);
}
/** @hide */
public static void appendShortString(StringBuilder sb, String packageName, String className) {
sb.append(packageName).append('/');
appendShortClassName(sb, packageName, className);
}
/**
* @hide
*/
public static void appendShortString(StringBuilder sb, String packageName, String className) {
sb.append(packageName).append('/');
appendShortClassName(sb, packageName, className);
}
/** @hide */
public static void printShortString(PrintWriter pw, String packageName, String className) {
pw.print(packageName);
pw.print('/');
printShortClassName(pw, packageName, className);
}
/**
* @hide
*/
public static void printShortString(PrintWriter pw, String packageName, String className) {
pw.print(packageName);
pw.print('/');
printShortClassName(pw, packageName, className);
}
/**
* Recover a ComponentName from a String that was previously created with
* {@link #flattenToString()}. It splits the string at the first '/',
* taking the part before as the package name and the part after as the
* class name. As a special convenience (to use, for example, when
* parsing component names on the command line), if the '/' is immediately
* 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".
*
* @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);
}
/**
* Recover a ComponentName from a String that was previously created with
* {@link #flattenToString()}. It splits the string at the first '/',
* taking the part before as the package name and the part after as the
* class name. As a special convenience (to use, for example, when
* parsing component names on the command line), if the '/' is immediately
* 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".
*
* @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 + "}";
}
/**
* 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 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 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();
}
@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 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;
}
public int describeContents() {
return 0;
}
}

View File

@@ -1,7 +1,7 @@
package android.content;
import android.net.Uri;
import android.database.ContentObserver;
import android.net.Uri;
public class ContentResolver {
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;
import android.util.Log;
import android.content.pm.PackageManager;
import android.app.ActivityManager;
import android.app.AlarmManager;
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.PackageManager;
import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.Intent;
import android.content.BroadcastReceiver;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.content.SharedPreferences;
import android.app.SharedPreferencesImpl;
import android.hardware.SensorManager;
import android.hardware.display.DisplayManager;
import android.hardware.usb.UsbManager;
import android.media.AudioManager;
import android.media.MediaRouter;
import android.net.ConnectivityManager;
import android.os.Looper;
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.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.FileInputStream;
import java.io.FileOutputStream;
@@ -77,7 +73,7 @@ public class Context extends Object {
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");
}
@@ -85,7 +81,7 @@ public class Context extends Object {
return r.newTheme();
}
public ApplicationInfo getApplicationInfo () {
public ApplicationInfo getApplicationInfo() {
// TODO: do this somewhere saner?
application_info.nativeLibraryDir = (new File(getDataDirFile(), "lib")).getAbsolutePath();
return application_info;
@@ -132,7 +128,7 @@ public class Context extends Object {
case "alarm":
return new AlarmManager();
default:
System.out.println("!!!!!!! getSystemService: case >"+name+"< is not implemented yet");
System.out.println("!!!!!!! getSystemService: case >" + name + "< is not implemented yet");
return null;
}
}
@@ -175,11 +171,11 @@ public class Context extends Object {
return new File(base, name);
}
throw new IllegalArgumentException(
"File " + name + " contains a path separator");
"File " + name + " contains a path separator");
}
private File getDataDirFile() {
if(data_dir == null) {
if (data_dir == null) {
data_dir = android.os.Environment.getExternalStorageDirectory();
}
return data_dir;
@@ -190,7 +186,7 @@ public class Context extends Object {
files_dir = new File(getDataDirFile(), "files");
}
if (!files_dir.exists()) {
if(!files_dir.mkdirs()) {
if (!files_dir.mkdirs()) {
if (files_dir.exists()) {
// spurious failure; probably racing with another process for this app
return files_dir;
@@ -207,29 +203,29 @@ public class Context extends Object {
}
public File getObbDir() {
if (obb_dir == null) {
if (obb_dir == null) {
obb_dir = new File(getDataDirFile(), "obb");
}
return obb_dir;
}
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
public File getCacheDir() {
if (cache_dir == null) {
cache_dir = new File("/tmp/");
}
return cache_dir;
if (cache_dir == null) {
cache_dir = new File("/tmp/");
}
return cache_dir;
}
private File getPreferencesDir() {
if (prefs_dir == null) {
prefs_dir = new File(getDataDirFile(), "shared_prefs");
}
return prefs_dir;
if (prefs_dir == null) {
prefs_dir = new File(getDataDirFile(), "shared_prefs");
}
return prefs_dir;
}
public File getSharedPrefsFile(String name) {
@@ -237,7 +233,7 @@ public class Context extends Object {
}
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);
return new SharedPreferencesImpl(prefsFile, mode);
}
@@ -248,7 +244,7 @@ public class Context extends Object {
}
public ComponentName startService(Intent service) {
return new ComponentName("","");
return new ComponentName("", "");
}
// 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 {
System.out.println("openFileOutput called for: '"+name+"'");
System.out.println("openFileOutput called for: '" + name + "'");
return new FileOutputStream(android.os.Environment.getExternalStorageDirectory().getPath() + "/files/" + name);
}
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
}
@@ -270,8 +266,8 @@ public class Context extends Object {
public void registerComponentCallbacks(ComponentCallbacks callbacks) {}
// 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, 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[] 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(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); }
}

View File

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

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