You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
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:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -16,20 +16,24 @@
|
||||
|
||||
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;
|
||||
ACTIVITY_INTENT_ACTION,
|
||||
BROADCAST_INTENT_ACTION,
|
||||
SERVICE_ACTION,
|
||||
INTENT_CATEGORY,
|
||||
FEATURE;
|
||||
}
|
||||
|
||||
SdkConstantType value();
|
||||
|
||||
@@ -26,7 +26,9 @@ 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 {
|
||||
|
||||
@@ -23,8 +23,10 @@ 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 {
|
||||
|
||||
@@ -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 {
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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() {
|
||||
@@ -219,10 +215,10 @@ public class Activity extends Context {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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;
|
||||
|
||||
@@ -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,20 +167,20 @@ 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)) {
|
||||
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){
|
||||
if (name == null || value == null) {
|
||||
continue;
|
||||
}
|
||||
if (META_DATA_LIB_NAME.equals(name.getValueAsString())){
|
||||
if (META_DATA_LIB_NAME.equals(name.getValueAsString())) {
|
||||
libname = value.getValueAsString();
|
||||
}
|
||||
if (META_DATA_FUNC_NAME.equals(name.getValueAsString())){
|
||||
if (META_DATA_FUNC_NAME.equals(name.getValueAsString())) {
|
||||
funcname = value.getValueAsString();
|
||||
}
|
||||
}
|
||||
@@ -204,7 +202,8 @@ 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()),
|
||||
|
||||
@@ -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 {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,19 +17,15 @@
|
||||
package android.app;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
//import android.os.FileUtils;
|
||||
//import android.os.Looper;
|
||||
import android.system.ErrnoException;
|
||||
// import android.os.FileUtils;
|
||||
// import android.os.Looper;
|
||||
import android.system.Os;
|
||||
import android.system.StructStat;
|
||||
import android.util.Log;
|
||||
|
||||
//import com.google.android.collect.Maps;
|
||||
// import com.google.android.collect.Maps;
|
||||
import com.android.internal.util.XmlUtils;
|
||||
|
||||
import dalvik.system.BlockGuard;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -45,9 +41,8 @@ import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import android.system.ErrnoException;
|
||||
import libcore.io.IoUtils;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public final class SharedPreferencesImpl implements SharedPreferences {
|
||||
private static final String TAG = "SharedPreferencesImpl";
|
||||
@@ -114,7 +109,7 @@ public final class SharedPreferencesImpl implements SharedPreferences {
|
||||
BufferedInputStream str = null;
|
||||
try {
|
||||
str = new BufferedInputStream(
|
||||
new FileInputStream(mFile), 16*1024);
|
||||
new FileInputStream(mFile), 16 * 1024);
|
||||
map = XmlUtils.readMapXml(str);
|
||||
} catch (XmlPullParserException e) {
|
||||
Log.w(TAG, "getSharedPreferences", e);
|
||||
@@ -159,7 +154,8 @@ public final class SharedPreferencesImpl implements SharedPreferences {
|
||||
synchronized (this) {
|
||||
if (mDiskWritesInFlight > 0) {
|
||||
// If we know we caused it, it's not unexpected.
|
||||
if (DEBUG) Log.d(TAG, "disk write in flight, not unexpected.");
|
||||
if (DEBUG)
|
||||
Log.d(TAG, "disk write in flight, not unexpected.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -180,13 +176,13 @@ public final class SharedPreferencesImpl implements SharedPreferences {
|
||||
}
|
||||
|
||||
public void registerOnSharedPreferenceChangeListener(OnSharedPreferenceChangeListener listener) {
|
||||
synchronized(this) {
|
||||
synchronized (this) {
|
||||
mListeners.put(listener, mContent);
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterOnSharedPreferenceChangeListener(OnSharedPreferenceChangeListener listener) {
|
||||
synchronized(this) {
|
||||
synchronized (this) {
|
||||
mListeners.remove(listener);
|
||||
}
|
||||
}
|
||||
@@ -210,7 +206,7 @@ public final class SharedPreferencesImpl implements SharedPreferences {
|
||||
System.out.println("\n\n...> getAll()\n\n");
|
||||
synchronized (this) {
|
||||
awaitLoadedLocked();
|
||||
//noinspection unchecked
|
||||
// noinspection unchecked
|
||||
return new HashMap<String, Object>(mMap);
|
||||
}
|
||||
}
|
||||
@@ -226,7 +222,7 @@ public final class SharedPreferencesImpl implements SharedPreferences {
|
||||
public Set<String> getStringSet(String key, Set<String> defValues) {
|
||||
synchronized (this) {
|
||||
awaitLoadedLocked();
|
||||
Set<String> v = (Set<String>) mMap.get(key);
|
||||
Set<String> v = (Set<String>)mMap.get(key);
|
||||
return v != null ? v : defValues;
|
||||
}
|
||||
}
|
||||
@@ -364,14 +360,14 @@ public final class SharedPreferencesImpl implements SharedPreferences {
|
||||
}
|
||||
};
|
||||
|
||||
// QueuedWork.add(awaitCommit);
|
||||
// since we've made this synchronous, we can't exactly start "waiting" for the commit before we made the commit
|
||||
// awaitCommit.run();
|
||||
// QueuedWork.add(awaitCommit);
|
||||
// since we've made this synchronous, we can't exactly start "waiting" for the commit before we made the commit
|
||||
// awaitCommit.run();
|
||||
|
||||
Runnable postWriteRunnable = new Runnable() {
|
||||
public void run() {
|
||||
awaitCommit.run();
|
||||
// QueuedWork.remove(awaitCommit);
|
||||
// QueuedWork.remove(awaitCommit);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -461,7 +457,7 @@ public final class SharedPreferencesImpl implements SharedPreferences {
|
||||
return mcr.writeToDiskResult;
|
||||
}
|
||||
|
||||
private void notifyListeners(final MemoryCommitResult mcr) {/*
|
||||
private void notifyListeners(final MemoryCommitResult mcr) { /*
|
||||
if (mcr.listeners == null || mcr.keysModified == null ||
|
||||
mcr.keysModified.size() == 0) {
|
||||
return;
|
||||
@@ -483,7 +479,8 @@ public final class SharedPreferencesImpl implements SharedPreferences {
|
||||
}
|
||||
});
|
||||
}
|
||||
*/}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -533,7 +530,7 @@ public final class SharedPreferencesImpl implements SharedPreferences {
|
||||
}
|
||||
}
|
||||
|
||||
//QueuedWork.singleThreadExecutor().execute(writeToDiskRunnable);
|
||||
// QueuedWork.singleThreadExecutor().execute(writeToDiskRunnable);
|
||||
writeToDiskRunnable.run();
|
||||
}
|
||||
|
||||
@@ -547,7 +544,7 @@ public final class SharedPreferencesImpl implements SharedPreferences {
|
||||
Log.e(TAG, "Couldn't create directory for SharedPreferences file " + file);
|
||||
return null;
|
||||
}
|
||||
/* FileUtils.setPermissions(
|
||||
/* FileUtils.setPermissions(
|
||||
parent.getPath(),
|
||||
FileUtils.S_IRWXU|FileUtils.S_IRWXG|FileUtils.S_IXOTH,
|
||||
-1, -1);*/
|
||||
@@ -574,8 +571,7 @@ public final class SharedPreferencesImpl implements SharedPreferences {
|
||||
}
|
||||
if (!mBackupFile.exists()) {
|
||||
if (!mFile.renameTo(mBackupFile)) {
|
||||
Log.e(TAG, "Couldn't rename file " + mFile
|
||||
+ " to backup file " + mBackupFile);
|
||||
Log.e(TAG, "Couldn't rename file " + mFile + " to backup file " + mBackupFile);
|
||||
mcr.setDiskWriteResult(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
package android.content;
|
||||
|
||||
public class ActivityNotFoundException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
package android.content;
|
||||
|
||||
public class BroadcastReceiver {
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -65,7 +65,9 @@ public class ClipboardManager extends android.text.ClipboardManager {
|
||||
*/
|
||||
void onPrimaryClipChanged();
|
||||
}
|
||||
/** {@hide} */
|
||||
/**
|
||||
* {@hide}
|
||||
*/
|
||||
public ClipboardManager(Context context, Handler handler) {
|
||||
}
|
||||
public ClipboardManager() {
|
||||
|
||||
@@ -42,8 +42,10 @@ public final class ComponentName implements Cloneable, Comparable<ComponentName>
|
||||
* 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");
|
||||
if (pkg == null)
|
||||
throw new NullPointerException("package name is null");
|
||||
if (cls == null)
|
||||
throw new NullPointerException("class name is null");
|
||||
mPackage = pkg;
|
||||
mClass = cls;
|
||||
}
|
||||
@@ -57,7 +59,8 @@ public final class ComponentName implements Cloneable, Comparable<ComponentName>
|
||||
* implements the component.
|
||||
*/
|
||||
public ComponentName(Context pkg, String cls) {
|
||||
if (cls == null) throw new NullPointerException("class name is null");
|
||||
if (cls == null)
|
||||
throw new NullPointerException("class name is null");
|
||||
mPackage = pkg.getPackageName();
|
||||
mClass = cls;
|
||||
}
|
||||
@@ -127,7 +130,7 @@ public final class ComponentName implements Cloneable, Comparable<ComponentName>
|
||||
int PN = packageName.length();
|
||||
int CN = className.length();
|
||||
if (CN > PN && className.charAt(PN) == '.') {
|
||||
pw.write(className, PN, CN-PN);
|
||||
pw.write(className, PN, CN - PN);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -167,18 +170,24 @@ public final class ComponentName implements Cloneable, Comparable<ComponentName>
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public void appendShortString(StringBuilder sb) {
|
||||
appendShortString(sb, mPackage, mClass);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public static void appendShortString(StringBuilder sb, String packageName, String className) {
|
||||
sb.append(packageName).append('/');
|
||||
appendShortClassName(sb, packageName, className);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public static void printShortString(PrintWriter pw, String packageName, String className) {
|
||||
pw.print(packageName);
|
||||
pw.print('/');
|
||||
@@ -203,11 +212,11 @@ public final class ComponentName implements Cloneable, Comparable<ComponentName>
|
||||
*/
|
||||
public static ComponentName unflattenFromString(String str) {
|
||||
int sep = str.indexOf('/');
|
||||
if (sep < 0 || (sep+1) >= str.length()) {
|
||||
if (sep < 0 || (sep + 1) >= str.length()) {
|
||||
return null;
|
||||
}
|
||||
String pkg = str.substring(0, sep);
|
||||
String cls = str.substring(sep+1);
|
||||
String cls = str.substring(sep + 1);
|
||||
if (cls.length() > 0 && cls.charAt(0) == '.') {
|
||||
cls = pkg + cls;
|
||||
}
|
||||
@@ -234,8 +243,7 @@ public final class ComponentName implements Cloneable, Comparable<ComponentName>
|
||||
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);
|
||||
return mPackage.equals(other.mPackage) && mClass.equals(other.mClass);
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package android.content;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -30,7 +29,9 @@ import java.util.Set;
|
||||
public final class ContentValues {
|
||||
public static final String TAG = "ContentValues";
|
||||
|
||||
/** Holds the actual values */
|
||||
/**
|
||||
* Holds the actual values
|
||||
*/
|
||||
private HashMap<String, Object> mValues;
|
||||
|
||||
/**
|
||||
@@ -76,7 +77,7 @@ public final class ContentValues {
|
||||
if (!(object instanceof ContentValues)) {
|
||||
return false;
|
||||
}
|
||||
return mValues.equals(((ContentValues) object).mValues);
|
||||
return mValues.equals(((ContentValues)object).mValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -258,7 +259,7 @@ public final class ContentValues {
|
||||
public Long getAsLong(String key) {
|
||||
Object value = mValues.get(key);
|
||||
try {
|
||||
return value != null ? ((Number) value).longValue() : null;
|
||||
return value != null ? ((Number)value).longValue() : null;
|
||||
} catch (ClassCastException e) {
|
||||
if (value instanceof CharSequence) {
|
||||
try {
|
||||
@@ -283,7 +284,7 @@ public final class ContentValues {
|
||||
public Integer getAsInteger(String key) {
|
||||
Object value = mValues.get(key);
|
||||
try {
|
||||
return value != null ? ((Number) value).intValue() : null;
|
||||
return value != null ? ((Number)value).intValue() : null;
|
||||
} catch (ClassCastException e) {
|
||||
if (value instanceof CharSequence) {
|
||||
try {
|
||||
@@ -308,7 +309,7 @@ public final class ContentValues {
|
||||
public Short getAsShort(String key) {
|
||||
Object value = mValues.get(key);
|
||||
try {
|
||||
return value != null ? ((Number) value).shortValue() : null;
|
||||
return value != null ? ((Number)value).shortValue() : null;
|
||||
} catch (ClassCastException e) {
|
||||
if (value instanceof CharSequence) {
|
||||
try {
|
||||
@@ -333,7 +334,7 @@ public final class ContentValues {
|
||||
public Byte getAsByte(String key) {
|
||||
Object value = mValues.get(key);
|
||||
try {
|
||||
return value != null ? ((Number) value).byteValue() : null;
|
||||
return value != null ? ((Number)value).byteValue() : null;
|
||||
} catch (ClassCastException e) {
|
||||
if (value instanceof CharSequence) {
|
||||
try {
|
||||
@@ -358,7 +359,7 @@ public final class ContentValues {
|
||||
public Double getAsDouble(String key) {
|
||||
Object value = mValues.get(key);
|
||||
try {
|
||||
return value != null ? ((Number) value).doubleValue() : null;
|
||||
return value != null ? ((Number)value).doubleValue() : null;
|
||||
} catch (ClassCastException e) {
|
||||
if (value instanceof CharSequence) {
|
||||
try {
|
||||
@@ -383,7 +384,7 @@ public final class ContentValues {
|
||||
public Float getAsFloat(String key) {
|
||||
Object value = mValues.get(key);
|
||||
try {
|
||||
return value != null ? ((Number) value).floatValue() : null;
|
||||
return value != null ? ((Number)value).floatValue() : null;
|
||||
} catch (ClassCastException e) {
|
||||
if (value instanceof CharSequence) {
|
||||
try {
|
||||
@@ -408,12 +409,12 @@ public final class ContentValues {
|
||||
public Boolean getAsBoolean(String key) {
|
||||
Object value = mValues.get(key);
|
||||
try {
|
||||
return (Boolean) value;
|
||||
return (Boolean)value;
|
||||
} catch (ClassCastException e) {
|
||||
if (value instanceof CharSequence) {
|
||||
return Boolean.valueOf(value.toString());
|
||||
} else if (value instanceof Number) {
|
||||
return ((Number) value).intValue() != 0;
|
||||
return ((Number)value).intValue() != 0;
|
||||
} else {
|
||||
Log.e(TAG, "Cannot cast value for " + key + " to a Boolean: " + value, e);
|
||||
return null;
|
||||
@@ -431,7 +432,7 @@ public final class ContentValues {
|
||||
public byte[] getAsByteArray(String key) {
|
||||
Object value = mValues.get(key);
|
||||
if (value instanceof byte[]) {
|
||||
return (byte[]) value;
|
||||
return (byte[])value;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -471,7 +472,7 @@ public final class ContentValues {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Deprecated
|
||||
public ArrayList<String> getStringArrayList(String key) {
|
||||
return (ArrayList<String>) mValues.get(key);
|
||||
return (ArrayList<String>)mValues.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -483,7 +484,8 @@ public final class ContentValues {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String name : mValues.keySet()) {
|
||||
String value = getAsString(name);
|
||||
if (sb.length() > 0) sb.append(" ");
|
||||
if (sb.length() > 0)
|
||||
sb.append(" ");
|
||||
sb.append(name + "=" + value);
|
||||
}
|
||||
return sb.toString();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -179,7 +175,7 @@ public class Context extends Object {
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -214,7 +210,7 @@ public class Context extends Object {
|
||||
}
|
||||
|
||||
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
|
||||
@@ -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); }
|
||||
}
|
||||
|
||||
@@ -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
Reference in New Issue
Block a user