Vending: Don't redirect to self
This commit is contained in:
parent
fa4046f86d
commit
51c5e231bb
2 changed files with 43 additions and 10 deletions
|
|
@ -10,7 +10,7 @@
|
|||
android:protectionLevel="normal" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
|
||||
<uses-permission android:name="org.microg.gms.permission.READ_SETTINGS" />
|
||||
|
|
@ -20,6 +20,25 @@
|
|||
android:name="android.permission.USE_CREDENTIALS"
|
||||
android:maxSdkVersion="22" />
|
||||
|
||||
<queries>
|
||||
<intent>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<data android:scheme="market" />
|
||||
</intent>
|
||||
<intent>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<data
|
||||
android:scheme="https"
|
||||
android:host="market.android.com" />
|
||||
</intent>
|
||||
<intent>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<data
|
||||
android:scheme="https"
|
||||
android:host="play.google.com" />
|
||||
</intent>
|
||||
</queries>
|
||||
|
||||
<application
|
||||
android:forceQueryable="true"
|
||||
android:icon="@mipmap/ic_app"
|
||||
|
|
@ -68,7 +87,8 @@
|
|||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name="org.microg.vending.MarketIntentRedirect"
|
||||
<activity
|
||||
android:name="org.microg.vending.MarketIntentRedirect"
|
||||
android:theme="@style/Theme.Dialog.NoActionBar"
|
||||
android:exported="true">
|
||||
<intent-filter android:priority="-100">
|
||||
|
|
@ -79,6 +99,7 @@
|
|||
</intent-filter>
|
||||
<intent-filter android:priority="-100">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
|
|
@ -89,9 +110,11 @@
|
|||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<receiver android:name="com.android.vending.licensing.LicenseServiceNotificationRunnable$IgnoreReceiver"
|
||||
<receiver
|
||||
android:name="com.android.vending.licensing.LicenseServiceNotificationRunnable$IgnoreReceiver"
|
||||
android:exported="false" />
|
||||
<receiver android:name="com.android.vending.licensing.LicenseServiceNotificationRunnable$SignInReceiver"
|
||||
<receiver
|
||||
android:name="com.android.vending.licensing.LicenseServiceNotificationRunnable$SignInReceiver"
|
||||
android:exported="false" />
|
||||
|
||||
</application>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ package org.microg.vending;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
|
@ -32,6 +33,11 @@ public class MarketIntentRedirect extends Activity {
|
|||
finish();
|
||||
}
|
||||
|
||||
private boolean isNonSelfIntent(@NonNull Intent intent) {
|
||||
ResolveInfo resolveInfo = getPackageManager().resolveActivity(intent, 0);
|
||||
return resolveInfo != null && resolveInfo.activityInfo != null && !getPackageName().equals(resolveInfo.activityInfo.packageName);
|
||||
}
|
||||
|
||||
private void processIntent(@NonNull Intent intent) {
|
||||
Log.d(TAG, "Received " + intent);
|
||||
Intent newIntent = new Intent(intent);
|
||||
|
|
@ -39,9 +45,11 @@ public class MarketIntentRedirect extends Activity {
|
|||
newIntent.setComponent(null);
|
||||
if ("market".equals(newIntent.getScheme())) {
|
||||
try {
|
||||
Log.d(TAG, "Redirect to " + newIntent);
|
||||
startActivity(newIntent);
|
||||
return;
|
||||
if (isNonSelfIntent(newIntent)) {
|
||||
Log.d(TAG, "Redirect to " + newIntent);
|
||||
startActivity(newIntent);
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
|
|
@ -62,9 +70,11 @@ public class MarketIntentRedirect extends Activity {
|
|||
Log.d(TAG, "Rewrote as " + newIntent + " (" + newIntent.getDataString() + ")");
|
||||
}
|
||||
try {
|
||||
Log.d(TAG, "Redirect to " + newIntent);
|
||||
startActivity(newIntent);
|
||||
return;
|
||||
if (isNonSelfIntent(newIntent)) {
|
||||
Log.d(TAG, "Redirect to " + newIntent);
|
||||
startActivity(newIntent);
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, e);
|
||||
Toast.makeText(this, "Unable to open", Toast.LENGTH_SHORT).show();
|
||||
|
|
|
|||
Loading…
Reference in a new issue