Merge "Revert^2 "Update clang version to clang-r487747""
diff --git a/build/Android.bp b/build/Android.bp
index 53c958b..982eabf 100644
--- a/build/Android.bp
+++ b/build/Android.bp
@@ -161,7 +161,10 @@
java_device_for_host {
name: "build-tools_core-lambda-stubs-device",
visibility: ["//visibility:private"],
- libs: ["core-lambda-stubs"],
+ // Use the prebuilt of the stubs irrespective of whether prebuilts are enabled
+ // in this build configuration. This ensures that this non-host specific library
+ // is treated consistently on all hosts.
+ libs: ["prebuilt_core-lambda-stubs"],
target: {
windows: {
enabled: true,
diff --git a/build/sdk.atree b/build/sdk.atree
index 7cbad39..c5510fe 100644
--- a/build/sdk.atree
+++ b/build/sdk.atree
@@ -259,7 +259,6 @@
# Old sample tree
development/samples/AccelerometerPlay samples/${PLATFORM_NAME}/legacy/AccelerometerPlay
-development/samples/AndroidBeamDemo samples/${PLATFORM_NAME}/legacy/AndroidBeamDemo
development/samples/ApiDemos samples/${PLATFORM_NAME}/legacy/ApiDemos
development/samples/AppNavigation samples/${PLATFORM_NAME}/legacy/AppNavigation
development/samples/BackupRestore samples/${PLATFORM_NAME}/legacy/BackupRestore
diff --git a/samples/AndroidBeamDemo/Android.bp b/samples/AndroidBeamDemo/Android.bp
deleted file mode 100644
index fdc2748..0000000
--- a/samples/AndroidBeamDemo/Android.bp
+++ /dev/null
@@ -1,13 +0,0 @@
-package {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-android_test {
- name: "AndroidBeamDemo",
- // Only compile source java files in this apk.
- srcs: ["src/**/*.java"],
- sdk_version: "current",
- dex_preopt: {
- enabled: false,
- },
-}
diff --git a/samples/AndroidBeamDemo/AndroidManifest.xml b/samples/AndroidBeamDemo/AndroidManifest.xml
deleted file mode 100644
index f4c06d9..0000000
--- a/samples/AndroidBeamDemo/AndroidManifest.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2011, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-** http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
--->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.android.beam"
- android:versionCode="1"
- android:versionName="1.0">
- <uses-permission android:name="android.permission.NFC" />
- <uses-sdk android:minSdkVersion="14" />
- <uses-feature android:name="android.hardware.nfc" />
- <application android:icon="@drawable/ic_launcher" android:label="@string/app_name">
- <activity android:name="com.example.android.beam.Beam"
- android:label="@string/app_name"
- android:launchMode="singleTop">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- <intent-filter>
- <action android:name="android.nfc.action.NDEF_DISCOVERED" />
- <category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="application/com.example.android.beam" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/samples/AndroidBeamDemo/_index.html b/samples/AndroidBeamDemo/_index.html
deleted file mode 100755
index 9fe80b0..0000000
--- a/samples/AndroidBeamDemo/_index.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<p>Android Beam Demo shows how to use the Android Beam feature introduced in API level 14. This
-application beams a simple message from one device to another when they are in close enough proximity. This
-application must be installed on two devices that have NFC capabilities, running Android 4.0 or later.</p>
diff --git a/samples/AndroidBeamDemo/res/drawable-hdpi/ic_launcher.png b/samples/AndroidBeamDemo/res/drawable-hdpi/ic_launcher.png
deleted file mode 100644
index c96fa9e..0000000
--- a/samples/AndroidBeamDemo/res/drawable-hdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/samples/AndroidBeamDemo/res/drawable-hdpi/ic_menu_preferences.png b/samples/AndroidBeamDemo/res/drawable-hdpi/ic_menu_preferences.png
deleted file mode 100644
index 5321f82..0000000
--- a/samples/AndroidBeamDemo/res/drawable-hdpi/ic_menu_preferences.png
+++ /dev/null
Binary files differ
diff --git a/samples/AndroidBeamDemo/res/drawable-ldpi/ic_launcher.png b/samples/AndroidBeamDemo/res/drawable-ldpi/ic_launcher.png
deleted file mode 100644
index ab4d45e..0000000
--- a/samples/AndroidBeamDemo/res/drawable-ldpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/samples/AndroidBeamDemo/res/drawable-mdpi/ic_launcher.png b/samples/AndroidBeamDemo/res/drawable-mdpi/ic_launcher.png
deleted file mode 100644
index 2079684..0000000
--- a/samples/AndroidBeamDemo/res/drawable-mdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/samples/AndroidBeamDemo/res/drawable-mdpi/ic_menu_preferences.png b/samples/AndroidBeamDemo/res/drawable-mdpi/ic_menu_preferences.png
deleted file mode 100644
index ccc50e6..0000000
--- a/samples/AndroidBeamDemo/res/drawable-mdpi/ic_menu_preferences.png
+++ /dev/null
Binary files differ
diff --git a/samples/AndroidBeamDemo/res/drawable-xhdpi/ic_launcher.png b/samples/AndroidBeamDemo/res/drawable-xhdpi/ic_launcher.png
deleted file mode 100644
index ab62d17..0000000
--- a/samples/AndroidBeamDemo/res/drawable-xhdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/samples/AndroidBeamDemo/res/drawable-xhdpi/ic_menu_preferences.png b/samples/AndroidBeamDemo/res/drawable-xhdpi/ic_menu_preferences.png
deleted file mode 100644
index 02cfbad..0000000
--- a/samples/AndroidBeamDemo/res/drawable-xhdpi/ic_menu_preferences.png
+++ /dev/null
Binary files differ
diff --git a/samples/AndroidBeamDemo/res/layout/main.xml b/samples/AndroidBeamDemo/res/layout/main.xml
deleted file mode 100644
index eacb68e..0000000
--- a/samples/AndroidBeamDemo/res/layout/main.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2011, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-** http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
--->
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/textView"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/info"
- android:padding="10dp"
- android:textSize="18sp"
- />
diff --git a/samples/AndroidBeamDemo/res/menu/options.xml b/samples/AndroidBeamDemo/res/menu/options.xml
deleted file mode 100644
index 8012d8e..0000000
--- a/samples/AndroidBeamDemo/res/menu/options.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:id="@+id/menu_settings"
- android:icon="@drawable/ic_menu_preferences"
- android:showAsAction="ifRoom"
- android:title="@string/menu_settings" />
-</menu>
\ No newline at end of file
diff --git a/samples/AndroidBeamDemo/res/values/strings.xml b/samples/AndroidBeamDemo/res/values/strings.xml
deleted file mode 100644
index 68ed73f..0000000
--- a/samples/AndroidBeamDemo/res/values/strings.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="app_name">Beam</string>
- <string name="info">Ensure that Android Beam is enabled by turning it on in
- the system Settings (select the setting icon above), then place this device up
- against another Android device that supports Android Beam to send a
- message.</string>
- <string name="menu_settings">Android Beam settings</string>
-</resources>
diff --git a/samples/AndroidBeamDemo/src/com/example/android/beam/Beam.java b/samples/AndroidBeamDemo/src/com/example/android/beam/Beam.java
deleted file mode 100644
index 79019ab..0000000
--- a/samples/AndroidBeamDemo/src/com/example/android/beam/Beam.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.android.beam;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.nfc.NdefMessage;
-import android.nfc.NdefRecord;
-import android.nfc.NfcAdapter;
-import android.nfc.NfcAdapter.CreateNdefMessageCallback;
-import android.nfc.NfcAdapter.OnNdefPushCompleteCallback;
-import android.nfc.NfcEvent;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.os.Parcelable;
-import android.provider.Settings;
-import android.text.format.Time;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import java.nio.charset.Charset;
-
-
-public class Beam extends Activity implements CreateNdefMessageCallback,
- OnNdefPushCompleteCallback {
- NfcAdapter mNfcAdapter;
- TextView mInfoText;
- private static final int MESSAGE_SENT = 1;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
-
- mInfoText = (TextView) findViewById(R.id.textView);
- // Check for available NFC Adapter
- mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
- if (mNfcAdapter == null) {
- mInfoText = (TextView) findViewById(R.id.textView);
- mInfoText.setText("NFC is not available on this device.");
- } else {
- // Register callback to set NDEF message
- mNfcAdapter.setNdefPushMessageCallback(this, this);
- // Register callback to listen for message-sent success
- mNfcAdapter.setOnNdefPushCompleteCallback(this, this);
- }
- }
-
-
- /**
- * Implementation for the CreateNdefMessageCallback interface
- */
- @Override
- public NdefMessage createNdefMessage(NfcEvent event) {
- Time time = new Time();
- time.setToNow();
- String text = ("Beam me up!\n\n" +
- "Beam Time: " + time.format("%H:%M:%S"));
- NdefMessage msg = new NdefMessage(NdefRecord.createMime(
- "application/com.example.android.beam", text.getBytes())
- /**
- * The Android Application Record (AAR) is commented out. When a device
- * receives a push with an AAR in it, the application specified in the AAR
- * is guaranteed to run. The AAR overrides the tag dispatch system.
- * You can add it back in to guarantee that this
- * activity starts when receiving a beamed message. For now, this code
- * uses the tag dispatch system.
- */
- //,NdefRecord.createApplicationRecord("com.example.android.beam")
- );
- return msg;
- }
-
- /**
- * Implementation for the OnNdefPushCompleteCallback interface
- */
- @Override
- public void onNdefPushComplete(NfcEvent arg0) {
- // A handler is needed to send messages to the activity when this
- // callback occurs, because it happens from a binder thread
- mHandler.obtainMessage(MESSAGE_SENT).sendToTarget();
- }
-
- /** This handler receives a message from onNdefPushComplete */
- private final Handler mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case MESSAGE_SENT:
- Toast.makeText(getApplicationContext(), "Message sent!", Toast.LENGTH_LONG).show();
- break;
- }
- }
- };
-
- @Override
- public void onResume() {
- super.onResume();
- // Check to see that the Activity started due to an Android Beam
- if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) {
- processIntent(getIntent());
- }
- }
-
- @Override
- public void onNewIntent(Intent intent) {
- // onResume gets called after this to handle the intent
- setIntent(intent);
- }
-
- /**
- * Parses the NDEF Message from the intent and prints to the TextView
- */
- void processIntent(Intent intent) {
- Parcelable[] rawMsgs = intent.getParcelableArrayExtra(
- NfcAdapter.EXTRA_NDEF_MESSAGES);
- // only one message sent during the beam
- NdefMessage msg = (NdefMessage) rawMsgs[0];
- // record 0 contains the MIME type, record 1 is the AAR, if present
- mInfoText.setText(new String(msg.getRecords()[0].getPayload()));
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // If NFC is not available, we won't be needing this menu
- if (mNfcAdapter == null) {
- return super.onCreateOptionsMenu(menu);
- }
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.options, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.menu_settings:
- Intent intent = new Intent(Settings.ACTION_NFCSHARING_SETTINGS);
- startActivity(intent);
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
- }
-}
diff --git a/samples/ApiDemos/AndroidManifest.xml b/samples/ApiDemos/AndroidManifest.xml
index 159437c..2a362e9 100644
--- a/samples/ApiDemos/AndroidManifest.xml
+++ b/samples/ApiDemos/AndroidManifest.xml
@@ -3274,13 +3274,6 @@
/>
</activity>
- <activity android:name=".nfc.ForegroundNdefPush" android:label="NFC/ForegroundNdefPush">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.SAMPLE_CODE" />
- </intent-filter>
- </activity>
-
<activity android:name=".security.KeyStoreUsage" android:label="Security/KeyStore"
android:windowSoftInputMode="adjustPan">
<intent-filter>
diff --git a/samples/ApiDemos/res/layout/picture_in_picture.xml b/samples/ApiDemos/res/layout/picture_in_picture.xml
index e33d373..3d44bcf 100644
--- a/samples/ApiDemos/res/layout/picture_in_picture.xml
+++ b/samples/ApiDemos/res/layout/picture_in_picture.xml
@@ -102,6 +102,24 @@
</RadioGroup>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="8dp"
+ android:orientation="horizontal">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/label_aspect_ratio" />
+
+ <Spinner
+ android:id="@+id/aspect_ratio"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1" />
+ </LinearLayout>
+
<Button
android:id="@+id/enter_pip_button"
android:layout_width="wrap_content"
diff --git a/samples/ApiDemos/res/layout/picture_in_picture_content.xml b/samples/ApiDemos/res/layout/picture_in_picture_content.xml
index bae18db..8e948b9 100644
--- a/samples/ApiDemos/res/layout/picture_in_picture_content.xml
+++ b/samples/ApiDemos/res/layout/picture_in_picture_content.xml
@@ -14,6 +14,7 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
+<!-- Note that app:aspectRatio can be changed dynamically. -->
<com.example.android.apis.view.FixedAspectRatioImageView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
diff --git a/samples/ApiDemos/res/values/strings.xml b/samples/ApiDemos/res/values/strings.xml
index 3e1478a..9c981ec 100644
--- a/samples/ApiDemos/res/values/strings.xml
+++ b/samples/ApiDemos/res/values/strings.xml
@@ -74,6 +74,15 @@
<string name="label_exit_position">Exit position</string>
<string name="label_position_start">Start</string>
<string name="label_position_end">End</string>
+ <string name="label_aspect_ratio">Aspect Ratio</string>
+ <!-- List of aspect ratio to demo, we use Rational.parseRational to parse what's inside () -->
+ <string-array name="aspect_ratio_list">
+ <item>Extreme wide (21/9)</item>
+ <item>Video (16/9)</item>
+ <item>Square (1/1)</item>
+ <item>Video call (9/16)</item>
+ <item>Extreme tall (9/21)</item>
+ </string-array>
<string name="activity_keep_clear">App/Activity/Keep Clear Rects</string>
<string name="keep_clear_property_set">
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/PictureInPicture.java b/samples/ApiDemos/src/com/example/android/apis/app/PictureInPicture.java
index f2c08c8..da06cf7 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/PictureInPicture.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/PictureInPicture.java
@@ -39,14 +39,18 @@
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
+import android.widget.Spinner;
import android.widget.Switch;
import android.window.OnBackInvokedDispatcher;
import com.example.android.apis.R;
+import com.example.android.apis.view.FixedAspectRatioImageView;
import java.util.ArrayList;
import java.util.List;
@@ -57,6 +61,7 @@
private static final String EXTRA_ENABLE_SEAMLESS_RESIZE = "seamless_resize";
private static final String EXTRA_ENTER_PIP_ON_BACK = "enter_pip_on_back";
private static final String EXTRA_CURRENT_POSITION = "current_position";
+ private static final String EXTRA_ASPECT_RATIO = "aspect_ratio";
private static final int TABLET_BREAK_POINT_DP = 700;
@@ -95,13 +100,14 @@
(v, id) -> updateContentPosition(id);
private LinearLayout mContainer;
- private ImageView mImageView;
+ private FixedAspectRatioImageView mImageView;
private View mControlGroup;
private Switch mAutoPipToggle;
private Switch mSourceRectHintToggle;
private Switch mSeamlessResizeToggle;
private Switch mEnterPipOnBackToggle;
private RadioGroup mCurrentPositionGroup;
+ private Spinner mAspectRatioSpinner;
private List<RemoteAction> mPipActions;
private RemoteAction mCloseAction;
@@ -119,6 +125,13 @@
mSeamlessResizeToggle = findViewById(R.id.seamless_resize_toggle);
mEnterPipOnBackToggle = findViewById(R.id.enter_pip_on_back);
mCurrentPositionGroup = findViewById(R.id.current_position);
+ mAspectRatioSpinner = findViewById(R.id.aspect_ratio);
+
+ // Initiate views if applicable
+ final ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
+ R.array.aspect_ratio_list, android.R.layout.simple_spinner_item);
+ adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ mAspectRatioSpinner.setAdapter(adapter);
// Attach listeners
mImageView.addOnLayoutChangeListener(mOnLayoutChangeListener);
@@ -135,6 +148,22 @@
}
});
mCurrentPositionGroup.setOnCheckedChangeListener(mOnPositionChangedListener);
+ mAspectRatioSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+ final String rawText = parent.getItemAtPosition(position).toString();
+ final String textToParse = rawText.substring(
+ rawText.indexOf('(') + 1,
+ rawText.indexOf(')'));
+ mImageView.addOnLayoutChangeListener(mOnLayoutChangeListener);
+ mImageView.setAspectRatio(Rational.parseRational(textToParse));
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> parent) {
+ // Do nothing.
+ }
+ });
findViewById(R.id.enter_pip_button).setOnClickListener(v -> enterPictureInPictureMode());
findViewById(R.id.enter_content_pip_button).setOnClickListener(v -> enterContentPip());
@@ -152,6 +181,7 @@
? R.id.radio_current_end
: R.id.radio_current_start;
mCurrentPositionGroup.check(positionId);
+ mAspectRatioSpinner.setSelection(1);
updateLayout(getResources().getConfiguration());
}
diff --git a/samples/ApiDemos/src/com/example/android/apis/nfc/ForegroundNdefPush.java b/samples/ApiDemos/src/com/example/android/apis/nfc/ForegroundNdefPush.java
deleted file mode 100644
index 08eb839..0000000
--- a/samples/ApiDemos/src/com/example/android/apis/nfc/ForegroundNdefPush.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.example.android.apis.nfc;
-
-import com.example.android.apis.R;
-
-import android.app.Activity;
-import android.nfc.NdefMessage;
-import android.nfc.NdefRecord;
-import android.nfc.NfcAdapter;
-import android.os.Bundle;
-import android.widget.TextView;
-
-/**
- * An example of how to use the NFC foreground NDEF push APIs.
- */
-public class ForegroundNdefPush extends Activity {
- private NfcAdapter mAdapter;
- private TextView mText;
- private NdefMessage mMessage;
-
- @Override
- public void onCreate(Bundle savedState) {
- super.onCreate(savedState);
-
- mAdapter = NfcAdapter.getDefaultAdapter(this);
-
- // Create an NDEF message a URL
- mMessage = new NdefMessage(NdefRecord.createUri("http://www.android.com"));
-
- setContentView(R.layout.foreground_dispatch);
- mText = (TextView) findViewById(R.id.text);
-
- if (mAdapter != null) {
- mAdapter.setNdefPushMessage(mMessage, this);
- mText.setText("Tap another Android phone with NFC to push a URL");
- } else {
- mText.setText("This phone is not NFC enabled.");
- }
- }
-}
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/FixedAspectRatioImageView.java b/samples/ApiDemos/src/com/example/android/apis/view/FixedAspectRatioImageView.java
index f834487..b505bb3 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/FixedAspectRatioImageView.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/FixedAspectRatioImageView.java
@@ -29,7 +29,7 @@
* one of the dimension is in exact while the other one in wrap_content size mode.
*/
public class FixedAspectRatioImageView extends ImageView {
- private final Rational mAspectRatio;
+ private Rational mAspectRatio;
public FixedAspectRatioImageView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -43,6 +43,13 @@
}
}
+ public void setAspectRatio(Rational aspectRatio) {
+ if (!mAspectRatio.equals(aspectRatio)) {
+ mAspectRatio = aspectRatio;
+ requestLayout();
+ }
+ }
+
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
diff --git a/samples/browseable/BeamLargeFiles/AndroidManifest.xml b/samples/browseable/BeamLargeFiles/AndroidManifest.xml
deleted file mode 100644
index b084253..0000000
--- a/samples/browseable/BeamLargeFiles/AndroidManifest.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright 2013 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.android.beamlargefiles"
- android:versionCode="1"
- android:versionName="1.0">
-
- <!-- Large file beam requires API 16 or above. -->
- <!-- Min/target SDK versions (<uses-sdk>) managed by build.gradle -->
-
- <!-- The NFC permission is required to use NfcAdapter. -->
- <uses-permission android:name="android.permission.NFC" />
- <!-- Inform app distribution channels that NFC is used, though not required. -->
- <!-- (This step is optional, but recommended.) -->
- <uses-feature android:name="android.hardware.nfc" android:required="false" />
-
- <application android:allowBackup="true"
- android:label="@string/app_name"
- android:icon="@drawable/ic_launcher"
- android:theme="@style/AppTheme">
-
- <!-- Main activity -->
- <activity android:name=".MainActivity"
- android:label="@string/app_name">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
-
- <!-- Content provider, used to provide images for transmission. -->
- <provider
- android:name="com.example.android.common.assetprovider.AssetProvider"
- android:authorities="com.example.android.beamlargefiles.files"
- android:exported="true"/>
-
- </application>
-
-
-</manifest>
diff --git a/samples/browseable/BeamLargeFiles/_index.jd b/samples/browseable/BeamLargeFiles/_index.jd
deleted file mode 100644
index cfb07f4..0000000
--- a/samples/browseable/BeamLargeFiles/_index.jd
+++ /dev/null
@@ -1,17 +0,0 @@
-
-page.tags="BeamLargeFiles"
-sample.group=Connectivity
-@jd:body
-
-<p>
-
- This sample demonstrates how to transfer large files via Android Beam. After the initial
- handshake over NFC, file transfer will take place over a secondary high-speed
- communication channel such as Bluetooth or WiFi Direct.
-
- \n\nThis feature requires Android 4.1 (Jelly Bean) or above. Unlike traditional Beam,
- your application will not receive an Intent on the receiving device. Instead, the system
- will save the file to disk and display a notification that the user can select to open
- the file using a standard ACTION_VIEW Intent.
-
- </p>
diff --git a/samples/browseable/BeamLargeFiles/res/drawable-hdpi/ic_launcher.png b/samples/browseable/BeamLargeFiles/res/drawable-hdpi/ic_launcher.png
deleted file mode 100644
index b1efaf4..0000000
--- a/samples/browseable/BeamLargeFiles/res/drawable-hdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/samples/browseable/BeamLargeFiles/res/drawable-hdpi/tile.9.png b/samples/browseable/BeamLargeFiles/res/drawable-hdpi/tile.9.png
deleted file mode 100644
index 1358628..0000000
--- a/samples/browseable/BeamLargeFiles/res/drawable-hdpi/tile.9.png
+++ /dev/null
Binary files differ
diff --git a/samples/browseable/BeamLargeFiles/res/drawable-mdpi/ic_launcher.png b/samples/browseable/BeamLargeFiles/res/drawable-mdpi/ic_launcher.png
deleted file mode 100644
index f5f9244..0000000
--- a/samples/browseable/BeamLargeFiles/res/drawable-mdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/samples/browseable/BeamLargeFiles/res/drawable-xhdpi/ic_launcher.png b/samples/browseable/BeamLargeFiles/res/drawable-xhdpi/ic_launcher.png
deleted file mode 100644
index 5d07b3f..0000000
--- a/samples/browseable/BeamLargeFiles/res/drawable-xhdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/samples/browseable/BeamLargeFiles/res/drawable-xxhdpi/ic_launcher.png b/samples/browseable/BeamLargeFiles/res/drawable-xxhdpi/ic_launcher.png
deleted file mode 100644
index 6ef21e1..0000000
--- a/samples/browseable/BeamLargeFiles/res/drawable-xxhdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/samples/browseable/BeamLargeFiles/res/layout-sw600dp-land/activity_main.xml b/samples/browseable/BeamLargeFiles/res/layout-sw600dp-land/activity_main.xml
deleted file mode 100644
index 8fed5f7..0000000
--- a/samples/browseable/BeamLargeFiles/res/layout-sw600dp-land/activity_main.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<!--
- Copyright 2013 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-<ScrollView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:fillViewport="true"
- android:id="@+id/sample_main_layout">
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
- <TextView android:id="@+id/sample_output"
- style="@style/Widget.SampleMessage"
- android:background="@android:color/white"
- android:layout_weight="1"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:text="@string/intro_message"
- android:layout_margin="16dp" />
- <fragment
- android:name="com.example.android.common.logger.LogFragment"
- android:id="@+id/log_fragment"
- android:layout_weight="1"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_margin="16dp" />
- </LinearLayout>
-</ScrollView>
diff --git a/samples/browseable/BeamLargeFiles/res/layout-sw600dp/activity_main.xml b/samples/browseable/BeamLargeFiles/res/layout-sw600dp/activity_main.xml
deleted file mode 100644
index f811ef7..0000000
--- a/samples/browseable/BeamLargeFiles/res/layout-sw600dp/activity_main.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<!--
- Copyright 2013 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-<ScrollView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:fillViewport="true"
- android:id="@+id/sample_main_layout">
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
- <TextView android:id="@+id/sample_output"
- style="@style/Widget.SampleMessage"
- android:background="@android:color/white"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:padding="16dp"
- android:layout_margin="16dp"/>
- <fragment
- android:name="com.example.android.common.logger.LogFragment"
- android:id="@+id/log_fragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_margin="16dp" />
- </LinearLayout>
-</ScrollView>
diff --git a/samples/browseable/BeamLargeFiles/res/layout/activity_main.xml b/samples/browseable/BeamLargeFiles/res/layout/activity_main.xml
deleted file mode 100644
index d170958..0000000
--- a/samples/browseable/BeamLargeFiles/res/layout/activity_main.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<!--
- Copyright 2013 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-<ScrollView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:fillViewport="true"
- android:id="@+id/sample_main_layout">
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
- <TextView android:id="@+id/sample_output"
- style="@style/Widget.SampleMessage"
- android:layout_weight="1"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:padding="16dp" />
- <View
- android:layout_width="fill_parent"
- android:layout_height="1dp"
- android:background="@android:color/darker_gray"/>
- <fragment
- android:name="com.example.android.common.logger.LogFragment"
- android:id="@+id/log_fragment"
- android:layout_weight="1"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
- </LinearLayout>
-</ScrollView>
diff --git a/samples/browseable/BeamLargeFiles/res/menu/main.xml b/samples/browseable/BeamLargeFiles/res/menu/main.xml
deleted file mode 100644
index 8de3baa..0000000
--- a/samples/browseable/BeamLargeFiles/res/menu/main.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<!--
- Copyright 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<menu xmlns:android="http://schemas.android.com/apk/res/android" />
-
diff --git a/samples/browseable/BeamLargeFiles/res/values-sw600dp/template-dimens.xml b/samples/browseable/BeamLargeFiles/res/values-sw600dp/template-dimens.xml
deleted file mode 100644
index 22074a2..0000000
--- a/samples/browseable/BeamLargeFiles/res/values-sw600dp/template-dimens.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
- Copyright 2013 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources>
-
- <!-- Semantic definitions -->
-
- <dimen name="horizontal_page_margin">@dimen/margin_huge</dimen>
- <dimen name="vertical_page_margin">@dimen/margin_medium</dimen>
-
-</resources>
diff --git a/samples/browseable/BeamLargeFiles/res/values-sw600dp/template-styles.xml b/samples/browseable/BeamLargeFiles/res/values-sw600dp/template-styles.xml
deleted file mode 100644
index 03d1974..0000000
--- a/samples/browseable/BeamLargeFiles/res/values-sw600dp/template-styles.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
- Copyright 2013 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources>
-
- <style name="Widget.SampleMessage">
- <item name="android:textAppearance">?android:textAppearanceLarge</item>
- <item name="android:lineSpacingMultiplier">1.2</item>
- <item name="android:shadowDy">-6.5</item>
- </style>
-
-</resources>
diff --git a/samples/browseable/BeamLargeFiles/res/values-v11/template-styles.xml b/samples/browseable/BeamLargeFiles/res/values-v11/template-styles.xml
deleted file mode 100644
index 8c1ea66..0000000
--- a/samples/browseable/BeamLargeFiles/res/values-v11/template-styles.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--
- Copyright 2013 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources>
-
- <!-- Activity themes -->
- <style name="Theme.Base" parent="android:Theme.Holo.Light" />
-
-</resources>
diff --git a/samples/browseable/BeamLargeFiles/res/values-v21/base-colors.xml b/samples/browseable/BeamLargeFiles/res/values-v21/base-colors.xml
deleted file mode 100644
index 8b6ec3f..0000000
--- a/samples/browseable/BeamLargeFiles/res/values-v21/base-colors.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright 2013 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<resources>
-
-
-</resources>
diff --git a/samples/browseable/BeamLargeFiles/res/values-v21/base-template-styles.xml b/samples/browseable/BeamLargeFiles/res/values-v21/base-template-styles.xml
deleted file mode 100644
index c778e4f..0000000
--- a/samples/browseable/BeamLargeFiles/res/values-v21/base-template-styles.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright 2013 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<resources>
-
- <!-- Activity themes -->
- <style name="Theme.Base" parent="android:Theme.Material.Light">
- </style>
-
-</resources>
diff --git a/samples/browseable/BeamLargeFiles/res/values/base-strings.xml b/samples/browseable/BeamLargeFiles/res/values/base-strings.xml
deleted file mode 100644
index dd897b6..0000000
--- a/samples/browseable/BeamLargeFiles/res/values/base-strings.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright 2013 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<resources>
- <string name="app_name">BeamLargeFiles</string>
- <string name="intro_message">
- <![CDATA[
-
-
- This sample demonstrates how to transfer large files via Android Beam. After the initial
- handshake over NFC, file transfer will take place over a secondary high-speed
- communication channel such as Bluetooth or WiFi Direct.
-
- \n\nThis feature requires Android 4.1 (Jelly Bean) or above. Unlike traditional Beam,
- your application will not receive an Intent on the receiving device. Instead, the system
- will save the file to disk and display a notification that the user can select to open
- the file using a standard ACTION_VIEW Intent.
-
-
- ]]>
- </string>
-</resources>
diff --git a/samples/browseable/BeamLargeFiles/res/values/template-dimens.xml b/samples/browseable/BeamLargeFiles/res/values/template-dimens.xml
deleted file mode 100644
index 39e710b..0000000
--- a/samples/browseable/BeamLargeFiles/res/values/template-dimens.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<!--
- Copyright 2013 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources>
-
- <!-- Define standard dimensions to comply with Holo-style grids and rhythm. -->
-
- <dimen name="margin_tiny">4dp</dimen>
- <dimen name="margin_small">8dp</dimen>
- <dimen name="margin_medium">16dp</dimen>
- <dimen name="margin_large">32dp</dimen>
- <dimen name="margin_huge">64dp</dimen>
-
- <!-- Semantic definitions -->
-
- <dimen name="horizontal_page_margin">@dimen/margin_medium</dimen>
- <dimen name="vertical_page_margin">@dimen/margin_medium</dimen>
-
-</resources>
diff --git a/samples/browseable/BeamLargeFiles/res/values/template-styles.xml b/samples/browseable/BeamLargeFiles/res/values/template-styles.xml
deleted file mode 100644
index cfffcbd..0000000
--- a/samples/browseable/BeamLargeFiles/res/values/template-styles.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<!--
- Copyright 2013 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<resources>
-
- <!-- Activity themes -->
-
- <style name="Theme.Base" parent="android:Theme.Holo.Light" />
-
- <style name="AppTheme" parent="Theme.Base" />
- <!-- Widget styling -->
-
- <style name="Widget" />
-
- <style name="Widget.SampleMessage">
- <item name="android:padding">@dimen/margin_medium</item>
- <item name="android:textAppearance">?android:textAppearanceMedium</item>
- <item name="android:lineSpacingMultiplier">1.1</item>
- <item name="android:layout_margin">16dp</item>
- <item name="android:shadowDy">-6.5</item>
- </style>
-
- <style name="Widget.SampleMessageTile">
- <item name="android:background">@drawable/tile</item>
- <item name="android:shadowColor">#7F000000</item>
- <item name="android:shadowDy">-3.5</item>
- <item name="android:shadowRadius">2</item>
- </style>
-
-
- <style name="Widget.SampleOutput">
- <item name="android:padding">@dimen/margin_medium</item>
- <item name="android:textAppearance">?android:textAppearanceMedium</item>
- <item name="android:lineSpacingMultiplier">1.1</item>
- </style>
-
- <style name="Log" parent="Widget.SampleOutput">
- <item name="android:typeface">monospace</item>
- </style>
-
-</resources>
diff --git a/samples/browseable/BeamLargeFiles/src/com.example.android.beamlargefiles/BeamLargeFilesFragment.java b/samples/browseable/BeamLargeFiles/src/com.example.android.beamlargefiles/BeamLargeFilesFragment.java
deleted file mode 100644
index 6dd50fe..0000000
--- a/samples/browseable/BeamLargeFiles/src/com.example.android.beamlargefiles/BeamLargeFilesFragment.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
-* Copyright (C) 2013 The Android Open Source Project
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package com.example.android.beamlargefiles;
-
-import android.app.Activity;
-import android.net.Uri;
-import android.nfc.NfcAdapter;
-import android.nfc.NfcEvent;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.util.Log;
-
-/**
- * This class demonstrates how to use Beam to send files too large to transfer reliably via NFC.
- *
- * <p>While any type of data can be placed into a normal NDEF messages, NFC is not considered
- * "high-speed" communication channel. Large images can easily take > 30 seconds to transfer.
- * Because NFC requires devices to be in extremely close proximity, this is not ideal.
- *
- * <p>Instead, Android 4.2+ devices can use NFC to perform an initial handshake, before handing
- * off to a faster communication channel, such as Bluetooth, for file transfer.
- *
- * <p>The tradeoff is that this application will not be invoked on the receiving device. Instead,
- * the transfer will be handled by the OS. The user will be shown a notification when the transfer
- * is complete. Selecting the notification will open the file in the default viewer for its MIME-
- * type. (If it's important that your application be used to open the file, you'll need to register
- * an intent-filter to watch for the appropriate MIME-type.)
- */
-public class BeamLargeFilesFragment extends Fragment implements NfcAdapter.CreateBeamUrisCallback {
-
- private static final String TAG = "BeamLargeFilesFragment";
- /** Filename that is to be sent for this activity. Relative to /assets. */
- private static final String FILENAME = "stargazer_droid.jpg";
- /** Content provider URI. */
- private static final String CONTENT_BASE_URI =
- "content://com.example.android.beamlargefiles.files/";
-
- /**
- * Standard lifecycle event. Registers a callback for large-file transfer, by calling
- * NfcAdapter.setBeamPushUrisCallback().
- *
- * Note: Like sending NDEF messages over standard Android Beam, there is also a non-callback
- * API available. See: NfcAdapter.setBeamPushUris().
- *
- * @param savedInstanceState Saved instance state.
- */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setHasOptionsMenu(true);
- Activity a = getActivity();
-
- // Setup Beam to transfer a large file. Note the call to setBeamPushUrisCallback().
- // BEGIN_INCLUDE(setBeamPushUrisCallback)
- NfcAdapter nfc = NfcAdapter.getDefaultAdapter(a);
- if (nfc != null) {
- Log.w(TAG, "NFC available. Setting Beam Push URI callback");
- nfc.setBeamPushUrisCallback(this, a);
- } else {
- Log.w(TAG, "NFC is not available");
- }
- // END_INCLUDE(setBeamPushUrisCallback)
- }
-
- /**
- * Callback for Beam events (large file version). The return value here should be an array of
- * content:// or file:// URIs to send.
- *
- * Note that the system must have read access to whatever URIs are provided here.
- *
- * @param nfcEvent NFC event which triggered callback
- * @return URIs to be sent to remote device
- */
- // BEGIN_INCLUDE(createBeamUris)
- @Override
- public Uri[] createBeamUris(NfcEvent nfcEvent) {
- Log.i(TAG, "Beam event in progress; createBeamUris() called.");
- // Images are served using a content:// URI. See AssetProvider for implementation.
- Uri photoUri = Uri.parse(CONTENT_BASE_URI + FILENAME);
- Log.i(TAG, "Sending URI: " + photoUri);
- return new Uri[] {photoUri};
- }
- // END_INCLUDE(createBeamUris)
-}
diff --git a/samples/browseable/BeamLargeFiles/src/com.example.android.beamlargefiles/MainActivity.java b/samples/browseable/BeamLargeFiles/src/com.example.android.beamlargefiles/MainActivity.java
deleted file mode 100644
index 8143678..0000000
--- a/samples/browseable/BeamLargeFiles/src/com.example.android.beamlargefiles/MainActivity.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
-* Copyright 2013 The Android Open Source Project
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-
-package com.example.android.beamlargefiles;
-
-import android.graphics.Color;
-import android.os.Bundle;
-import android.support.v4.app.FragmentTransaction;
-import android.text.Html;
-import android.widget.TextView;
-import android.view.Menu;
-
-import com.example.android.common.activities.SampleActivityBase;
-import com.example.android.common.logger.Log;
-import com.example.android.common.logger.LogFragment;
-import com.example.android.common.logger.LogWrapper;
-import com.example.android.common.logger.MessageOnlyLogFilter;
-
-/**
- * A simple launcher activity containing a summary sample description
- * and a few action bar buttons.
- */
-public class MainActivity extends SampleActivityBase {
-
- public static final String TAG = "MainActivity";
-
- public static final String FRAGTAG = "BeamLargeFilesFragment";
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- TextView sampleOutput = (TextView) findViewById(R.id.sample_output);
- sampleOutput.setText(Html.fromHtml(getString(R.string.intro_message)));
-
- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
- BeamLargeFilesFragment fragment = new BeamLargeFilesFragment();
- transaction.add(fragment, FRAGTAG);
- transaction.commit();
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.main, menu);
- return true;
- }
-
- /** Create a chain of targets that will receive log data */
- @Override
- public void initializeLogging() {
- // Wraps Android's native log framework.
- LogWrapper logWrapper = new LogWrapper();
- // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
- Log.setLogNode(logWrapper);
-
- // Filter strips out everything except the message text.
- MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
- logWrapper.setNext(msgFilter);
-
- // On screen logging via a fragment with a TextView.
- LogFragment logFragment = (LogFragment) getSupportFragmentManager()
- .findFragmentById(R.id.log_fragment);
- msgFilter.setNext(logFragment.getLogView());
- logFragment.getLogView().setTextAppearance(this, R.style.Log);
- logFragment.getLogView().setBackgroundColor(Color.WHITE);
-
- Log.i(TAG, "Ready");
- }
-}
diff --git a/samples/browseable/BeamLargeFiles/src/com.example.android.common/activities/SampleActivityBase.java b/samples/browseable/BeamLargeFiles/src/com.example.android.common/activities/SampleActivityBase.java
deleted file mode 100644
index 3228927..0000000
--- a/samples/browseable/BeamLargeFiles/src/com.example.android.common/activities/SampleActivityBase.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
-* Copyright 2013 The Android Open Source Project
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package com.example.android.common.activities;
-
-import android.os.Bundle;
-import android.support.v4.app.FragmentActivity;
-
-import com.example.android.common.logger.Log;
-import com.example.android.common.logger.LogWrapper;
-
-/**
- * Base launcher activity, to handle most of the common plumbing for samples.
- */
-public class SampleActivityBase extends FragmentActivity {
-
- public static final String TAG = "SampleActivityBase";
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- initializeLogging();
- }
-
- /** Set up targets to receive log data */
- public void initializeLogging() {
- // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
- // Wraps Android's native log framework
- LogWrapper logWrapper = new LogWrapper();
- Log.setLogNode(logWrapper);
-
- Log.i(TAG, "Ready");
- }
-}
diff --git a/samples/browseable/BeamLargeFiles/src/com.example.android.common/assetprovider/AssetProvider.java b/samples/browseable/BeamLargeFiles/src/com.example.android.common/assetprovider/AssetProvider.java
deleted file mode 100644
index f6c0f61..0000000
--- a/samples/browseable/BeamLargeFiles/src/com.example.android.common/assetprovider/AssetProvider.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
-* Copyright (C) 2013 The Android Open Source Project
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package com.example.android.common.assetprovider;
-
-import android.content.ContentProvider;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.res.AssetFileDescriptor;
-import android.content.res.AssetManager;
-import android.database.Cursor;
-import android.net.Uri;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-import static java.net.URLConnection.guessContentTypeFromName;
-
-/**
- * Generic content provider, which makes any files available in this app's "assets" directory
- * available publicly.
- *
- * <p>To use, add the following to your AndroidManifest.xml:
- *
- * <code><pre>
- * <provider
- * android:name=".AssetProvider"
- * android:authorities="[YOUR CONTENT PROVIDER DOMAIN HERE]"
- * android:exported="true"/>
- * </pre></code>
- */
-public class AssetProvider extends ContentProvider {
- AssetManager mAssets;
-
- @Override
- public boolean onCreate() {
- Context ctx = getContext();
- if (ctx == null) {
- // Context not available. Give up.
- return false;
- }
- mAssets = ctx.getAssets();
- return true;
- }
-
- @Override
- public String getType(Uri uri){
- // Returns the MIME type for the selected URI, in conformance with the ContentProvider
- // interface. Looks up the file indicated by /res/assets/{uri.path}, and returns the MIME
- // type for that file as guessed by the URLConnection class.
-
- // Setup
- String path = uri.getPath();
-
- // Check if file exists
- if (!fileExists(path)) {
- return null;
- }
-
- // Determine MIME-type based on filename
- return guessContentTypeFromName(uri.toString());
- }
-
-
- @Override
- public AssetFileDescriptor openAssetFile (Uri uri, String mode)
- throws FileNotFoundException, SecurityException {
- // ContentProvider interface for opening a file descriptor by URI. This content provider
- // maps all URIs to the contents of the APK's assets folder, so a file handle to
- // /res/assets/{uri.path} will be returned.
-
- // Security check. This content provider only supports read-only access. (Also, the contents
- // of an APKs assets folder are immutable, so read-write access doesn't make sense here.)
- if (!"r".equals(mode)) {
- throw new SecurityException("Only read-only access is supported, mode must be [r]");
- }
-
- // Open asset from within APK and return file descriptor
- String path = uri.getPath();
- try {
- return mAssets.openFd(path);
- } catch (IOException e) {
- throw new FileNotFoundException();
- }
- }
-
- /**
- * Check if file exists inside APK assets.
- *
- * @param path Fully qualified path to file.
- * @return true if exists, false otherwise.
- */
- private boolean fileExists(String path) {
- try {
- // Check to see if file can be opened. If so, file exists.
- mAssets.openFd(path).close();
- return true;
- } catch (IOException e) {
- // Unable to open file descriptor for specified path; file doesn't exist.
- return false;
- }
- }
-
- // Required/unused ContentProvider methods below.
- @Override
- public Cursor query(Uri uri, String[] projection, String selection,
- String[] selectionArgs, String sortOrder) {
- // Note: It might be worth implementing support for querying
- // android.provider.OpenableColumns here in the future.
- throw new RuntimeException("Operation not supported");
- }
-
- @Override
- public Uri insert(Uri uri, ContentValues contentValues) {
- throw new RuntimeException("Operation not supported");
- }
-
- @Override
- public int delete(Uri uri, String selection, String[] selectionArgs) {
- throw new RuntimeException("Operation not supported");
- }
-
- @Override
- public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
- throw new RuntimeException("Operation not supported");
- }
-}
diff --git a/samples/browseable/BeamLargeFiles/src/com.example.android.common/logger/Log.java b/samples/browseable/BeamLargeFiles/src/com.example.android.common/logger/Log.java
deleted file mode 100644
index 17503c5..0000000
--- a/samples/browseable/BeamLargeFiles/src/com.example.android.common/logger/Log.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.example.android.common.logger;
-
-/**
- * Helper class for a list (or tree) of LoggerNodes.
- *
- * <p>When this is set as the head of the list,
- * an instance of it can function as a drop-in replacement for {@link android.util.Log}.
- * Most of the methods in this class server only to map a method call in Log to its equivalent
- * in LogNode.</p>
- */
-public class Log {
- // Grabbing the native values from Android's native logging facilities,
- // to make for easy migration and interop.
- public static final int NONE = -1;
- public static final int VERBOSE = android.util.Log.VERBOSE;
- public static final int DEBUG = android.util.Log.DEBUG;
- public static final int INFO = android.util.Log.INFO;
- public static final int WARN = android.util.Log.WARN;
- public static final int ERROR = android.util.Log.ERROR;
- public static final int ASSERT = android.util.Log.ASSERT;
-
- // Stores the beginning of the LogNode topology.
- private static LogNode mLogNode;
-
- /**
- * Returns the next LogNode in the linked list.
- */
- public static LogNode getLogNode() {
- return mLogNode;
- }
-
- /**
- * Sets the LogNode data will be sent to.
- */
- public static void setLogNode(LogNode node) {
- mLogNode = node;
- }
-
- /**
- * Instructs the LogNode to print the log data provided. Other LogNodes can
- * be chained to the end of the LogNode as desired.
- *
- * @param priority Log level of the data being logged. Verbose, Error, etc.
- * @param tag Tag for for the log data. Can be used to organize log statements.
- * @param msg The actual message to be logged.
- * @param tr If an exception was thrown, this can be sent along for the logging facilities
- * to extract and print useful information.
- */
- public static void println(int priority, String tag, String msg, Throwable tr) {
- if (mLogNode != null) {
- mLogNode.println(priority, tag, msg, tr);
- }
- }
-
- /**
- * Instructs the LogNode to print the log data provided. Other LogNodes can
- * be chained to the end of the LogNode as desired.
- *
- * @param priority Log level of the data being logged. Verbose, Error, etc.
- * @param tag Tag for for the log data. Can be used to organize log statements.
- * @param msg The actual message to be logged. The actual message to be logged.
- */
- public static void println(int priority, String tag, String msg) {
- println(priority, tag, msg, null);
- }
-
- /**
- * Prints a message at VERBOSE priority.
- *
- * @param tag Tag for for the log data. Can be used to organize log statements.
- * @param msg The actual message to be logged.
- * @param tr If an exception was thrown, this can be sent along for the logging facilities
- * to extract and print useful information.
- */
- public static void v(String tag, String msg, Throwable tr) {
- println(VERBOSE, tag, msg, tr);
- }
-
- /**
- * Prints a message at VERBOSE priority.
- *
- * @param tag Tag for for the log data. Can be used to organize log statements.
- * @param msg The actual message to be logged.
- */
- public static void v(String tag, String msg) {
- v(tag, msg, null);
- }
-
-
- /**
- * Prints a message at DEBUG priority.
- *
- * @param tag Tag for for the log data. Can be used to organize log statements.
- * @param msg The actual message to be logged.
- * @param tr If an exception was thrown, this can be sent along for the logging facilities
- * to extract and print useful information.
- */
- public static void d(String tag, String msg, Throwable tr) {
- println(DEBUG, tag, msg, tr);
- }
-
- /**
- * Prints a message at DEBUG priority.
- *
- * @param tag Tag for for the log data. Can be used to organize log statements.
- * @param msg The actual message to be logged.
- */
- public static void d(String tag, String msg) {
- d(tag, msg, null);
- }
-
- /**
- * Prints a message at INFO priority.
- *
- * @param tag Tag for for the log data. Can be used to organize log statements.
- * @param msg The actual message to be logged.
- * @param tr If an exception was thrown, this can be sent along for the logging facilities
- * to extract and print useful information.
- */
- public static void i(String tag, String msg, Throwable tr) {
- println(INFO, tag, msg, tr);
- }
-
- /**
- * Prints a message at INFO priority.
- *
- * @param tag Tag for for the log data. Can be used to organize log statements.
- * @param msg The actual message to be logged.
- */
- public static void i(String tag, String msg) {
- i(tag, msg, null);
- }
-
- /**
- * Prints a message at WARN priority.
- *
- * @param tag Tag for for the log data. Can be used to organize log statements.
- * @param msg The actual message to be logged.
- * @param tr If an exception was thrown, this can be sent along for the logging facilities
- * to extract and print useful information.
- */
- public static void w(String tag, String msg, Throwable tr) {
- println(WARN, tag, msg, tr);
- }
-
- /**
- * Prints a message at WARN priority.
- *
- * @param tag Tag for for the log data. Can be used to organize log statements.
- * @param msg The actual message to be logged.
- */
- public static void w(String tag, String msg) {
- w(tag, msg, null);
- }
-
- /**
- * Prints a message at WARN priority.
- *
- * @param tag Tag for for the log data. Can be used to organize log statements.
- * @param tr If an exception was thrown, this can be sent along for the logging facilities
- * to extract and print useful information.
- */
- public static void w(String tag, Throwable tr) {
- w(tag, null, tr);
- }
-
- /**
- * Prints a message at ERROR priority.
- *
- * @param tag Tag for for the log data. Can be used to organize log statements.
- * @param msg The actual message to be logged.
- * @param tr If an exception was thrown, this can be sent along for the logging facilities
- * to extract and print useful information.
- */
- public static void e(String tag, String msg, Throwable tr) {
- println(ERROR, tag, msg, tr);
- }
-
- /**
- * Prints a message at ERROR priority.
- *
- * @param tag Tag for for the log data. Can be used to organize log statements.
- * @param msg The actual message to be logged.
- */
- public static void e(String tag, String msg) {
- e(tag, msg, null);
- }
-
- /**
- * Prints a message at ASSERT priority.
- *
- * @param tag Tag for for the log data. Can be used to organize log statements.
- * @param msg The actual message to be logged.
- * @param tr If an exception was thrown, this can be sent along for the logging facilities
- * to extract and print useful information.
- */
- public static void wtf(String tag, String msg, Throwable tr) {
- println(ASSERT, tag, msg, tr);
- }
-
- /**
- * Prints a message at ASSERT priority.
- *
- * @param tag Tag for for the log data. Can be used to organize log statements.
- * @param msg The actual message to be logged.
- */
- public static void wtf(String tag, String msg) {
- wtf(tag, msg, null);
- }
-
- /**
- * Prints a message at ASSERT priority.
- *
- * @param tag Tag for for the log data. Can be used to organize log statements.
- * @param tr If an exception was thrown, this can be sent along for the logging facilities
- * to extract and print useful information.
- */
- public static void wtf(String tag, Throwable tr) {
- wtf(tag, null, tr);
- }
-}
diff --git a/samples/browseable/BeamLargeFiles/src/com.example.android.common/logger/LogFragment.java b/samples/browseable/BeamLargeFiles/src/com.example.android.common/logger/LogFragment.java
deleted file mode 100644
index b302acd..0000000
--- a/samples/browseable/BeamLargeFiles/src/com.example.android.common/logger/LogFragment.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
-* Copyright 2013 The Android Open Source Project
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-/*
- * Copyright 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.android.common.logger;
-
-import android.graphics.Typeface;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.text.Editable;
-import android.text.TextWatcher;
-import android.view.Gravity;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ScrollView;
-
-/**
- * Simple fraggment which contains a LogView and uses is to output log data it receives
- * through the LogNode interface.
- */
-public class LogFragment extends Fragment {
-
- private LogView mLogView;
- private ScrollView mScrollView;
-
- public LogFragment() {}
-
- public View inflateViews() {
- mScrollView = new ScrollView(getActivity());
- ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams(
- ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.MATCH_PARENT);
- mScrollView.setLayoutParams(scrollParams);
-
- mLogView = new LogView(getActivity());
- ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams);
- logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
- mLogView.setLayoutParams(logParams);
- mLogView.setClickable(true);
- mLogView.setFocusable(true);
- mLogView.setTypeface(Typeface.MONOSPACE);
-
- // Want to set padding as 16 dips, setPadding takes pixels. Hooray math!
- int paddingDips = 16;
- double scale = getResources().getDisplayMetrics().density;
- int paddingPixels = (int) ((paddingDips * (scale)) + .5);
- mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels);
- mLogView.setCompoundDrawablePadding(paddingPixels);
-
- mLogView.setGravity(Gravity.BOTTOM);
- mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium);
-
- mScrollView.addView(mLogView);
- return mScrollView;
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
-
- View result = inflateViews();
-
- mLogView.addTextChangedListener(new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {}
-
- @Override
- public void afterTextChanged(Editable s) {
- mScrollView.fullScroll(ScrollView.FOCUS_DOWN);
- }
- });
- return result;
- }
-
- public LogView getLogView() {
- return mLogView;
- }
-}
\ No newline at end of file
diff --git a/samples/browseable/BeamLargeFiles/src/com.example.android.common/logger/LogNode.java b/samples/browseable/BeamLargeFiles/src/com.example.android.common/logger/LogNode.java
deleted file mode 100644
index bc37cab..0000000
--- a/samples/browseable/BeamLargeFiles/src/com.example.android.common/logger/LogNode.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.example.android.common.logger;
-
-/**
- * Basic interface for a logging system that can output to one or more targets.
- * Note that in addition to classes that will output these logs in some format,
- * one can also implement this interface over a filter and insert that in the chain,
- * such that no targets further down see certain data, or see manipulated forms of the data.
- * You could, for instance, write a "ToHtmlLoggerNode" that just converted all the log data
- * it received to HTML and sent it along to the next node in the chain, without printing it
- * anywhere.
- */
-public interface LogNode {
-
- /**
- * Instructs first LogNode in the list to print the log data provided.
- * @param priority Log level of the data being logged. Verbose, Error, etc.
- * @param tag Tag for for the log data. Can be used to organize log statements.
- * @param msg The actual message to be logged. The actual message to be logged.
- * @param tr If an exception was thrown, this can be sent along for the logging facilities
- * to extract and print useful information.
- */
- public void println(int priority, String tag, String msg, Throwable tr);
-
-}
diff --git a/samples/browseable/BeamLargeFiles/src/com.example.android.common/logger/LogView.java b/samples/browseable/BeamLargeFiles/src/com.example.android.common/logger/LogView.java
deleted file mode 100644
index c01542b..0000000
--- a/samples/browseable/BeamLargeFiles/src/com.example.android.common/logger/LogView.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.example.android.common.logger;
-
-import android.app.Activity;
-import android.content.Context;
-import android.util.*;
-import android.widget.TextView;
-
-/** Simple TextView which is used to output log data received through the LogNode interface.
-*/
-public class LogView extends TextView implements LogNode {
-
- public LogView(Context context) {
- super(context);
- }
-
- public LogView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public LogView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- /**
- * Formats the log data and prints it out to the LogView.
- * @param priority Log level of the data being logged. Verbose, Error, etc.
- * @param tag Tag for for the log data. Can be used to organize log statements.
- * @param msg The actual message to be logged. The actual message to be logged.
- * @param tr If an exception was thrown, this can be sent along for the logging facilities
- * to extract and print useful information.
- */
- @Override
- public void println(int priority, String tag, String msg, Throwable tr) {
-
-
- String priorityStr = null;
-
- // For the purposes of this View, we want to print the priority as readable text.
- switch(priority) {
- case android.util.Log.VERBOSE:
- priorityStr = "VERBOSE";
- break;
- case android.util.Log.DEBUG:
- priorityStr = "DEBUG";
- break;
- case android.util.Log.INFO:
- priorityStr = "INFO";
- break;
- case android.util.Log.WARN:
- priorityStr = "WARN";
- break;
- case android.util.Log.ERROR:
- priorityStr = "ERROR";
- break;
- case android.util.Log.ASSERT:
- priorityStr = "ASSERT";
- break;
- default:
- break;
- }
-
- // Handily, the Log class has a facility for converting a stack trace into a usable string.
- String exceptionStr = null;
- if (tr != null) {
- exceptionStr = android.util.Log.getStackTraceString(tr);
- }
-
- // Take the priority, tag, message, and exception, and concatenate as necessary
- // into one usable line of text.
- final StringBuilder outputBuilder = new StringBuilder();
-
- String delimiter = "\t";
- appendIfNotNull(outputBuilder, priorityStr, delimiter);
- appendIfNotNull(outputBuilder, tag, delimiter);
- appendIfNotNull(outputBuilder, msg, delimiter);
- appendIfNotNull(outputBuilder, exceptionStr, delimiter);
-
- // In case this was originally called from an AsyncTask or some other off-UI thread,
- // make sure the update occurs within the UI thread.
- ((Activity) getContext()).runOnUiThread( (new Thread(new Runnable() {
- @Override
- public void run() {
- // Display the text we just generated within the LogView.
- appendToLog(outputBuilder.toString());
- }
- })));
-
- if (mNext != null) {
- mNext.println(priority, tag, msg, tr);
- }
- }
-
- public LogNode getNext() {
- return mNext;
- }
-
- public void setNext(LogNode node) {
- mNext = node;
- }
-
- /** Takes a string and adds to it, with a separator, if the bit to be added isn't null. Since
- * the logger takes so many arguments that might be null, this method helps cut out some of the
- * agonizing tedium of writing the same 3 lines over and over.
- * @param source StringBuilder containing the text to append to.
- * @param addStr The String to append
- * @param delimiter The String to separate the source and appended strings. A tab or comma,
- * for instance.
- * @return The fully concatenated String as a StringBuilder
- */
- private StringBuilder appendIfNotNull(StringBuilder source, String addStr, String delimiter) {
- if (addStr != null) {
- if (addStr.length() == 0) {
- delimiter = "";
- }
-
- return source.append(addStr).append(delimiter);
- }
- return source;
- }
-
- // The next LogNode in the chain.
- LogNode mNext;
-
- /** Outputs the string as a new line of log data in the LogView. */
- public void appendToLog(String s) {
- append("\n" + s);
- }
-
-
-}
diff --git a/samples/browseable/BeamLargeFiles/src/com.example.android.common/logger/LogWrapper.java b/samples/browseable/BeamLargeFiles/src/com.example.android.common/logger/LogWrapper.java
deleted file mode 100644
index 16a9e7b..0000000
--- a/samples/browseable/BeamLargeFiles/src/com.example.android.common/logger/LogWrapper.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.example.android.common.logger;
-
-import android.util.Log;
-
-/**
- * Helper class which wraps Android's native Log utility in the Logger interface. This way
- * normal DDMS output can be one of the many targets receiving and outputting logs simultaneously.
- */
-public class LogWrapper implements LogNode {
-
- // For piping: The next node to receive Log data after this one has done its work.
- private LogNode mNext;
-
- /**
- * Returns the next LogNode in the linked list.
- */
- public LogNode getNext() {
- return mNext;
- }
-
- /**
- * Sets the LogNode data will be sent to..
- */
- public void setNext(LogNode node) {
- mNext = node;
- }
-
- /**
- * Prints data out to the console using Android's native log mechanism.
- * @param priority Log level of the data being logged. Verbose, Error, etc.
- * @param tag Tag for for the log data. Can be used to organize log statements.
- * @param msg The actual message to be logged. The actual message to be logged.
- * @param tr If an exception was thrown, this can be sent along for the logging facilities
- * to extract and print useful information.
- */
- @Override
- public void println(int priority, String tag, String msg, Throwable tr) {
- // There actually are log methods that don't take a msg parameter. For now,
- // if that's the case, just convert null to the empty string and move on.
- String useMsg = msg;
- if (useMsg == null) {
- useMsg = "";
- }
-
- // If an exeption was provided, convert that exception to a usable string and attach
- // it to the end of the msg method.
- if (tr != null) {
- msg += "\n" + Log.getStackTraceString(tr);
- }
-
- // This is functionally identical to Log.x(tag, useMsg);
- // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg)
- Log.println(priority, tag, useMsg);
-
- // If this isn't the last node in the chain, move things along.
- if (mNext != null) {
- mNext.println(priority, tag, msg, tr);
- }
- }
-}
diff --git a/samples/browseable/BeamLargeFiles/src/com.example.android.common/logger/MessageOnlyLogFilter.java b/samples/browseable/BeamLargeFiles/src/com.example.android.common/logger/MessageOnlyLogFilter.java
deleted file mode 100644
index 19967dc..0000000
--- a/samples/browseable/BeamLargeFiles/src/com.example.android.common/logger/MessageOnlyLogFilter.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.example.android.common.logger;
-
-/**
- * Simple {@link LogNode} filter, removes everything except the message.
- * Useful for situations like on-screen log output where you don't want a lot of metadata displayed,
- * just easy-to-read message updates as they're happening.
- */
-public class MessageOnlyLogFilter implements LogNode {
-
- LogNode mNext;
-
- /**
- * Takes the "next" LogNode as a parameter, to simplify chaining.
- *
- * @param next The next LogNode in the pipeline.
- */
- public MessageOnlyLogFilter(LogNode next) {
- mNext = next;
- }
-
- public MessageOnlyLogFilter() {
- }
-
- @Override
- public void println(int priority, String tag, String msg, Throwable tr) {
- if (mNext != null) {
- getNext().println(Log.NONE, null, msg, null);
- }
- }
-
- /**
- * Returns the next LogNode in the chain.
- */
- public LogNode getNext() {
- return mNext;
- }
-
- /**
- * Sets the LogNode data will be sent to..
- */
- public void setNext(LogNode node) {
- mNext = node;
- }
-
-}
diff --git a/scripts/aday b/scripts/aday
index 3d97809..f4479b4 100755
--- a/scripts/aday
+++ b/scripts/aday
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import datetime
import sys
@@ -8,7 +8,7 @@
day = int(build[3:5])
month = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.index(letter) * 3
- year = 2009 + (month / 12)
+ year = 2009 + (month // 12)
month %= 12
return datetime.date(year, month + 1, 1) + datetime.timedelta(days=day - 1)
@@ -18,4 +18,4 @@
if len(sys.argv) != 2:
sys.exit('usage: aday BUILD_NUMBER')
- print build_to_date(sys.argv[1])
+ print(build_to_date(sys.argv[1]))
diff --git a/scripts/architecture.py b/scripts/architecture.py
deleted file mode 100644
index f239250..0000000
--- a/scripts/architecture.py
+++ /dev/null
@@ -1,58 +0,0 @@
-"""Abstraction layer for different ABIs."""
-
-import re
-import symbol
-
-def UnpackLittleEndian(word):
- """Split a hexadecimal string in little endian order."""
- return [word[x:x+2] for x in range(len(word) - 2, -2, -2)]
-
-
-ASSEMBLE = 'as'
-DISASSEMBLE = 'objdump'
-LINK = 'ld'
-UNPACK = 'unpack'
-
-OPTIONS = {
- 'x86': {
- ASSEMBLE: ['--32'],
- LINK: ['-melf_i386']
- }
-}
-
-
-class Architecture(object):
- """Creates an architecture abstraction for a given ABI.
-
- Args:
- name: The abi name, as represented in a tombstone.
- """
-
- def __init__(self, name):
- symbol.ARCH = name
- self.toolchain = symbol.FindToolchain()
- self.options = OPTIONS.get(name, {})
-
- def Assemble(self, args):
- """Generates an assembler command, appending the given args."""
- return [symbol.ToolPath(ASSEMBLE)] + self.options.get(ASSEMBLE, []) + args
-
- def Link(self, args):
- """Generates a link command, appending the given args."""
- return [symbol.ToolPath(LINK)] + self.options.get(LINK, []) + args
-
- def Disassemble(self, args):
- """Generates a disassemble command, appending the given args."""
- return ([symbol.ToolPath(DISASSEMBLE)] + self.options.get(DISASSEMBLE, []) +
- args)
-
- def WordToBytes(self, word):
- """Unpacks a hexadecimal string in the architecture's byte order.
-
- Args:
- word: A string representing a hexadecimal value.
-
- Returns:
- An array of hexadecimal byte values.
- """
- return self.options.get(UNPACK, UnpackLittleEndian)(word)
diff --git a/scripts/cargo2android.py b/scripts/cargo2android.py
index ce6096d..4875e7a 100755
--- a/scripts/cargo2android.py
+++ b/scripts/cargo2android.py
@@ -1778,7 +1778,7 @@
parser.add_argument(
'--product-available',
action='store_true',
- default=False,
+ default=True,
help='Mark the main library as product_available.')
parser.add_argument(
'--recovery-available',
@@ -1788,7 +1788,7 @@
parser.add_argument(
'--vendor-available',
action='store_true',
- default=False,
+ default=True,
help='Mark the main library as vendor_available.')
parser.add_argument(
'--vendor-ramdisk-available',
diff --git a/scripts/example_crashes.py b/scripts/example_crashes.py
index 5d4751c..f386dfd 100755
--- a/scripts/example_crashes.py
+++ b/scripts/example_crashes.py
@@ -84,59 +84,6 @@
#07 pc 0000000000014e90 /system/lib64/libc.so (__start_thread+16)
"""
-mips = """
-Build fingerprint: 'Android/aosp_mips/generic_mips:4.4.3.43.43.43/AOSP/enh06302258:eng/test-keys'
-Revision: '0'
-ABI: 'mips'
-pid: 958, tid: 960, name: crasher >>> crasher <<<
-signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
- zr 00000000 at 802babc0 v0 00000000 v1 77b99dd0
- a0 000003be a1 000003c0 a2 00000006 a3 00000000
- t0 00000000 t1 9e7f5440 t2 00000020 t3 ffffff18
- t4 77a9c000 t5 00000001 t6 00000000 t7 00000000
- s0 000003c0 s1 77b99dd8 s2 00000000 s3 00000006
- s4 77db2028 s5 000003be s6 77c39fa8 s7 77b99dd0
- t8 00000000 t9 77c89e80 k0 00000000 k1 00000000
- gp 77cce350 sp 77b99c78 s8 77db2020 ra 77c3b48c
- hi 00000000 lo 00000008 bva 7fff7008 epc 77c89e94
-
-backtrace:
- #00 pc 00067e94 /system/lib/libc.so (tgkill+20)
- #01 pc 0001948c /system/lib/libc.so (pthread_kill+244)
- #02 pc 0001b0e8 /system/lib/libc.so (raise+60)
- #03 pc 00012908 /system/lib/libc.so (abort+104)
- #04 pc 000012a4 /system/xbin/crasher
- #05 pc 00018008 /system/lib/libc.so (__pthread_start(void*)+96)
- #06 pc 00013198 /system/lib/libc.so (__start_thread+36)
-"""
-
-mips64 = """
-Build fingerprint: 'Android/aosp_mips64/generic_mips64:5.1.51/AOSP/agampe05040015:userdebug/test-keys'
-Revision: '1'
-ABI: 'mips64'
-pid: 342, tid: 342, name: crasher64 >>> crasher64 <<<
-signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
- zr 0000000000000000 at 0000000000000001 v0 0000000000000000 v1 000000ffec1c6528
- a0 0000000000000156 a1 0000000000000156 a2 0000000000000006 a3 0000000000000000
- a4 000000000000ffff a5 fffffffffffffffc a6 0000000000000000 a7 0000000000000001
- t0 0000000000000001 t1 0000000000000000 t2 0000000000000001 t3 0000000000000001
- s0 0000000000000002 s1 000000ffec1c6538 s2 000000ffec1c6478 s3 0000000000000006
- s4 0000000000100000 s5 000000fff1d44f98 s6 000000fff186c488 s7 0000000000000000
- t8 ffffffffffff0000 t9 000000ffec01c2a0 k0 0000000000000000 k1 0000000000000000
- gp 000000ffec0a6680 sp 000000ffff8c7150 s8 0000000000100206 ra 000000ffec016684
- hi 0000000000000000 lo 0000000000000000 bva 000000ffffffe010 epc 000000ffec01c2a8
-
-backtrace:
- #00 pc 00000000000832a8 /system/lib64/libc.so (tgkill+8)
- #01 pc 000000000007d684 /system/lib64/libc.so (pthread_kill+116)
- #02 pc 000000000002dd78 /system/lib64/libc.so (raise+56)
- #03 pc 000000000002684c /system/lib64/libc.so (abort+92)
- #04 pc 000000000000199c /system/xbin/crasher64
- #05 pc 000000000002595c /system/lib64/libc.so (__libc_init+140)
- #06 pc 0000000000000fd4 /system/xbin/crasher64
- #07 pc 0000000000000f80 /system/xbin/crasher64
-"""
-
x86 = """
Build fingerprint: 'Android/aosp_x86_64/generic_x86_64:4.4.3.43.43.43/AOSP/enh06302258:eng/test-keys'
Revision: '0'
@@ -184,6 +131,31 @@
#08 pc 00000000000138f5 /system/lib64/libc.so (__bionic_clone+53)
"""
+riscv64 = """
+Build fingerprint: 'generic/aosp_riscv64/vsoc_riscv64:4.4.3.43.43.43/AOSP/eng.prasha.20230307.172954:eng/test-keys'
+Revision: '0'
+ABI: 'riscv64'
+pid: 794, tid: 794, name: crasher64 >>> crasher64 <<<
+signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
+ gp ffffffff81dabe60 tp 00ffffff1aae0050 t0 000000000002ba76 t1 00ffffff140d598c
+ t2 00000000d82989b1 t3 00ffffff1407e570 t4 00ffffff1ac2d000 t5 0000000000000018
+ t6 0000000000000018 s0 000000000000031a s1 000000000000031a s2 ffffffffffffffff
+ s3 00ffffffca72dd20 s4 0000000000000000 s5 00fffff499ead378 s6 00fffff469ea7b90
+ s7 00aaaaaba6d2b2c8 s8 00fffff5fa3a1588 s9 0000000000000000 s10 0000000000000000
+ s11 0000000000000000 a0 0000000000000000 a1 000000000000031a a2 0000000000000006
+ a3 00ffffffca72da00 a4 0000000000000000 a5 000000007fffffff a6 000000007fffffff
+ a7 00000000000000f0
+ pc 00ffffff1407e582 ra 00ffffff140811d2 sp 00ffffffca72d9d0
+
+backtrace:
+ #00 pc 0000000000049582 /apex/com.android.runtime/lib64/bionic/libc.so (syscall+18)
+ #01 pc 000000000004c1ce /apex/com.android.runtime/lib64/bionic/libc.so (abort+98)
+ #02 pc 0000000000004012 /system/bin/crasher64 (maybe_abort+40)
+ #03 pc 000000000000457c /system/bin/crasher64 (do_action+966)
+ #04 pc 0000000000005528 /system/bin/crasher64 (main+78)
+ #05 pc 0000000000047cd4 /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+80)
+"""
+
libmemunreachable = """
Unreachable memory
48 bytes in 2 unreachable allocations
diff --git a/scripts/gdbclient.py b/scripts/gdbclient.py
index 1c864be..3ba0573 100755
--- a/scripts/gdbclient.py
+++ b/scripts/gdbclient.py
@@ -242,12 +242,7 @@
return (binary_file, pid, run_cmd)
-def format_hostport(host, port):
- if host is not None:
- return "{}:{}".format(host, port)
- return str(port)
-
-def generate_vscode_lldb_script(root, sysroot, binary_name, host, port, solib_search_path):
+def generate_vscode_lldb_script(root, sysroot, binary_name, port, solib_search_path):
# TODO It would be nice if we didn't need to copy this or run the
# lldbclient.py program manually. Doing this would probably require
# writing a vscode extension or modifying an existing one.
@@ -263,11 +258,11 @@
"initCommands": ['settings append target.exec-search-paths {}'.format(' '.join(solib_search_path))],
"targetCreateCommands": ["target create {}".format(binary_name),
"target modules search-paths add / {}/".format(sysroot)],
- "processCreateCommands": ["gdb-remote {}".format(format_hostport(host, port))]
+ "processCreateCommands": ["gdb-remote {}".format(str(port))]
}
return json.dumps(res, indent=4)
-def generate_lldb_script(root, sysroot, binary_name, host, port, solib_search_path):
+def generate_lldb_script(root, sysroot, binary_name, port, solib_search_path):
commands = []
commands.append(
'settings append target.exec-search-paths {}'.format(' '.join(solib_search_path)))
@@ -277,11 +272,11 @@
commands.append("settings append target.source-map '/b/f/w' '{}'".format(root))
commands.append("settings append target.source-map '' '{}'".format(root))
commands.append('target modules search-paths add / {}/'.format(sysroot))
- commands.append('gdb-remote {}'.format(format_hostport(host, port)))
+ commands.append('gdb-remote {}'.format(str(port)))
return '\n'.join(commands)
-def generate_setup_script(debugger_path, sysroot, linker_search_dir, binary_file, is64bit, host, port, debugger, connect_timeout=5):
+def generate_setup_script(debugger_path, sysroot, linker_search_dir, binary_file, is64bit, port, debugger, connect_timeout=5):
# Generate a setup script.
root = os.environ["ANDROID_BUILD_TOP"]
symbols_dir = os.path.join(sysroot, "system", "lib64" if is64bit else "lib")
@@ -297,10 +292,10 @@
if debugger == "vscode-lldb":
return generate_vscode_lldb_script(
- root, sysroot, binary_file.name, host, port, solib_search_path)
+ root, sysroot, binary_file.name, port, solib_search_path)
elif debugger == 'lldb':
return generate_lldb_script(
- root, sysroot, binary_file.name, host, port, solib_search_path)
+ root, sysroot, binary_file.name, port, solib_search_path)
else:
raise Exception("Unknown debugger type " + debugger)
@@ -319,11 +314,6 @@
if device is None:
sys.exit("ERROR: Failed to find device.")
- if ":" in device.serial:
- host = device.serial.split(":")[0]
- else:
- host = None
-
root = os.environ["ANDROID_BUILD_TOP"]
sysroot = os.path.join(os.environ["ANDROID_PRODUCT_OUT"], "symbols")
@@ -389,7 +379,6 @@
linker_search_dir=linker_search_dir,
binary_file=binary_file,
is64bit=is64bit,
- host=host,
port=args.port,
debugger=debugger)
diff --git a/scripts/stack b/scripts/stack
index 70bc3fb..713bbc3 100755
--- a/scripts/stack
+++ b/scripts/stack
@@ -44,7 +44,7 @@
args = parser.parse_args()
if args.arch:
- symbol.ARCH = args.arch
+ symbol.ARCH_IS_32BIT = not "64" in args.arch
if args.symbols_dir:
symbol.SYMBOLS_DIR = args.symbols_dir
if args.symbols_zip:
@@ -56,10 +56,11 @@
symbol.VERBOSE = args.verbose
if args.file == '-':
print("Reading native crash info from stdin")
+ sys.stdin.reconfigure(errors='ignore')
f = sys.stdin
else:
print("Searching for native crashes in %s" % args.file)
- f = open(args.file, "r")
+ f = open(args.file, "r", errors='ignore')
lines = f.readlines()
f.close()
diff --git a/scripts/stack_core.py b/scripts/stack_core.py
index 831eb7d..5bbc1d8 100755
--- a/scripts/stack_core.py
+++ b/scripts/stack_core.py
@@ -65,10 +65,9 @@
register_names = {
"arm": "r0|r1|r2|r3|r4|r5|r6|r7|r8|r9|sl|fp|ip|sp|lr|pc|cpsr",
"arm64": "x0|x1|x2|x3|x4|x5|x6|x7|x8|x9|x10|x11|x12|x13|x14|x15|x16|x17|x18|x19|x20|x21|x22|x23|x24|x25|x26|x27|x28|x29|x30|sp|pc|pstate",
- "mips": "zr|at|v0|v1|a0|a1|a2|a3|t0|t1|t2|t3|t4|t5|t6|t7|s0|s1|s2|s3|s4|s5|s6|s7|t8|t9|k0|k1|gp|sp|s8|ra|hi|lo|bva|epc",
- "mips64": "zr|at|v0|v1|a0|a1|a2|a3|a4|a5|a6|a7|t0|t1|t2|t3|s0|s1|s2|s3|s4|s5|s6|s7|t8|t9|k0|k1|gp|sp|s8|ra|hi|lo|bva|epc",
"x86": "eax|ebx|ecx|edx|esi|edi|x?cs|x?ds|x?es|x?fs|x?ss|eip|ebp|esp|flags",
"x86_64": "rax|rbx|rcx|rdx|rsi|rdi|r8|r9|r10|r11|r12|r13|r14|r15|cs|ss|rip|rbp|rsp|eflags",
+ "riscv64": "ra|sp|gp|tp|t0|t1|t2|s0|s1|a0|a1|a2|a3|a4|a5|a6|a7|s2|s3|s4|s5|s6|s7|s8|s9|s10|s11|t3|t4|t5|t6|pc",
}
# We use the "file" command line tool to extract BuildId from ELF files.
@@ -77,15 +76,14 @@
r"Build ID:\s*(?P<build_id>[0-9a-f]+)",
flags=re.DOTALL)
- def UpdateAbiRegexes(self):
- if symbol.ARCH == "arm64" or symbol.ARCH == "mips64" or symbol.ARCH == "x86_64":
- self.width = "{16}"
- self.spacing = " "
- else:
+ def UpdateBitnessRegexes(self):
+ if symbol.ARCH_IS_32BIT:
self.width = "{8}"
self.spacing = ""
-
- self.register_line = re.compile("(([ ]*\\b(" + self.register_names[symbol.ARCH] + ")\\b +[0-9a-f]" + self.width + "){2,5})")
+ else:
+ self.width = "{16}"
+ self.spacing = " "
+ self.register_line = re.compile(" (([ ]*\\b(\S*)\\b +[0-9a-f]" + self.width + "){1,5}$)")
# Note that both trace and value line matching allow for variable amounts of
# whitespace (e.g. \t). This is because the we want to allow for the stack
@@ -184,9 +182,9 @@
def ConvertTrace(self, lines):
lines = [self.CleanLine(line) for line in lines]
try:
- if not symbol.ARCH:
- symbol.SetAbi(lines)
- self.UpdateAbiRegexes()
+ if symbol.ARCH_IS_32BIT is None:
+ symbol.SetBitness(lines)
+ self.UpdateBitnessRegexes()
for line in lines:
self.ProcessLine(line)
self.PrintOutput(self.trace_lines, self.value_lines)
@@ -372,11 +370,11 @@
test_name = lib.rsplit("/", 1)[-1]
test_dir = "/data/nativetest"
test_dir_bitness = ""
- if symbol.ARCH.endswith("64"):
+ if symbol.ARCH_IS_32BIT:
+ bitness = "32"
+ else:
bitness = "64"
test_dir_bitness = "64"
- else:
- bitness = "32"
# Unfortunately, the location of the real symbol file is not
# standardized, so we need to go hunting for it.
@@ -541,7 +539,7 @@
if nest_count > 0:
nest_count = nest_count - 1
arrow = "v------>"
- if symbol.ARCH == "arm64" or symbol.ARCH == "mips64" or symbol.ARCH == "x86_64":
+ if not symbol.ARCH_IS_32BIT:
arrow = "v-------------->"
self.trace_lines.append((arrow, source_symbol, source_location))
else:
@@ -584,8 +582,8 @@
def assert_register_matches(self, abi, example_crash, stupid_pattern):
tc = TraceConverter()
lines = example_crash.split('\n')
- symbol.SetAbi(lines)
- tc.UpdateAbiRegexes()
+ symbol.SetBitness(lines)
+ tc.UpdateBitnessRegexes()
for line in lines:
tc.ProcessLine(line)
is_register = (re.search(stupid_pattern, line) is not None)
@@ -594,16 +592,10 @@
tc.PrintOutput(tc.trace_lines, tc.value_lines)
def test_arm_registers(self):
- self.assert_register_matches("arm", example_crashes.arm, '\\b(r0|r4|r8|ip)\\b')
+ self.assert_register_matches("arm", example_crashes.arm, '\\b(r0|r4|r8|ip|scr)\\b')
def test_arm64_registers(self):
- self.assert_register_matches("arm64", example_crashes.arm64, '\\b(x0|x4|x8|x12|x16|x20|x24|x28|sp)\\b')
-
- def test_mips_registers(self):
- self.assert_register_matches("mips", example_crashes.mips, '\\b(zr|a0|t0|t4|s0|s4|t8|gp|hi)\\b')
-
- def test_mips64_registers(self):
- self.assert_register_matches("mips64", example_crashes.mips64, '\\b(zr|a0|a4|t0|s0|s4|t8|gp|hi)\\b')
+ self.assert_register_matches("arm64", example_crashes.arm64, '\\b(x0|x4|x8|x12|x16|x20|x24|x28|sp|v[1-3]?[0-9])\\b')
def test_x86_registers(self):
self.assert_register_matches("x86", example_crashes.x86, '\\b(eax|esi|xcs|eip)\\b')
@@ -611,15 +603,17 @@
def test_x86_64_registers(self):
self.assert_register_matches("x86_64", example_crashes.x86_64, '\\b(rax|rsi|r8|r12|cs|rip)\\b')
+ def test_riscv64_registers(self):
+ self.assert_register_matches("riscv64", example_crashes.riscv64, '\\b(gp|t2|t6|s3|s7|s11|a3|a7|sp)\\b')
+
class LibmemunreachablePatternTests(unittest.TestCase):
def test_libmemunreachable(self):
tc = TraceConverter()
lines = example_crashes.libmemunreachable.split('\n')
- symbol.SetAbi(lines)
- self.assertEqual(symbol.ARCH, "arm")
-
- tc.UpdateAbiRegexes()
+ symbol.SetBitness(lines)
+ self.assertTrue(symbol.ARCH_IS_32BIT)
+ tc.UpdateBitnessRegexes()
header_lines = 0
trace_lines = 0
for line in lines:
@@ -639,8 +633,8 @@
def test_long_asan_crash(self):
tc = TraceConverter()
lines = example_crashes.long_asan_crash.splitlines()
- symbol.SetAbi(lines)
- tc.UpdateAbiRegexes()
+ symbol.SetBitness(lines)
+ tc.UpdateBitnessRegexes()
# Test by making sure trace_line_count is monotonically non-decreasing. If the stack trace
# is split, a separator is printed and trace_lines is flushed.
trace_line_count = 0
@@ -656,8 +650,8 @@
class ValueLinesTest(unittest.TestCase):
def test_value_line_skipped(self):
tc = TraceConverter()
- symbol.SetAbi(["ABI: 'arm'"])
- tc.UpdateAbiRegexes()
+ symbol.ARCH_IS_32BIT = True
+ tc.UpdateBitnessRegexes()
tc.ProcessLine(" 12345678 00001000 .")
self.assertEqual([], tc.value_lines)
diff --git a/scripts/symbol.py b/scripts/symbol.py
index 0a255e8..f4c2395 100755
--- a/scripts/symbol.py
+++ b/scripts/symbol.py
@@ -58,13 +58,12 @@
SYMBOLS_DIR = FindSymbolsDir()
-ARCH = None
+ARCH_IS_32BIT = None
VERBOSE = False
# These are private. Do not access them from other modules.
_CACHED_TOOLCHAIN = None
-_CACHED_TOOLCHAIN_ARCH = None
_CACHED_CXX_FILT = None
# Caches for symbolized information.
@@ -147,18 +146,18 @@
def ToolPath(tool, toolchain=None):
"""Return a fully-qualified path to the specified tool, or just the tool if it's on PATH """
- if shutil.which(tool) is not None:
- return tool
+ if shutil.which(tool):
+ return tool
if not toolchain:
toolchain = FindToolchain()
return os.path.join(toolchain, tool)
def FindToolchain():
- """Returns the toolchain matching ARCH."""
+ """Returns the toolchain."""
- global _CACHED_TOOLCHAIN, _CACHED_TOOLCHAIN_ARCH
- if _CACHED_TOOLCHAIN is not None and _CACHED_TOOLCHAIN_ARCH == ARCH:
+ global _CACHED_TOOLCHAIN
+ if _CACHED_TOOLCHAIN:
return _CACHED_TOOLCHAIN
llvm_binutils_dir = ANDROID_BUILD_TOP + "/prebuilts/clang/host/linux-x86/llvm-binutils-stable/";
@@ -166,8 +165,7 @@
raise Exception("Could not find llvm tool chain directory %s" % (llvm_binutils_dir))
_CACHED_TOOLCHAIN = llvm_binutils_dir
- _CACHED_TOOLCHAIN_ARCH = ARCH
- print("Using", _CACHED_TOOLCHAIN_ARCH, "toolchain from:", _CACHED_TOOLCHAIN)
+ print("Using toolchain from:", _CACHED_TOOLCHAIN)
return _CACHED_TOOLCHAIN
@@ -324,21 +322,6 @@
return result
-def StripPC(addr):
- """Strips the Thumb bit a program counter address when appropriate.
-
- Args:
- addr: the program counter address
-
- Returns:
- The stripped program counter address.
- """
- global ARCH
- if ARCH == "arm":
- return addr & ~1
- return addr
-
-
def CallObjdumpForSet(lib, unique_addrs):
"""Use objdump to find out the names of the containing functions.
@@ -381,8 +364,8 @@
if not os.path.exists(symbols):
return None
- start_addr_dec = str(StripPC(int(addrs[0], 16)))
- stop_addr_dec = str(StripPC(int(addrs[-1], 16)) + 8)
+ start_addr_dec = str(int(addrs[0], 16))
+ stop_addr_dec = str(int(addrs[-1], 16) + 8)
cmd = [ToolPath("llvm-objdump"),
"--section=.text",
"--demangle",
@@ -431,7 +414,7 @@
addr = components.group(1)
target_addr = addrs[addr_index]
i_addr = int(addr, 16)
- i_target = StripPC(int(target_addr, 16))
+ i_target = int(target_addr, 16)
if i_addr == i_target:
result[target_addr] = (current_symbol, i_target - current_symbol_addr)
addr_cache[target_addr] = result[target_addr]
@@ -517,268 +500,64 @@
return result.strip()
-def GetAbiFromToolchain(toolchain_var, bits):
- toolchain = os.environ.get(toolchain_var)
- if not toolchain:
- return None
+def SetBitness(lines):
+ global ARCH_IS_32BIT
- toolchain_match = re.search("\/(aarch64|arm|mips|x86)\/", toolchain)
- if toolchain_match:
- abi = toolchain_match.group(1)
- if abi == "aarch64":
- return "arm64"
- elif bits == 64:
- if abi == "x86":
- return "x86_64"
- elif abi == "mips":
- return "mips64"
- return abi
- return None
-
-def Get32BitArch():
- # Check for ANDROID_TOOLCHAIN_2ND_ARCH first, if set, use that.
- # If not try ANDROID_TOOLCHAIN to find the arch.
- # If this is not set, then default to arm.
- arch = GetAbiFromToolchain("ANDROID_TOOLCHAIN_2ND_ARCH", 32)
- if not arch:
- arch = GetAbiFromToolchain("ANDROID_TOOLCHAIN", 32)
- if not arch:
- return "arm"
- return arch
-
-def Get64BitArch():
- # Check for ANDROID_TOOLCHAIN, if it is set, we can figure out the
- # arch this way. If this is not set, then default to arm64.
- arch = GetAbiFromToolchain("ANDROID_TOOLCHAIN", 64)
- if not arch:
- return "arm64"
- return arch
-
-def SetAbi(lines):
- global ARCH
-
- abi_line = re.compile("ABI: \'(.*)\'")
trace_line = re.compile("\#[0-9]+[ \t]+..[ \t]+([0-9a-f]{8}|[0-9a-f]{16})([ \t]+|$)")
asan_trace_line = re.compile("\#[0-9]+[ \t]+0x([0-9a-f]+)[ \t]+")
- ARCH = None
+ ARCH_IS_32BIT = False
for line in lines:
- abi_match = abi_line.search(line)
- if abi_match:
- ARCH = abi_match.group(1)
- break
trace_match = trace_line.search(line)
if trace_match:
# Try to guess the arch, we know the bitness.
if len(trace_match.group(1)) == 16:
- ARCH = Get64BitArch()
+ ARCH_IS_32BIT = False
else:
- ARCH = Get32BitArch()
+ ARCH_IS_32BIT = True
break
asan_trace_match = asan_trace_line.search(line)
if asan_trace_match:
# We might be able to guess the bitness by the length of the address.
if len(asan_trace_match.group(1)) > 8:
- ARCH = Get64BitArch()
+ ARCH_IS_32BIT = False
# We know for a fact this is 64 bit, so we are done.
break
else:
- ARCH = Get32BitArch()
# This might be 32 bit, or just a small address. Keep going in this
# case, but if we couldn't figure anything else out, go with 32 bit.
- if not ARCH:
- raise Exception("Could not determine arch from input, use --arch=XXX to specify it")
-
-
-class FindToolchainTests(unittest.TestCase):
- def assert_toolchain_found(self, abi):
- global ARCH
- ARCH = abi
- FindToolchain() # Will throw on failure.
-
- @unittest.skipIf(ANDROID_BUILD_TOP == '.', 'Test only supported in an Android tree.')
- def test_toolchains_found(self):
- self.assert_toolchain_found("arm")
- self.assert_toolchain_found("arm64")
- self.assert_toolchain_found("mips")
- self.assert_toolchain_found("x86")
- self.assert_toolchain_found("x86_64")
+ ARCH_IS_32BIT = True
class FindClangDirTests(unittest.TestCase):
@unittest.skipIf(ANDROID_BUILD_TOP == '.', 'Test only supported in an Android tree.')
def test_clang_dir_found(self):
self.assertIsNotNone(FindClangDir())
-class SetArchTests(unittest.TestCase):
- def test_abi_check(self):
- global ARCH
+class SetBitnessTests(unittest.TestCase):
+ def test_32bit_check(self):
+ global ARCH_IS_32BIT
- SetAbi(["ABI: 'arm'"])
- self.assertEqual(ARCH, "arm")
- SetAbi(["ABI: 'arm64'"])
- self.assertEqual(ARCH, "arm64")
+ SetBitness(["#00 pc 000374e0"])
+ self.assertTrue(ARCH_IS_32BIT)
- SetAbi(["ABI: 'mips'"])
- self.assertEqual(ARCH, "mips")
- SetAbi(["ABI: 'mips64'"])
- self.assertEqual(ARCH, "mips64")
+ def test_64bit_check(self):
+ global ARCH_IS_32BIT
- SetAbi(["ABI: 'x86'"])
- self.assertEqual(ARCH, "x86")
- SetAbi(["ABI: 'x86_64'"])
- self.assertEqual(ARCH, "x86_64")
-
- def test_32bit_trace_line_toolchain(self):
- global ARCH
-
- os.environ.clear()
- os.environ["ANDROID_TOOLCHAIN"] = "linux-x86/arm/arm-linux-androideabi-4.9/bin"
- SetAbi(["#00 pc 000374e0"])
- self.assertEqual(ARCH, "arm")
-
- os.environ.clear()
- os.environ["ANDROID_TOOLCHAIN"] = "linux-x86/mips/arm-linux-androideabi-4.9/bin"
- SetAbi(["#00 pc 000374e0"])
- self.assertEqual(ARCH, "mips")
-
- os.environ.clear()
- os.environ["ANDROID_TOOLCHAIN"] = "linux-x86/x86/arm-linux-androideabi-4.9/bin"
- SetAbi(["#00 pc 000374e0"])
- self.assertEqual(ARCH, "x86")
-
- def test_32bit_trace_line_toolchain_2nd(self):
- global ARCH
-
- os.environ.clear()
- os.environ["ANDROID_TOOLCHAIN_2ND_ARCH"] = "linux-x86/arm/arm-linux-androideabi-4.9/bin"
- os.environ["ANDROID_TOOLCHAIN_ARCH"] = "linux-x86/aarch64/aarch64-linux-android-4.9/bin"
- SetAbi(["#00 pc 000374e0"])
- self.assertEqual(ARCH, "arm")
-
- os.environ.clear()
- os.environ["ANDROID_TOOLCHAIN_2ND_ARCH"] = "linux-x86/mips/mips-linux-androideabi-4.9/bin"
- os.environ["ANDROID_TOOLCHAIN"] = "linux-x86/unknown/unknown-linux-androideabi-4.9/bin"
- SetAbi(["#00 pc 000374e0"])
- self.assertEqual(ARCH, "mips")
-
- os.environ.clear()
- os.environ["ANDROID_TOOLCHAIN_2ND_ARCH"] = "linux-x86/x86/x86-linux-androideabi-4.9/bin"
- os.environ["ANDROID_TOOLCHAIN"] = "linux-x86/unknown/unknown-linux-androideabi-4.9/bin"
- SetAbi(["#00 pc 000374e0"])
- self.assertEqual(ARCH, "x86")
-
- def test_64bit_trace_line_toolchain(self):
- global ARCH
-
- os.environ.clear()
- os.environ["ANDROID_TOOLCHAIN"] = "linux-x86/aarch/aarch-linux-androideabi-4.9/bin"
- SetAbi(["#00 pc 00000000000374e0"])
- self.assertEqual(ARCH, "arm64")
-
- os.environ.clear()
- os.environ["ANDROID_TOOLCHAIN"] = "linux-x86/mips/arm-linux-androideabi-4.9/bin"
- SetAbi(["#00 pc 00000000000374e0"])
- self.assertEqual(ARCH, "mips64")
-
- os.environ.clear()
- os.environ["ANDROID_TOOLCHAIN"] = "linux-x86/x86/arm-linux-androideabi-4.9/bin"
- SetAbi(["#00 pc 00000000000374e0"])
- self.assertEqual(ARCH, "x86_64")
-
- def test_trace_default_abis(self):
- global ARCH
-
- os.environ.clear()
- SetAbi(["#00 pc 000374e0"])
- self.assertEqual(ARCH, "arm")
- SetAbi(["#00 pc 00000000000374e0"])
- self.assertEqual(ARCH, "arm64")
+ SetBitness(["#00 pc 00000000000374e0"])
+ self.assertFalse(ARCH_IS_32BIT)
def test_32bit_asan_trace_line_toolchain(self):
- global ARCH
+ global ARCH_IS_32BIT
- os.environ.clear()
- os.environ["ANDROID_TOOLCHAIN"] = "linux-x86/arm/arm-linux-androideabi-4.9/bin"
- SetAbi(["#10 0xb5eeba5d (/system/vendor/lib/egl/libGLESv1_CM_adreno.so+0xfa5d)"])
- self.assertEqual(ARCH, "arm")
-
- os.environ.clear()
- os.environ["ANDROID_TOOLCHAIN"] = "linux-x86/mips/arm-linux-androideabi-4.9/bin"
- SetAbi(["#10 0xb5eeba5d (/system/vendor/lib/egl/libGLESv1_CM_adreno.so+0xfa5d)"])
- self.assertEqual(ARCH, "mips")
-
- os.environ.clear()
- os.environ["ANDROID_TOOLCHAIN"] = "linux-x86/x86/arm-linux-androideabi-4.9/bin"
- SetAbi(["#10 0xb5eeba5d (/system/vendor/lib/egl/libGLESv1_CM_adreno.so+0xfa5d)"])
- self.assertEqual(ARCH, "x86")
-
- def test_32bit_asan_trace_line_toolchain_2nd(self):
- global ARCH
-
- os.environ.clear()
- os.environ["ANDROID_TOOLCHAIN_2ND_ARCH"] = "linux-x86/arm/arm-linux-androideabi-4.9/bin"
- os.environ["ANDROID_TOOLCHAIN_ARCH"] = "linux-x86/aarch64/aarch64-linux-android-4.9/bin"
- SetAbi(["#3 0xae1725b5 (/system/vendor/lib/libllvm-glnext.so+0x6435b5)"])
- self.assertEqual(ARCH, "arm")
-
- os.environ.clear()
- os.environ["ANDROID_TOOLCHAIN_2ND_ARCH"] = "linux-x86/mips/mips-linux-androideabi-4.9/bin"
- os.environ["ANDROID_TOOLCHAIN"] = "linux-x86/unknown/unknown-linux-androideabi-4.9/bin"
- SetAbi(["#3 0xae1725b5 (/system/vendor/lib/libllvm-glnext.so+0x6435b5)"])
- self.assertEqual(ARCH, "mips")
-
- os.environ.clear()
- os.environ["ANDROID_TOOLCHAIN_2ND_ARCH"] = "linux-x86/x86/x86-linux-androideabi-4.9/bin"
- os.environ["ANDROID_TOOLCHAIN"] = "linux-x86/unknown/unknown-linux-androideabi-4.9/bin"
- SetAbi(["#3 0xae1725b5 (/system/vendor/lib/libllvm-glnext.so+0x6435b5)"])
- self.assertEqual(ARCH, "x86")
+ SetBitness(["#10 0xb5eeba5d (/system/vendor/lib/egl/libGLESv1_CM_adreno.so+0xfa5d)"])
+ self.assertTrue(ARCH_IS_32BIT)
def test_64bit_asan_trace_line_toolchain(self):
- global ARCH
+ global ARCH_IS_32BIT
- os.environ.clear()
- os.environ["ANDROID_TOOLCHAIN"] = "linux-x86/aarch/aarch-linux-androideabi-4.9/bin"
- SetAbi(["#0 0x11b35d33bf (/system/lib/libclang_rt.asan-arm-android.so+0x823bf)"])
- self.assertEqual(ARCH, "arm64")
-
- os.environ.clear()
- os.environ["ANDROID_TOOLCHAIN"] = "linux-x86/mips/arm-linux-androideabi-4.9/bin"
- SetAbi(["#1 0x11b35d33bf (/system/lib/libclang_rt.asan-arm-android.so+0x823bf)"])
- self.assertEqual(ARCH, "mips64")
-
- os.environ.clear()
- os.environ["ANDROID_TOOLCHAIN"] = "linux-x86/x86/arm-linux-androideabi-4.9/bin"
- SetAbi(["#12 0x11b35d33bf (/system/lib/libclang_rt.asan-arm-android.so+0x823bf)"])
- self.assertEqual(ARCH, "x86_64")
-
- # Verify that if an address that might be 32 bit comes first, that
- # encountering a 64 bit address returns a 64 bit abi.
- ARCH = None
- os.environ.clear()
- os.environ["ANDROID_TOOLCHAIN"] = "linux-x86/x86/arm-linux-androideabi-4.9/bin"
- SetAbi(["#12 0x5d33bf (/system/lib/libclang_rt.asan-arm-android.so+0x823bf)",
- "#12 0x11b35d33bf (/system/lib/libclang_rt.asan-arm-android.so+0x823bf)"])
- self.assertEqual(ARCH, "x86_64")
-
- def test_asan_trace_default_abis(self):
- global ARCH
-
- os.environ.clear()
- SetAbi(["#4 0x1234349ab (/system/vendor/lib/libllvm-glnext.so+0x64fc4f)"])
- self.assertEqual(ARCH, "arm64")
- SetAbi(["#1 0xae17ec4f (/system/vendor/lib/libllvm-glnext.so+0x64fc4f)"])
- self.assertEqual(ARCH, "arm")
-
- def test_no_abi(self):
- global ARCH
-
- # Python2 vs Python3 compatibility: Python3 warns on Regexp deprecation, but Regex
- # does not provide that name.
- if not hasattr(unittest.TestCase, 'assertRaisesRegex'):
- unittest.TestCase.assertRaisesRegex = getattr(unittest.TestCase, 'assertRaisesRegexp')
- self.assertRaisesRegex(Exception,
- "Could not determine arch from input, use --arch=XXX to specify it",
- SetAbi, [])
+ SetBitness(["#12 0x5d33bf (/system/lib/libclang_rt.asan-arm-android.so+0x823bf)",
+ "#12 0x11b35d33bf (/system/lib/libclang_rt.asan-arm-android.so+0x823bf)"])
+ self.assertFalse(ARCH_IS_32BIT)
class FormatSymbolWithoutParametersTests(unittest.TestCase):
def test_c(self):
@@ -801,7 +580,7 @@
def test_nested(self):
self.assertEqual(FormatSymbolWithoutParameters("foo(int i)::bar(int j)"), "foo::bar")
- def test_unballanced(self):
+ def test_unbalanced(self):
self.assertEqual(FormatSymbolWithoutParameters("foo(bar(int i)"), "foo(bar(int i)")
self.assertEqual(FormatSymbolWithoutParameters("foo)bar(int i)"), "foo)bar(int i)")
self.assertEqual(FormatSymbolWithoutParameters("foo<bar(int i)"), "foo<bar(int i)")
diff --git a/sdk/build_tools_source.prop_template b/sdk/build_tools_source.prop_template
index 6da346c..d2dad00 100644
--- a/sdk/build_tools_source.prop_template
+++ b/sdk/build_tools_source.prop_template
@@ -1,3 +1,3 @@
Pkg.UserSrc=false
-Pkg.Revision=${PLATFORM_SDK_VERSION}.0.1
+Pkg.Revision=${PLATFORM_SDK_VERSION}.0.2
#Pkg.Revision=33.0.0 rc4
diff --git a/sdk/plat_tools_source.prop_template b/sdk/plat_tools_source.prop_template
index 05b1ae9..6ac41bb 100644
--- a/sdk/plat_tools_source.prop_template
+++ b/sdk/plat_tools_source.prop_template
@@ -1,2 +1,2 @@
Pkg.UserSrc=false
-Pkg.Revision=34.0.0
+Pkg.Revision=34.0.1
diff --git a/tools/etc1tool/etc1tool.cpp b/tools/etc1tool/etc1tool.cpp
index 376cbf8..868c444 100644
--- a/tools/etc1tool/etc1tool.cpp
+++ b/tools/etc1tool/etc1tool.cpp
@@ -489,7 +489,6 @@
bool bEncodeDecodeSeen = false;
bool bEncode = false;
bool bEncodeHeader = false;
- bool bDecode = false;
bool bShowDifference = false;
for (int i = 1; i < argc; i++) {
@@ -517,7 +516,6 @@
bEncodeHeader = false;
} else if (strcmp(pArg, "--decode") == 0) {
multipleEncodeDecodeCheck(&bEncodeDecodeSeen);
- bDecode = true;
} else if (strcmp(pArg, "--showDifference") == 0) {
if (bShowDifference) {
usage("Only one --showDifference option allowed.\n");
diff --git a/tools/motion/OWNERS b/tools/motion/OWNERS
new file mode 100644
index 0000000..545b822
--- /dev/null
+++ b/tools/motion/OWNERS
@@ -0,0 +1,3 @@
+cinek@google.com
+gallmann@google.com
+michschn@google.com
diff --git a/treble/OWNERS b/treble/OWNERS
new file mode 100644
index 0000000..04f03c5
--- /dev/null
+++ b/treble/OWNERS
@@ -0,0 +1,5 @@
+inseob@google.com
+jeongik@google.com
+justinyun@google.com
+kiyoungkim@google.com
+jiyong@google.com
\ No newline at end of file
diff --git a/treble/build_with_artifact.sh b/treble/build_with_artifact.sh
new file mode 100644
index 0000000..fd43c96
--- /dev/null
+++ b/treble/build_with_artifact.sh
@@ -0,0 +1,56 @@
+#!/bin/sh
+#
+# Copyright (C) 2023 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+ARG_SHORT=d:,t:,h
+ARG_LONG=dist_dir:,target_product:,help
+OPTS=$(getopt -n build_with_artifact --options $ARG_SHORT --longoptions $ARG_LONG -- "$@")
+
+eval set -- "$OPTS"
+
+function print_usage(){
+ echo "usage: development/treble/build_with_artifact.sh --dist_dir <dist_dir> --target_product <target_product>"
+ exit 2
+}
+
+while :
+do
+ case "$1" in
+ -d | --dist_dir )
+ DIST_DIR="$2"
+ shift 2
+ ;;
+ -t | --target_product )
+ TARGET_PRODUCT="$2"
+ shift 2
+ ;;
+ -h | --help )
+ print_usage
+ ;;
+ -- )
+ shift;
+ break
+ ;;
+ * )
+ print_usage
+ ;;
+ esac
+done
+
+if [ -z DIST_DIR ] || [ -z TARGET_PRODUCT ] ; then
+ print_usage
+fi
+
+BUILD_WITH_PARTIAL_ARTIFACT=true build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=$TARGET_PRODUCT TARGET_BUILD_VARIANT=userdebug droid dist DIST_DIR=$DIST_DIR
\ No newline at end of file
diff --git a/vndk/tools/header-checker/Android.bp b/vndk/tools/header-checker/Android.bp
index f017bcb..12816bf 100644
--- a/vndk/tools/header-checker/Android.bp
+++ b/vndk/tools/header-checker/Android.bp
@@ -198,10 +198,12 @@
],
static_libs: [
+ "libbase",
"libgtest",
"libgtest_main",
"libheader-checker",
"libjsoncpp",
+ "liblog",
],
shared_libs: [
diff --git a/vndk/tools/header-checker/src/utils/source_path_utils.cpp b/vndk/tools/header-checker/src/utils/source_path_utils.cpp
index a3f34f6..d112087 100644
--- a/vndk/tools/header-checker/src/utils/source_path_utils.cpp
+++ b/vndk/tools/header-checker/src/utils/source_path_utils.cpp
@@ -29,15 +29,30 @@
static const std::vector<std::string> header_extensions{
".h", ".hh", ".hpp", ".hxx", ".h++", ".inl", ".inc", ".ipp", ".h.generic"};
-static bool ShouldSkipFile(llvm::StringRef &file_name) {
- // Look for header files only
- if (file_name.empty() || file_name.startswith(".")) {
- return true;
- }
+static const std::vector<std::string> libcxx_include_dir{"libcxx", "include"};
+
+static bool HasHeaderExtension(llvm::StringRef file_name) {
return std::find_if(header_extensions.begin(), header_extensions.end(),
[file_name](const std::string &e) {
return file_name.endswith(e);
- }) == header_extensions.end();
+ }) != header_extensions.end();
+}
+
+static bool PathEndsWith(llvm::StringRef path,
+ const std::vector<std::string> &suffix) {
+ auto path_it = llvm::sys::path::rbegin(path);
+ auto suffix_it = suffix.rbegin();
+ while (suffix_it != suffix.rend()) {
+ if (path_it == llvm::sys::path::rend(path)) {
+ return false;
+ }
+ if (*path_it != *suffix_it) {
+ return false;
+ }
+ ++path_it;
+ ++suffix_it;
+ }
+ return true;
}
static std::string GetCwd() {
@@ -121,6 +136,11 @@
static bool CollectExportedHeaderSet(const std::string &dir_name,
std::set<std::string> *exported_headers,
const RootDirs &root_dirs) {
+ // Bazel creates temporary files in header directories. To avoid race
+ // condition, this function filters headers by name extensions.
+ // An exception is that libc++ headers do not have extensions.
+ bool collect_headers_without_extensions =
+ PathEndsWith(dir_name, libcxx_include_dir);
std::error_code ec;
llvm::sys::fs::recursive_directory_iterator walker(dir_name, ec);
// Default construction - end of directory.
@@ -135,11 +155,18 @@
const std::string &file_path = walker->path();
llvm::StringRef file_name(llvm::sys::path::filename(file_path));
- // Ignore non header files.
- if (ShouldSkipFile(file_name)) {
+ if (file_name.empty() || file_name.startswith(".")) {
+ // Ignore hidden files and directories.
walker.no_push();
continue;
}
+ if (!file_name.contains(".")) {
+ if (!collect_headers_without_extensions) {
+ continue;
+ }
+ } else if (!HasHeaderExtension(file_name)) {
+ continue;
+ }
llvm::ErrorOr<llvm::sys::fs::basic_file_status> status = walker->status();
if (!status) {
diff --git a/vndk/tools/header-checker/src/utils/source_path_utils_test.cpp b/vndk/tools/header-checker/src/utils/source_path_utils_test.cpp
index 2b74eba..8bb238f 100644
--- a/vndk/tools/header-checker/src/utils/source_path_utils_test.cpp
+++ b/vndk/tools/header-checker/src/utils/source_path_utils_test.cpp
@@ -14,12 +14,73 @@
#include "utils/source_path_utils.h"
+#include <android-base/file.h>
#include <gtest/gtest.h>
+#include <filesystem>
+#include <vector>
namespace header_checker {
namespace utils {
+TEST(SourcePathUtilsTest, CollectAllExportedHeaders) {
+ TemporaryDir temp_dir;
+ std::error_code ec;
+ // Prepare a header directory containing links, hidden files, etc.
+ const std::filesystem::path header_dir =
+ std::filesystem::path(temp_dir.path) / "include";
+ ASSERT_TRUE(std::filesystem::create_directory(header_dir, ec));
+ ASSERT_FALSE(ec);
+
+ const std::filesystem::path header = header_dir / "header.h";
+ ASSERT_TRUE(android::base::WriteStringToFile("// test", header));
+
+ const std::filesystem::path no_ext_header = header_dir / "header";
+ ASSERT_TRUE(android::base::WriteStringToFile("// test", no_ext_header));
+
+ const std::filesystem::path subdir = header_dir / "subdir";
+ ASSERT_TRUE(std::filesystem::create_directory(subdir, ec));
+ ASSERT_FALSE(ec);
+
+ const std::filesystem::path subdir_link = header_dir / "subdir_link";
+ std::filesystem::create_directory_symlink(subdir, subdir_link, ec);
+ ASSERT_FALSE(ec);
+
+ const std::filesystem::path hidden_subdir_link = header_dir / ".subdir_link";
+ std::filesystem::create_directory_symlink(subdir, hidden_subdir_link, ec);
+ ASSERT_FALSE(ec);
+
+ const std::filesystem::path header_link = subdir / "header_link.h";
+ std::filesystem::create_symlink(header, header_link, ec);
+ ASSERT_FALSE(ec);
+
+ const std::filesystem::path hidden_header_link = subdir / ".header_link.h";
+ std::filesystem::create_symlink(header, hidden_header_link, ec);
+ ASSERT_FALSE(ec);
+
+ const std::filesystem::path non_header_link = subdir / "header_link.txt";
+ std::filesystem::create_symlink(header, non_header_link, ec);
+ ASSERT_FALSE(ec);
+ // Prepare a header directory like libc++.
+ const std::filesystem::path libcxx_dir =
+ std::filesystem::path(temp_dir.path) / "libcxx" / "include";
+ ASSERT_TRUE(std::filesystem::create_directories(libcxx_dir, ec));
+ ASSERT_FALSE(ec);
+
+ const std::filesystem::path libcxx_header = libcxx_dir / "array";
+ ASSERT_TRUE(android::base::WriteStringToFile("// test", libcxx_header));
+ // Test the function.
+ std::vector<std::string> exported_header_dirs{header_dir, libcxx_dir};
+ std::vector<RootDir> root_dirs{{header_dir, "include"},
+ {libcxx_dir, "libcxx"}};
+ std::set<std::string> headers =
+ CollectAllExportedHeaders(exported_header_dirs, root_dirs);
+
+ std::set<std::string> expected_headers{
+ "include/header.h", "include/subdir/header_link.h",
+ "include/subdir_link/header_link.h", "libcxx/array"};
+ ASSERT_EQ(headers, expected_headers);
+}
TEST(SourcePathUtilsTest, NormalizeAbsolutePaths) {
const std::vector<std::string> args{"/root/dir"};