Merge Android 14
Bug: 298295554 Merged-In: Ib6aea146a33329d3f6c1e375e99f600699318ce4 Change-Id: Id645358f0476a48beaa6f660132adc89da0d9508
This commit is contained in:
@@ -324,7 +324,8 @@ class MmsNetworkManager {
|
|||||||
|
|
||||||
private void registerConnectivityChangeReceiverLocked() {
|
private void registerConnectivityChangeReceiverLocked() {
|
||||||
if (!mReceiverRegistered) {
|
if (!mReceiverRegistered) {
|
||||||
mContext.registerReceiver(mConnectivityChangeReceiver, mConnectivityIntentFilter);
|
mContext.registerReceiver(mConnectivityChangeReceiver, mConnectivityIntentFilter,
|
||||||
|
Context.RECEIVER_EXPORTED/*UNAUDITED*/);
|
||||||
mReceiverRegistered = true;
|
mReceiverRegistered = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,7 +132,8 @@ public class BugleApplication extends Application implements UncaughtExceptionHa
|
|||||||
LogUtil.i(TAG, "Carrier config changed. Reloading MMS config.");
|
LogUtil.i(TAG, "Carrier config changed. Reloading MMS config.");
|
||||||
MmsConfig.loadAsync();
|
MmsConfig.loadAsync();
|
||||||
}
|
}
|
||||||
}, new IntentFilter(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED));
|
}, new IntentFilter(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED),
|
||||||
|
Context.RECEIVER_EXPORTED/*UNAUDITED*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initMmsLib(final Context context, final BugleGservices bugleGservices,
|
private static void initMmsLib(final Context context, final BugleGservices bugleGservices,
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ import com.android.messaging.util.UriUtil;
|
|||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launches ConversationActivity for sending a message to, or viewing messages from, a specific
|
* Launches ConversationActivity for sending a message to, or viewing messages from, a specific
|
||||||
@@ -46,6 +48,7 @@ import java.net.URLDecoder;
|
|||||||
*/
|
*/
|
||||||
public class LaunchConversationActivity extends Activity implements
|
public class LaunchConversationActivity extends Activity implements
|
||||||
LaunchConversationData.LaunchConversationDataListener {
|
LaunchConversationData.LaunchConversationDataListener {
|
||||||
|
private static final int MAX_RECIPIENT_LENGTH = 100;
|
||||||
static final String SMS_BODY = "sms_body";
|
static final String SMS_BODY = "sms_body";
|
||||||
static final String ADDRESS = "address";
|
static final String ADDRESS = "address";
|
||||||
final Binding<LaunchConversationData> mBinding = BindingBase.createBinding(this);
|
final Binding<LaunchConversationData> mBinding = BindingBase.createBinding(this);
|
||||||
@@ -76,6 +79,9 @@ public class LaunchConversationActivity extends Activity implements
|
|||||||
recipients = new String[] { intent.getStringExtra(Intent.EXTRA_EMAIL) };
|
recipients = new String[] { intent.getStringExtra(Intent.EXTRA_EMAIL) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (recipients != null) {
|
||||||
|
recipients = trimInvalidRecipients(recipients);
|
||||||
|
}
|
||||||
mSmsBody = intent.getStringExtra(SMS_BODY);
|
mSmsBody = intent.getStringExtra(SMS_BODY);
|
||||||
if (TextUtils.isEmpty(mSmsBody)) {
|
if (TextUtils.isEmpty(mSmsBody)) {
|
||||||
// Used by intents sent from the web YouTube (and perhaps others).
|
// Used by intents sent from the web YouTube (and perhaps others).
|
||||||
@@ -103,6 +109,20 @@ public class LaunchConversationActivity extends Activity implements
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String[] trimInvalidRecipients(String[] recipients) {
|
||||||
|
List<String> trimmedRecipients = new ArrayList<>();
|
||||||
|
for (String recipient : recipients) {
|
||||||
|
if (recipient.length() < MAX_RECIPIENT_LENGTH) {
|
||||||
|
trimmedRecipients.add(recipient);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (trimmedRecipients.size() > 0) {
|
||||||
|
return trimmedRecipients.toArray(new String[0]);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String getBody(final Uri uri) {
|
private String getBody(final Uri uri) {
|
||||||
if (uri == null) {
|
if (uri == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import android.content.ContentResolver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.android.messaging.Factory;
|
import com.android.messaging.Factory;
|
||||||
@@ -28,6 +29,8 @@ import com.google.common.io.Files;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@@ -121,6 +124,10 @@ public class FileUtil {
|
|||||||
// We're told it's possible to create world readable hardlinks to other apps private data
|
// We're told it's possible to create world readable hardlinks to other apps private data
|
||||||
// so we ban all /data file uris.
|
// so we ban all /data file uris.
|
||||||
public static boolean isInPrivateDir(Uri uri) {
|
public static boolean isInPrivateDir(Uri uri) {
|
||||||
|
return isFileUriInPrivateDir(uri) || isContentUriInPrivateDir(uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isFileUriInPrivateDir(Uri uri) {
|
||||||
if (!UriUtil.isFileUri(uri)) {
|
if (!UriUtil.isFileUri(uri)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -128,6 +135,24 @@ public class FileUtil {
|
|||||||
return FileUtil.isSameOrSubDirectory(Environment.getDataDirectory(), file);
|
return FileUtil.isSameOrSubDirectory(Environment.getDataDirectory(), file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isContentUriInPrivateDir(Uri uri) {
|
||||||
|
if (!uri.getScheme().equals(ContentResolver.SCHEME_CONTENT)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Context context = Factory.get().getApplicationContext();
|
||||||
|
ParcelFileDescriptor pfd = context.getContentResolver().openFileDescriptor(uri, "r");
|
||||||
|
int fd = pfd.getFd();
|
||||||
|
// Use the file descriptor to find out the read file path through symbolic link.
|
||||||
|
Path fdPath = Paths.get("/proc/self/fd/" + fd);
|
||||||
|
Path filePath = java.nio.file.Files.readSymbolicLink(fdPath);
|
||||||
|
pfd.close();
|
||||||
|
return FileUtil.isSameOrSubDirectory(Environment.getDataDirectory(), filePath.toFile());
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks, whether the child directory is the same as, or a sub-directory of the base
|
* Checks, whether the child directory is the same as, or a sub-directory of the base
|
||||||
* directory.
|
* directory.
|
||||||
|
|||||||
Reference in New Issue
Block a user