Skip to content

Commit

Permalink
Merge branch 'microg:master' into vending
Browse files Browse the repository at this point in the history
  • Loading branch information
ale5000-git authored Feb 22, 2024
2 parents 9d4a5b0 + 12dd51f commit 15038fe
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 10 deletions.
31 changes: 27 additions & 4 deletions vending-app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand All @@ -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"
Expand Down Expand Up @@ -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">
Expand All @@ -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" />

Expand All @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

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;
Expand All @@ -32,16 +33,23 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
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);
newIntent.setPackage(null);
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);
}
Expand All @@ -62,9 +70,11 @@ private void processIntent(@NonNull Intent intent) {
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();
Expand Down

0 comments on commit 15038fe

Please sign in to comment.