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
api-impl: use liblog for android.util.Log; use Log.v for debugging prints and Log.w for stub tracing
This commit is contained in:
@@ -22,7 +22,7 @@ import android.system.ErrnoException;
|
||||
// import android.os.Looper;
|
||||
import android.system.Os;
|
||||
import android.system.StructStat;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
// import com.google.android.collect.Maps;
|
||||
import com.android.internal.util.XmlUtils;
|
||||
import dalvik.system.BlockGuard;
|
||||
@@ -99,7 +99,7 @@ public final class SharedPreferencesImpl implements SharedPreferences {
|
||||
}
|
||||
// Debugging
|
||||
if (mFile.exists() && !mFile.canRead()) {
|
||||
Log.w(TAG, "Attempt to read preferences file " + mFile + " without permission");
|
||||
Slog.w(TAG, "Attempt to read preferences file " + mFile + " without permission");
|
||||
}
|
||||
Map map = null;
|
||||
StructStat stat = null;
|
||||
@@ -112,11 +112,11 @@ public final class SharedPreferencesImpl implements SharedPreferences {
|
||||
new FileInputStream(mFile), 16 * 1024);
|
||||
map = XmlUtils.readMapXml(str);
|
||||
} catch (XmlPullParserException e) {
|
||||
Log.w(TAG, "getSharedPreferences", e);
|
||||
Slog.w(TAG, "getSharedPreferences", e);
|
||||
} catch (FileNotFoundException e) {
|
||||
Log.w(TAG, "getSharedPreferences", e);
|
||||
Slog.w(TAG, "getSharedPreferences", e);
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, "getSharedPreferences", e);
|
||||
Slog.w(TAG, "getSharedPreferences", e);
|
||||
} finally {
|
||||
IoUtils.closeQuietly(str);
|
||||
}
|
||||
@@ -155,7 +155,7 @@ public final class SharedPreferencesImpl implements SharedPreferences {
|
||||
if (mDiskWritesInFlight > 0) {
|
||||
// If we know we caused it, it's not unexpected.
|
||||
if (DEBUG)
|
||||
Log.d(TAG, "disk write in flight, not unexpected.");
|
||||
Slog.d(TAG, "disk write in flight, not unexpected.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -203,7 +203,7 @@ public final class SharedPreferencesImpl implements SharedPreferences {
|
||||
}
|
||||
|
||||
public Map<String, ?> getAll() {
|
||||
System.out.println("\n\n...> getAll()\n\n");
|
||||
Slog.v(TAG, "\n\n...> getAll()\n\n");
|
||||
synchronized (this) {
|
||||
awaitLoadedLocked();
|
||||
// noinspection unchecked
|
||||
@@ -250,7 +250,7 @@ public final class SharedPreferencesImpl implements SharedPreferences {
|
||||
}
|
||||
public boolean getBoolean(String key, boolean defValue) {
|
||||
synchronized (this) {
|
||||
System.out.println("android.app.SharedPreferencesImpl.getBoolean("+key+", "+defValue+")");
|
||||
Slog.v(TAG, "android.app.SharedPreferencesImpl.getBoolean("+key+", "+defValue+")");
|
||||
awaitLoadedLocked();
|
||||
Boolean v = (Boolean)mMap.get(key);
|
||||
return v != null ? v : defValue;
|
||||
@@ -542,7 +542,7 @@ public final class SharedPreferencesImpl implements SharedPreferences {
|
||||
} catch (FileNotFoundException e) {
|
||||
File parent = file.getParentFile();
|
||||
if (!parent.mkdir()) {
|
||||
Log.e(TAG, "Couldn't create directory for SharedPreferences file " + file);
|
||||
Slog.e(TAG, "Couldn't create directory for SharedPreferences file " + file);
|
||||
return null;
|
||||
}
|
||||
/* FileUtils.setPermissions(
|
||||
@@ -552,7 +552,7 @@ public final class SharedPreferencesImpl implements SharedPreferences {
|
||||
try {
|
||||
str = new FileOutputStream(file);
|
||||
} catch (FileNotFoundException e2) {
|
||||
Log.e(TAG, "Couldn't create SharedPreferences file " + file, e2);
|
||||
Slog.e(TAG, "Couldn't create SharedPreferences file " + file, e2);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
@@ -572,7 +572,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);
|
||||
Slog.e(TAG, "Couldn't rename file " + mFile + " to backup file " + mBackupFile);
|
||||
mcr.setDiskWriteResult(false);
|
||||
return;
|
||||
}
|
||||
@@ -607,14 +607,14 @@ public final class SharedPreferencesImpl implements SharedPreferences {
|
||||
mcr.setDiskWriteResult(true);
|
||||
return;
|
||||
} catch (XmlPullParserException e) {
|
||||
Log.w(TAG, "writeToFile: Got exception:", e);
|
||||
Slog.w(TAG, "writeToFile: Got exception:", e);
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, "writeToFile: Got exception:", e);
|
||||
Slog.w(TAG, "writeToFile: Got exception:", e);
|
||||
}
|
||||
// Clean up an unsuccessfully written file
|
||||
if (mFile.exists()) {
|
||||
if (!mFile.delete()) {
|
||||
Log.e(TAG, "Couldn't clean up partially-written file " + mFile);
|
||||
Slog.e(TAG, "Couldn't clean up partially-written file " + mFile);
|
||||
}
|
||||
}
|
||||
mcr.setDiskWriteResult(false);
|
||||
|
||||
@@ -27,7 +27,7 @@ import android.os.Vibrator;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
import android.view.WindowManagerImpl;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
@@ -106,7 +106,7 @@ public class Context extends Object {
|
||||
}
|
||||
|
||||
public Context() {
|
||||
System.out.println("new Context! this one is: " + this);
|
||||
Slog.v(TAG, "new Context! this one is: " + this);
|
||||
}
|
||||
|
||||
public int checkPermission(String permission, int pid, int uid) {
|
||||
@@ -174,7 +174,7 @@ public class Context extends Object {
|
||||
case "accessibility":
|
||||
return new AccessibilityManager();
|
||||
default:
|
||||
System.out.println("!!!!!!! getSystemService: case >" + name + "< is not implemented yet");
|
||||
Slog.e(TAG, "!!!!!!! getSystemService: case >" + name + "< is not implemented yet");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -247,7 +247,7 @@ public class Context extends Object {
|
||||
// spurious failure; probably racing with another process for this app
|
||||
return files_dir;
|
||||
}
|
||||
Log.w(TAG, "Unable to create files directory " + files_dir.getPath());
|
||||
Slog.w(TAG, "Unable to create files directory " + files_dir.getPath());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -293,7 +293,7 @@ public class Context extends Object {
|
||||
}
|
||||
|
||||
public SharedPreferences getSharedPreferences(String name, int mode) {
|
||||
System.out.println("\n\n...> getSharedPreferences(" + name + ")\n\n");
|
||||
Slog.v(TAG, "\n\n...> getSharedPreferences(" + name + ")\n\n");
|
||||
File prefsFile = getSharedPrefsFile(name);
|
||||
return new SharedPreferencesImpl(prefsFile, mode);
|
||||
}
|
||||
@@ -309,19 +309,19 @@ public class Context extends Object {
|
||||
|
||||
// TODO: do these both work? make them look more alike
|
||||
public FileInputStream openFileInput(String name) throws FileNotFoundException {
|
||||
System.out.println("openFileInput called for: '" + name + "'");
|
||||
Slog.v(TAG, "openFileInput called for: '" + name + "'");
|
||||
File file = new File(getFilesDir(), name);
|
||||
|
||||
return new FileInputStream(file);
|
||||
}
|
||||
|
||||
public FileOutputStream openFileOutput(String name, int mode) throws java.io.FileNotFoundException {
|
||||
System.out.println("openFileOutput called for: '" + name + "'");
|
||||
Slog.v(TAG, "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 + "<");
|
||||
Slog.w(TAG, "!!! app wants to know if it has a permission: >" + permission + "< (returning PREMISSION_DENIED)");
|
||||
|
||||
return -1; // PackageManager.PERMISSION_DENIED
|
||||
}
|
||||
@@ -329,15 +329,15 @@ public class Context extends Object {
|
||||
public void registerComponentCallbacks(ComponentCallbacks callbacks) {}
|
||||
|
||||
public boolean bindService(Intent dummy, ServiceConnection dummy2, int dummy3) {
|
||||
System.out.println("bindService("+dummy+", "+dummy2+", "+dummy3+")");
|
||||
Slog.w(TAG, "bindService("+dummy+", "+dummy2+", "+dummy3+")");
|
||||
return false; // maybe?
|
||||
}
|
||||
|
||||
public void startActivity(Intent intent) {
|
||||
System.out.println("------------------");
|
||||
System.out.println("app wants to startActivity("+intent+"), but we don't support that... :/");
|
||||
Slog.w(TAG, "------------------");
|
||||
Slog.w(TAG, "app wants to startActivity("+intent+"), but we don't support that... :/");
|
||||
try { throw new java.lang.Exception(); } catch (java.lang.Exception e) { e.printStackTrace(); }
|
||||
System.out.println("------------------");
|
||||
Slog.w(TAG, "------------------");
|
||||
}
|
||||
|
||||
public final TypedArray obtainStyledAttributes(AttributeSet set, int[] attrs) {
|
||||
|
||||
@@ -364,11 +364,5 @@ public final class Log {
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public static /*native*/ int
|
||||
println_native(int bufID,
|
||||
int priority, String tag, String msg) {
|
||||
String out = String.format("`¯´[%d][%d] [%s] : %s", bufID, priority, tag, msg);
|
||||
System.out.println(out);
|
||||
return out.getBytes().length;
|
||||
}
|
||||
public static native int println_native(int bufID, int priority, String tag, String msg);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package android.view;
|
||||
import android.content.Context;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Slog;
|
||||
import android.util.Xml;
|
||||
import java.io.FileReader;
|
||||
import java.lang.reflect.Constructor;
|
||||
@@ -11,6 +12,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
|
||||
public class LayoutInflater {
|
||||
private static final String TAG = "LayoutInflater";
|
||||
|
||||
public interface Factory {
|
||||
}
|
||||
@@ -33,7 +35,7 @@ public class LayoutInflater {
|
||||
}
|
||||
|
||||
public final View createView(String name, String prefix, AttributeSet attrs) throws Exception {
|
||||
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>> createView(" + name + ", " + prefix + ", " + attrs + ");");
|
||||
Slog.v(TAG, ">>>>>>>>>>>>>>>>>>>>>>>>> createView(" + name + ", " + prefix + ", " + attrs + ");");
|
||||
|
||||
String view_class_name = prefix!=null ? prefix + name : name;
|
||||
Class view_class = Class.forName(view_class_name);
|
||||
@@ -68,7 +70,7 @@ public class LayoutInflater {
|
||||
name = attrs.getAttributeValue(null, "class");
|
||||
}
|
||||
|
||||
System.out.println("******** Creating view: " + name);
|
||||
Slog.v(TAG, "******** Creating view: " + name);
|
||||
|
||||
View view;
|
||||
|
||||
@@ -78,7 +80,7 @@ public class LayoutInflater {
|
||||
view = createView(name, null, attrs);
|
||||
}
|
||||
|
||||
System.out.println("Created view is: " + view);
|
||||
Slog.v(TAG, "Created view is: " + view);
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -116,9 +118,9 @@ public class LayoutInflater {
|
||||
|
||||
final String name = parser.getName();
|
||||
|
||||
System.out.println("**************************");
|
||||
System.out.println("Creating root view: " + name);
|
||||
System.out.println("**************************");
|
||||
Slog.v(TAG, "**************************");
|
||||
Slog.v(TAG, "Creating root view: " + name);
|
||||
Slog.v(TAG, "**************************");
|
||||
|
||||
if (name.equals("merge")) {
|
||||
if (root == null || !attachToRoot) {
|
||||
@@ -139,7 +141,7 @@ public class LayoutInflater {
|
||||
ViewGroup.LayoutParams params = null;
|
||||
|
||||
if (root != null) {
|
||||
System.out.println("Creating params from root: " + root);
|
||||
Slog.v(TAG, "Creating params from root: " + root);
|
||||
|
||||
// Create layout params that match root, if supplied
|
||||
params = root.generateLayoutParams(attrs);
|
||||
@@ -150,12 +152,12 @@ public class LayoutInflater {
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("-----> start inflating children");
|
||||
Slog.v(TAG, "-----> start inflating children");
|
||||
|
||||
// Inflate all children under temp
|
||||
rInflate(parser, temp, attrs, true);
|
||||
|
||||
System.out.println("-----> done inflating children");
|
||||
Slog.v(TAG, "-----> done inflating children");
|
||||
|
||||
// We are supposed to attach all the views we found (int temp)
|
||||
// to root. Do that now.
|
||||
|
||||
@@ -12,6 +12,7 @@ import android.os.Looper;
|
||||
import android.os.Parcelable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.LayoutDirection;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
import android.view.animation.Animation;
|
||||
|
||||
@@ -26,7 +27,7 @@ public class View extends Object {
|
||||
/**
|
||||
* The logging tag used by this class with android.util.Log.
|
||||
*/
|
||||
protected static final String VIEW_LOG_TAG = "View";
|
||||
protected static final String TAG = "View";
|
||||
|
||||
/**
|
||||
* When set to true, apps will draw debugging information about their layouts.
|
||||
@@ -882,7 +883,7 @@ public class View extends Object {
|
||||
// --- stubs
|
||||
|
||||
public void setContentDescription(CharSequence contentDescription) {
|
||||
System.out.println("setContentDescription called with: >" + contentDescription + "<");
|
||||
Slog.w(TAG, "setContentDescription called with: >" + contentDescription + "<");
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
@@ -916,11 +917,11 @@ public class View extends Object {
|
||||
}
|
||||
|
||||
public void setPressed(boolean pressed) {
|
||||
System.out.println("calling setPressed on " + this + " with value: " + pressed);
|
||||
Slog.w(TAG, "calling setPressed on " + this + " with value: " + pressed);
|
||||
}
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
System.out.println("calling setSelected on " + this + " with value: " + selected);
|
||||
Slog.w(TAG, "calling setSelected on " + this + " with value: " + selected);
|
||||
}
|
||||
|
||||
public ViewTreeObserver getViewTreeObserver() {
|
||||
@@ -940,7 +941,7 @@ public class View extends Object {
|
||||
public native void setVisibility(int visibility);
|
||||
public void setPadding(int left, int top, int right, int bottom) {}
|
||||
public void setBackgroundResource(int resid) {
|
||||
// System.out.println("*** setBackgroundResource: " + getString(resid));
|
||||
// Slog.w(TAG, "*** setBackgroundResource: " + getString(resid));
|
||||
}
|
||||
|
||||
public void getHitRect(Rect outRect) {}
|
||||
@@ -970,7 +971,7 @@ public class View extends Object {
|
||||
}
|
||||
|
||||
public boolean performHapticFeedback(int feedbackConstant, int flags) {
|
||||
System.out.println("vibration motor go burrrr");
|
||||
Slog.v(TAG, "vibration motor go burrrr");
|
||||
return true; // FIXME why is it not void
|
||||
}
|
||||
|
||||
@@ -1000,7 +1001,7 @@ public class View extends Object {
|
||||
}
|
||||
|
||||
public void postInvalidate(int left, int top, int right, int bottom) {
|
||||
System.out.println("postInvalidate(" + left + "," + top + "," + right + "," + bottom + ") called");
|
||||
Slog.w(TAG, "postInvalidate(" + left + "," + top + "," + right + "," + bottom + ") called");
|
||||
}
|
||||
|
||||
public void setOnGenericMotionListener(View.OnGenericMotionListener l) {}
|
||||
|
||||
Reference in New Issue
Block a user