-
Notifications
You must be signed in to change notification settings - Fork 171
#259 #260
#259 #260
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ | |
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.ServiceConnection; | ||
import android.content.pm.PackageInfo; | ||
import android.content.pm.PackageManager; | ||
import android.content.pm.PackageManager.NameNotFoundException; | ||
import android.content.pm.ResolveInfo; | ||
|
@@ -375,7 +376,13 @@ public void run() { | |
// try it only if samsung SKUs are specified | ||
stores2check.add(new SamsungApps(activity, options)); | ||
} | ||
//Nokia TODO change logic | ||
stores2check.add(new NokiaStore(context)); | ||
if (!hasRequestedPermission(context, "com.nokia.payment.BILLING")) { | ||
if (isDebugLog()) { | ||
Log.w(TAG, "Required permission \"com.nokia.payment.BILLING\" NOT REQUESTED"); | ||
} | ||
} | ||
} | ||
|
||
//todo redo | ||
|
@@ -492,6 +499,7 @@ private static void checkSettings(Options options, Context context){ | |
if (BuildConfig.FORTUMO_ENABLE) { | ||
checkFortumo(options, context); | ||
} | ||
checkNokia(options, context); | ||
} | ||
|
||
private static void checkFortumo(Options options, Context context) { | ||
|
@@ -593,6 +601,43 @@ private static void checkFortumo(Options options, Context context) { | |
|
||
} | ||
|
||
private static void checkNokia(Options options, Context context) { | ||
List<Appstore> availableStores = options.availableStores; | ||
boolean hasNokia = false; | ||
if (availableStores != null && availableStores.size() > 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use !availableStore.isEmpty instead of availableStores.size() > 0 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is a matter of taste. As for me I don't like ! before smt.isEmpty. |
||
for (Appstore appstore : availableStores) { | ||
if (appstore.getAppstoreName().equals(NAME_NOKIA)) { | ||
hasNokia = true; | ||
break; | ||
} | ||
} | ||
} | ||
if (hasNokia) { | ||
if (!hasRequestedPermission(context, "com.nokia.payment.BILLING")) { | ||
throw new IllegalStateException("Nokia permission \"com.nokia.payment.BILLING\" NOT REQUESTED"); | ||
} | ||
} | ||
} | ||
|
||
//todo move to Utils | ||
private static boolean hasRequestedPermission(Context context, String permission) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't move method immediate? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have to understand the architecture before to add new classes. And this fix is urgent. |
||
try { | ||
PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_PERMISSIONS); | ||
if (info.requestedPermissions != null) { | ||
for (String p : info.requestedPermissions) { | ||
if (p.equals(permission)) { | ||
return true; | ||
} | ||
} | ||
} | ||
} catch (NameNotFoundException e) { | ||
if (isDebugLog()) { | ||
Log.e(TAG, "error during checking permissions", e); | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
//todo move to Utils | ||
private static void checkPermission(Context context, String paramString, StringBuilder builder) { | ||
if (context.checkCallingOrSelfPermission(paramString) != PackageManager.PERMISSION_GRANTED) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does method static? OpenIab helper contains Options in field. You can make method non-static and remove Option from parametres.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for Context parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these methods should be moved later to an Utils class.