Fix app name label spoofing am: 54e74cae5f
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/14076525 Change-Id: I149be19aa3ec85e6a6646c43a938c1ad3d1b327c
This commit is contained in:
@@ -29,6 +29,8 @@ import android.content.pm.ApplicationInfo;
|
|||||||
import android.content.pm.PackageItemInfo;
|
import android.content.pm.PackageItemInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Process;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@@ -315,16 +317,26 @@ public class RequestPermissionActivity extends Activity implements
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Error: this activity may be started only with intent "
|
Log.e(TAG, "Error: this activity may be started only with intent "
|
||||||
+ BluetoothAdapter.ACTION_REQUEST_ENABLE + " or "
|
+ BluetoothAdapter.ACTION_REQUEST_ENABLE + ", "
|
||||||
|
+ BluetoothAdapter.ACTION_REQUEST_DISABLE + " or "
|
||||||
+ BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
|
+ BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
|
||||||
setResult(RESULT_CANCELED);
|
setResult(RESULT_CANCELED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String packageName = getCallingPackage();
|
String packageName = getLaunchedFromPackage();
|
||||||
if (TextUtils.isEmpty(packageName)) {
|
int mCallingUid = getLaunchedFromUid();
|
||||||
|
|
||||||
|
if (UserHandle.isSameApp(mCallingUid, Process.SYSTEM_UID)
|
||||||
|
&& getIntent().getStringExtra(Intent.EXTRA_PACKAGE_NAME) != null) {
|
||||||
packageName = getIntent().getStringExtra(Intent.EXTRA_PACKAGE_NAME);
|
packageName = getIntent().getStringExtra(Intent.EXTRA_PACKAGE_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!UserHandle.isSameApp(mCallingUid, Process.SYSTEM_UID)
|
||||||
|
&& getIntent().getStringExtra(Intent.EXTRA_PACKAGE_NAME) != null) {
|
||||||
|
Log.w(TAG, "Non-system Uid: " + mCallingUid + " tried to override packageName \n");
|
||||||
|
}
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(packageName)) {
|
if (!TextUtils.isEmpty(packageName)) {
|
||||||
try {
|
try {
|
||||||
ApplicationInfo applicationInfo = getPackageManager().getApplicationInfo(
|
ApplicationInfo applicationInfo = getPackageManager().getApplicationInfo(
|
||||||
|
Reference in New Issue
Block a user